home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / sgi / 13431 < prev    next >
Encoding:
Internet Message Format  |  1992-09-09  |  2.3 KB

  1. Path: sparky!uunet!olivea!sgigate!odin!fido!bruceh
  2. From: bruceh@sgi.com (Bruce R. Holloway)
  3. Newsgroups: comp.sys.sgi
  4. Subject: Re: Need help for z-buffer problem on INDIGO
  5. Message-ID: <pl1ln1o@fido.asd.sgi.com>
  6. Date: 9 Sep 92 18:48:14 GMT
  7. References: <21181@sbsvax.cs.uni-sb.de>
  8. Sender: news@fido.asd.sgi.com (Usenet News Admin)
  9. Organization: Silicon Graphics, Inc.
  10. Lines: 48
  11.  
  12. In article <21181@sbsvax.cs.uni-sb.de> et11hkh@sbusol.rz.uni-sb.de (Rainer Zewe) writes:
  13. >In the first part of my program, I'm drawing the landscape,
  14. >using the perspective projection( znear=1.0, zfar=10000.0) and
  15. >the viewing transformation lookat.
  16. >Some special objects are drawn in feedback mode to get the screen-
  17. >coordinates. After some specific algorithms, these objects are
  18. >drawn into the landscape with the orthographic projection ortho
  19. >(... znear=1.0, zfar=10000.0 ).
  20. >
  21. >Now my proplem is, that the hidden surface algorithm doesn't work
  22. >correctly in the second part.
  23. >I think, that the scaling of the z-buffer isn't the same in the
  24. >two types of projections.
  25.  
  26. Yes, I think you are right.  In the perspective case, far points will be
  27. foreshortened, which will put them closer in the z-buffer.  In the ortho
  28. case, the z-buffer values should be a linear function of object space z's.
  29.  
  30. >My questions: How does the scaling of z-buffer work?
  31. >              Is there a way to convert z-buffer values, get by 
  32. >              feedback, into eye-coordinates?
  33.  
  34. There was an article published in issue #11 of _IRIS_Universe_, our
  35. company magazine for users, called "The Hidden Charms of Z-Buffer", by
  36. Kurt Akeley.  He had an appendix which had the following formulas:
  37.  
  38.     When the projection matrix is defined by
  39.  
  40.         perspective(fovy, aspect, near, far);
  41.  
  42.     and the viewport transformation for z is defined by
  43.  
  44.         lsetdepth(front, back);
  45.  
  46.     then z_eye & z_screen are related by the following equations:
  47.  
  48.                     far + near   far*near    back - front   back + front
  49.         z_screen = (---------- + --------) * ------------ + ------------, and
  50.                         2         z_eye       far - near         2
  51.  
  52.                             far*near*(back - front)
  53.         z_eye = -----------------------------------------------.
  54.                 z_screen*(far - near) - (back*far - front*near)
  55.  
  56. For today, I will leave as an exercise the formulas which apply in the
  57. ortho case.
  58.  
  59. Regards, bruceh
  60.