跳转到主要内容

开发者文档

为 ForgeCut 创建自定义着色器、原生 DLL 与特效。

1. 自定义 GLSL 着色器

ForgeCut 使用 GLSL 片元着色器渲染实时特效与音频可视化。C++ 引擎使用与 WebGL 兼容的语法,例如 texture2D()。

内置 uniform

引擎会自动提供以下着色器变量。

uniform sampler2D texRGB;     // Main video frame
uniform sampler2D texA;       // Transition Source A
uniform sampler2D texB;       // Transition Source B
uniform vec2 texRes;          // Current render resolution
uniform vec2 iResolution;     // Alias for texRes
uniform float iTime;          // Absolute timeline time
uniform vec3 iAudio;          // Audio reactivity (x: Low, y: Mid, z: High)
uniform float opacity;        // Base clip opacity
varying vec2 vTexCoord;       // Standard UVs (0.0 to 1.0)
varying vec2 vFragCoord;      // Pixel coordinates

生成界面参数

在 .frag 文件中添加参数注释,即可在 Effect Controls 面板中显示滑块。

在 GLSL 中声明 uniform

参数注释会创建滑块。请另用 uniform float yourVariable; 声明变量,以便着色器编译和渲染。

// Syntax: @param float [name] [min] [max] [default]
// @param float blurAmount 0.0 5.0 1.0
// @param float redTint 0.0 1.0 0.5

// You MUST declare these below the comments:
uniform float blurAmount;
uniform float redTint;

void main() {
    // Your code here...
}

保留 Alpha 通道

将源视频的 alpha 值乘以轨道不透明度,使着色器与背景图层正确混合。

vec4 bgCol = texture2D(texRGB, vTexCoord);
vec3 myEffectColor = vec3(1.0, 0.0, 0.0);

// Correct Alpha output for Forge Cut
float finalAlpha = bgCol.a * opacity;
gl_FragColor = vec4(myEffectColor, finalAlpha);

2. 原生 C++ 视频插件(Windows DLL)

对于单应性变换或物理模拟等高负载操作,可构建原生库。包含 FastNLE_VideoPlugin.h 并导出以下 C 函数。

extern "C" {
    const char* GetPluginName();
    int GetParameterCount();
    void GetParameterInfo(int index, FastNLE_ParamInfo* outInfo);
    
    // Processes a raw RGBA 8-bit image buffer in-place
    void ProcessVideoFrame(uint8_t* rgbaBuffer, int width, int height, float time, const float* paramValues);
    
    void ReleasePlugin();
}

3. VST3 音频支持

VST3 宿主处理交错音频、平面音频转换和插件窗口。为音频片段加载 .vst3 插件,再用 Effect Controls 中的齿轮打开界面。启用 Automate 可将支持的参数记录为时间轴关键帧。


4. OpenFX(OFX)支持

ForgeCut 可作为 kOfxImageEffectContextFilter 和 kOfxImageEffectContextGeneral 的 OpenFX 宿主。将 .ofx 软件包拖入时间轴,即可在 Effect Controls 中查看支持的参数。

开发者文档 | ForgeCut