Sign in to follow this  

Non-precise pixel retrieving in 2.0 shaders

This topic is 3717 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

A picture(bmp) 512*512, backbuffer size also 512*512. I want to retrieve color of certain pixel (8 left 6 top in this example) Instead I see mix of colors of several neighbour pixels Shader code: sampler s0: register(s0); float4 main_ps(float2 tex: TEXCOORD0) : COLOR { float div=512; return tex2D(s0, float2(8.5/div, 6.5/div)); } Also, then I just draw whole texture on screen sampler s0: register(s0); float2 w: register(c1); float2 h: register(c2); float4 main_ps(float2 tex: TEXCOORD0) : COLOR { return tex2D(s0, tex+0.5*w-0.5*h); } one-pixel height black horizontal line (on white picture) is blurred. w,h is picture size. Half-pixel offset is for precision, without it blur is even stronger. So, can pixel shaders retrieve pixels precisely? If not, is there a way to at least improve their precision?

Share this post


Link to post
Share on other sites

This topic is 3717 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this