Jump to content
  • Advertisement
Sign in to follow this  
adoniseagle

OpenGL [Solved] Lighting problems (Zfighting)

This topic is 3710 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

Hi all, I'm just trying ot draw some spheres with opengl fixed lighting function and the result look good. But when I activate the depth buffer, the result is too bad. It's seems to have conflits with some values(normal, Zfighting??). I join an image for illustration : With depth buffer: http://pix.nofrag.com/1/f/3/2ec1556957aa01dcfce82bfd71b22.jpg Without Depth buffer: http://pix.nofrag.com/0/4/5/f961c5d55b720f10b9900fc887feb.jpg Do you have some idea ? => 1 I have tried to play with polygon offset (bad result too) => 2 I have use my own drawing code for the sphere (same result) => 3 I have tried to play with depth buffer option( GL_LESS...) Thanks, [Edited by - adoniseagle on May 25, 2008 7:51:25 AM]

Share this post


Link to post
Share on other sites
Advertisement
If it is z-fighting, check how you setup the projection matrix.
If you are using glFrustum or gluPerspective, make sure znear is large then 0.0 and zfar is not huge
Maybe znear=0.1 and zfar=4000.0

Share this post


Link to post
Share on other sites
I'm using that to setup the projection matrix :

glMatrixMode(GL_PROJECTION); glPushMatrix();
glLoadIdentity();
gluPerspective(46.,widthWindow/heightWindow,0.,1000);

So you suggest me to increase my Znear Value and ZFar too.

I have tried this value gluPerspective(46.,widthWindow/heightWindow,0.1,4000)
and my problem is solved.

Thanks a lot.

Could you explain me if you have more explanation about the origin of the Zfighting problem ...

Share this post


Link to post
Share on other sites
Ok, I suppose when the 2D projection is computed we can obtain some value with undef values because of division with a Zero at denominator.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!