introduction to ray tracingintroduction to ray...

29
Introduction to Ray Tracing Introduction to Ray Tracing CSE 681

Upload: others

Post on 05-Mar-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Introduction to Ray TracingIntroduction to Ray Tracing

CSE 681

Page 2: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Ray Tracing• Shoot a ray through each pixel;y g p ;• Find first object intersected by ray.

Image plane

Eye

• Compute ray. (More linear algebra.)• Compute ray-object intersection.

CSE 681

p y j

Page 3: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Ray Tracing

• For each pixel– Form ray from eye through pixelForm ray from eye through pixel– For each object

• Intersection ray with object• If intersection is closer than any other so far, save it

– Color pixel with shade of object at point of intersection

CSE 681

Page 4: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Example

CSE 681

Page 5: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Shade of Object at PointA bi• Ambient

• Diffuse

• Specular

• Shadows

• Material properties

• Texture

• Reflections

• Transparency (refraction)

CSE 681

Page 6: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Diffuse Reflection• Light that gets absorbed into the objects surface• Light that gets absorbed into the objects surface• Gets reflected equally in all directions• Need to calculate angle of incoming light to surface• Need to calculate angle of incoming light to surface

CSE 681

Page 7: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Diffuse Reflectionl l / l f li h hi i bj• Calculate amount/color of light shining on an object.

• Depends on angle between light ray and surface normal.

CSE 681

Page 8: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Example: Diffuse reflection

CSE 681

Page 9: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Specular Reflectionp• Calculate light bouncing off object to your eye;• Angle of incidence = angle of reflection.g e o c de ce g e o e ec o .• Most intense at angle of reflection; falls off from there

Angle of incidence

Angle of reflection

Eye

CSE 681

Page 10: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Example: Specular Reflection

CSE 681

Page 11: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

What’s wrong with this picture?

CSE 681

Page 12: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Shadows• Determine when light ray is blocked from reaching object• Determine when light ray is blocked from reaching object.• Ray-object intersection calculation

For each pixelfor each objectfor each light sourcefor each object

CSE 681

Page 13: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Reflection

Image plane

Eye

CSE 681

Page 14: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Transparency

CSE 681

Page 15: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Transparency & Refraction• Ray changes direction in transition between materials• Ray changes direction in transition between materials• Material properties give ratio of in/out angles

CSE 681

Page 16: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Transparency & Refraction

CSE 681

Page 17: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Recursive Ray Tracing

Image plane

Eye

CSE 681

Page 18: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Polyhedral Models

CSE 681

Page 19: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Texture Mapping

CSE 681

Page 20: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Sampling and Aliasing

Problem: Representing pixel by a single ray.

CSE 681

Page 21: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Anti-AliasingSolution:• Use multiple rays;• Average values calculated by rays.g y y

Image plane

EEye

CSE 681

Page 22: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Sampling and Aliasing

Problem: Sampling frequency may match image frequency.

Image plane

EEye

Viewport

CSE 681

Page 23: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Random/Stochastic Sampling

Randomly sample rays through pixel.

Image plane

EEye

Viewport

CSE 681

Page 24: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Efficiency• 1280 x 1024 = 1,310,720 ≈ 106 pixels.• 106 initial rays.• 106 reflection rays.• Potentially 106 refraction rays.• 3 x 106 shadow rays (3 lights.)

Next level:• Potentially 4 x 106 refraction/reflection rays.

1,000,000 polygons., , p yg107 x 106 = 1013 ray-polygon intersection calculations.

CSE 681

Page 25: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Intersection Data Structures

1. Coarse test to see if ray could *possibly* intersection objectj

2. Divide space up - sort objects into spatial buckets – trace ray from bucket to bucketbuckets trace ray from bucket to bucket

CSE 681

Page 26: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Bounding Boxes

CSE 681

Page 27: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Spatial Subdivision

CSE 681

Page 28: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Theory: sampling the environment

1. Rendering as sampling problemg p g p2. Expected value & variance3 Techniques to efficiently reduce variance3. Techniques to efficiently reduce variance

CSE 681

Page 29: Introduction to Ray TracingIntroduction to Ray Tracingweb.cse.ohio-state.edu/~parent.1/classes/681/Lectures/03...Microsoft PowerPoint - 03.RayTracingIntro-2.ppt [Compatibility Mode]

Major Course Topics• Object & coordinate transformations.• Ray-object intersections.• Diffuse & specular reflection.Diffuse & specular reflection.• Shadows.• Opacity & refraction.• Shadows.Shadows.• Recursive ray tracing.• Polyhedral models.• Texture mappingTexture mapping.• Anti-aliasing and sampling.• Bounding boxes and spatial subdivision.• Sampling theory

CSE 681

Sampling theory.