Vertex program's precision causes Z-fighting?

Started by
5 comments, last by MrWereWolf 18 years, 11 months ago
To render the scene in my app I use multiple passes, ambient pass, light pass, texture pass and fog pass. The thing is that I wanted to make my light pass to use vertex program, but it seems that the vertices generated by the vertex program in the lighting pass don't match exactly the positions of the vertices in previous and future passes, wich is a criminal thing for a multipass engine, because of the z fighting. The vertices seem to have the same position, but their depth don't match exactly. If I use vertex program for all passes, the Z fighting is gone, but it's too expensive, specially because I have 250.000+ vertices. The reason for this is probably because vertex programs have shitty precision, specially at those DP4's. What could be my solution? -Stop using vertex programs; -Use vertex program for all passes; -Use glPolygonOffset? -Quit programming? Any other idea? //Mr.WereWolf//
Advertisement
If your using GLSL the ftransform function is supposed to match the fixed functionality.
And have you profiled it with using only vertex programs (you said you tried it and it worked, but you didn't say how much it slowed down). If I remember right ATI or nVidia implements the fixed pipeline with a vextex program on the card. Which implies that it shouldn't really slow down, at least on that card. Possibly the speed hit is only negible (I'm assuming it's negible based on the above, so I could be way off) on current gen cards, or your vertex program isn't as optimized as it could be.
just make a vertex program which does what you need and no more, the speed hit shouldnt be an issue on anything new as the R300 series does everything via shaders anyways as does the NV4x, the NV3x was the last series to have a mixed FF and shader pipeline


First, I use a (dusty) NV2x card, and anyway I'd like my app to be compatible with older cards.

I don't use GLSL.

I'd prefer not to use vertex program for all passes, cause other passes might use some texgen functions.

I'm thinking of using glPolygonOffset to fix this problem.

What do you think?


//Mr.WereWolf//
You're using the ARB_vertex_program extension, I suppose.
There is an invariance option for vertex programs, to ensure that the output position matches exactly the one obtained with fixed-function processing:
!!ARBvp1.0
OPTION ARB_position_invariant
//the rest of your vp. you should not write the result.position register here!!!


--------------------------------If you can't understand what I said, it's not you, it's because my english sucks!

Thanks, I didn't knew that, maybe that will fix my problem.

//Mr.WereWolf//

This topic is closed to new replies.

Advertisement