mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-24 12:25:11 +00:00
191b1ea23f
This should help reusing the same effect instead of having an effect per filter.
49 lines
864 B
Text
49 lines
864 B
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;
|
|
}
|
|
|
|
// Box Blur
|
|
float4 PSBox(VertDataOut v_in) : TARGET
|
|
{
|
|
float4 rgba = float4(0,0,0,0);
|
|
for (int k = -widthHalf; k <= widthHalf; k++) {
|
|
rgba += image.Sample(textureSampler, v_in.uv + (texel * k));
|
|
}
|
|
rgba = rgba / width;
|
|
return rgba;
|
|
}
|
|
|
|
technique Draw
|
|
{
|
|
pass
|
|
{
|
|
vertex_shader = VSDefault(v_in);
|
|
pixel_shader = PSBox(v_in);
|
|
}
|
|
}
|