2017-08-19 22:19:58 +00:00
|
|
|
// OBS Default
|
2017-07-03 00:46:33 +00:00
|
|
|
uniform float4x4 ViewProj;
|
|
|
|
|
2017-08-19 22:19:58 +00:00
|
|
|
// Settings (Shared)
|
|
|
|
uniform texture2d u_image;
|
|
|
|
uniform float2 u_imageSize;
|
2017-10-22 17:05:29 +00:00
|
|
|
uniform float2 u_imageTexel;
|
2017-08-19 22:19:58 +00:00
|
|
|
uniform int u_radius;
|
|
|
|
uniform int u_diameter;
|
|
|
|
uniform float2 u_texelDelta;
|
|
|
|
|
|
|
|
// Settings (Private)
|
|
|
|
//uniform float registerkernel[25];
|
|
|
|
uniform texture2d kernel;
|
|
|
|
uniform float2 kernelTexel;
|
|
|
|
|
2018-04-28 12:41:18 +00:00
|
|
|
sampler_state textureSampler {
|
2017-07-03 00:46:33 +00:00
|
|
|
Filter = Point;
|
|
|
|
AddressU = Clamp;
|
|
|
|
AddressV = Clamp;
|
2017-08-19 22:19:58 +00:00
|
|
|
MinLOD = 0;
|
|
|
|
MaxLOD = 0;
|
|
|
|
};
|
2017-07-03 00:46:33 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-08-19 22:19:58 +00:00
|
|
|
float4 PSGaussian(VertDataOut v_in) : TARGET {
|
2018-04-28 12:41:18 +00:00
|
|
|
float2 uvOffset = float2(0, 0);
|
|
|
|
float4 rgba = u_image.SampleLevel(textureSampler, v_in.uv, 0)
|
|
|
|
* kernel.SampleLevel(textureSampler, (float2(0, u_radius - 1) * kernelTexel), 0).r;
|
|
|
|
for (int k = 1; k <= u_radius; k++) {
|
|
|
|
uvOffset += u_texelDelta;
|
|
|
|
float l_g = kernel.SampleLevel(textureSampler, (float2(k, u_radius - 1) * kernelTexel), 0).r;
|
|
|
|
float4 l_p = u_image.SampleLevel(textureSampler, v_in.uv + uvOffset, 0) * l_g;
|
|
|
|
float4 l_n = u_image.SampleLevel(textureSampler, v_in.uv - uvOffset, 0) * l_g;
|
|
|
|
rgba += l_p + l_n;
|
|
|
|
}
|
|
|
|
return rgba;
|
2017-07-03 00:46:33 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 05:01:23 +00:00
|
|
|
technique Draw
|
2017-07-03 00:46:33 +00:00
|
|
|
{
|
2017-07-03 05:01:23 +00:00
|
|
|
pass
|
2017-07-03 00:46:33 +00:00
|
|
|
{
|
|
|
|
vertex_shader = VSDefault(v_in);
|
|
|
|
pixel_shader = PSGaussian(v_in);
|
|
|
|
}
|
|
|
|
}
|