Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping...

20
© Wolfgang Heidrich University of British Columbia Complex Shading Algorithms CPSC 414

Transcript of Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping...

Page 1: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© Wolfgang Heidrich

University ofBritish Columbia

Complex Shading Algorithms

CPSC 414

Page 2: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© 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

Page 3: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© 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

Page 4: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© 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

Page 5: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© 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

Page 6: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© 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

Page 7: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© 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

βδ

θα

Page 8: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© Wolfgang Heidrich

University ofBritish Columbia

Torrance-Sparrow Model

*

+

Page 9: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© Wolfgang Heidrich

University ofBritish Columbia

Banks Model

Anisotropic model (Banks '94, Heidrich '98)

Page 10: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© Wolfgang Heidrich

University ofBritish Columbia

Sampled BRDFs

Factorization of sampled BRDFs (Kautz ´99)• measured/simulated BRDF data• rendering similar to analytic models

Page 11: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© 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!)

Page 12: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© Wolfgang Heidrich

University ofBritish Columbia

Overview

• Shading algorithms based on the Rendering Pipeline– Arbitrary reflection models (BRDFs)– Bump mapping– Environment mapping

Page 13: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© 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

Page 14: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© 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

Page 15: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© 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

Page 16: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© 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

Page 17: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© 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

Page 18: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© Wolfgang Heidrich

University ofBritish Columbia

Bump Mapping

Examples

Page 19: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© 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.

Page 20: Complex Shading Algorithmsjmk/papers/others/Heidrich_AdvShade_GL.pdf · Bump Mapping Normal Mapping Approach: • Skip the computation of the normal – That is the expensive step

© Wolfgang Heidrich

University ofBritish Columbia

Coming Up…

Wed, Nov 21:• Shadow algorithms

Fri, Nov 23 - …:• Ray-Tracing