home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!sgigate!odin!fido!bruceh
- From: bruceh@sgi.com (Bruce R. Holloway)
- Newsgroups: comp.sys.sgi
- Subject: Re: Need help for z-buffer problem on INDIGO
- Message-ID: <pl1ln1o@fido.asd.sgi.com>
- Date: 9 Sep 92 18:48:14 GMT
- References: <21181@sbsvax.cs.uni-sb.de>
- Sender: news@fido.asd.sgi.com (Usenet News Admin)
- Organization: Silicon Graphics, Inc.
- Lines: 48
-
- In article <21181@sbsvax.cs.uni-sb.de> et11hkh@sbusol.rz.uni-sb.de (Rainer Zewe) writes:
- >In the first part of my program, I'm drawing the landscape,
- >using the perspective projection( znear=1.0, zfar=10000.0) and
- >the viewing transformation lookat.
- >Some special objects are drawn in feedback mode to get the screen-
- >coordinates. After some specific algorithms, these objects are
- >drawn into the landscape with the orthographic projection ortho
- >(... znear=1.0, zfar=10000.0 ).
- >
- >Now my proplem is, that the hidden surface algorithm doesn't work
- >correctly in the second part.
- >I think, that the scaling of the z-buffer isn't the same in the
- >two types of projections.
-
- Yes, I think you are right. In the perspective case, far points will be
- foreshortened, which will put them closer in the z-buffer. In the ortho
- case, the z-buffer values should be a linear function of object space z's.
-
- >My questions: How does the scaling of z-buffer work?
- > Is there a way to convert z-buffer values, get by
- > feedback, into eye-coordinates?
-
- There was an article published in issue #11 of _IRIS_Universe_, our
- company magazine for users, called "The Hidden Charms of Z-Buffer", by
- Kurt Akeley. He had an appendix which had the following formulas:
-
- When the projection matrix is defined by
-
- perspective(fovy, aspect, near, far);
-
- and the viewport transformation for z is defined by
-
- lsetdepth(front, back);
-
- then z_eye & z_screen are related by the following equations:
-
- far + near far*near back - front back + front
- z_screen = (---------- + --------) * ------------ + ------------, and
- 2 z_eye far - near 2
-
- far*near*(back - front)
- z_eye = -----------------------------------------------.
- z_screen*(far - near) - (back*far - front*near)
-
- For today, I will leave as an exercise the formulas which apply in the
- ortho case.
-
- Regards, bruceh
-