4 - Camera, Projections, and Viewport
ucla | CS 174A | 2024-01-30 19:09
Table of Contents
Eye Space
- params
- eye location
- center of interest
- tilt angle or top point
- we define the camera in the World space
- we create bases based on the following calculations
Basis
normalize to get unit vectors for basis - align as column vectors
- however, now
is now positive in the LHCS, so to fix this, we mirror it i.e. negate s.t. - the eye basis now points
in line with the COI so greater magnitudes of sends the object farther back away from the camera at the origin of the eye space (VCS)Viewport Idea
- we can take a point and project it to the viewport by applying a single amtrix that is the cross product of multiple matrices: transformation, eye, projection, etc.
- then send that to the viewport; each matrix is 4x4 and the point is 4x1
Projections
- orthographic projections
- the canonical view volume is the unit parallel projection with
- given a volume the view volume dimension are -W to W width, -H to H and distance D=far point - near point
- the parallel projection matrix is the identity
Perspective Projection
- NOTE: slides are different
- square projection viewport
- the half angle is angle wrt to x-axis from the z/k axis to the edge of the view volume to one side, the area swept by
is the width of the view volumeNormalization
- the projection plane:
is the near plane that is a distance away from the eye space origin - the object (a point:
) is placed on the far plane at a distance , then the projected x value on the projection plane is - here
is the range of x-values swept by the half angle on the projection plane - similarly for the y-axis, where H is like W
- however for z-axis everything collapses to the projection plane so it is a constant
- the division of
is known as perspective division and scales the x,y based on distance -> making farther smaller and closer bigger - final matrix is all of these plus the 1 at the last 4th dim
- but we lose depth which we need for hidden surface removal, so we can define a new matrix with some linear function for
- so we create a perspective projection matrix that maps the perspective objects into a parallel NDC (openGL) cube which we can render to the viewport; here N is near value, F is far value, D is depth:
Window to Viewport Mapping
- where T is transformation and S is scaling
Final Rendering Pipeline