Jump to content
  • Advertisement
Sign in to follow this  
GaryNas

GPU Interpolation

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

Under Direct3D 9, what kind of interpolation is done between vertex shader output and pixel shader input; specifically those items passed with a TEXCOORDn semantic? What exactly happens inside the "rasterization and component interpolation" stage of the pipeline?

Share this post


Link to post
Share on other sites
Advertisement
I believe it's all linear interpolation. All components of all properties are linearly interpolated. Texture coordinates as well.

Share this post


Link to post
Share on other sites
Close, but not quite. Texture coordinates are interpolated in world space, as opposed to clip space (despite the fact that rasterization is otherwise happening in clip space). This is more mathematically complex, but it is necessary for proper results when objects are viewed obliquely. More (somewhat outdated) info here.

Share this post


Link to post
Share on other sites
Interesting. So does this happen for all TEXCOORD outputs? Including the ones that are just used to pass custom info? Or is the idea therefore not to pass anything but actual texture coordinates in TEXCOORDs between vs and ps?

Share this post


Link to post
Share on other sites
Quote:
Original post by Mike nl
Interesting. So does this happen for all TEXCOORD outputs? Including the ones that are just used to pass custom info? Or is the idea therefore not to pass anything but actual texture coordinates in TEXCOORDs between vs and ps?

It happens for all vertex attributes, from texture coordinates to colors to fog coefficients. The problem which lead to the need for this method is not unique to texture coordinates. It's what you have to do if you want perspective-correct interpolation of anything. The only time it causes problems is when you actually do want screen-space interpolation, which is rare (though it's happened to me).

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
It happens for all vertex attributes, from texture coordinates to colors to fog coefficients. The problem which lead to the need for this method is not unique to texture coordinates. It's what you have to do if you want perspective-correct interpolation of anything. The only time it causes problems is when you actually do want screen-space interpolation, which is rare (though it's happened to me).


Thanks for your great information and link on this. Believe it or not, I'm actually looking into this topic because I need to do screen-space interpolation. I'm trying to learn about the perspective correct interpolation that happens from vertex to pixel shaders so I can somehow negate it. D3D10 simply has semantic modifiers, but it seems like D3D9 requires a bit of trickery.

If you have time, could you expand a bit on how you accomplished screen-space interpolation?

Thanks!

Share this post


Link to post
Share on other sites
Primarily, by using orthographic projection. [grin] I had a method of undoing it for perspective projection, but it was rather seat-of-the-pants and I doubt I still have the code for it still lying around. It _is_ possible, though, and I remember it being fairly straightforward... merely a matter of dividing the texture coordinates by the positional W coordinate, or something.

Share this post


Link to post
Share on other sites
Quote:
Original post by GaryNas
Thanks for your great information and link on this. Believe it or not, I'm actually looking into this topic because I need to do screen-space interpolation. I'm trying to learn about the perspective correct interpolation that happens from vertex to pixel shaders so I can somehow negate it. D3D10 simply has semantic modifiers, but it seems like D3D9 requires a bit of trickery.

If you have time, could you expand a bit on how you accomplished screen-space interpolation?


D3D9 and shader model 3 have screen coordinates x,y as system values (vPos or position register).

For broader solution involving projective textures you can refer to that small article :
Screen space interpolation and non perspective correct attributes.

Hope that helps,
LeGreg

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!