Advertisement

Infinity Far Plane

Started by December 02, 2003 01:07 PM
11 comments, last by Corrail 21 years ago
Hi all! I''d like to realize shadow volumes with z-fail but don''t know how to set the far clip plane to inifite. does anyone have an idea? Thanks a lot Corrail -------------------------------------------------------- "If it looks good, it is good computer graphics" "If it looks like computer graphics, it is bad computer graphics" Corrail corrail@gmx.at ICQ#59184081
--------------------------------------------------------There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.There is another theory which states that this has already happened...
In discrete space, very_large_number = infinity. The largest number you can set it to is max_value_of(float). To find this out, Google for data type sizes (eg int32 is 232).





"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Advertisement
But I know there is a way to tell OpenGL to use a real infinity far plane. You have to pass a certain projection matrix to the GL but I don''t know which and how.

--------------------------------------------------------

"If it looks good, it is good computer graphics"
"If it looks like computer graphics, it is bad computer graphics"

Corrail
corrail@gmx.at
ICQ#59184081
--------------------------------------------------------There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.There is another theory which states that this has already happened...
Yeah, but if you set it to the maximum value a float can have, then what difference will it make? You can not use any values that are higher than that anyway... except if you use double or something like it...
But this won''t solve my problem anyway. If I''ve got a fragment which is farther away than my VERY far clip plane it will be discard which I''d like to prevent!

--------------------------------------------------------

"If it looks good, it is good computer graphics"
"If it looks like computer graphics, it is bad computer graphics"

Corrail
corrail@gmx.at
ICQ#59184081
--------------------------------------------------------There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.There is another theory which states that this has already happened...
quote:
Original post by Corrail
But this won''t solve my problem anyway. If I''ve got a fragment which is farther away than my VERY far clip plane it will be discard which I''d like to prevent!

--------------------------------------------------------

"If it looks good, it is good computer graphics"
"If it looks like computer graphics, it is bad computer graphics"

Corrail
corrail@gmx.at
ICQ#59184081


Please read my previous post again. It is impossible to have infinity in a discrete (see def. 3) system. Your computer is a discrete system. Infinity can only be simulated and is thereby limited to some discrete value. If you''re working on a 32-bit platform, the size of float should be 32 bits (sign, exponent and mantissa together) - this is your not-so-theoretical-but-actual size limit. If you tell the graphics card to regard infinity as "infinity", it will do its best to clip everything at the largest possible value it can handle - this is either max_value_of(float) or max_value_of(double). I''m pretty sure it''s the first one, though (at least in most cases).
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Advertisement
But Depth Buffer works like this:

The Depth value which is stored in Depth buffer isn''t an absolute value. The smaller your distance between your near plane and your far plane the more exact. AFAIK the depth value is stored in Depth Buffer like this:

near plane is 1000
far planet is 2000
Depth Buffer value is 0,5

So absolute depth value is 1500.

But somewhere these values have to be translated from absolute values to this interval and a Depth-Testing has to be done. So if I use a such high value my depth testing will cause artifacts.


If I use your idea of passing the highest possible value to the GL for far plane how am I able to determine which the highest value is? Different GL implimentation use different floating point precision?

--------------------------------------------------------

"If it looks good, it is good computer graphics"
"If it looks like computer graphics, it is bad computer graphics"

Corrail
corrail@gmx.at
ICQ#59184081
--------------------------------------------------------There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.There is another theory which states that this has already happened...
You could go with something like 10 million - that is a reasonably small/large number.





"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
1. Using homogenous coordinates it is possible, using OpenGL to render a point that is infinitely far away from the origin. Not just very far away, but infinitely far away. This is done by setting the w coordinate to 0. Further more, OpenGL is guarenteed to correctly render polygons specified with vertices that are infinitely far away.

2. The standard projection matrix is:
  2 × Near			Right + Left------------	     0		------------	       0Right - Left			Right - Left 

		  2 × Near	Top + Bottom     0		------------	------------	       0		Top - Bottom	Top - Bottom 

				  Far + Near	  2 × Far × Near     0		     0		- ----------	- --------------				  Far - Near	    Far - Near 

     0		     0		     -1		       0  


As Far tends to infinity (mathematical infinity, not MAX_FLOAT) the projection matrix becomes:
  2 × Near			Right + Left------------	     0		------------	    0Right - Left			Right - Left 

		  2 × Near	Top + Bottom     0		------------	------------	    0		Top - Bottom	Top - Bottom 

     0		     0		     -1		-2 × Near 

     0		     0		     -1		    0  


For more information see this white paper

Enigma

EDIT: space between lines of matrices was collapsed.

[edited by - Enigma on December 3, 2003 5:49:25 AM]
Thanks Enigma! That''s exactly what I''m looking for! :-)

And I''ve got to pass this matrix just like

glMatrixMode(GL_PROJECTION);
glLoadMatrixf(my_infinity_projection_matrix);

Or do I have to change the clip planes too?

--------------------------------------------------------

"If it looks good, it is good computer graphics"
"If it looks like computer graphics, it is bad computer graphics"

Corrail
corrail@gmx.at
ICQ#59184081
--------------------------------------------------------There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.There is another theory which states that this has already happened...

This topic is closed to new replies.

Advertisement