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); }