Top Banner
Advanced Computer Graphics Advanced Computer Graphics (Spring 2005) (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi http://www.cs.columbia.edu/~cs4162 Slides adapted from unit 5 (lectures 21-22) of COM
44

Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Advanced Computer Graphics Advanced Computer Graphics (Spring 2005) (Spring 2005)

COMS 4162, Lecture 15: Ray Tracing/Global Illumination

Ravi Ramamoorthi

http://www.cs.columbia.edu/~cs4162

Slides adapted from unit 5 (lectures 21-22) of COMS 4160

Page 2: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

To DoTo Do

Enjoy spring break!! If you want, you can work on raytracer/project during

break, but this is not required

Page 3: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Course OutlineCourse Outline

3D Graphics Pipeline

Rendering(Creating, shading images from geometry, lighting, materials)

Modeling(Creating 3D Geometry)

Page 4: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Course OutlineCourse Outline

3D Graphics Pipeline

Rendering(Creating, shading images from geometry, lighting, materials)

Modeling(Creating 3D Geometry)

Unit 1: Foundations of Signal and Image ProcessingUnderstanding the way 2D images are formed and displayed, the important concepts and algorithms, and to build an image processing utility like PhotoshopWeeks 1 – 3. Assignment 1 due Feb 15

Unit 2: Meshes, ModelingWeeks 4 – 6. Ass 2 due Mar 10

Unit 3: Ray TracingWeeks 7 – 9. Ass 3 due Apr 12

Page 5: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

This lectureThis lecture

High-level overview and summary of ray tracing / global illumination (from 4160)

After spring break: technical details of writing a ray tracer for assignment 3 and more advanced topics

Chapters 15.10 and 16 are useful background, although they don’t follow treatment here

Page 6: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Effects needed for RealismEffects needed for Realism

(Soft) Shadows

Reflections (Mirrors and Glossy)

Transparency (Water, Glass)

Interreflections (Color Bleeding)

Complex Illumination (Natural, Area Light)

Realistic Materials (Velvet, Paints, Glass)

And many more

Page 7: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Image courtesy Paul Heckbert 1983

Page 8: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

OutlineOutline

Ray Tracing

Global Illumination and Rendering Equation

Page 9: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Ray Tracing: HistoryRay Tracing: History

Appel 68

Whitted 80 [recursive ray tracing] Landmark in computer graphics

Lots of work on various geometric primitives

Lots of work on accelerations

Current Research Real-Time raytracing (historically, slow technique) Ray tracing architecture

Page 10: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Ray TracingRay Tracing

Different Approach to Image Synthesis as compared to Hardware pipeline (OpenGL)

Pixel by Pixel instead of Object by Object

Easy to compute shadows/transparency/etc

Demo applet: http://www.cs.berkeley.edu/~efros/java/tracer/tracer.html

Page 11: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Ray Casting

Virtual Viewpoint

Virtual Screen Objects

Ray misses all objects: Pixel colored blackRay intersects object: shade using color, lights, materialsMultiple intersections: Use closest one (as does OpenGL)

Page 12: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Shadows

Virtual Viewpoint

Virtual Screen Objects

Light Source

Shadow ray to light is unblocked: object visibleShadow ray to light is blocked: object in shadow

Page 13: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Shadows: Numerical Issues• Numerical inaccuracy may cause intersection to be below surface (effect exaggerated in figure)

• Causing surface to incorrectly shadow itself• Move a little towards light before shooting shadow ray

Page 14: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Mirror Reflections/Refractions

Virtual Viewpoint

Virtual Screen ObjectsGenerate reflected ray in mirror direction, Get reflections and refractions of objects

Page 15: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Recursive Ray TracingRecursive Ray Tracing

For each pixel Trace Primary Eye Ray, find intersection

Trace Secondary Shadow Ray(s) to all light(s) Color = Visible ? Illumination Model : 0 ;

Trace Reflected Ray Color += reflectivity * Color of reflected ray

Page 16: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Problems with RecursionProblems with Recursion

Reflection rays may be traced forever

Generally, set maximum recursion depth

Same for transmitted rays (take refraction into account)

Page 17: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Turner Whitted 1980

Page 18: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Effects needed for Realism

• (Soft) Shadows

• Reflections (Mirrors and Glossy)

• Transparency (Water, Glass)

• Interreflections (Color Bleeding)

• Complex Illumination (Natural, Area Light)

• Realistic Materials (Velvet, Paints, Glass)

Discussed in this lecture so farNot discussed but possible with distribution ray tracingHard (but not impossible) with ray tracing; radiosity methods

Page 19: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Ray/Object IntersectionsRay/Object Intersections

Heart of Ray Tracer One of the main initial research areas Optimized routines for wide variety of primitives

Various types of info Shadow rays: Intersection/No Intersection Primary rays: Point of intersection, material, normals Texture coordinates

Work out examples in next lecture Triangle, sphere, polygon, general implicit surface

Page 20: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Ray-Tracing Transformed ObjectsRay-Tracing Transformed Objects

We have an optimized ray-sphere test But we want to ray trace an ellipsoid…

Solution: Ellipsoid transforms sphere Apply inverse transform to ray, use ray-sphere Allows for instancing (traffic jam of cars)

Mathematical details worked out in class

Page 21: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

AccelerationAcceleration

Testing each object for each ray is slow Fewer Rays

Adaptive sampling, depth control Generalized Rays

Beam tracing, cone tracing, pencil tracing etc. Faster Intersections

Optimized Ray-Object Intersections Fewer Intersections

Page 22: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Acceleration StructuresAcceleration Structures

Bounding boxes (possibly hierarchical) If no intersection bounding box, needn’t check objects

Bounding Box

Ray

Spatial Hierarchies (Oct-trees, kd trees, BSP trees)

Page 23: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Acceleration Structures: GridsAcceleration Structures: Grids

Page 24: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Interactive RaytracingInteractive Raytracing

Ray tracing historically slow

Now viable alternative for complex scenes Key is sublinear complexity with acceleration; need not

process all triangles in scene

Allows many effects hard in hardware

OpenRT project real-time ray tracing (http://www.openrt.de)

Page 25: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Raytracing on Graphics HardwareRaytracing on Graphics Hardware

Modern Programmable Hardware general streaming architecture

Can map various elements of ray tracing

Kernels like eye rays, intersect etc.

In vertex or fragment programs

Convergence between hardware, ray tracing

[Purcell et al. 2002, 2003]

http://graphics.stanford.edu/papers/photongfx

Page 26: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.
Page 27: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

OutlineOutline

Ray Tracing

Global Illumination and Rendering Equation

Page 28: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Global IlluminationGlobal Illumination

Diffuse interreflection, color bleeding [Cornell Box]

Page 29: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Global IlluminationGlobal IlluminationCaustics: Focusing through specular surface

Major research effort in 80s, 90s till today

Page 30: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Reflectance Equation (review)

ir

x

( , ) ( , ) ( , ) ( , , )( )r r e r i i i r iL x L x L x f x n Reflected Light(Output Image)

Emission Incident Light (fromlight source)

BRDF Cosine of Incident angle

Page 31: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Reflectance Equation (review)

ir

x

( , ) ( , ) ( , ) ( , , )( )r r e r i i i r iL x L x L x f x n Reflected Light(Output Image)

Emission Incident Light (fromlight source)

BRDF Cosine of Incident angle

Sum over all light sources

Page 32: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Reflectance Equation (review)

ir

x

( , ) ( , ) ( , ) ( , , ) cosr r e r i i i r iiL x L x L x df x

Reflected Light(Output Image)

Emission Incident Light (fromlight source)

BRDF Cosine of Incident angle

Replace sum with integral

id

Page 33: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Global Illumination

ir

x

( , ) ( , ) ( , , ) cos( , )r r e r i r ir iiL x dL x L x f x

Reflected Light(Output Image)

Emission ReflectedLight (fromsurface)

BRDF Cosine of Incident angle

id

Surfaces (interreflection)

dAx

i x x

Page 34: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Rendering Equation

ir

x

( , ) ( , , ) c( , ) ( , ) ose r i rr r i ir iL x L xL x f x d

Reflected Light(Output Image)

Emission ReflectedLight

BRDF Cosine of Incident angle

id

Surfaces (interreflection)

dAx

UNKNOWN UNKNOWNKNOWN KNOWN KNOWN

Page 35: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Rendering Equation (Kajiya 86)Rendering Equation (Kajiya 86)

Page 36: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Rendering Equation as Integral Equation

Reflected Light(Output Image)

Emission ReflectedLight

BRDF Cosine of Incident angle

UNKNOWN UNKNOWNKNOWN KNOWN KNOWN

( ) ( )( ) ( , )l u e u K u dvl v v

Is a Fredholm Integral Equation of second kind [extensively studied numerically] with canonical form

( , ) ( , , ) c( , ) ( , ) ose r i rr r i ir iL x L xL x f x d

Kernel of equation

Page 37: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Linear Operator Equation

( ) ( )( ) ( , )l u e u K u dvl v v Kernel of equationLight Transport Operator

L E KL Can be discretized to a simple matrix equation[or system of simultaneous linear equations] (L, E are vectors, K is the light transport matrix)

Page 38: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Ray Tracing and extensions– General class numerical Monte Carlo methods– Approximate set of all paths of light in scene

L E KL IL K EL

( )I K EL 1( )I KL E

Binomial Theorem2 3( ...)I KL K K E

2 3 ...E KE K E K EL

Page 39: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Ray Tracing2 3 ...E KE K E K EL

Emission directlyFrom light sources

Direct Illuminationon surfaces

Global Illumination(One bounce indirect)[Mirrors, Refraction]

(Two bounce indirect) [Caustics etc]

Page 40: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Ray Tracing2 3 ...K EE K K EEL

Emission directlyFrom light sources

Direct Illuminationon surfaces

Global Illumination(One bounce indirect)[Mirrors, Refraction]

(Two bounce indirect) [Caustics etc]

OpenGL Shading

Page 41: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Rendering Equation

ir

x

( , ) ( , , ) c( , ) ( , ) ose r i rr r i ir iL x L xL x f x d

Reflected Light(Output Image)

Emission ReflectedLight

BRDF Cosine of Incident angle

id

Surfaces (interreflection)

dAx

UNKNOWN UNKNOWNKNOWN KNOWN KNOWN

i x x

Page 42: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Change of Variables

Integral over angles sometimes insufficient. Write integral in terms of surface radiance only (change of variables)

( , ) ( , ) ( , ) ( , , ) cosr r e r r i i r i iL x L x L x df x

x

x

dA

i

i

i

o

id2

cos

| |o

i

dAd

x x

Page 43: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Change of Variables

Integral over angles sometimes insufficient. Write integral in terms of surface radiance only (change of variables)

( , ) ( , ) ( , ) ( , , ) cosr r e r r i i r i iL x L x L x df x

2

cos

| |o

i

dAd

x x

all visible2

to

cos cos( , ) ( , ) ( , ) ( , , )

| |i o

r r e r r i i r

x x

L x L x L x f xx

dx

A

2

cos cos( , ) ( , )

| |i oG x x G x x

x x

Page 44: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi cs4162 Slides.

Rendering Equation: Standard Form

Integral over angles sometimes insufficient. Write integral in terms of surface radiance only (change of variables)

Domain integral awkward. Introduce binary visibility fn V

( , ) ( , ) ( , ) ( , , ) cosr r e r r i i r i iL x L x L x df x

2

cos

| |o

i

dAd

x x

all visible2

to

cos cos( , ) ( , ) ( , ) ( , , )

| |i o

r r e r r i i r

x x

L x L x L x f xx

dx

A

2

cos cos( , ) ( , )

| |i oG x x G x x

x x

all surfaces

( , ) ( , ) ( , ) ( , , ) ( , ) ( , )r r e r r

x

i i rL x L x L x f x G x dAx x V x

Same as equation 2.52 Cohen Wallace. It swaps primedAnd unprimed, omits angular args of BRDF, - sign.Same as equation above 16.3 in Shirley, except he has no emission, slightly diff. notation