Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!sgi!tarolli@westcoast.esd.sgi.com From: tarolli@westcoast.esd.sgi.com (Gary Tarolli) Newsgroups: comp.sys.sgi Subject: Re: question on gl Summary: clipping Message-ID: <94947@sgi.sgi.com> Date: 2 Apr 91 21:48:00 GMT References: <14144@medusa.cs.purdue.edu> <1991Apr2.150125.22972@odin.corp.sgi.com> <14154@medusa.cs.purdue.edu> Sender: guest@sgi.sgi.com Distribution: usa Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 45 In article <14154@medusa.cs.purdue.edu>, avr@cs.purdue.EDU (Andrew V. Royappa) writes: > > > >In article <1991Apr2.150125.22972@odin.corp.sgi.com>, dave@sgi.com (dave "who can do? ratmandu!" ratcliffe) writes: > >> In article <14144@medusa.cs.purdue.edu> avr@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, > >> yep--this *is* the case -1.0 to 1.0 for x, y, *and* z clipping. > >> > > > >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. > > > > 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 ? > If you are using ortho, you can safely clip against -1.0, 1.0 since this is the value of w anyway. But if you are using perspective, then things get very tricky. Most people clip in homogeneous space (x,y,z,w). If you don't then I believe it is very difficult to do things mathematically correct. Anyway, in homogeneous space you clip against -w and +w. That is the pyramid. I suggest you look at Newman+Sproull or Foley and VanDam for more info on homogeneous spaces and line clipping. Its more tricky then you think, and its even trickier then they allude to. For example if you try to clip in normalize device coords after division by w, what do you do if w=0? I think that's why most people clip in homogeneous space... Good luck... -------------------- Gary Tarolli