lighting and shadingfussell/courses/cs384g/... · lighting and shading. today: local illumination...
TRANSCRIPT
![Page 1: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/1.jpg)
Lighting and Shading
![Page 2: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/2.jpg)
Today: Local Illumination
Solving the rendering equation is too expensive
First do local illumination
Then “hack in” reflections and shadows
![Page 3: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/3.jpg)
Local Shading: Notation
light intensity in, light intensity out
vector pointing to: light, normal direction,eye, reflection direction
![Page 4: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/4.jpg)
Ignore camera and light direction completely
Ambient Term
material constant
![Page 5: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/5.jpg)
Ignore camera and light direction completely
Ambient Term
material constant
one eq.per colorchannel
![Page 6: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/6.jpg)
Lambertian surface – constant BRDF
Diffuse Term
![Page 7: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/7.jpg)
Lambertian surface – constant BRDF
Diffuse Term
ignore back faces
![Page 8: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/8.jpg)
Perfect specular surface doesn’t work
Specular Term
![Page 9: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/9.jpg)
Perfect specular surface doesn’t work
Phong model:
Specular Term
specularity coefficient
![Page 10: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/10.jpg)
Perfect specular surface doesn’t work
Phong model:
Looks like “highlight” thatmoves with light & eye
Specular Term
![Page 11: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/11.jpg)
Putting It Together
![Page 12: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/12.jpg)
Putting It Together
typically:
![Page 13: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/13.jpg)
Putting It Together
typically:
three copies of equation, one per color channel
![Page 14: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/14.jpg)
Specularity Coefficientmore specular
hig
her
exp
oo
nent
![Page 15: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/15.jpg)
Light Attenuation
Real light attenuation: inverse square law
![Page 16: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/16.jpg)
Light Attenuation
Real light attenuation: inverse square law
Tends to look bad: too dimor washed out
So, we cheat
![Page 17: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/17.jpg)
d is light-to-point distance
Can tweak constant & linear term to taste
Light Attenuation
![Page 18: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/18.jpg)
Directional Light
“Light at infinity”
• Sun
All light rays parallel
Obviously, no attenuation
![Page 19: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/19.jpg)
Dealing with Discrete Geometry
Flat shading: use normal per face
Very obvious discontinuitiesat edges
Only used for stylized “chunky” effect
![Page 20: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/20.jpg)
Gouraud Interpolation
First, compute color at vertices
Linearly interpolate color over face
![Page 21: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/21.jpg)
Gouraud Interpolation
First, compute color at vertices
Linearly interpolate color over face
Color now continuous, but still obvious artifacts (nobody uses this anymore)
![Page 22: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/22.jpg)
Phong Interpolation
First, linearly interpolate normals
Next, renormalize normals(important)
Then, compute color per pixel
![Page 23: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/23.jpg)
Phong Interpolation
First, linearly interpolate normals
Next, renormalize normals(important)
Then, compute color per pixel
Because of all of the normalizations, used to be considered decadent;now the standard local shading scheme
![Page 24: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/24.jpg)
Local vs Global Illumination
Local:
• shade each object based only on itself, the eye, and the light sources
Global:
• take all other objects in scene into account also
• BRDFs and the rendering equation
![Page 25: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/25.jpg)
Local vs Global Illumination
Grey Area:
• take other objects into account, without full global illumination
• adds realism without being too slow
![Page 26: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/26.jpg)
Local vs Global Illumination
Grey Area:
• take other objects into account, without full global illumination
• adds realism without being too slow
• common techniques exist for
• shadows
• reflections
• refractions
![Page 27: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/27.jpg)
Shooting Shadow Rays
![Page 28: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/28.jpg)
Shooting Shadow Rays
For each intersection pt:
• for each light:
• shoot ray from point to light
• if it hits an object:
• do nothing (shadow)
• else add shading contribution
![Page 29: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/29.jpg)
Classic Bug
![Page 30: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/30.jpg)
Classic Bug
at what t does the ray hit an object?
![Page 31: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/31.jpg)
Classic Bug
at what t does the ray hit an object?
![Page 32: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/32.jpg)
Classic Bug
at what t does the ray hit an object?
if lucky: {-1.2, 0.0}
![Page 33: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/33.jpg)
Classic Bug
at what t does the ray hit an object?
if lucky: {-1.2, 0.0}
if unlucky: {-1.2, 1e-12}
![Page 34: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/34.jpg)
Ignore t Near Zero?
![Page 35: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/35.jpg)
Ignore t Near Zero?
![Page 36: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/36.jpg)
Ignore t Near Zero?
Fix: move slightly in normal direction (orbackward ray direction) before shooting shadow ray
![Page 37: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/37.jpg)
Hard Shadows
real-world doesn’tlook like this
![Page 38: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/38.jpg)
Hard Shadows
real-world doesn’tlook like this
shadows usuallysoft
why?
![Page 39: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/39.jpg)
Soft Shadows
![Page 40: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/40.jpg)
Other Secondary Rays
Translucent objects
![Page 41: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/41.jpg)
Other Secondary Rays
Reflection & refraction
![Page 42: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/42.jpg)
Reflection
Purely specular (mirrored) surface
![Page 43: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/43.jpg)
Reflection
Purely specular (mirrored) surface:
1. Incoming ray hits surface
![Page 44: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/44.jpg)
Reflection
Purely specular (mirrored) surface:
1. Incoming ray hits surface
2. Shoot secondary reflection ray
![Page 45: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/45.jpg)
Reflection
Purely specular (mirrored) surface:
1. Incoming ray hits surface
2. Shoot secondary reflection ray
3. Set pixel color to color “seen” by
![Page 46: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/46.jpg)
Choosing the Reflection Ray
Angle of reflection = angle of incidence
![Page 47: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/47.jpg)
Choosing the Reflection Ray
Angle of reflection = angle of incidence
I.e. negate component of in normal dir
• leave tangent component untouched
![Page 48: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/48.jpg)
Choosing the Reflection Ray
Angle of reflection = angle of incidence
I.e. negate component of in normal dir
• leave tangent component untouched
![Page 49: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/49.jpg)
Choosing the Reflection Ray
Angle of reflection = angle of incidence
I.e. negate component of in normal dir
• leave tangent component untouched
![Page 50: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/50.jpg)
The math:
Choosing the Reflection Ray
![Page 51: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/51.jpg)
Reflection in Practice
Objects may not be perfectly mirrored
• blend reflected color with basic shading
![Page 52: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/52.jpg)
Reflection in Practice
Objects may not be perfectly mirrored
• blend reflected color with basic shading
Objects have base color
• multiplies reflected color
![Page 53: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/53.jpg)
Reflections in Practice
Reflection ray might hit reflective objects
• cast recursive reflection rays…
• stop after somemaximum recursionlimit
![Page 54: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/54.jpg)
Refraction
![Page 55: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/55.jpg)
Refraction
Light bends whenmoving betweendifferent materials
Caused by changein speed of light
We “see” dotted straw
![Page 56: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/56.jpg)
Index of Refraction
Measures speed of light in material
![Page 57: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/57.jpg)
Index of Refraction
Measures speed of light in material
Common values:
• Vacuum: 1.0
• Air: 1.0001
• Water: 1.33
• Glass: 1.5
![Page 58: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/58.jpg)
Snell’s Law
Special cases:
•
•
![Page 59: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/59.jpg)
Implementing Snell’s Law
Solve for alpha
Shoot refraction ray
![Page 60: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/60.jpg)
Refractions in Practice
Again, usually multiplied by a base color
Light bends when entering and leaving
• must detect both when ray-tracing
![Page 61: Lighting and Shadingfussell/courses/cs384g/... · Lighting and Shading. Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then](https://reader034.vdocuments.us/reader034/viewer/2022050212/5f5e04e0b91a6d21f26c615c/html5/thumbnails/61.jpg)
Reflection & Refraction Example