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 k=Pref=COIPeye=E i=vtop=up×k j=k×i

  • however, now i is now positive in the LHCS, so to fix this, we mirror it i.e. negate s.t. ii
  • the eye basis now points k in line with the COI so greater magnitudes of k 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. True Position=[PM][EM][TM]P
  • then send that to the viewport; each matrix is 4x4 and the point is 4x1

    Projections

  • orthographic projections
    • Parallel projections

  • the canonical view volume is the unit parallel projection with x(1,1), y(1,1), z(0,1)
  • 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 volume

    Normalization

  • the projection plane: (x,d) is the near plane that is a distance d away from the eye space origin
  • the object (a point: (x,y)) is placed on the far plane at a distance F=x, then the projected x value on the projection plane is xd=xzs.t.x=xzdW=xztanθ
  • here W 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 y=yzdH=yzdHWH=yArztanθ
  • however for z-axis everything collapses to the projection plane so it is a constant z=1tanθ
  • the division of ztanθ 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 z
  • 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
  • WTV=T(vl+vr2,vb+vt2)S(W2,H2)T(0,0)

    Final Rendering Pipeline