Sign in to follow this  
telvanni

Non-precise pixel retrieving in 2.0 shaders

Recommended Posts

telvanni    122
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

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