obs-StreamFX/data/filter-blur/gaussian.effect
Michael Fabian Dirks 8f05b348dd filter-blur: Split into individual files
An unknown issue with the OBS effect parser causes it to generate nothing when more than two techniques are in the same file. This works around the issue, but doesn't actually fix it.
2017-07-03 07:01:23 +02:00

54 lines
1 KiB
Text

uniform float4x4 ViewProj;
uniform texture2d image;
uniform float2 texel;
uniform int widthHalf;
uniform int width;
sampler_state textureSampler {
Filter = Point;
AddressU = Clamp;
AddressV = Clamp;
};
struct VertDataIn {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
struct VertDataOut {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
VertDataOut VSDefault(VertDataIn v_in)
{
VertDataOut vert_out;
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj);
vert_out.uv = v_in.uv;
return vert_out;
}
// Gaussian Blur
float Gaussian(float x, float deviation) {
return (1.0 / sqrt(2.0 * 3.141592 * deviation)) * exp(-((x * x) / (2.0 * deviation)));
}
float4 PSGaussian(VertDataOut v_in) : TARGET
{
float4 rgba = float4(0, 0, 0, 0);
for (int k = -widthHalf; k <= widthHalf; k++) {
float4 smpl = image.Sample(textureSampler, v_in.uv + (texel * k));
smpl *= Gaussian(k / width, 1.0);
rgba += smpl;
}
return rgba;
}
technique Draw
{
pass
{
vertex_shader = VSDefault(v_in);
pixel_shader = PSGaussian(v_in);
}
}