This commit is contained in:
2026-05-02 17:13:53 +10:00
parent 1a4c33b9dc
commit fb1bf01fef
19 changed files with 780 additions and 69 deletions

View File

@@ -0,0 +1,36 @@
{
"id": "gaussian-blur",
"name": "Gaussian Blur",
"description": "Applies a simple Gaussian-style blur to the decoded video input.",
"category": "Built-in",
"entryPoint": "shadeVideo",
"parameters": [
{
"id": "radius",
"label": "Radius",
"type": "float",
"default": 2.0,
"min": 0.0,
"max": 8.0,
"step": 0.1
},
{
"id": "strength",
"label": "Strength",
"type": "float",
"default": 1.0,
"min": 0.0,
"max": 1.0,
"step": 0.01
},
{
"id": "samples",
"label": "Samples",
"type": "float",
"default": 2.0,
"min": 0.0,
"max": 25.0,
"step": 1.0
}
]
}

View File

@@ -0,0 +1,35 @@
float4 shadeVideo(ShaderContext context)
{
float2 texel = 1.0 / max(context.inputResolution, float2(1.0, 1.0));
float blurRadius = max(radius, 0.0);
float2 sampleStep = texel * blurRadius;
int sampleRadius = int(clamp(samples, 0.0, 8.0) + 0.5);
float4 center = sampleVideo(context.uv);
float4 blur = float4(0.0, 0.0, 0.0, 0.0);
float totalWeight = 0.0;
for (int y = -sampleRadius; y <= sampleRadius; ++y)
{
for (int x = -sampleRadius; x <= sampleRadius; ++x)
{
float distanceSquared = float(x * x + y * y);
float sigma = max(float(sampleRadius) * 0.5, 0.5);
float weight = exp(-distanceSquared / (2.0 * sigma * sigma));
float2 offset = float2(float(x), float(y)) * sampleStep;
blur += sampleVideo(context.uv + offset) * weight;
totalWeight += weight;
}
}
if (sampleRadius == 0)
{
blur = center;
totalWeight = 1.0;
}
blur /= max(totalWeight, 0.0001);
float mixValue = saturate(strength);
return lerp(center, blur, mixValue);
}