230 likes | 960 Views
- f. s. Details of gluLookAt (eye, center, up). Change of Basis (after the translation to eye ). L. L T. Equivalent to:. Modelview Matrix. Viewing Transform. Model Transform. world coordinates. OpenGL Pipeline. R 4. R 4. R 4. [-1,1] 3. R 4. Projection in OpenGL.
E N D
-f s Details of gluLookAt (eye, center, up) Change of Basis (after the translation to eye) L LT Equivalent to:
Modelview Matrix Viewing Transform Model Transform world coordinates OpenGL Pipeline R4 R4 R4 [-1,1]3 R4
Projection in OpenGL • Different from those we just discussed (R4R3) • Setting up a viewing frustum (in eye coordinates), establish a mapping to NDC [-1,1]3 • The desired behavior is set by R-1; find its inverse as the projection matrix R • Frustum is in left-hand coordinate system • Clip coordinate is in right-hand coordinate system • The Z-values in clip coordinate are depth buffer values [shift to [0,1]?!] • Reference (this is helpful)
y z x near,far: can be +/- near,far: negative if behind the viewer (specified in a left hand coordinate) glOrtho (l,r,b,t,n,f) , eye coord. NDC. (1,1,-1) (-1,-1,1) Say, near = -10 (behind viewer), zeye = 10, zNDC = -1 far = 20 (in front of viewer), zeye = -20, zNDC = 1
y z x rf/n f r n n,f must be positive n cannot be zero glFrustum (l,r,b,t,n,f) (1,1,1) eye coord. NDC. (-1,-1,-1)
Check: eye coord. NDC.
From glFrustum Set h/2 n fovy n,f must be positive n cannot be zero gluPerspective (fovy, aspect, n,f)
Depth Buffer Precision (ref) • Depth buffer precision is affected by the values specified for zNear and zFar. • The greater the ratio of zFar to zNear is, the less effective the depth buffer will be at distinguishing between surfaces that are near each other. • If r =zFar/zNear, roughly log2r bits of depth buffer precision are lost. • Because r approaches infinity as zNear approaches 0, zNear must never be set to 0. Depth precision error Ze: z_eye Zn: z_NDC
Verification • V: viewpoint (gluLookAt) • N: viewplane (the near plane) equation • Project OFF letter model • compare your result with OpenGL result.