raytracing - Advanced Computer Graphics Advanced Computer...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Advanced Computer Graphics Advanced Computer Graphics (Spring 2005) (Spring 2005) COMS 4162, Lectures 16, 17: Nuts and bolts of Ray Tracing Ravi Ramamoorthi http://www.cs.columbia.edu/~cs4162 Acknowledgements: Thomas Funkhouser and Greg Humphreys To Do To Do Start working on raytracer assignment (ass 3) Start thinking about final project (ass 4) Heckberts Heckberts Business Card Ray Tracer Business Card Ray Tracer Outline Outline Camera Ray Casting (choosing ray directions) [2.3] Ray- object intersections [2.4] Ray- tracing transformed objects [2.4] Lighting calculations [2.5] Recursive ray tracing [2.6] Outline in Code Outline in Code Image 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 Casting Virtual Viewpoint Virtual Screen Objects Ray misses all objects: Pixel colored black Ray intersects object: shade using color, lights, materials Multiple intersections: Use closest one (as does OpenGL) Finding Ray Direction Finding 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], fov Similar to Similar to gluLookAt gluLookAt derivation derivation gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz) Camera at eye, looking at center, with up direction being up Eye Up vector Center From 4160 lecture 4 on deriving gluLookAt Constructing a coordinate frame? Constructing a coordinate frame? a w a = 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 u b w u b w = v w u = Slide 20 from 4160 lecture 2 Camera coordinate frame Camera coordinate frame a w a = 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 vector b w u b w = v w u = Eye Up vector Center Canonical viewing geometry Canonical viewing geometry-w u v ( / 2 ) ( / 2 ) tan tan 2 / 2 2 / 2 fovx j width fovy height i width height = = u v w ray eye u v w + = + + Outline Outline Camera Ray Casting (choosing ray directions) [2.3] Ray-object intersections [2.4] Ray- tracing transformed objects [2.4] Lighting calculations [2.5] Recursive ray tracing [2.6] Outline in Code Outline in Code Image Raytrace (Camera cam, Scene scene, int width, int height)...
View Full Document

This note was uploaded on 02/17/2008 for the course CS CG taught by Professor Wyman during the Spring '08 term at University of Iowa.

Page1 / 9

raytracing - Advanced Computer Graphics Advanced Computer...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online