obs-StreamFX/data/effects/box-blur.effect
Michael Fabian Dirks 4dbf414214 effects, filter-blur: Precalculated Kernel, Formatting, Rendering and more
Filter:
* Massively improved Rendering loop to reduce overhead and provide cleaner code.

Gaussian Blur:
* Added precalculated Kernels using Textures. Slightly reduced GPU load.
* Added basic attempt at a Nvidia o(n/2+1) gaussian blur implementation.
* Fix up LOD for texture sampling.

Box Blur:
* Halved loop count.
2017-08-20 00:25:05 +02:00

55 lines
1.1 KiB
Text

// OBS Default
uniform float4x4 ViewProj;
// Settings (Shared)
uniform texture2d u_image;
uniform float2 u_imageSize;
uniform float2 u_imageTexelDelta;
uniform int u_radius;
uniform int u_diameter;
uniform float2 u_texelDelta;
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 = u_image.Sample(textureSampler, v_in.uv);
for (int k = 1; k <= u_radius; k++) {
rgba += u_image.Sample(textureSampler, v_in.uv + (u_texelDelta * k));
rgba += u_image.Sample(textureSampler, v_in.uv - (u_texelDelta * k));
}
rgba = rgba / u_diameter;
return rgba;
}
technique Draw
{
pass
{
vertex_shader = VSDefault(v_in);
pixel_shader = PSBox(v_in);
}
}