How To Solve Z buffer Fighting
A bit off topic, but I feel that someone should tell you that glu is deprecated, as is all of the fixed function pipeline. Since you are new to 3d graphics, I figure its worth mentioning that. You should read up on the programmable pipeline. Also, this is a great book that I love which helped me transition from fixed function pipeline to programmable pipeline: http://www.amazon.com/OpenGL-4-0-Shading-Language-Cookbook/dp/1849514763/ref=sr_1_1?ie=UTF8&qid=1340288671&sr=8-1&keywords=opengl+4.0+shading+language+cookbook
The reason for pushing the far plane has to do with depth values being written between 0 and 1, Most depth values lie in the range .95 and up and are smashed together. If things in your scene disappear when increasing the near plane, then your objects are way too small. Try scaling them up.
There is another solution to Z fighting: Multi-pass rendering. Draw your scene in multiple passes. Each pass gets the full 0-1 depth range, and your draw distance can be as long as you'll like. I know this is a good solution to drawing things in space, where the great distances may need to be handled differently that normal.
yes. more than half of machines still have fixed pipeline yet.
But are those machines realistically in your target audience? Or are you compromising your program for the sake of hardware that nobody is even going to run it on?
The real problem may be that you try to draw more than one plane at the same depth, if you have problems with depth buffer fighting. The result will be undefined, random, or flickering. Or all of the above. It is not realistic to draw two things at the same place and have any expectations on the outcome.
You have to decide what surface should be "above", and adjust the coordinates accordingly. If this doesn't help, then you need to adjust resolution (as described above).
The are special mechanisms in OpenGL that adds a small delta to target this problem. It is described in the OpenGL superbible, which I do not have access to just now.
You have to decide what surface should be "above", and adjust the coordinates accordingly. If this doesn't help, then you need to adjust resolution (as described above).
The are special mechanisms in OpenGL that adds a small delta to target this problem. It is described in the OpenGL superbible, which I do not have access to just now.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement