Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / Full Screen Projective Texture Mapping Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Kain1956

March 26, 2005, 10:48 PM

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?

 
Reedbeta

March 27, 2005, 12:04 AM

It seems to me you will need a perspective projection, not an ortho one, to do this, if you are drawing the quads with perspective. Consider: you basically want the texture coordinates of the quads to be a function of their screen space coordinates. The way I would do this is to put the quads' vertex locations into their texture coordinates, and then set the texture matrix to the product of the projection and modelview matrices. That way the texture coordinates will be the same as the post-projection vertex coordinates. The post-projection vertex coordinates are in the range [-1, 1] in X and Y, so apply one additional scale-and-bias to the texture matrix to move these into the [0, 1] range. The texture matrix is then scale-and-bias * projection * modelview. (This could be done even more efficiently using a vertex shader, though the texture matrix will do the job fine.)

 
Kain1956

March 27, 2005, 02:30 PM

I have not tried what you have described but I wanted to add more information to see if this still makes sense to you. 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 640x480 ortho projection to have each pixel from the frame buffer texture line straight into the grass. I could be wrong.

 
Reedbeta

March 27, 2005, 03:46 PM

Hang on. I assumed that during the first pass, you're rendering the field from the same viewpoint that you will use during the second pass. Is that right? Or are you rendering the field from above, using an ortho projection in the first pass?

Anyways, ortho and perspective projections both use straight lines, but in an ortho all the lines are parallel and in perspective, they radiate out from a center point. If you are rendering the first pass with the same viewpoint as in the second pass, it will be a perspective projection to splat the framebuffer texture onto the world, since you are basically drawing a line from the camera through each pixel of the framebuffer and seeing where it hits the world, and these lines are radiating out from a center point rather than being parallel.

 
Kain1956

March 27, 2005, 06:18 PM

I am rendering both with the same viewport so I assume that the view matrix is not included in the equation. If what you say is correct, then all I need to give to directx for the texture matrix is the projection matrix of the world view and the scale and bias of .5. Does that seem correct?

 
This thread contains 5 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.