View Full Version : Problem with textureProj(......)
03-16-2011, 10:54 PM
This function means access the texrture with projection .But,when i was learning Shadow maps, i found myself do not fully understand the way textureProj works
,especially the meaning of access the texrture with projection.
could someone explain this function in detail for me ?
03-16-2011, 11:44 PM
It's really quite simple.
The perspective projection (http://www.arcsynthesis.org/gltut/Positioning/Tut04%20Perspective%20Projection.html) is an operation that involves two steps: a matrix multiply and a division by one of the coordinates.
When you're doing perspective projections to compute window-space coordinates, you do the matrix multiply, and OpenGL does the division for you. This is important for things like perspective-correct interpolation and so forth.
Texture projection is the same thing: you're projecting position values. Except here, you're projecting them into the space of the texture rather than window-space. But the same process happens. You transform the positions by a matrix, and then do a division.
The textureProj functions allow OpenGL to do the division for you. So if you're accessing a 2D texture, you provide 3 coordinates: the X, Y and W values from your perspective projection matrix multiplication. OpenGL will divide the X and Y by W and use the resultant value to access the texture.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.