Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

20
Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th , 2008
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    215
  • download

    0

Transcript of Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Page 1: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Parallelizing Raytracing

Gillian SmithCMPE 220

February 19th, 2008

Page 2: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Agenda What is raytracing? How raytracers work Parallelization

Page 3: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

What Is Raytracing? 3D rendering

technique Mathematical

representation of scenes

Extremely computationally intensive

Results capture complex lighting effects

Page 4: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

What Is Raytracing?

Page 5: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

What Is Raytracing?

Page 6: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

How Raytracers Work Image plane is

placed between the camera and the scene

The color of each pixel in that plane is computed by the raytracer

Pixels are independent of each other

Page 7: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Algorithm Overview (Per Pixel)1. Shoot a ray from the camera through the

pixel and towards the scene2. Compute the intersection between

objects in the scene and the ray3. For the closest intersection point to the

camera, compute the color that should be stored in the pixel

Page 8: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Compute Ray through Pixel

Front ViewSide View

P0: Camera’s Position

D: Camera’s Direction

U: Camera’s “Up” Direction

U

D

Pi

Θ

Ray: R = P0 + tV

|| 0

0

PP

PPV

i

i

Page 9: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Algorithm Overview (Per Pixel)1. Shoot a ray from the camera through the

pixel and towards the scene2. Compute the intersection between

objects in the scene and the ray3. For the closest intersection point to the

camera, compute the color that should be stored in the pixel

Page 10: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Compute Intersection

Slide Credit: Greg Humphreys, University of Virginia

P0

V

Sphere: |P - C|2 – r2 = 0

Point on Ray: P = P0 + tV

C

P

P’

R

P0

V

Page 11: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Compute IntersectionSubstitute for P in equation for sphere:

|P0 + tV – C|2 – r2 = 0

Solve for t, choose smaller value

C

P

P’

R

P0

V

Page 12: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Algorithm Overview (Per Pixel)1. Shoot a ray from the camera through

the pixel and towards the scene2. Compute the intersection between

objects in the scene and the ray3. For the closest intersection point to

the camera, compute the color that should be stored in the pixel

Page 13: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Determine color at pixel Raycasting method

Look up color from scene specification

Raytracing method Find contribution to

pixel from each light source

Reflections Refractions

Page 14: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Local Illumination Light has a color, LC Object’s material

Diffuse color, CD Specular color, CS Specular highlight, S

Pixel Diffuse CDLC(N.L)

Pixel Specular CSLC(R.V)S

Final color is sum of all diffuse and specular colors from every light in the scene

Page 15: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Global Illumination Illumination effects dependent on other

objects in the scene Shadows Reflections Refraction

Calculated by sending additional rays from the object Shadows: send ray to light Reflections: reflect ray around normal Refraction: depends on index of refraction

Page 16: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Computational Expense•Rendered at 800x600

•PowerBook G4 (1.25GHz PowerPC, 1GB RAM)

•> 10 hours to render

Page 17: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Computational Expense•598x634 image.

•131,072 triangles

•Depth of field effect

•GeForce 7800 GTX

•Less than 2 minutes.

Page 18: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Raytracing Can Be Parallelized “Embarrassingly (pleasantly?) parallel” Pixels are independent of each other All pixels must known complete scene

specification SPPM

Computing global illumination involves recursion

Some pixel computations will finish before others

Page 19: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Project: Kestrel Implementation Additional math

tangent square root

Precision 32bit fixed point Scene must stay in a particular range

Space Memory: Store scene in every PE Register: Lots of values to keep track of for

each computation

Page 20: Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.

Parallelizing Raytracing

Gillian SmithCMPE 220

February 19th, 2008