Sign in to follow this  

Vertex program's precision causes Z-fighting?

This topic is 4599 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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//

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites


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//

Share this post


Link to post
Share on other sites
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!!!


Share this post


Link to post
Share on other sites

This topic is 4599 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this