PDA

View Full Version : Z-fighting problem with vertex programs and shadow volumes



passalis
02-17-2004, 05:50 PM
Hi all,

I have implemented shadow volumes, and I do a render pass for ambient light with glDepthFunc(GL_LESS) and then for each light I do an additional pass with glDepthFunc(GL_EQUAL) and blending enabled(if of course it passes the stencil test for this light).

The objects during the ambient pass are rendered through the fixed pipeline (just their textures multiplied with 0.1). The later render passes though, for some object use ARB_vertex_program for bump map puproses.

The problem is that for the objects that are rendered using vertex programs there is a lot of z-fighting during the blending (indepedently of whether they are shadowed or not). This does not happen for those objects that are rendered using fixed pipeline both at the ambient pass and the specular passes.

As far as I know I couldnot find any bug in my code. My guess is that the transformation is done with different percision in the vertex program compared to the fixed pipeline. I have a GeForce 4 GO so the fixed pipeline is done in the GPU (T&L) and the vertex programs probably in the CPU. Has anyone encountered such problems? Any advice on how to solve it?

PS1: in the vertex program I do the usual stuff with the vertex position and do not mess with it in any other way:
DP4 result.position.x, mvp[0], pos ;
DP4 result.position.y, mvp[1], pos ;
DP4 result.position.z, mvp[2], pos ;
DP4 result.position.w, mvp[3], pos ;

PS2: Of course I know that a solution would be to write a VP that emulates the fixed pipeline and use this one to do the ambient pass for those objects that will later be rendered using VP but I was hoping for something simpler.

chemdog
02-17-2004, 06:51 PM
There's an OPTION in the vertex program to specify fixed function position invariance.

OPTION ARB_position_invariant

passalis
02-17-2004, 08:18 PM
Thanks man, it solved the problem completely!

Bobo.Bobo
02-18-2004, 11:06 AM
Hi,
I've got the same problem and could you help me? I don't know how to turn on this OPTION... http://www.opengl.org/discussion_boards/ubb/smile.gif I'm writing in NVidia CG language and I don't know where to put it.
Thanks for help!

passalis
02-18-2004, 04:39 PM
Hmmm, in ARB you just put it on the second line (after !!ARBvp1.0). I don't know whether CG supports it (since it compiles to many vertex program profiles) but you can always just add the line yourself at the compiled code.