View Full Version : Projected Textures
Anybody done projected textures in opengl? I'd like to give it a shot, but don't know where to start.
Any urls that might help?
I recently wrote a very simple demo program whose sole purpose is to illustrate projective texturing. I think the code is pretty easy to follow, so I put it out on my web page in case you'd like to look at it.
It has a Makefile for linux and a project file for MSVC++.
The thing about projective texturing is that you can think of it as just another camera in the scene. You use GL_EYE_LINEAR texgen - and I'll mention that it's important when you specifiy your texgen eye planes because they're transformed by the inverse of the current modelview matrix. (This took me a while to figure out, but it's the kind of thing you never forget after wasting hours trying to make your program behave correctly. http://www.opengl.org/discussion_boards/ubb/smile.gif ) Anyway, what that means is that you'll probably want the VIEW in the modelview matrix when you specify your eye planes for texgen. That way coordinates that texgen produces are in "world" space. You can then put your view, projection, and scale and bias transforms into the texture matrix and voila. That's it. The reason you need a scale and bias is that the standard projection functions (like gluPerspective) move coordinates that are in the view frustum in eye space into the [-1,1] range. Since texture coordinates are in the range [0,1], you need a final scale by half and bias by half.
I think the code that I linked to should complement this post pretty well. If you are comfortable with how transforms work and how to position the camera and stuff, projective texturing is pretty simple to get the hang of.
Good luck -
[This message has been edited by cass (edited 04-09-2000).]
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.