DOC PREVIEW
Berkeley COMPSCI 294 - Lecture Notes

This preview shows page 1-2-3 out of 10 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1Advanced Computer Graphics Advanced Computer Graphics (Fall 2009)(Fall 2009)CS 294-13, Rendering Lecture 1: Introduction and Basic Ray Tracing Ravi Ramamoorthihttp://inst.eecs.berkeley.edu/~cs294-13/fa09Some slides courtesy Thomas Funkhouser and Pat HanrahanTo DoTo Do Start working on raytracer assignment (if necessary) Start thinking about path tracer, final projectFirst AssignmentFirst Assignment In groups of two (find partners) Monte Carlo Path Tracer If no previous ray tracing experience, ray tracer first.  See how far you go. Many extra credit items possible, fast multi-dim. rendering, imp. sampling… This lecture focuses on basic ray tracing Likely to be a review for most of you, go over fastRay Tracing HistoryRay Tracing HistoryRay Tracing HistoryRay Tracing HistoryImage courtesy Paul Heckbert 19832OutlineOutline Camera Ray Casting (choosing ray directions)  Ray-object intersections  Ray-tracing transformed objects  Lighting calculations  Recursive ray tracing Outline in CodeOutline in CodeImage Raytrace (Camera cam, Scene scene, int width, int height){Image image = new Image (width, height) ;for (int i = 0 ; i < height ; i++) for (int j = 0 ; j < width ; j++) {Ray ray = RayThruPixel (cam, i, j) ;Intersection hit = Intersect (ray, scene) ;image[i][j] = FindColor (hit) ;}return image ;}Ray CastingVirtual ViewpointVirtual Screen ObjectsRay misses all objects: Pixel colored blackRay intersects object: shade using color, lights, materialsMultiple intersections: Use closest one (as does OpenGL)Finding Ray DirectionFinding Ray Direction Goal is to find ray direction for given pixel i and j Many ways to approach problem Objects in world coord, find dirn of each ray (we do this) Camera in canonical frame, transform objects (OpenGL) Basic idea Ray has origin (camera center) and direction  Find direction given camera params and i and j Camera params as in gluLookAt Lookfrom[3], LookAt[3], up[3], fovSimilar to Similar to gluLookAtgluLookAtderivationderivation gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz) Camera at eye, looking at center, with up direction being upEyeUp vectorCenterConstructing a coordinate frame?Constructing a coordinate frame?awaWe want to associate w with a, and v with b But a and b are neither orthogonal nor unit norm And we also need to find ubwubwvwu3Camera coordinate frameCamera coordinate frameawa We want to position camera at origin, looking down –Z dirn Hence, vector a is given by eye – center The vector b is simply the up vectorbwubwvwuEyeUp vectorCenterCanonical viewing geometryCanonical viewing geometry-wαuβv(/2) ( /2)tan tan2/2 2 /2fovx j width fovy height iwidth height       uvwray eyeuvwOutlineOutline Camera Ray Casting (choosing ray directions)  Ray-object intersections  Ray-tracing transformed objects  Lighting calculations Recursive ray tracingOutline in CodeOutline in CodeImage Raytrace (Camera cam, Scene scene, int width, int height){Image image = new Image (width, height) ;for (int i = 0 ; i < height ; i++) for (int j = 0 ; j < width ; j++) {Ray ray = RayThruPixel (cam, i, j) ;Intersection hit = Intersect (ray, scene) ;image[i][j] = FindColor (hit) ;}return image ;}RayRay--Sphere IntersectionSphere Intersection012()() 0ray P P Ptsphere P C P C r  CP0RayRay--Sphere IntersectionSphere Intersection012()() 0ray P P Ptsphere P C P C rSubstitute01201 01()()0ray P P Ptsphere PPtCPPtCr  Simplify2211 1 0 0 0()2( )( )( ) 0tPP tPP C P C P C r     4RayRay--Sphere IntersectionSphere Intersection2211 1 0 0 0()2( )( )( ) 0tPP tPP C P C P C r     Solve quadratic equations for t 2 real positive roots: pick smaller root Both roots same: tangent to sphere One positive, one negative root: ray origin inside sphere (pick + root) Complex roots: no intersection (check discriminant of equation first)RayRay--Sphere IntersectionSphere Intersection Intersection point:  Normal (for sphere, this is same as coordinates in sphere frame of reference, useful other tasks) 01ray P P Pt PCnormalPCRayRay--Triangle IntersectionTriangle Intersection One approach: Ray-Plane intersection, then check if inside triangle Plane equation: ABC()()()()CA BAnCA BA0plane P n A nRayRay--Triangle IntersectionTriangle Intersection One approach: Ray-Plane intersection, then check if inside triangle Plane equation:  Combine with ray equation: ABC()()()()CA BAnCA BA0plane P n A n0101()ray P P PtPPtnAn01AnPntPnRay inside TriangleRay inside Triangle Once intersect with plane, still need to find if in triangle Many possibilities for triangles, general polygons (point in polygon tests) We find parametrically [barycentric coordinates]. Also useful for other applications (texture mapping)ABCPαβγ0, 0, 01PABCRay inside TriangleRay inside TriangleABCPαβγ0, 0, 01PABC()()PABACA01,0115Other primitivesOther primitives Much early work in ray tracing focused on ray-primitive intersection tests Cones, cylinders, ellipsoides Boxes (especially useful for bounding boxes) General planar polygons Many more Many references. For example, chapter in Glassnerintroduction to ray tracing (see me if interested)Ray Scene IntersectionRay Scene IntersectionOutlineOutline Camera Ray Casting (choosing ray directions)  Ray-object intersections  Ray-tracing transformed objects  Lighting calculations  Recursive ray tracing Transformed ObjectsTransformed Objects E.g. transform sphere into ellipsoid Could develop routine to trace ellipsoid (compute


View Full Document

Berkeley COMPSCI 294 - Lecture Notes

Documents in this Course
"Woo" MAC

"Woo" MAC

11 pages

Pangaea

Pangaea

14 pages

Load more
Download Lecture Notes
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 Lecture Notes 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 Lecture Notes 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?