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
Decomposing Reflection Phong = Amb + Diff + Spec Don t Confuse Phong Shading
Refresher on lighting Diffuse component : idiff i=iamb+idiff+ispec Diffuse is Lambert s law: i diff nl Photons are scattered equally in all directions i diff ( nl) m diff s diff cos
Lighting Specular component : ispec Diffuse is dull (left) Specular: simulates a highlight
Specular component: Phong Phong specular highlight model Reflect l around n: r l 2(n l)n m shi m i ( r v) (cos ) shi spec ( n l) n r -l n l nl i spec mshi max(0,( r v) ) m spec s spec 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: i amb m amb s amb
Lighting i=iamb+idiff+ispec + + = This is just a hack! Has little to do with how reality works!
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
Now Some Info About Lights
Additions to the lighting equation Depends on distance: 1/(a+bt+ct ) Can have more lights: just sum their respective contributions Different light types: 2
Omni r l E L Lights pl pl I r r L 2 ps ps Directional Omni with falloff Spotlight
Falloff OpenGL way f dist s c s l 1 r s q r 2 Typical for Games f dist r r end end 1, r r 0 start,
Spotlights I L ( l) I L *( s 0 l) s exp S- angle P-penumbra U - cutoff
BRDF Theory Ratio between incoming and outgoing light Outgoing Incoming f ( l, v) Lo ( v) E( l)cos( ) i Think of f(l,v) as a function l v
BRDFs Better Modeling Better Modeling: Diffuse define better diffuse Specular different types of specular Ambient beyond just simple Phong ambient
What We ve Done Already For Phong Reflectance We calculate L o = f(l,v)*e(l)*cos( i ) Phong = i*mat+i*nl*mat+i*(nr) m *mat E(l) E(l) f(l,v) E(l) f(l,v) f ( l, v) Lo ( v) E( l)cos( ) i
BRDF Theory Generally Parameterized by: i - incoming o outgoing n Normal V View Vector L Light Vector Easy to param based on two quantities
BRDF Characteristics Helmholtz Reciprocity f ( l, v) f ( v, l) Conservation of Energy What comes in, must go? - Out - Absorbed - Scattered
Light Material Interaction When Light Hits Material: Interacts with surface Goes through surface an interacts below surface Independent of color (most of time for us) Sub-Surface Interaction Surface Interaction
Fresnel Reflectance Governs interface between two surfaces r i is the ideal reflection (look familiar?) t is the ideal refraction Snell s Law (n 1 sin( i ) = n 2 sin( t ) ) i = 90, glancing angle produces white color
Fresnel Example
Which Would You Drink?
Subsurface Scattering Very Important for flesh Most organic materials exhibit Lots of other materials too Without With
Micro-Geometry
Micro-geometry A. Self Shadowing B. Masking C. Interreflection (self) A B C
Example: Micro-Geometry Retro-Reflection
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)
Micro-facet Incorporates: NDF distribution of facets on surface Geometry surface geometry Fresnel f ( l, v) p( h) G( l, v) Rf ( h) 4k cos( )cos( ) p i o
Example BRDFs Modified Phong Old Phong Physically Accurate Phong mat f ( l, v) mat f ( l, v) mat *cos( r ) cos( i ) 0 mat *cos( r ) m m,,
Simple Visibility Many BRDFs (especially game ones) have no visibility term at all This means the visibility term = 1 Implies geometry factor = nl * nv.
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
More Geometry Factors Kelemen-Szirmay-Kalos Geometry Factor Has cheap and effective approximation
Rougher = Blurrier
Smith Geometry Factor Gsmith cos i cos (1 k) i k cos o cos (1 k) o k Incorporates roughness into Geometry Term k=(2m 2 /) Roughness
Many Different Things To Consider
Samples from real-world materials
Demo
More Geometry Factor Phong Ambient Ambient Occlusion AO + GI Light Instead of general inclusion within the BRDF We can account for geometry for each geometry specifically
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
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)
Example
Other Illumination Models Cliff Lindsay
Overview of today s lecture Refresher on simple lighting models Plus some new stuff More Advanced Illumination Models
Additions to the lighting equation Depends on distance: 1/(a+bt+ct ) Can have more lights: just sum their respective contributions Different light types: 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
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.
Realistic rendering For each visible point p in the scene How much light is reflected towards the camera
Direct + Indirect p
Local vs. Global
Indirect Light Direct-only 1-bounce indirect 2-bounce indirect
Ray Tracing
Different Ways to Achieve GI Ray Tracing Path Tracing Photon Mapping Radiosity Metropolis Light Transport
Put it all together