uniform float4x4 ViewProj; uniform texture2d image; uniform float2 texel_step; sampler_state textureSampler{ Filter = Linear; AddressU = Clamp; AddressV = Clamp; MinLOD = 0; MaxLOD = 0; }; struct VertData { float4 pos : POSITION; float2 uv : TEXCOORD0; }; VertData mainTransform(VertData v_in) { v_in.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj); return v_in; } float4 mainImage(VertData v_in) : TARGET { // Downsample filter as defined here: // https://blog.en.uwa4d.com/2022/09/06/screen-post-processing-effects-chapter-5-dual-blur-and-its-implementation/ float4 col = image.Sample(textureSampler, v_in.uv); float4 col_dn_rt = image.Sample(textureSampler, v_in.uv + 0.5f*texel_step); float4 col_dn_lt = image.Sample(textureSampler, v_in.uv + 0.5f*float2(-texel_step.x, texel_step.y)); float4 col_up_rt = image.Sample(textureSampler, v_in.uv + 0.5f*float2(texel_step.x, -texel_step.y)); float4 col_up_lt = image.Sample(textureSampler, v_in.uv - 0.5f*texel_step); return (4.0*col + col_dn_rt + col_dn_lt + col_up_rt + col_up_lt)/8.0; } technique Draw { pass { vertex_shader = mainTransform(v_in); pixel_shader = mainImage(v_in); } }