Archived

This topic is now archived and is closed to further replies.

bakery2k1

Projective textures with shaders

Recommended Posts

bakery2k1    712
I have been trying to implement projective texturing using both vertex and pixel shaders. In the vertex shader, I am specifying the texture coordinates to be the same as the transformed vertex position. I thought this would mean that the texture would be put "flat" on the scene, but I can still see where deeper parts are, as if the projection matrix is not being used. What have I missed? Any papers etc on this? Thanks

Share this post


Link to post
Share on other sites
CrazedGenius    156
Create a concatenated world/view/projection matrix as if you were rendering a scene from the projector''s point of view. Use that as your texture matrix.

However, you need to add one more matrix to scale and bias this to the 0-1 range of texture coordinates. There are docs at the nVidia developer''s site that talk about this. If that doesn''t make sense, reply here and I''ll post some code.

Share this post


Link to post
Share on other sites
bakery2k1    712
Thanks.

I did exactly that, but used a texture generation matrix instead of the texture matrix itself (I had already used this method in OpenGL). The exact problem was that the x and y coordinates for texture look-up were not being divided by the w coordinate (per pixel). This is done automatically in OGL, but wasn''t happening in DX. I fixed this by using

texld r0, t0_dw.xyw

in pixel shader version 1.4

Share this post


Link to post
Share on other sites