Distance inclarity

Started by
9 comments, last by cippyboy 20 years, 3 months ago
I feel numb about the words because I don`t know if that`s the issue here but here`s a pic to make things clear-> http://www.geocities.com/cippyboy_7/distance.jpg What you can see ? and what I think about it ? It is either becaue that polygon is very near to the poligons that are making up the car or... it`s a perspective calculation error... and I also have that NeHe glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); if it would make any difference. Conclusion questions -> why does that happen -> can it be fixed ?

Relative Games - My apps

Advertisement
Looks like a Z Buffer fighting artifact to me, im not sure how that ones solved but i remember having the same problem on my terrain engine and can''t seem to remember the fix as it was some while ago.

Its either: Z Buffer Confliction

OR

Texture Filtering...

Good lucks
I assume you''re talking about the number plate (assuming that''s what it is). Yes, it looks like a depth buffer problem (polygons too close together). You could try moving it further away from the body of the car or use glPolygonOffset. Before you do either, check whether you can solve the problem by moving your near clipping plane further away.

Enigma
Well the thing is that I don`t want to bring the plate up front... I could try but... I`d wish to fix this on some other way.
So I tryed moving the near clipping plane by... 10 units more(it was set on 1 unit), it just makes the artifact appear after 10 units more distance

I also used
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0,2);I think I saw that somwhere...2 and -2 tryed both

I noticed no difference though... it seems pretty unwanted and I think there`s nothing to be done but... I think I once saw this artifact with polygons near me... don`t know what triggered it but I`d try to make it happen again...

Relative Games - My apps

It is a z-buffer problem. I read somewhere the ideal ratio between near clip distance and far clip distance is 1/500. Try this and see.

gluPerspective(fov,(GLfloat)width/(GLfloat)height,0.1f,50.0f);

Where fov is your field of view angle (example 45.0f) and width and height are your screen width and height.
the z-buffer looses precision with distance in a non-linear way , there are some workarounds , I will eventualy post some code later on , just for now dont use less then 1 values for the near clipping plane as Keermalec sugested.

edit: typo

[edited by - lilken on January 5, 2004 7:12:26 PM]
---sorry for not using proper english , I'm from latin roots
I''ve seen this problem before and it''s really dumb.

You need to change the near clipping plane to at least 4. That means instead of this:
gluPerspective(fov,(GLfloat)width/(GLfloat)height,0.1f,50.0f);

do this:
gluPerspective(fov, (GLfloat)width/(GLfloat)height, 4, 50.0f);

But that will make anything disappear that is closer than 4 unites from the camera. To offset this problem, you just make everything larger.

Try just changing the perspective and see if the problem goes away.
*News tagenigma.com is my new domain.
gluPerspective(45,1024/768,1,500.0f);

is what the pic was sampled from
I`ve been inserting 10 as the near clipping plane, erasing everything within 10 units radius... the problem just appears 10 units away... no big difference.
I also think there`s some connection with glDepthRange that I once used and made thinks do that z-buffer artifact very close-up on almost all polygons.

PS:by reversing the glDepthRange stuff starts to look really weird(like inverse, neat effect on the future)
glDepthRange(1,0);

Relative Games - My apps

cippyboy, I think I found answers here:

http://users.frii.com/martz/oglfaq/depthbuffer.htm
http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

Basically, your near plane should not be too close to 0, and your far plane should not be too far away, though the nearness of the near plane has a more important effect.

To do:

1. Check your car license plate and car surface are not coplanar.

2. If not, set gluPerspective or glFrustum to something like 0.5,50.0

3. If it still is not enough, move your license plate a bit further from your car surface, as in 0.03 meters instead of 0.01 or whatever you have there.


[edited by - Keermalec on January 6, 2004 5:06:00 PM]
The articles(first) was really interesting to read and quite practicle I`d say so what do they suggest ? this->
"12.080 There is no way that a standard-sized depth buffer will have enough precision for my astronomically large scene. What are my options?

The typical approach is to use a multipass technique. The application might divide the geometry database into regions that don''t interfere with each other in Z. The geometry in each region is then rendered, starting at the furthest region, with a clear of the depth buffer before each region is rendered. This way the precision of the entire depth buffer is made available to each region."

So... does any modern day game engine uses something like this ? render a region, clear the buffer render the next region so that precision is never lost ? Wouldn`t it be slow ?

Relative Games - My apps

This topic is closed to new replies.

Advertisement