Jump to content
  • Advertisement
Sign in to follow this  

Non-precise pixel retrieving in 2.0 shaders

This topic is 3932 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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!