Example shaders
This commit is contained in:
47
shaders/temporal-echo/shader.json
Normal file
47
shaders/temporal-echo/shader.json
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"id": "temporal-echo",
|
||||
"name": "Temporal Echo",
|
||||
"description": "Blends multiple older pre-layer frames with decay and tint for configurable motion echoes.",
|
||||
"category": "Temporal",
|
||||
"entryPoint": "shadeVideo",
|
||||
"temporal": {
|
||||
"enabled": true,
|
||||
"historySource": "preLayerInput",
|
||||
"historyLength": 12
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"id": "echoAmount",
|
||||
"label": "Echo Amount",
|
||||
"type": "float",
|
||||
"default": 0.55,
|
||||
"min": 0.0,
|
||||
"max": 1.0,
|
||||
"step": 0.01
|
||||
},
|
||||
{
|
||||
"id": "decay",
|
||||
"label": "Decay",
|
||||
"type": "float",
|
||||
"default": 0.72,
|
||||
"min": 0.0,
|
||||
"max": 1.0,
|
||||
"step": 0.01
|
||||
},
|
||||
{
|
||||
"id": "frameStride",
|
||||
"label": "Frame Stride",
|
||||
"type": "float",
|
||||
"default": 2.0,
|
||||
"min": 1.0,
|
||||
"max": 6.0,
|
||||
"step": 1.0
|
||||
},
|
||||
{
|
||||
"id": "echoTint",
|
||||
"label": "Echo Tint",
|
||||
"type": "color",
|
||||
"default": [0.65, 0.85, 1.0, 1.0]
|
||||
}
|
||||
]
|
||||
}
|
||||
20
shaders/temporal-echo/shader.slang
Normal file
20
shaders/temporal-echo/shader.slang
Normal file
@@ -0,0 +1,20 @@
|
||||
float4 shadeVideo(ShaderContext context)
|
||||
{
|
||||
int stride = int(clamp(frameStride, 1.0, 6.0) + 0.5);
|
||||
float3 echo = float3(0.0, 0.0, 0.0);
|
||||
float total = 0.0;
|
||||
float weight = 1.0;
|
||||
|
||||
for (int i = 1; i <= 6; ++i)
|
||||
{
|
||||
int frame = i * stride;
|
||||
float3 sampleColor = sampleTemporalHistory(frame, context.uv).rgb * echoTint.rgb;
|
||||
echo += sampleColor * weight;
|
||||
total += weight;
|
||||
weight *= saturate(decay);
|
||||
}
|
||||
|
||||
float3 echoColor = echo / max(total, 0.0001);
|
||||
float amount = saturate(echoAmount) * echoTint.a;
|
||||
return float4(lerp(context.sourceColor.rgb, echoColor, amount), context.sourceColor.a);
|
||||
}
|
||||
Reference in New Issue
Block a user