Error in projected textures (good topic, sorry for the other 2)

First, sorry for the triple post! The forum crashs because it can’t accept the OR symbol, making me unregistered after posting the message! And then can’t delete and there is was no moderator around to solve the problem… :frowning:

Here is the problem:

I implemented projected textures and I got this:

The problem is the line of projected texture seen on the right on the pictures. The last picture shows better the ambient where the light is being projected.

I use the next code to generate the texture coordinates (in the vertex shader):


Then in the pixel shader:

if (texCoordProj.z<=0.0) discard;
proj = texture2DProj(texProjection,texCoordProj);

The texCoordProj.z<=0.0 gets rid of the backprojection, but that line is always there. Even without texCoordProj.z<=0.0, with the texture being back projected, it still makes that line. I think it may have something to do with the light’s frustum because the line seems parallel to the near clipping plane of the lights frustum… But why?

Maybe your shadow map is filtering against the border? Have you tried setting GL_CLAMP_TO_EDGE wrapping mode?

i cannot understamd what part of the projected texture this line is. but when i had an other problem with projective texture i use GL_CLAMP_TO_BORDER and i finaly fix this.

OK, thanks… Fixed it! :smiley:

I was already using GL_CLAMP_TO_EDGE, but using GL_CLAMP_TO_BORDER solves the problem, even tought I create the textures with border 0. :confused:

If your texture is specified without a border, GL_CLAMP_TO_BORDER uses a constant color instead. You can change this color by setting GL_TEXTURE_BORDER_COLOR with glTexParameter*().

– Tom