Projective texture weirdness

Hi guys,

When do projective texturing, I get light on and close to the projection near plane.

Here is a picture of the problem

Here is a picture of the light and it’s frustum touching the object

Here is the projection texture I use :

Here is the code I use to setup the projection :



         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};
         glTexGenfv(GL_S, GL_OBJECT_PLANE, splane );
         glTexGenfv(GL_T, GL_OBJECT_PLANE, tplane );
         glTexGenfv(GL_R, GL_OBJECT_PLANE, rplane );
         glTexGenfv(GL_Q, GL_OBJECT_PLANE, qplane );



         //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).]

Ok. I found how to fix it but I don’t understand why.

The band only appears when use a mipmaping filtering mode, I have been trying to picture what happens but I don’t see how the band appears.

Anybody has a reason?

i couldnt actually see any problem in the screenshot.
perhaps use GL_NEAREST

edit - oh i see u do

[This message has been edited by zed (edited 02-15-2003).]

Zed, the problem is the band in the middle. Maybe I should have described the first picture a bit better.

The 2 half-elipses on each side are the projection and the back projection. The band in the middle should not be there, but I found it only appears with filtering mode of type GL_MIPMAP.

So I fixed my problem, but I still don’t understand why it was a problem in the first place

[This message has been edited by Gorg (edited 02-15-2003).]

ok i see,
try using GL_REPEAT u it should give u an idea of whats happening
well u need to do is for each mipmap level create a border around the image + use clamp_to_edge.

glubuildmipmaps wont cut the ice

Oh I see now what was happenning! Thanks Zed.