• Advertisement
Sign in to follow this  

stupid pixel shader question

This topic is 3354 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i thought a pixel shader was meant to shade pixels which it sometimes seems to, but when i try various simple blurring algorithms to smooth images like //-------------------------------------------------------------------------------------- // Pixel Shader //-------------------------------------------------------------------------------------- float4 PS( PS_INPUT input) : SV_Target { float4 p1 = txDiffuse.Sample(samLinear, input.Tex, int2(-1,1)); float4 p2 = txDiffuse.Sample(samLinear, input.Tex, int2(-1,0)); float4 p3 = txDiffuse.Sample(samLinear, input.Tex, int2(-1,-1)); float4 p4 = txDiffuse.Sample(samLinear, input.Tex, int2(0,-1)); float4 p5 = txDiffuse.Sample(samLinear, input.Tex, int2(0,1)); float4 p6 = txDiffuse.Sample(samLinear, input.Tex, int2(1,1)); float4 p7 = txDiffuse.Sample(samLinear, input.Tex, int2(1,0)); float4 p8 = txDiffuse.Sample(samLinear, input.Tex, int2(1,-1)); float4 p9 = txDiffuse.Sample(samLinear, input.Tex); float4 p10 = txDiffuse.Sample(samLinear, input.Tex, int2(-2,-2)); float4 p11 = txDiffuse.Sample(samLinear, input.Tex, int2(2,-2)); float4 p12 = txDiffuse.Sample(samLinear, input.Tex, int2(2,2)); float4 p13 = txDiffuse.Sample(samLinear, input.Tex, int2(-2,2)); return (((p10+p11+p12+p13)/36)+ ((p1+p3+p6+p8)/18)+((p2+p4+p5+p7)/12)+ ((p9/9)*3)); } it doesnt blur based on the pixels, it blurs based on texels, so how can i blur based on pixels???

Share this post


Link to post
Share on other sites
Advertisement
pixelOffset = texelOffset * inverseScreenSize;

you can pass the shader parameter "inverseScreenSize" in you program, it's value is float2(1.0f / screenSize.width, 1.0f / screenSize.height)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement