Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
© Wolfgang Heidrich
University ofBritish Columbia
Complex Shading Algorithms
CPSC 414
© Wolfgang Heidrich
University ofBritish Columbia
Overview
So far• Rendering Pipeline including recent developments
Today• Shading algorithms based on the Rendering Pipeline
– Arbitrary reflection models (BRDFs)– Bump mapping– Environment mapping
© Wolfgang Heidrich
University ofBritish Columbia
Reflection Models
In previous lecture:• Reflection models in hardware limited to diffuse +
Phong or Blinn-Phong• Physically not plausible (no preservation of energy)
Better reflection models• Based on physical principles• Derived by analyzing small-scale structure of objects• E.g.: Microfacet models
© Wolfgang Heidrich
University ofBritish Columbia
Microfacet Models
Model:• Rough surface is composed of small, planar parts that
are “perfect mirrors” (microfacets)
“Perfect mirror”:• Reflect incoming light from one direction to exactly
one outgoing direction • Correct term: Fresnel Reflector
© Wolfgang Heidrich
University ofBritish Columbia
Fresnel Reflector
Synopsis:• Perfectly smooth surface
– Thus light from one direction only reflected in exactly one outgoing direction
• Percentage of light reflected depends ONLY on the optical densities (“index of refraction”) of the materials separated by the surface (e.g. air and glass)– All energy not reflected is refracted in exactly one
direction (Snell’s law)– E.g.: Water, glass have optical densities of about
1.5: reflection only at grazing angles, not at perpendicular angles
– Metal: high density (several 100s) almost all light is reflected, independent of angle
© Wolfgang Heidrich
University ofBritish Columbia
Microfacet Models
Contributing Factors to Microfacet BRDFs:• Facet Distribution Function:
– Describes the statistics of the microfacets, I.e. how likely it is that we find a facet with a certain orientation
• Fresnel term:– Describes the amount of light reflected for a given
facet normal and light direction (see previous slide)• Geometric term
– Describes shadowing and occlusion of facets
© Wolfgang Heidrich
University ofBritish Columbia
Torrance-Sparrow ('67):• fr=F(θ)D(δ) • G(α,β)/(π cosα cosβ)
Sample factors• store as 2D textures
Texture coordinates:• reparameterize terms over cosines of angles• allows for hardware-based texture coordinate
generation
Example:Torrance-Sparrow Model
v
n
h
l
βδ
θα
© Wolfgang Heidrich
University ofBritish Columbia
Torrance-Sparrow Model
*
+
© Wolfgang Heidrich
University ofBritish Columbia
Banks Model
Anisotropic model (Banks '94, Heidrich '98)
© Wolfgang Heidrich
University ofBritish Columbia
Sampled BRDFs
Factorization of sampled BRDFs (Kautz ´99)• measured/simulated BRDF data• rendering similar to analytic models
© Wolfgang Heidrich
University ofBritish Columbia
Summary Material Rendering
Texture-based lighting:• Use texture mapping for storing complex functions
like BRDF models• Make sure the texture coordinates are easy to
compute– In our case: use cosines of angles rather than
angles themselves– An be computed as part of vertex program!
• Maximum flexibility by replacing fixed-function hardware lighting with arbitrary illumination models
• Implements per-fragment lighting (similar to Phongshading!)
© Wolfgang Heidrich
University ofBritish Columbia
Overview
• Shading algorithms based on the Rendering Pipeline– Arbitrary reflection models (BRDFs)– Bump mapping– Environment mapping
© Wolfgang Heidrich
University ofBritish Columbia
Bump Mapping
Concept:• Draw very simple geometry• Use texture mapping to perturb normal at every
surface location before performing a per-fragment lighting operation
© Wolfgang Heidrich
University ofBritish Columbia
Bump Mapping
Original Approach (Blinn ’76):• Store texture with a single channel (height value):• Compute per-pixel normal as if the surface was
displaced by the height value along the interpolated geometric normal
• Use that normal for per-fragment lighting
© Wolfgang Heidrich
University ofBritish Columbia
Bump Mapping
Normal Mapping Approach:• Skip the computation of the normal
– That is the expensive step• Directly encode the normal into the texture map
– (R,G,B)= (x,y,z), appropriately scaled• Then only need to perform illumination computation
– Interpolate light and viewing direction from the vertices of the primitive
– Use register combiners for doing lighting computation
© Wolfgang Heidrich
University ofBritish Columbia
Bump Mapping
Register Combiner Lighting• Diffuse:
– Inputs:8Gouraud-interpolated color holds light direction8Texture lookup yields normal for fragment
– Combiner operation:8Compute dot product between the two vectors
© Wolfgang Heidrich
University ofBritish Columbia
Bump Mapping
Register Combiner Lighting• Blinn/Phong specular component:
– Inputs:8Halfway vector between light and viewing
direction (coded as Gouraud interpolated surface color)
8Texture lookup yields normal for fragment– Combiner operation
8First combiner stage computes dot product8Other combiner stages can successively
square result to achieve different exponents
© Wolfgang Heidrich
University ofBritish Columbia
Bump Mapping
Examples
© Wolfgang Heidrich
University ofBritish Columbia
Bump Mapping
Issues:• How do we compute per-vertex light vector, viewing
vector, and halfway vector?– Software or vertex programs
• What about other exponents or general reflection models?– Dependent texture lookup:
8Use register combiners to perform per-fragment dot products
8Use the result as texture coordinates into an arbitrary reflection model.
© Wolfgang Heidrich
University ofBritish Columbia
Coming Up…
Wed, Nov 21:• Shadow algorithms
Fri, Nov 23 - …:• Ray-Tracing