Jump to content
  • Advertisement
Sign in to follow this  
Numsgil

Pixel coordinates

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

When a pixel is rasterized to be sent to the pixel shader, are the coordinates of the pixel in the top left corner, the center, or some other corner? Does it depend on any flags or options?

That is, given a pixel at (4, 5), is the pixel's bounds (4,5) to (5,6), or (3.5, 4.5) to (4.5, 5.5)?

I've tried looking through a few different sources, but I can't find a concrete answer. I could write a test to find out, but I'm betting someone knows off hand.

Share this post


Link to post
Share on other sites
Advertisement
For D3D9 pixel centers are at integer coordinates while texel centers are at 0.5, while in D3D10/D3D11 they're both at 0.5.

Share this post


Link to post
Share on other sites
This would be DX9 (XNA actually).

Just so I'm sure I understand, when you say Texel centers are at 0.5, does that mean only when sampling from a texture inside a shader? Otherwise, when triangles are rasterized to be sent to the pixel shader, their pixels are sampled at the center of the pixel?

Share this post


Link to post
Share on other sites
Yup. This is why you need to offset values by a half-texel when converting screen coordinates to texture coordinates. See this for more details.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!