Sign in to follow this  
Kain1956

Projective Texture Mapping

Recommended Posts

Kain1956    122
I am using projective texture mapping to splat on the previous front frame buffer onto new quads I am drawing. When I do this, the frame buffer texture does not line up correctly with the quads. For the texture matrix, I use a 640x480 ortho projection matrix(size of the frame buffer texture) because I want the frame buffer to overlay pixel to pixel ontop of the new quads I am drawing. I do not use the view project because the view is the same for the camera and the projection. Does anyone know if there is anything else I need to use?

Share this post


Link to post
Share on other sites
Jason Z    6436
I am not sure if this applies to you or not, but if you are using DX instead of OpenGL then you need to offset your screen space coordinates by (-0.5,-0.5). There is a good explanation about why in the DXSDK, but it has to do with how DX samples textures and how the pixel positions are handled.

Share this post


Link to post
Share on other sites
Gluc0se    146
Yah I would guess what Jason Z said, in that are you not accounting for the fact that screen space is [-1,1] x [-1,1] and texture space is [0,1] x [0,1]. If thats not the case, could you describe how it looks? :)

Share this post


Link to post
Share on other sites
Kain1956    122
I am taking that into account. It looks like the texture is larger than it is. For example, if I use a 128x128 texture, it will come out on the quad as a 240x300. It seems like the texture is not lining up correctly. What I am trying to do is, draw a field with certain decals. I then want to add grass ontop of this field and have the field color that is under the grass be splat ontop of this grass. To do this, I take the frame buffer and make it into a texture and then use that texture to be splat onto the grass. I would think that if the frame buffer is 640x480, I would want to use an ortho projection to have each pixel from the frame buffer texture line straight into the grass. I could be wrong.

Share this post


Link to post
Share on other sites
Jason Z    6436
What you are saying sounds about right, you might need to post a screen shot of your problem to get a better idea. Also, if you are using pre-transformed (already in screen space) vertices for your quad that copies the frame buffer back onto the scene it won't run the vertex shader at all - so you don't need to worry about the projection. It's more like manipulating image space objects instead of 3d space objects.

If the quad looks like it is the wrong size, you just have to make sure that the vertices end up in the four corners of the frame buffer, and that the vertex texture coordinates are all maxed out ( from 0 to 1 ). If you still have trouble, maybe you could post some code?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this