08-RayCasting

# 08-RayCasting - Notes Ray Casting Lecture 8 CPSC 478/578...

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

1 Ray Casting Ray Casting Lecture 8 CPSC 478/578 Spring 2005 Notes ± TA Office hours in the zoo: today, 7- 9pm; Friday 2-5 pm ± Reading this week 8.1, 8.2, 9.1-9.9, 7.1 ± Assignment # 1 due Monday 3D Rendering ± The color of each pixel on the view plane depends on the radiance emanating from visible surfaces View plane Eye position Simplest method is ray casting Rays through view plane Ray Casting ± For each sample … Construct ray from eye position through view plane Find first surface intersected by ray through pixel Compute color sample based on surface radiance Ray Casting ± For each sample … Construct ray from eye position through view plane Find first surface intersected by ray through pixel Compute color sample based on surface radiance Samples on view plane Eye position Rays through view plane Ray Casting ± Simple implementation: Image RayCast(Camera camera, Scene scene, int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j); Intersection hit = FindIntersection(ray, scene); image[i][j] = GetColor(hit); } } return image; }

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

View Full Document
2 Ray Casting ± Simple implementation: Image RayCast(Camera camera, Scene scene, int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel (camera, i, j); Intersection hit = FindIntersection(ray, scene); image[i][j] = GetColor(hit); } } return image; } Constructing Ray Through a Pixel right back Up direction P 0 towards View Plane P V Ray: P = P 0 + tV Constructing Ray Through a Pixel ± 2D Example d Θ towards P 0 right right = towards x up Θ = frustum half-angle d = distance to view plane P1 = P 0 + d*towards - d*tan( Θ )*right P2 = P 0 + d*towards + d*tan( Θ )*right P1 P2 2*d*tan( Θ) P P = P1 + ((i+.5)/width) * 2*d*tan ( Θ )*right V = (P - P 0 ) / ||P - P 0 || V Ray: P = P 0 + tV Ray Casting ± Simple implementation: Image RayCast(Camera camera, Scene scene, int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j); Intersection hit = FindIntersection (ray, scene); image[i][j] = GetColor(hit); } } return image; } Ray-Scene Intersection ± Intersections with geometric primitives Sphere Triangle Groups of primitives (scene) ± Acceleration techniques Bounding volume hierarchies Spatial partitions Uniform grids Octrees BSP trees Ray-Sphere Intersection Ray: P = P 0 + tV Sphere: |P - O| 2 -r 2 = 0 P 0 V O P r P’
3 Ray-Sphere Intersection I Ray: P = P 0 + tV Sphere: |P - O| 2 -r 2 = 0 Substituting for P, we get: | P 0 + tV -O | 2 2 = 0 Solve quadratic equation: at 2 + bt + c = 0 where: a = 1 b = 2 V • (P 0 -O) c = |P 0 -C | 2 2 = 0 P 0 V O P r P’ Algebraic Method P = P 0 + tV Ray-Sphere Intersection II

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/21/2009 for the course CPSC 478 taught by Professor Hollyrushmeier during the Spring '05 term at Yale.

### Page1 / 9

08-RayCasting - Notes Ray Casting Lecture 8 CPSC 478/578...

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

View Full Document
Ask a homework question - tutors are online