Rendering issues

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

Recommended Posts

Hi, I am trying to render a 3ds model - I am batching it per material basis. However it seems to have artifacts on rendering:- This is my Init code
	glClearColor(0, 0, 0, 0);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);


Any idea on how I can fix this ? I am not doing any kind of culling. Thanks

Share on other sites
Z fighting ( difference in depth buffer for two points are smaller than resolution of depth buffer... ) You can see this problem in some commercial games like Medal Of Honor (Q3 engine) if you turn 16-bit rendering instead of 32b ( switches z-buffer from 24b-16b ). Try changing depth buffer to 24b, or scale down youre models.... hope i helped, bye.

Share on other sites
also, the near and far z-planes can make a difference here, what are yours currently set tp?

Share on other sites
Near and far are 0.1f - 1000.0f. I changed to 24 and 32 bit. Its a lot better in that mode but artifacts still exists.

Thanks

Share on other sites
Quote:
 Original post by CRACK123Near and far are 0.1f - 1000.0f. I changed to 24 and 32 bit. Its a lot better in that mode but artifacts still exists.Thanks

Change near to 1.0 and keep far at 1000.0 or change far to 100 and keep the near. The ratio between the two shouldn't exceed 1:1000.

HTH

Share on other sites
Whats the reason that it should be only 1000 ? Also in many cases I have seen people using 1.0, 4000.0f etc -> this means ratio is 1:4000 ?

Share on other sites
I use 1 to 1000, I haven't seen any Z-fighting in my stuff yet. You could get away with 1 to 4000, but if you have verts that are really close, they'll fight it out.

Share on other sites
you can change the near and far dynamically to help your rendering. There really is no reason to waste empty space. Just set the near to a bit smaller than the nearest vertex in the fov and set the far to a bit higher than the object with the greatest distance in the fov.

You don't need to change this every frame but often enough to help solve your problem. Obviously you will have to make sure to keep track of objects and how to set the near and far during motion too.

Share on other sites
One issue to be aware of with the Z buffer is that it is not a linear scale. This means closer to the near plane, it has a greater precision than close to the far plane.

Also, pushing the near plane further out has a much more dramatic effect than bringing the far plane closer to you.

Read this page. It is very very useful, and has a nice applet thing to show you the results of different parameters: Learning to Love your Z-Buffer..