Example shaders
This commit is contained in:
51
shaders/waveform-overlay/shader.json
Normal file
51
shaders/waveform-overlay/shader.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"id": "waveform-overlay",
|
||||
"name": "Waveform Overlay",
|
||||
"description": "Draws a lightweight luma waveform overlay along the bottom of the video.",
|
||||
"category": "Utility",
|
||||
"entryPoint": "shadeVideo",
|
||||
"parameters": [
|
||||
{
|
||||
"id": "overlayHeight",
|
||||
"label": "Overlay Height",
|
||||
"type": "float",
|
||||
"default": 0.32,
|
||||
"min": 0.1,
|
||||
"max": 1.0,
|
||||
"step": 0.01
|
||||
},
|
||||
{
|
||||
"id": "waveformOpacity",
|
||||
"label": "Waveform Opacity",
|
||||
"type": "float",
|
||||
"default": 0.8,
|
||||
"min": 0.0,
|
||||
"max": 1.0,
|
||||
"step": 0.01
|
||||
},
|
||||
{
|
||||
"id": "backgroundOpacity",
|
||||
"label": "Background",
|
||||
"type": "float",
|
||||
"default": 0.35,
|
||||
"min": 0.0,
|
||||
"max": 1.0,
|
||||
"step": 0.01
|
||||
},
|
||||
{
|
||||
"id": "lineThickness",
|
||||
"label": "Line Thickness",
|
||||
"type": "float",
|
||||
"default": 2.0,
|
||||
"min": 0.5,
|
||||
"max": 10.0,
|
||||
"step": 0.1
|
||||
},
|
||||
{
|
||||
"id": "waveformColor",
|
||||
"label": "Waveform Color",
|
||||
"type": "color",
|
||||
"default": [0.2, 1.0, 0.65, 1.0]
|
||||
}
|
||||
]
|
||||
}
|
||||
24
shaders/waveform-overlay/shader.slang
Normal file
24
shaders/waveform-overlay/shader.slang
Normal file
@@ -0,0 +1,24 @@
|
||||
float4 shadeVideo(ShaderContext context)
|
||||
{
|
||||
float4 color = context.sourceColor;
|
||||
float height = saturate(overlayHeight);
|
||||
float overlayStart = 1.0 - height;
|
||||
if (context.uv.y < overlayStart)
|
||||
return color;
|
||||
|
||||
float2 scopeUv = float2(context.uv.x, (context.uv.y - overlayStart) / max(height, 0.001));
|
||||
float luma = dot(sampleVideo(float2(context.uv.x, 0.5)).rgb, float3(0.2126, 0.7152, 0.0722));
|
||||
float targetY = 1.0 - saturate(luma);
|
||||
float pixelThickness = max(lineThickness, 0.5) / max(context.outputResolution.y * height, 1.0);
|
||||
float wave = 1.0 - smoothstep(pixelThickness, pixelThickness * 2.5, abs(scopeUv.y - targetY));
|
||||
|
||||
float grid = 0.0;
|
||||
grid = max(grid, 1.0 - smoothstep(0.002, 0.006, abs(scopeUv.y - 0.25)));
|
||||
grid = max(grid, 1.0 - smoothstep(0.002, 0.006, abs(scopeUv.y - 0.50)));
|
||||
grid = max(grid, 1.0 - smoothstep(0.002, 0.006, abs(scopeUv.y - 0.75)));
|
||||
|
||||
float3 bg = lerp(color.rgb, float3(0.0, 0.0, 0.0), saturate(backgroundOpacity));
|
||||
float3 withGrid = lerp(bg, float3(0.16, 0.22, 0.28), grid * 0.5);
|
||||
float3 scoped = lerp(withGrid, waveformColor.rgb, wave * saturate(waveformOpacity) * waveformColor.a);
|
||||
return float4(scoped, color.a);
|
||||
}
|
||||
Reference in New Issue
Block a user