Multi pass test
This commit is contained in:
@@ -1,25 +1,22 @@
|
||||
float4 shadeVideo(ShaderContext context)
|
||||
float4 gaussianBlurDirection(ShaderContext context, float2 direction)
|
||||
{
|
||||
float2 texel = 1.0 / max(context.inputResolution, float2(1.0, 1.0));
|
||||
float blurRadius = max(radius, 0.0);
|
||||
float2 sampleStep = texel * blurRadius;
|
||||
float blurRadius = max(radius, 0.0) * saturate(strength);
|
||||
float2 sampleStep = texel * blurRadius * direction;
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
float distanceSquared = float(x * x);
|
||||
float sigma = max(float(sampleRadius) * 0.5, 0.5);
|
||||
float weight = exp(-distanceSquared / (2.0 * sigma * sigma));
|
||||
float2 offset = float(x) * sampleStep;
|
||||
blur += sampleVideo(context.uv + offset) * weight;
|
||||
totalWeight += weight;
|
||||
}
|
||||
|
||||
if (sampleRadius == 0)
|
||||
@@ -29,7 +26,20 @@ float4 shadeVideo(ShaderContext context)
|
||||
}
|
||||
|
||||
blur /= max(totalWeight, 0.0001);
|
||||
|
||||
float mixValue = saturate(strength);
|
||||
return lerp(center, blur, mixValue);
|
||||
return blur;
|
||||
}
|
||||
|
||||
float4 blurHorizontal(ShaderContext context)
|
||||
{
|
||||
return gaussianBlurDirection(context, float2(1.0, 0.0));
|
||||
}
|
||||
|
||||
float4 blurVertical(ShaderContext context)
|
||||
{
|
||||
return gaussianBlurDirection(context, float2(0.0, 1.0));
|
||||
}
|
||||
|
||||
float4 shadeVideo(ShaderContext context)
|
||||
{
|
||||
return blurVertical(context);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user