shading, lighting, & brdf...
TRANSCRIPT
Shading, lighting, & BRDF Theory Cliff Lindsay, PHD
Overview of today’s lecture
• BRDF Characteristics
• Lights in terms of BRDFs
• Classes of BRDFs
• Ambient light & Shadows in terms of BRDFs
Tomas Akenine-Mőller © 2002
Decomposing Reflection
• Phong = Amb + Diff + Spec
• Don’t Confuse Phong Shading
Tomas Akenine-Mőller © 2002
Refresher on lighting Diffuse component : idiff
• i=iamb+idiff+ispec
• Diffuse is Lambert’s law:
Tomas Akenine-Mőller © 2002
cos lndiffi
Photons are scattered equally in all
directions
diffdiffdiff smlni )(
Lighting
Specular component : ispec
• Diffuse is dull (left)
• Specular: simulates a highlight
Tomas Akenine-Mőller © 2002
Specular component: Phong • Phong specular highlight model
Tomas Akenine-Mőller © 2002
Reflect l around n: l)n2(nlr
n
l r
-l
nln )(
ln shishi mm
speci )(cos)( vr
specspec
m
specshi smvri ))(,0max(
Read about Blinns highlight formula: (n.h)m
Ambient component: iamb
• Ad-hoc – tries to account for light coming from other surfaces
• Just add a constant color:
Tomas Akenine-Mőller © 2002
ambambamb smi
Lighting i=iamb+idiff+ispec
• This is just a hack!
• Has little to do with how reality works! Tomas Akenine-Mőller © 2002
+ +
=
What’s lighting and what’s shading?
• Lighting: the interaction between light and matter
• Shading: do lighting (at vertices) and determine pixel’s colors from these
• Three types of shading:
– Flat, Goraud, and Phong
Tomas Akenine-Mőller © 2002
Now Some Info About Lights
Tomas Akenine-Mőller © 2002
Additions to the lighting equation • Depends on distance: 1/(a+bt+ct )
• Can have more lights: just sum their respective contributions
• Different light types:
Tomas Akenine-Mőller © 2002
2
Lights
Tomas Akenine-Mőller © 2002
Directional Omni with falloff Spotlight
2r
IE
r
pspll
psplr
LL
Omni
Falloff
Tomas Akenine-Mőller © 2002
2
1
rsrssf
qlc
dist
0
,
,1
startend
enddist
rr
rrf
OpenGL way
Typical for Games
Spotlights
Tomas Akenine-Mőller © 2002
0
)(*)(
exps
LL
lsIlI
S- angle
P-penumbra
U - cutoff
BRDF Theory
Ratio between incoming and outgoing light
Tomas Akenine-Mőller © 2002
v l
)cos()(
)(),(
i
o
lE
vLvlf
Outgoing
Incoming
Think of f(l,v) as a function
BRDFs – Better Modeling • Better Modeling:
– Diffuse – define better diffuse
– Specular – different types of specular
– Ambient – beyond just simple Phong ambient
Tomas Akenine-Mőller © 2002
What We’ve Done Already
• For Phong Reflectance – We calculate Lo = f(l,v)*E(l)*cos(i) – Phong = i*mat+i*NL*mat+i*(NR)m*mat
Tomas Akenine-Mőller © 2002
)cos()(
)(),(
i
o
lE
vLvlf
f(l,v) f(l,v) E(l) E(l) E(l)
BRDF Theory • Generally Parameterized by:
– i - incoming – o – outgoing – n – Normal – V – View Vector – L – Light Vector
Tomas Akenine-Mőller © 2002
Easy to param based on
two quantities
BRDF Characteristics
• Helmholtz Reciprocity
Tomas Akenine-Mőller © 2002
),(),( lvfvlf
Conservation of Energy
• What comes in, must go ?
- Out
- Absorbed
- Scattered
Light Material Interaction
Tomas Akenine-Mőller © 2002
Surface Interaction Sub-Surface Interaction
When Light Hits Material:
• Interacts with surface
• Goes through surface an interacts below surface
• Independent of color (most of time for us)
Fresnel Reflectance
Tomas Akenine-Mőller © 2002
Governs interface between two surfaces
• ri is the ideal reflection (look familiar?)
• t is the ideal refraction
•Snell’s Law (n1sin(i) = n2 sin(t) )
•i = 90, glancing angle produces white color
Fresnel Example
Tomas Akenine-Mőller © 2002
Which Would You Drink?
Tomas Akenine-Mőller © 2002
Subsurface Scattering
• Very Important for flesh • Most organic materials exhibit • Lots of other materials too
Tomas Akenine-Mőller © 2002
Without With
Micro-Geometry
Tomas Akenine-Mőller © 2002
Micro-geometry
A. Self Shadowing
B. Masking
C. Interreflection (self)
Tomas Akenine-Mőller © 2002
A B C
Example: Micro-Geometry
Retro-Reflection
Tomas Akenine-Mőller © 2002
Micro-facet
• Special Case Micro-geometry – Facets Assumed to be ideal mirrors – Uses Half-vector h (half-way vector) – NDF: Normal Distribution Function p(h) – Introduces Geometry Factor G(l,v)
Tomas Akenine-Mőller © 2002
Micro-facet • Incorporates:
– NDF – distribution of facets on surface – Geometry – surface geometry – Fresnel
Tomas Akenine-Mőller © 2002
)cos()cos(4
)(),()(),(
oip
h
k
RfvlGhpvlf
Example BRDFs
• Modified Phong
Tomas Akenine-Mőller © 2002
,
0
)cos(
)cos(*
),(
i
m
rmatmat
vlf
,)cos(*
),(
m
rmatmatvlf
Old Phong
Physically Accurate
Phong
Simple Visibility
• Many BRDFs (especially game ones) have no visibility term at all
• This means the visibility term = 1
• Implies geometry factor = nl * nv.
Tomas Akenine-Mőller © 2002
Torrance Sparrow Geometry • invented by Blinn in 1975 as a reformulation of the Torrance-
Sparrow • based on an micro-geometry model • not affected by roughness
Tomas Akenine-Mőller © 2002
More Geometry Factors
• Kelemen-Szirmay-Kalos Geometry Factor
• Has cheap and effective approximation
Tomas Akenine-Mőller © 2002
Rougher = Blurrier
Tomas Akenine-Mőller © 2002
Smith Geometry Factor
kkkkGsmith
o
o
i
i
)1(cos
cos
)1(cos
cos
Tomas Akenine-Mőller © 2002
Incorporates roughness into Geometry Term
k=(2m2/)
Roughness
Many Different Things To Consider
Tomas Akenine-Mőller © 2002
Samples from real-world materials
Tomas Akenine-Mőller © 2002
Demo
Tomas Akenine-Mőller © 2002
More Geometry Factor
Instead of general inclusion within the BRDF We can account for geometry for each geometry specifically
Tomas Akenine-Mőller © 2002
Phong Ambient Ambient Occlusion AO + GI Light
Ambient Occlusion
• At surface points P shoot out rays
– If we hit something shelf-shadow
– If not, calculate lighting (NL) or something
• Incorporate into reflectance function
Tomas Akenine-Mőller © 2002
AO
• Light = local hemisphere
– Centered at current surface point
– Radius = user parameter
• Can be rendered with ray tracing
• Gives perceptual clues of depth, curvature and spatial proximity
• Lots of techniques (For Games: Screen Space,
Horizon-Based, Image-Space)
Tomas Akenine-Mőller © 2002
Example
Tomas Akenine-Mőller © 2002
Other Illumination Models Cliff Lindsay
Overview of today’s lecture
• Refresher on simple lighting models
– Plus some new stuff
• More Advanced Illumination Models
Tomas Akenine-Mőller © 2002
Additions to the lighting equation • Depends on distance: 1/(a+bt+ct )
• Can have more lights: just sum their respective contributions
• Different light types:
Tomas Akenine-Mőller © 2002
2
What’s lighting and what’s shading?
• Lighting: the interaction between light and matter
• Shading: do lighting (at vertices) and determine pixel’s colors from these
• Three types of shading:
– Flat, Goraud, and Phong
Tomas Akenine-Mőller © 2002
Global Models
You have seen:
• Local illumination model: Phong – Ambient
– Diffuse
– Specular
– Point light sources
– No: shadows, inter-object light reflection.
• “More global” illumination model: Ray Tracing – Shadows
– Area light sources (via distributed ray tracing)
– inter-object light reflection
Tradeoffs:
• Improvements in fidelity come at the expense of computational complexity.
Tomas Akenine-Mőller © 2002
Realistic rendering
• For each visible point p in the scene
– How much light is reflected towards the camera
Tomas Akenine-Mőller © 2002
Direct + Indirect
Tomas Akenine-Mőller © 2002
p
Local vs. Global
Tomas Akenine-Mőller © 2002
Indirect Light
• Direct-only
• 1-bounce indirect
• 2-bounce indirect
Tomas Akenine-Mőller © 2002
Ray Tracing
Tomas Akenine-Mőller © 2002
Different Ways to Achieve GI
• Ray Tracing
• Path Tracing
• Photon Mapping
• Radiosity
• Metropolis Light Transport
Tomas Akenine-Mőller © 2002
Put it all together
Tomas Akenine-Mőller © 2002