PDA

View Full Version : Expanding graphics caused clipping errors?



urchinsub
09-21-2010, 10:45 AM
I made a cube and then little figurines to put on all six sides of it. Everything looked good but their size was small (ex: float bottom=0.0, top=7750.0). I decided that the small values I used for my vertices would invite problems later when I try to make the graphics more detailed.
My solution was to manual change the display code so that everything was scaled by 10. Then I moved the camera's position as if it's distance from the objects had been scaled by 10.
The result is that everything looks proportionally equivalent on the screen as it did before. The problem is that polygons and pieces of polygons seem to be dissappearing, mostly at the bottom of the figurines where they rest on the cube but the edges of the cube are behaving similarly.
The graphics are all in display lists and I used GL_QUAD_STRIP quite often. These errors only occured after I manually scaled everything. Any ideas? Thanks.

ZbuffeR
09-21-2010, 03:54 PM
Depth buffer precision ?
You may have forgotten to x10 the camera clips planes too, both for near and far.

Anyway, whatever scale you use will work, floats have relative precision anyway.

urchinsub
09-22-2010, 02:15 AM
It doesn't seem to be the clipping planes. Thanks for your help though.
I want to replace my hand-coded graphics with nicer modeled ones. I thought scaling them to that size might cause detail loss with floating-point errors, that's why I tried changing it. I'll just roll-back to an earlier version but I fear I may still need to discover the cause of this error later.
Thanks again.

urchinsub
09-22-2010, 03:02 AM
Having examined the graphics of the older program more closely I see the problem was pre-existing, just not as noticable. For some reason, scaling the camera position still left the cube a little larger on the screen than in the older code. From a distance it just looks like a pixelation issue but up close you can see it is leaving out particular triangles from the GL_QUAD_STRIPS at different points of view. I have checked the order of my vertices in my quadstrips and they are ok. I rewrote them using GL_QUADS and still get the same results.
Any ideas? Thanks.

ZbuffeR
09-22-2010, 06:24 AM
What are your values for near and far clip planes ? It directly affects depth buffer precision, which still looks the most probable cause of your problem, see here :
http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

Verify you ask for (and get) a 24 bits z buffer.

A screenshot would help.