texture problems when doing multiple passes

Anyone want to take a shot at why my texture is doing this? I’m trying to bumpmap and shadow projection in multiple passes:
first, drawing from the camera’s POV.
second, drawing the model and floor normally. The model is bumpmapped, using register combiners and vertex program.
third, draw the floor and model with shadows. enabling blending.
http://www.prism.gatech.edu/~gte810p/sshot3.jpg http://www.prism.gatech.edu/~gte810p/sshot4.jpg

Do you output valid texture coordinates to all texture units?

Could be z-fighting. Make sure your z comparison function passes on equality.

titan: I believe I have valid text coords for all units. The quad that the model is on (the floor) renders fine. It is only on the model that I get the artifact. I’ll keep looking through to make sure though.

OneSadCookie: I have glDepthFunc(GL_LEQUAL). Is that what you mean? The other depth function I use is SGIX for the shadow mapping, and that’s set to GL_TEXTURE_LEQUAL_R_SGIX.

Thanks for the ideas.

Originally posted by MrRolf:
OneSadCookie: I have glDepthFunc(GL_LEQUAL). Is that what you mean?

I think OneSadCookie meant that you should make sure that you’re not doing something that would make your geometry lose it’s positional invariance in your second pass. ie. Some state changes (and methods of sending your geometry to Opengl) will cause your geometry to be in a slightly different position between passes.

However, your images look a little too uniform for z-fighting (but you never know). Do each of the passes render OK if done on their own?

yes, both passes render OK seperately.

I don’t do anything to the geometry between passes. Here are the state changes I do though:

//… Let ogl do some matrix math for me here

glBindTexture(GL_TEXTURE_2D, shadowTex);



//Do this for S, T, R, Q
glTexGenfv(GL_S, GL_EYE_PLANE, objPlaneS);

//Repeat above for GL_TEXTURE1_ARB

glBlendFunc(GL_ONE, GL_ONE);

[This message has been edited by MrRolf (edited 07-27-2003).]

When you do depth texture shadows you’re supposed to include an offset to stop depth aliasing like this.

The other solution (for solid objects only) is to draw the backfacing objects and cull the frunt faces when you render the depth texture.

Do you use glPolygonOffset before you render the scene from the light’s view?


dorbie: I enable GL_POLYGON_OFFSET_FILL and call glPolygonOffset with appropriate numbers before I draw to the shadow map. I varied the factor from 1.1 to 40.0, and the units from 1.0 to 80.0. This unfortunately did not help my problem.

I enabled front face culling, and it had no affect on the texture problem.


If I disable bumpmapping on the model, it works fine.
I use 4 texture units, 2 2D and 2 cubemap, to bump mapp. I also use register combiners and a vertex program. Could these somehow be interfering with the shadowed texture? Is there some special way that I need to blend this?


OK, based on experience this still looks like a problem with the depth shadow test. It’s very strange that you’d get this with front face culling when drawing the shadow map. Perhaps there’s a format incompatibility of some sort and we’re seeing some kind of LSB overflow.

Very strange.

Do you touch the depth fragment out in the bump map shader?

[This message has been edited by dorbie (edited 07-27-2003).]

I’m using VP1.0. I touch/use OPOS, HPOS, NRML, TEX0, TEX1, TEX2 C[0-5], R0-R3.

If I disable the VP, the shadow texture works fine. So I assume somewhere in the VP I’m messing up. Where in those varibles could the depth component be?

I think I know where the problem is now (thanks dorbie). In the VP I do:
DP4 o[HPOS].x, c[0], v[OPOS];
DP4 o[HPOS].y, c[1], v[OPOS];
DP4 o[HPOS].z, c[2], v[OPOS];
DP4 o[HPOS].w, c[3], v[OPOS];

This is computing the resulting vertex position. Maybe the precision or rounding is off and it’s giving me the depthmap problems. Now the hard part… how to correct/compensate for this.

You’re aware that vertex programs aren’t invariant with fixed function transforms, right? If you do multiple passes and need the vertex program depth to be invariant with the fixed function depth use the position invariant option (se ARB_vertex_program specs).

That code looks like NV vertex program, then iirc you set the invariant opption with a glCall instead of writing it into the program.

But if you dont make anything special for NV i suggest you take a look at ARB_vertex_program, then the programs works on ATI cards as well.

I just assumed the position would be the same. After putting in the NV_position_invariant option (and taking out the DP4) it works fine.

Thanks to all that helped out!

Mazy: I’ll look into converting the program to be non NV specific.