advanced cg topics 3 of 8: ray tracing...

55
Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics William H. Hsu Department of Computing and Information Sciences, KSU KSOL course pages: http://snipurl.com/1y5gc Course web site: http://www.kddresearch.org/Courses/CIS636 Instructor home page: http://www.cis.ksu.edu/~bhsu Readings: All slides from SIGGRAPH 2000 tutorial on OpenGL, Shreiner, Angel, Shreiner: http://www.cs.unm.edu/~angel/SIGGRAPH/ Sections 2.6, 3.1 , 20.3 – 20.13 , Eberly 2 e – see http://snurl.com/1ye72 NeHe tutorials: 6 – 10, http://nehe.gamedev.net Article: http://www.kuro5hin.org/story/2003/10/28/9853/1617 CIS 736 Computer Graphics Advanced CG Topics 3 of 8: Ray Tracing Topics

Upload: others

Post on 17-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

William H. Hsu

Department of Computing and Information Sciences, KSU

KSOL course pages: http://snipurl.com/1y5gc

Course web site: http://www.kddresearch.org/Courses/CIS636

Instructor home page: http://www.cis.ksu.edu/~bhsu

Readings:

All slides from SIGGRAPH 2000 tutorial on OpenGL, Shreiner, Angel, Shreiner: http://www.cs.unm.edu/~angel/SIGGRAPH/

Sections 2.6, 3.1, 20.3 – 20.13, Eberly 2e – see http://snurl.com/1ye72

NeHe tutorials: 6 – 10, http://nehe.gamedev.net

Article: http://www.kuro5hin.org/story/2003/10/28/9853/1617

CIS 736Computer Graphics

Advanced CG Topics 3 of 8:Ray Tracing Topics

Page 2: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Lecture Outline

Four More Short OpenGL Tutorials from SIGGRAPH 2000

Vicki Shreiner: Animation and Depth Buffering Double buffering

Illumination: light positioning, light models, attenuation

Material properties

Animation basics in OpenGL

Vicki Shreiner: Imaging and Raster Primitives

Ed Angel: Texture Mapping

Dave Shreiner: Advanced Topics Display lists and vertex arrays

Accumulation buffer

Fog

Stencil buffering

Fragment programs (to be concluded in Tutorial 3)

Page 3: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Page 4: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Ray Tracing

What is it? Why use it? Basics Advanced topics References

Page 5: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Ray-Tracing: Why Use It?

Simulate rays of light Produces natural lighting effects

• Reflection • Depth of Field

• Refraction • Motion Blur

• Soft Shadows • Caustics

Page 6: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Ray-Tracing: Why Use It?

Hard to simulate effects with rasterization techniques (OpenGL) Rasterizers require many passes Ray-tracing easier to implement

Page 7: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Ray-Tracing: Who Uses It?

Entertainment (Movies, Commercials) Games pre-production Simulation

Page 8: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Ray-Tracing: History

Decartes, 1637 A.D. - analysis of rainbow Arthur Appel, 1968 - used for lighting 3D models Turner Whitted, 1980 - “An Improved Illumination Model for

Shaded Display” really kicked everyone off. 1980-now - Lots of research

Page 9: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

The Basics

Generating Rays Intersecting Rays with the Scene Lighting Shadowing Reflections

Page 10: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

The Basic Idea

Simulate light rays from light source to eye

Reflected ray Incident ray

Eye Light

Surface

Page 11: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

“Forward” Ray-Tracing

Trace rays from light Lots of work for little return

Eye

LightImagePlane

Object

Light Rays

Page 12: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

“Backward” Ray-Tracing

Trace rays from eye instead Do work where it matters

Eye

Light

This is what most people mean by “ray tracing”.

ImagePlane

Object

Page 13: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Ray Parametric form

Ray expressed as function of a single parameter (“t”)

<x, y, z> = <xo, yo, zo> + t * <xd, yd, zd>

<x, y, z> = ro + trd

r

o

= <x

o

, y

o

, z

o

>

r

d

= <x

d

, y

d

, z

d

>

t = 0.0

t = 1.0

t = 2.0

t = 2.5

Page 14: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Generating Rays

Trace a ray for each pixel in the image plane

Eye

tan(fovx) * 2

(Looking down from the top)

ImagePlane

Eye

fovx

Page 15: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Generating Rays

Trace a ray for each pixel in the image plane

m

n

(tan(fovx)* 2) / m

(tan(fovy)* 2) / nEye

ImagePlane

(Looking fromthe side)

Page 16: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Generating Rays

Trace a ray for each pixel in the image plane

renderImage(){ for each pixel i, j in the image

ray.setStart(0, 0, 0); // r

o

ray.setDir ((.5 + i) * tan(fovx)* 2 / m, (.5 + j) * tan(fovy)* 2 / n,

1.0); // r

d

ray.normalize(); image[i][j] = rayTrace(ray); }

Page 17: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Triangle Intersection

Want to know: at what point (p) does ray intersect triangle? Compute lighting, reflected rays, shadowing from that point

r

o

r

d <?, ?, ?>(t = ???)

p

Page 18: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Triangle Intersection

Step 1 : Intersect with plane( Ax + By + Cz + D = 0 )

Plane normal n = <A, B, C>

p

p = -(n. ro + D) / (n. rd )

r

d

r

o

Page 19: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Triangle Intersection

Step 2 : Check against triangle edges

p

V1

V2

V0

n

Plug p into (p. Ei + di ) for each edge

if signs are all positive or negative, point is inside triangle!

V0V1

E0Ei = ViVi+1 x n (plane A, B, C)di = -A.N (plane D)

Page 20: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Triangle Normals

Could use plane normals (flat shading) Better to interpolate from vertices

p

n

nV1

nV2

nV0

b

ac

V1

V2

V0

n = anV0 + bnV1 + cnV2

Find areas

area(V0V1V2)

Page 21: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Finding Intersections

Check all triangles, keep the closest intersection

hitObject(ray) { for each triangle in scene does ray intersect triangle? if(intersected and was closer) save that intersection if(intersected) return intersection point and normal}

Page 22: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Lighting

We’ll use triangles for lights Build complex shapes from triangles

Some lighting terms

Eye

V

R

N

I

Surface

Light

Page 23: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Lighting

Use modified Phong lighting similar to OpenGL simulates rough and shiny surfaces

for each light In = IambientKambient +

IdiffuseKdiffuse (L.N) + IspecularKspecular (R.V)n

Page 24: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Ambient Light

Iambient Simulates the indirect lighting in a scene.

Eye

Light

Page 25: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Diffuse Light

Idiffuse simulates direct lighting on a rough surface

Viewer independent Paper, rough wood, brick, etc...

Eye

Light

Page 26: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Specular Light

Ispecular simulates direct lighting on a smooth surface

Viewer dependent Plastic, metal, polished wood, etc...

Eye

Light

Page 27: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Shadow Test

Check against other objects to see if point is shadowed

Eye

ShadowingObject

Page 28: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Reflection

Angle of incidence = angle of reflection ( θ I = θ R )

I, R, N lie in the same plane

R = I - 2 (N . I) N

R

N

I θ I θ R

Page 29: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Putting It All Together

Recursive ray evaluation

rayTrace(ray) { hitObject(ray, p, n, triangle); color = object color; if(object is light) return(color); else return(lighting(p, n, color));}

Page 30: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Putting It All Together

Calculating surface color

lighting(point) { color = ambient color; for each light if(hitObject(shadow ray)) color += lightcolor *

dot(shadow ray, n); color += rayTrace(reflection) * pow(dot(reflection, ray), shininess); return(color);}

Page 31: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Putting It All Together

The main program

main() { triangles = readTriangles(); image = renderImage(triangles); writeImage(image);}

Page 32: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

This is A Good Start

Lighting, Shadows, Reflection are enough to make some compelling images

Want better lighting and objects Need more speed

Page 33: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

More Quality, More Speed

Better Lighting + Forward Tracing Texture Mapping Modeling Techniques Motion Blur, Depth of Field, Blurry Reflection/Refraction

Distributed Ray-Tracing

Improving Image Quality Acceleration Techniques

Page 34: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Refraction

Keep track of medium (air, glass, etc) Need index of refraction (η ) Need solid objects

T

N

I θ I

θ T

sin(θ I) η 1

sin(θ T) η 2

=Medium 1(e.g. air)

Medium 2(e.g. water)

Page 35: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Refraction

Page 36: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Improved Light Model

Cook & Torrance Metals have different color at angle Oblique reflections leak around corners Based on a microfacet model

Page 37: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Using “Forward” Ray Tracing

Backward tracing doesn’t handle indirect lighting too well To get caustics, trace forward and store results in texture map.

Page 38: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Using “Forward” Ray Tracing

Page 39: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Texture Mapping

Use texture map to add surface detail Think of it like texturing in OpenGL

Diffuse, Specular colors Shininess value Bump map Transparency value

Page 40: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Texture Mapping

Page 41: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Parametric Surfaces

More expressive than triangle Intersection is probably slower u and v on surface can be used as texture s,t

Page 42: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Constructive Solid Geometry

Union, Subtraction, Intersection of solid objects

Have to keep track of intersections

Page 43: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Hierarchical Transformation

Scene made of parts Each part made of smaller parts Each smaller part has transformation linking it to larger part Transformation can be changing over time - Animation

Page 44: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Distributed Ray Tracing

Average multiple rays instead of just one ray Use for both shadows, reflections, transmission (refraction) Use for motion blur Use for depth of field

Page 45: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Distributed Ray Tracing

Page 46: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Distributed Ray Tracing

One ray is not enough (jaggies) Can use multiple rays per pixel - supersampling Can use a few samples, continue if they’re very different -

adaptive supersampling Texture interpolation & filtering

Page 47: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Acceleration

1280x1024 image with 10 rays/pixel 1000 objects (triangle, CSG, NURBS) 3 levels recursion

39321600000 intersection tests

100000 tests/second -> 109 days!

Must use an acceleration method!

Page 48: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Bounding volumes

Use simple shape for quick test, keep a hierarchy

Page 49: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Space Subdivision

Break your space into pieces Search the structure linearly

Page 50: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Parallel Processing

You can always throw more processors at it.

Page 51: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Really Advanced Stuff

Error analysis Hybrid radiosity/ray-tracing Metropolis Light Transport Memory-Coherent Ray-tracing

Page 52: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

References

Introduction to Ray-Tracing, Glassner et al, 1989, 0-12-286160-4

Advanced Animation and Rendering Techniques, Watt & Watt, 1992, 0-201-54412-1

Computer Graphics: Image Synthesis, Joy et al, 1988, 0-8186-8854-4

SIGGRAPH Proceedings (All)

Page 53: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Summary

Four More Short OpenGL Tutorials from SIGGRAPH 2000

Vicki Shreiner: Animation and Depth Buffering Double buffering

Illumination: light positioning, light models, attenuation

Material properties

Animation basics in OpenGL

Vicki Schreiner: Imaging and Raster Primitives

Ed Angel: Texture Mapping in OpenGL

Dave Shreiner: Advanced Topics Display lists and vertex arrays

Fog

Stencil buffering, fragment programs (to be continued)

Page 54: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Terminology

Double Buffering

Lighting

Illumination Equation – describes light in scene

Ambient light – catch-all term for whole scene, all lights

Diffuse reflectance – omnidirectional, from matte surfaces

Specular reflectance – unidirectional, for highlights: shiny surfaces

Attenuation – how quickly light drops off as function of distance

Pixel and Fragment Programs (“Pixel Shaders”)

Vertex Shaders

Texture Maps

Other Mappings Discussed in Course

Bump aka displacement – perturb surface normal, calculate lighting

Reflection and transparency

Shadow

Environment

Page 55: Advanced CG Topics 3 of 8: Ray Tracing Topicskdd.cs.ksu.edu/Courses/Spring-2008/CIS736/Lectures/CG-Advanced/Ne… · Material properties ... Produces natural lighting effects

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Next: Polygons, OpenGL Tutorial 3

Dave Shreiner: Advanced Topics (concluded)

Advanced Primitives: Cubic Curves, Bicubic Surfaces

More on Shadow Stencil Buffer

Alpha, Blending, Antialiasing

Accumulation Buffer, Fog, Jitter

Using the OpenGL Shading Language

More on fragment programs

Demo: color interpolation

Example: Fast Phong shading

Special Effects