question on gl

Bruce R. Holloway bruceh at sgi.com
Wed Apr 3 08:49:01 AEST 1991


In article <14154 at medusa.cs.purdue.edu> avr at cs.purdue.edu (Andrew V. Royappa) writes:
>>> 
>>> In article <14144 at medusa.cs.purdue.edu> avr at cs.purdue.EDU (Andrew V. Royappa) writes:
>>>>
>>>>The gl graphics user's guide says that the perspective & viewing
>>>>transformations transforms the perspective pyramid into the box 
>>>>-1.0 <= x,y,z <= 1.0, to facilitate clipping. Is this in fact
>>>>the case, 
>>
>>actually we clip against -w and +w, where w is normally 1.0 for orthographic
>>projections.  For perspective transformations, w is NOT 1.0, and instead of
>>transforming the pyramid into a unit box, we really do clip against the 
>>pyramid.  
>>
>>	Gary Tarolli
>
>Huh. Well, I'm writing some simple 3D routines using X11, and decided
>to use the gl transformations printed at the back of the manual. After
>applying the MVP matrix to a line segment, I clip against 
>-1.0<=x,y,z<=1.0. I see errors sometime even though the clip appears
>to do exactly what I want it do. 
>
>So then, should I clip against the cube only when using the ortho
>projections, and against the pyramid when using perspective ?
>
>If yes, could you please give me the exact bounds of the pyramid used by
>gl ?

The most popular texts on computer graphics do describe clipping in the
intervals -1 <= x,y <= 1 and 0 <= z <= 1.  When the original Geometry
Engine(tm) chip was designed, all three axes were treated equally for
simplicity, and this is the way SGI has always done it.  I've heard that
Jim Blinn has suggested that in some cases the most efficient way is to
use the intervals 0 <= x,y,z <= 1.  In other words, you might be able to
save a few floating-point ALU cycles.  Anyway, you can use any of these
methods, it's just that your projection matrix will be a little different.

Clipping may be done the same for both orthographic & perspective
projections and generally precedes the perspective division step in the
calculation.  The coordinates following perspective division are what must
map into the canonical view volume.  Here's how that works.  It is required
that -1 <= (x/w) <= +1, so if w > 0, -w <= x <= +w.  Thus, the requirement
may be expressed as the two conditions w + x >= 0 and w - x >= 0, without
actually investing any time in the perspective division until it is
determined that the point is inside the view volume.  (It's a bit of a
tangent, but I can explain separately why w > 0 for the projection
matrices we use, if necessary.)

Regards, bruceh



More information about the Comp.sys.sgi mailing list