Hi guys,
When do projective texturing, I get light on and close to the projection near plane.
Here is a picture of the problem http://members.rogers.com/deseric/problem.jpg
Here is a picture of the light and it’s frustum touching the object http://members.rogers.com/deseric/projectlight.jpg
Here is the projection texture I use : http://members.rogers.com/deseric/light.jpg
Here is the code I use to setup the projection :
glActiveTextureARB(GL_TEXTURE0_ARB); glClientActiveTextureARB(GL_TEXTURE0_ARB); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glEnable(GL_TEXTURE_GEN_R); glEnable(GL_TEXTURE_GEN_Q); GLfloat splane[4] = {1,0,0,0}; GLfloat tplane[4] = {0,1,0,0}; GLfloat rplane[4] = {0,0,1,0}; GLfloat qplane[4] = {0,0,0,1}; glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); glTexGenfv(GL_S, GL_OBJECT_PLANE, splane ); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); glTexGenfv(GL_T, GL_OBJECT_PLANE, tplane ); glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); glTexGenfv(GL_R, GL_OBJECT_PLANE, rplane ); glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); glTexGenfv(GL_Q, GL_OBJECT_PLANE, qplane ); glMatrixMode(GL_TEXTURE); glLoadIdentity(); //scale and bias to bring texcoord in [-1,1] to [0,1] glTranslatef(0.5f, 0.5f, 0.0f); glScalef(0.5f, 0.5f, 1.0f);
const GraphicTools::ViewVolume& theVolume = light.GetViewVolume();
glFrustum( theVolume.Left, theVolume.Right, theVolume.Bottom, theVolume.Top, theVolume.Near, theVolume.Far ); MultMatrix( light.GetFrame().GetWorldToFrame() ); MultMatrix( objectSpaceToWorldSpace );
The light origin does not coincide with the light frustum which has it’s near set to 3. I have tried moving back the near very close to 0, but nothing changed.
This gives me trouble because when I remove the back projection, I need to fudge the the bias to a bit less 0.5 to remove the band. But when I do that, if I am very close to an object and some of it’s vertices are behind the far plane ,I get a sharp cut in the middle of the light projection . This is because I use a 1d texture with one side black and one side white and use NEAREST has my filtering mode. So obviously some of the fugded texcoords fall in the black even they should be in the white.
Anyone ever got that or have any clue why it is doing so?
EDIT : fixed a link
EDIT : BTW, the projection is correct when all the points are in front(or behind) the projector plane
[This message has been edited by Gorg (edited 02-14-2003).]