PDA

View Full Version : huge objects disappear



mekron
12-23-2003, 12:11 AM
Hallo,
i use objects that are very huge, for example spheres with a diameter of 1200000 units and more. The problem is, that fragments of this objects seem to fade away when rendered. When i use a sphere with a diameter less then 120000 units everything is just fine.
Sometimes the hole thing is visible, sometimes only parts fade away and sometimes the hole sphere disappears, depending on the point of view of the camera. It doesn't matter if i use huge coordinates from the beginning or if i use coordinates say 1.0, 1.0, 1.0 (x, y, z) and scale them to 1200000, 120....(glScalef()).
It's not a problem with the far clipping plane, i checked this allready. I set the far clipping plane to 12000000000 units, this seems to be o.k.
I also tried this: a smaler sphere and a smaler field of view (0.06 instead of 60.0 degrees) to compensate the 'visible' effect of the smaler sphere. The result is allways the same: parts of the sphere disappear!
I use a Voodoo3 3000 videocard.

What is the explanation of this problem and how can i fix it?

regards
mekron

dorbie
12-23-2003, 07:26 AM
This makes no sense unless it's some numerical precision issue. Perhaps with homogeneous divide, or you are supplying incomplete info.

Strictly speaking it shouldn't happen.

When the perspective transform occurs the 4th coord W gets multiplied by z, this then is an implicit divide of the other coordinates by z to produce x/w and y/w in screen space.

With really large numbers you would have large values for both x and w and that may cause problems for the divide (actually I doubt this is a problem since they would both be large.)

Since you mention a fading effect rather than clipping this is also strange unless what you're seeing is akin to pixels flickering on and off in which case it could be some kind of fragment clip with z buffer (or w buffer) interpolation getting hammered. With the voodoo3 I think it uses a w buffer so perhaps your very large values for w is what is throwing it a curve ball.

Fading also could be some texture issue with the interpolants there again caused by scale.

If you have large eye transformation values on the modelview as seems likely this could cause precision problems in the modelview multiplication and vertex transformation. This is a well known problem but doesn't really cause fading.

Fading could also be caused by fog interracting with some of the above issues. Make sure fog is off, or perhaps turn fog color to white to test if the fading is caused by fog.

[This message has been edited by dorbie (edited 12-23-2003).]

mekron
12-24-2003, 12:35 AM
Originally posted by dorbie:
This makes no sense unless it's some numerical precision issue. Perhaps with homogeneous divide, or you are supplying incomplete info.

Strictly speaking it shouldn't happen.

When the perspective transform occurs the 4th coord W gets multiplied by z, this then is an implicit divide of the other coordinates by z to produce x/w and y/w in screen space.

With really large numbers you would have large values for both x and w and that may cause problems for the divide (actually I doubt this is a problem since they would both be large.)

Since you mention a fading effect rather than clipping this is also strange unless what you're seeing is akin to pixels flickering on and off in which case it could be some kind of fragment clip with z buffer (or w buffer) interpolation getting hammered. With the voodoo3 I think it uses a w buffer so perhaps your very large values for w is what is throwing it a curve ball.

Fading also could be some texture issue with the interpolants there again caused by scale.

If you have large eye transformation values on the modelview as seems likely this could cause precision problems in the modelview multiplication and vertex transformation. This is a well known problem but doesn't really cause fading.

Fading could also be caused by fog interracting with some of the above issues. Make sure fog is off, or perhaps turn fog color to white to test if the fading is caused by fog.

[This message has been edited by dorbie (edited 12-23-2003).]

maybe my explaination was not precisely enough, because explaining things in an other language is a little tricky sometimes.
cut away is a much better explaination for the phenomenon then 'fade away'. Here comes an example:
The original diameter of the sphere is about 1.0 unit, its origin is at the center of the coordinate-system (0,0,0).
I scale the sphere 300000.0 times with glScalef() and set the point of view at a certain distance: 0.0, 0.0, -500000.0(x, y, z). The angle of view is 60.0 degrees;
gluPerspective(60.0, w/h, 0.01, 12000000000).
The result is a sphere, were several fragments of the surface of the sphere are cut away, or in other words, the sphere has big holes in it. This holes come in several shapes and sizes. The shape und size of this holes change if i change the point of view. When i change the position of the point of view at a distance of about 700000 units to the sphere the screen turns completely black.

I hope this improved explanation helps.

mekron

mikael_aronsson
12-24-2003, 02:38 AM
I think you have the answer in your own text:

"gluPerspective(60.0, w/h, 0.01, 12000000000)"

Most OpenGL implementations use float (32 bit floating point values), this means that you have 7-8 digits to play with, 12000000000 is a very big number, and 0.01 is a very low number, this gives terrible result for the depth buffer so this explains the behavior.

Mikael

dorbie
12-24-2003, 04:30 AM
The problem is your depth buffer precision.

OpenGL implementations often have limited depth buffer precision, because it uses memory and bandwidth.

In addition because of the perspective projection most of the depth buffer precision is 'spent' closer to the near clip plane. This causes a more rapid falloff in precision towards the near plane with less precision in the distance. The rate at which precision falls off at the near plane is a function of the ratio of far plane distance divided by near plane distance. The combination of a very close far plane and very distant near plane really destroys yor near plane precision, and gives you MUCH LESS precision in the distance than near the eye.

This page will explain further:
http://www.sgi.com/software/opengl/advanced96/node23.html

To fix this problem you should move your near plane out to a sensible distance and pull the far plane in if you can, moving the near plane out is more important though. If you need stuff close and in the distance then hopefully you don't need them at the the same time and can move the near plane out depending on what you're viewing. If you really need this viewing range then draw the far stuff first clear the depth buffer then the near stuff setting unique near and far values for each section.


[This message has been edited by dorbie (edited 12-24-2003).]

mekron
12-25-2003, 12:19 PM
Setting the near clipping plane to a value greater then 0.01 solves the problem!
Thank's all of you for your support!

mekron