UCSD CSE 167 - Camera Perspective, Viewing, and Culling

Unformatted text preview:

#6: Camera Perspecctive,Viewing, and CullingCSE167: Computer GraphicsInstructor: Ronen BarzelUCSD, Winter 20061Outline for todayCamera Space Projection View Volumes Culling Bounding Hierarchy23-D Graphics Rendering PipelineModeling TransformationViewing TransformationLighting & ShadingClippingProjectionScan conversion, HidingPrimitivesImageObject coordinatesWorld spaceEye space AKA Camera spaceNormalized view spaceImage space, Device coordinates3From modeling to rendering So far, we’ve discussed the following spaces Object space (local space) World space (global space) Today we’ll add: Camera space Normalized view space Image space (2D)4Camera Think of camera itself as a model Place it in 3D space Camera’s frame: origin at eye point -z points in the viewing direction x,y define the film plane• x is to the right on the film• y is up on the filmyzxWORLDxyzeye point5Remember… Local-to-world matrix, AKA Model Transform6Camera Matrix The local-to-world matrix for the camerayzxWorld coordinatesxyzCamera SpaceCamera MatrixC7How to specify camera matrix Can construct it using our existing techniques. Common idiom: “Look-at transformation” Given the eye point, AKA look-from point Given a target point, AKA look-at point Matrix points the camera toward the look-at point Which way is up? There’s a degree of freedom available: spin the camera Specify an up vector in the world, that will point along y in the camera.xyxyxy8Camera Look-At setupyzxWorld coordinatesxyzCamera SpaceCamera MatrixClook-from = eye point elook-at = target point tetview vectorup vector u9“Look-at” Matrix calculation Given: look-from: eye at position e look-at: target at position t up-vector: Fill the a,b,c,d columns of the matrix with the world-spacecoordinates of the camera’s frame: d is position of frame origin, i.e. the eye point: d = e c is the z axis of the frame, i.e. the view vector: !c =e ! te ! t !u10“Look-at” Matrix calculation a is the camera frame’s x axis. we want it to be perpendicular to theview vector, and also perpendicular to the up vector: b is the camera frame’ s y axis. it must be perpendicular to a and c. Notes: cross product order is important to make sure the frame is right-handed since a and c are unit length and perpendicular to each other, we don’tneed to normalize b. !a =!u !!c!u !!c !b =!c !!a11“Look-at” Matrix calculation, summary Note: The up vector may not end up parallel to the camera y axis The projection of the up vector onto the film plane lines up with camera y If the up vector is parallel to the view vector, the result is undefined! the up vector will project to nothing in the image no matter how you spin the camera, there’s no thing to line up with the camera y it’s a user error! Given: eye point e, target point t, and up vector !uConstruct: columns of camera matrix Cd = e!c =e ! te ! t!a =!u "!c!u "!c!b =!c "!a !ute !b12Camera Space For rendering, we want to consider all objects in camera space We have matrix C that transforms from camera space into world space View an object that was placed into world space using matrix M To go from object space to camera space:• First go from object to world via M• Then go backwards from world to camera, using the inverse of C• Compose these into a single matrix:Object-to-camera = C-1M13Model-to-Camera transformxyzCamera SpaceCamera-to-worldCC-1World-to-cameraModel-to-Camera = C-1M14In camera space We have things lined up the way we like them on screen: X to the right Y up -Z going into the screen Objects to look at are in front of us, i.e. have negative z values But the objects are still in 3D. Now let’s look at how to project them into 2D to get them onscreen15Outline for today Camera SpaceProjection View Volumes Culling Bounding Hierarchy16Normalized view space, Image Space We’re ultimately heading to 2D image space: We’ll need a mapping from 3D space into 2D image space But for rendering (hiding) we’ll need to know the depth information (z) So we’ll really map into a 3D space, at least at firstNormalized view space A 3D space Everything visible in the image will range from -1 to 1 in both x and y, with (0,0)in the center of the image The z coordinate will also range from -1 to 1 for depth, with 1 being the nearestand -1 being farthest.17View Projections Transform from camera space to normalized view space Two basic kinds:Perspective projection: make things farther away seem smaller• Most common for computer graphics• Simple model of human eye, or camera lens• (Actually, a model of an ideal pinhole camera)Orthographic projection: simply flatten, without any perspective• Used for architectural or plan views (top,side,front)• Not used for realistic rendering Others, more complex: lens, with focus & depth of field fish-eye lens dome projection computations don’t easily fit into basic hardware rendering pipeline18Perspective Projection Things farther away get smaller Parallel lines no longer parallel: vanishing point Discovery/formalization attributed toFilippo Brunelleschi in the early 1400’s Earliest example: La Trinitá (1427) by Masaccio19Perspective Projection Assume that we have “film” at distance d from the eye Distant tall object projects to same height as near small object By similar triangles, we have: Notice: divide by z not a linear operation!!yd=y1z1=y2z2Giving the transformation relations:!y = dyz,!!!!!!!x = dxz20Aside: go the other way If you make some assumptions about what parts of the image are square,etc., it’s possible to recover the 3D geometry.(Figure from a group at Oxford)21Perspective Projection Not a linear equation not an affine transformation doesn’t preserve angles-but does preserve straight lines Note: it will blow up if z=0 (object at the eye) Z maps to pseudo-distance necessary to preserve straight lines maintains depth order when B<0: if z1<z2 then z’1<z’2 We’ll come up with values for d1, d2, A, and B, in a little while will choose them to keep area of interest within -1 to 1 in x,y,z Ugly formula. Make it work with homogeneous matrices…!x!y!z"#$$$%&'''=d1xzd2yzA +Bz"#$$$$$$$%&'''''''22Homogeneous Perspective Projection The


View Full Document

UCSD CSE 167 - Camera Perspective, Viewing, and Culling

Documents in this Course
Lighting

Lighting

38 pages

Review

Review

59 pages

Surfaces

Surfaces

22 pages

Review

Review

110 pages

Midterm

Midterm

4 pages

Lighting

Lighting

38 pages

Lighting

Lighting

71 pages

Review

Review

110 pages

Lighting

Lighting

71 pages

Load more
Download Camera Perspective, Viewing, and Culling
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Camera Perspective, Viewing, and Culling and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Camera Perspective, Viewing, and Culling 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?