Download presentation
Presentation is loading. Please wait.
1
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 The Mystic Z Values
2
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Today’s Short Film Special Effects in A.I.
3
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Announcement Assignment 1 still due on March 5. Volunteers wanted for paper presentations on March 18 & 25: –2 presentations each date. –+5 bonus for presentation grades. –Paper list to be posted next week.
4
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Z Buffer THE choice of hidden surface removal algorithms in computer graphics. Also called “Depth Buffer.” Note that Z distance.
5
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 “So, Where are the problem?” The Z values in OpenGL depth buffer are not exactly the Z in world space (or eye space). For example, gluPerspective in the next slide:
6
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Projection Matrix gluPerspective(fovY, aspect, Zn, Zf) produces projection matrix of: [A000] [0f00] [00BC] [00-10] Where B = (Zf+Zn)/(Zn-Zf), C=2*Zf*Zn/(Zn-Zf) So Z buffer will get B*Z + C
7
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Why Not Just Use Z? We want Z to be within 0 and 1. So it may be represented in fewer bits (such as 16-bit or 24-bit Z values).
8
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 A Derivation: Step (0) Ys/D=Y/(Z+D), If we let Ws=(Z+D)/D, then Ys=Y/Ws and Zs=Z/Ws. Exercise: What is the projection matrix? Z Y D Ys
9
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Step (1): Move the eye to Z=0 Ys=Y/(Z/D), Ws=Z/D, so Zs=(Z-D)/Ws Exercise: What is the projection matrix? Z Y D Ys
10
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 A Derivation: Step (2) Now, we want to map Zn 0 and Zf 1. If the matrix is: [1000] [0100] [00AB] [001/D0] Then: A*Zn+B=0, A*Zf+B=Zf/D. Exercise: What are A and B?
11
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 References Chapter 18 of “Jim Blinn's Corner: A Trip Down the Graphics Pipeline” Kenny Hoff’s Note on “Deriving the OpenGL Perspective Depth Transformmation” http://www.cs.unc.edu/~hoff/techrep http://www.cs.unc.edu/~hoff/techrep Steve Baker, “Learning to Love your Z-buffer” http://sjbaker.org/steve/omniv/love_your_z_buffer.html http://sjbaker.org/steve/omniv/love_your_z_buffer.html
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.