GPU Interpolation

Started by
6 comments, last by LeGreg 15 years, 9 months ago
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?
Advertisement
I believe it's all linear interpolation. All components of all properties are linearly interpolated. Texture coordinates as well.
Million-to-one chances occur nine times out of ten!
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.
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?
Million-to-one chances occur nine times out of ten!
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).
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!
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.
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

This topic is closed to new replies.

Advertisement