36
Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Embed Size (px)

Citation preview

Page 1: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

Computer Graphics

Lecture 14

Illumination II – Global Models

Page 2: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 2

Global Illumination

• Extends the Local Illumination Model to include:– Reflection (one object in another)– Refraction (Snell’s Law)– Transparency (better model)– Shadows (at point, check each light source)– Antialiasing (usually means supersampling)

Page 3: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 3

Wireframe view of a test scene.

Orthographic view from above

Page 4: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 4

Test Scene.

High quality rendering of test scene.

Note :

• Mirror and chrome teapot.• Shadows on floor.• Shiny floor.

Page 5: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 5

Locally illuminated test scene.

Ambient term only

Page 6: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 6

Locally illuminated test scene.

Phong shading.

Ambient and Diffuse terms only

Notes :

• Highlight on wall from light is in the wrong place; screen space interpolation.• We cannot illuminate the lights with the light sources – wrong side !

Page 7: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 7

Locally illuminated test scene.

Phong shading.

Ambient, diffuse andSpecular terms.

Page 8: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 8

Locally illuminated test scene.

Flat shading.

Note : Mach bands.

Page 9: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 9

Locally illuminated test scene.

Gouraud shading.

Ambient, diffuse andSpecular terms.

Note: artefacts on wall.

Page 10: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 10

Solution to Gouraud artefacts.

Gouraud shading.

Re-triangulated mesh.

Page 11: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 11

Comparison.

Flat Gouraud Phong

Coarser mesh

Page 12: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 12

Use Local illumination.

• No.

• In our test scene, we can’t represent :– Mirror– Chrome teapot.– Shiny floor– Shadows

with local illumination.

Page 13: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 13

Kajiya’s Rendering Equation.

S BRDF

xdxxIxxxxxxxgxxI ),(.),,(),().,(),(

Viewer is at point x, looking toward point x.

-I(x,x) determines amount of light arriving at x from x- g(x,x) is a geometry term, = 0 when x is occluded, otherwise = attenuation factor 1/r2 (or 1/(s+k))- (x,x) is the amount of light emitted from x to x.- (x,x,x) is the fraction of light reflected and scattered off x to point x

from point x- The integral S is over all such points (x") on all surfaces.

Page 14: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 14

Global illumination.

• Two methods :

– View dependent methods.

• Calculate the view from the camera with global illumination.

– Recursive ray-tracing.

– View independent methods.

• Solve lighting for the entire scene.

• Radiosity solution.

Page 15: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 15

View dependent methods.

• Loop round the pixels…..• Good for lighting effects which have a strong

dependence on view location :– Specular highlights.– Reflections from curved surfaces.

• Only a small number of objects need to be considered at the same time.

• Poor when many objects need to be considered – E.g diffuse interactions (eg. colour bleeding).

Page 16: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 16

View independent methods.

• Loop round the scene…

• Good when many (all) objects need to be considered at same time.– Diffuse inter-reflections.

• Poor when shading has strong dependence on view location.– Specular reflection.

Page 17: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 17

Recall : Ray casting.

• Involves projecting an imaginary ray from the centre of projection (the viewers eye) through the centre of each pixel into the scene.

• The first object the ray intersects determines the shade.

Scene

Window

Eyepoint

Page 18: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 18

Whitted’s algorithm.

• Fire off secondary rays from surface that ray intersects.– Towards Light Source(s) : shadow rays. L (shadow feelers)

– In the reflection direction : reflection rays, R

– In a direction dictated by Snell’s Law : transmitted rays, T

N

L

direction)(Viewer VR

T

Page 19: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 19

Recursive ray tree.

• Reflection and Transmission Rays spawn other rays.– Shadow rays test only for occlusion.

• The complete set of rays is called a Ray Tree.

Viewpoint

1L

2L

3L

1R

2R

3R1T

2T

Light Source ray determines colour of current object.

Page 20: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 20

Recursive ray tree.

• Reflection and Transmission Rays spawn other rays.– Shadow rays test only for occlusion.

• The complete set of rays is called a Ray Tree.

Page 21: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 21

Test Scene.

Ray tree depth 1.

Note only ambient shade on mirror and teapot

Page 22: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 22

Test Scene.

Ray tree depth 2.

Note only ambient shade on reflection of mirror and teapot.

Page 23: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 23

Test Scene.

Ray tree depth 3.

Note only ambient shade on reflection of mirror in teapot.

Page 24: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 24

Test Scene.

Ray tree depth 4.

Note ambient shade on reflection of teapot in reflection of mirror in teapot.

Page 25: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 25

Test Scene.

Ray tree depth 5.

Page 26: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 26

Test Scene.

Ray tree depth 6.

Page 27: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 27

Test Scene.

Ray tree depth 7.

Page 28: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 28

When to stop ?

• Need to know when to stop the recursion.• Can define a fixed depth.• Hall introduced adaptive tree depth control.

– Calculate maximum contribution of a ray to a pixels final value.

– Multiply contribution of ray’s ancestors down the tree.

– Stop when below some threshold, perhaps stack overflow.

– May miss major contribution this way (culled bright pt)

Page 29: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 29

Adaptive tree depth control.

Viewpoint

1L

1R

1T0.3

0.2

Page 30: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 30

Adaptive tree depth control.

Viewpoint

1L

2L

3L

1R

2R

3R1T

2T

0.3 * 0.2

0.2 * 0.2

0.3

0.2

Page 31: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 31

Global vs. Local illumination.

• In both an object hit by a ray, if lit by a light source, is illuminated by a local illumination model, i.e with specular, diffuse & ambient terms.

• Global: a reflected ray, a shadow feeler, and a transmission ray (if appropriate) are also cast into the scene.

• Phong term only reflects light source.– Need to adjust local illumination terms to normalise total light

values.

– Inconsistent if local and global specular terms used together as local term spreads light source, global term does not.

Page 32: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 32

Increased reflectivityIn

crea

sed

tran

smis

sivi

tyPhong specular

term is held constant

Page 33: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 33

Incorrect result.

• Effect of not normalising reflection and transmission – light appears to be created.– Reflection & transmission = 100%

Page 34: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 34

Problems with Ray-tracing.

• A serious problem with Ray tracing is rays are traced from the eye.– Refraction is not physically correct.

• Shadow rays are cast only to light sources– Lights reflected in mirrors do not cast shadows– Shadows of transparent objects don’t exhibit

refraction.– Still need local illumination for diffuse shading.

Page 35: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 35

Speeding up Ray Tracing

• Ray tracing is slow, not real-time.

• Use appropriate extents for objects.

• Ray tracing is inherently parallel.

• Use item buffers – z-ordered lists, store closest object per pixel.

• Use light buffer – z-ordered list per light ray used for shadowing.

Page 36: Computer Graphics Inf4/MSc Computer Graphics Lecture 14 Illumination II – Global Models

Computer Graphics Inf4/MSc

6/11/2007 Lecture Notes #14 36

Recommended Reading

• Foley at al. Chapter 16, sections 16.11, 16.12 and 16.12.5.

• Introductory text Chapter 14 sections 14.6 and 14.7.

• Most graphics texts cover recursive ray tracing.