Jump to content
  • Advertisement
Sign in to follow this  
Mr_Fox

Get pixel's location

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

Hey,

 

Just want to check with you guys:

IIRC, any vertex after applying projection matrix, should report it pixel location at x, and y component right?

 

so if you have the simplest pixel shader like the following, each of your rasterized pixel should report its screen location in it's x, and y component:

float4 main( float4 f4ProjPos : SV_POSITION ) : SV_Target
{
    return f4ProjPos;
}

I have this simple case setup (I render a unit length cube), and after I run it with visual studio graphics debug, I found out there are decent number of pixel whose value is not pixel location (1-8 offset).

 

I am super confused with this result, so I am here hoping you guys could tell me what I have missed? Is the interpolation modifier I have to specifically set? or there are any fundamental HW stuff prohibit this?

 

Thanks 

Share this post


Link to post
Share on other sites
Advertisement

IIRC, any vertex after applying projection matrix, should report it pixel location at x, and y component right?

No, the projection matrix takes you to 4 dimensional pre-projective-divide NDC space, where xy>-w and xy<w. After dividing xy by w (which the GPU does for you during rasterization) you get -1<xy<1.

HOWEVER, yes, in the pixel shader, the SV_POSITION semantic implements a bit of magic and applies this divide by w and also applies the viewport matrix, resulting in xy pixel coordinates.

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!