[Solved] Lighting problems (Zfighting)
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]
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
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
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 ...
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 ...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement