Surface Material Physics for Shader Writers - PowerPoint PPT Presentation

1 / 68
About This Presentation
Title:

Surface Material Physics for Shader Writers

Description:

Surface Material Physics for Shader Writers Chas. Boyd DirectX Graphics Architect Windows Gaming & Graphics Technology Microsoft Corporation – PowerPoint PPT presentation

Number of Views:161
Avg rating:3.0/5.0
Slides: 69
Provided by: MarkB8
Learn more at: https://cse.osu.edu
Category:

less

Transcript and Presenter's Notes

Title: Surface Material Physics for Shader Writers


1
Surface Material Physicsfor Shader Writers
  • Chas. Boyd
  • DirectX Graphics Architect
  • Windows Gaming Graphics Technology
  • Microsoft Corporation

2
Motivation
  • Lighting and surface effects are clearly
    discernable to end-users
  • Enables novelty for them, and differentiation for
    you
  • Enable a title to have a distinct look
  • See other talks on lighting models, this one
    focuses on surfaces

3
Overview
  • Surfaces vs. Lighting
  • Surface Types
  • Metal
  • Rough
  • Specular
  • Subsurface
  • Layered Materials
  • Maya, SOFTIMAGE, Renderman

4
Assumptions
  • For all surfaces
  • Other effects such as shadows will be applied in
    the lighting model
  • These are independent of the surface effects
    described here

5
Surfaces and Lighting
  • Key participant in visual Look
  • Interacts with lighting environment in various
    ways
  • Need to take both into account in any given
    situation
  • Design content to have surfaces that look best in
    the lighting environment they will be used in and
    vice versa

6
Surface-Light Interaction
  • Light comes in
  • Surface modifies it
  • Light leaves towards camera/eye
  • Surface interactions include
  • Absorption, reflection, self-shadowing,
    self-occlusion, scattering
  • Subsurface effects
  • Absorption, scattering, re-emission

7
Fundamentals of Surfaces
  • Surfaces often contain multiple constituents
  • Absorptive dies, reflective layers, scattering
    particles of various sizes
  • This talk proceeds from simplest to more complex
    surface structures

8
Polished Metal Surface
  • Process
  • Light comes in
  • Some colors are absorbed
  • Remaining light reflects
  • Atomically smoothmirror finish
  • Structured highlights
  • image of environment are visible in them

9
STM Micrograph
10
Polished Metal
11
Map-Based Technique
  • Apply environment map for reflection
  • Scale it by metal color
  • Accounts for some colors absorbed
  • That is the final color for the screen
  • C envmapbase
  • Gamma Note no effect

12
Modulate Environment Map
13
Procedural Technique
  • Use very high specular exponent
  • 100 or higher
  • Accurate model for single constant color round
    light source
  • C lightdot(N,H)100 base
  • Gamma Note picking exponent

14
Use in Games
  • Works for gold, copper, bronze
  • some anodized effects
  • Ideal for weapons
  • Gun metal blue
  • Not appropriate for enameled metal
  • More metallic than any metallic auto-body
    enamel
  • Nor for oxidized e.g. verdigris
  • These are too rough for this model

15
Rougher Surfaces
  • Smudges, scuffs, dust, oxides
  • At high magnification we see

16
Rough Surface
Diffuse Scattering
Reduced Specular
17
Map-based Technique
  • Roughness varies per-pixel in gloss map e.g.
    alpha of base tex
  • Scale down environment map
  • c glossenvmapbase
  • Blur environment map in areas of low gloss
  • MIP LOD or post-process effect
  • MIP LOD is per-pixel in ps.2.0
  • Blur is partial integral of map

18
Procedural Technique
  • Use procedural specular
  • spec lightdot(N,H)25
  • but with same gloss term
  • c glossspecbase
  • Decrease exponent to achieve blur

19
Both Techniques
  • Add diffuse scattering term

20
Increased Roughness
21
Increased Roughness Surface
22
Fully Rough Surface
23
Fully Rough Surface
Diffuse Scattering
No Specular
24
Rough Surfaces
  • Concrete
  • Sand
  • Cloth
  • Plaster
  • Marble, non-polished
  • Pavement
  • Stone

25
Moon Photograph
26
Moon Rendering
27
Rough Surfaces
  • Diffuse reflector
  • Lambertian or Oren-Nayar effects

28
Map-based Technique
  • Blur map across very large scale
  • Integrate entire hemisphere

29
Cube Map And Its Integral
30
Diffuse only
31
Procedural Technique
  • Model only Diffuse term
  • For directional light
  • c light dot(N,L) base
  • Or use hemisphere light
  • Gamma Note
  • Correct using sqrt or 1-(1-x)2
  • for non-CAD applications

32
Layered Surface
Varnish
Dye Layer
33
Layered Surface Larger
Varnish
Dye Particles
34
Layered Surface
  • Thin layer of smooth clear material
  • Over rough dye particles
  • Underlayer is rough because particles may be
    suspended
  • Plastics
  • Linoleum
  • Enameled metal car finish
  • Varnished surface wood

35
Map-Based Technique
  • Envt. map scaled by gloss term
  • spec glossenvmap
  • Added to diffuse term
  • c dot(N,L)base spec
  • Base color does not tint highlight
  • Gamma Note add should be linear
  • Correct to linear, add, convert back
  • if have enough precision and time

36
Add Environment Diffuse
37
Specular Only
38
Procedural Technique
  • Base color does not modulate specular, only light
    color does
  • spec lightdot(N,H)100
  • c dot(N,L)base specgloss
  • Top layer bottom layer

39
Summary
  • Polished specularglossbase
  • Rough diffusebase
  • Varnished specgloss
  • diffusebase

40
Fresnel Effect
  • At top layer interface
  • Some light is reflected,
  • Remainder is transmitted through
  • Depends on surface material
  • And on incident angle!
  • Fresnel term f is proportion reflection
  • grazing angles 100 reflected
  • normal angles 5 reflected

41
Fresnel Mid
60 reflected
Air
Material
40 transmitted
42
Fresnel Normal
10 reflected
Air
Material
90 transmitted
43
Fresnel Grazing
90 reflected
Air
Material
10 transmitted
44
Fresnel Profile
Measurement
45o
90o
0o
45
Fresnel Term Approximation
  • Use f 1 - cosq (1 - E dot N)
  • Raise to power for better approximation
  • f (1 cosq)4
  • Schlick used 5th power
  • Hack curve fit to Glassner

46
Fresnel Vertex Shader
  • m4x4 oPos,v0,c8 // xform pos. to output space
  • m4x4 r0,v0,cW // xform pos. to world space,
  • m3x3 r1,v3,cW // xform normal to world space
  • add r0,-r0,c14 // compute eye ray
  • dp3 r3.x,r0.xyz,r0.xyz
  • rsq r3.xyz,r3.x
  • mul r0.xyz,r0.xyz,r3.xyz// normalize it
  • dp3 r0,r0,r1 // dot eye ray with normal
  • add r0,c1111,-r0 // complement color
  • mul r1,r0,r0 // 2
  • mul r0,r1,r1 // 4
  • mul r0,r0,c1 // scale for fresnel
  • add oD0,r0,c0 // bias and emit as diffuse

47
Fresnel Pixel Shader
  • ps.1.1
  • def v0 // eye ray
  • def c0 // 5 bias
  • def c1 // 95 scale
  • tex t0 // normal map
  • dp3 r0,v0_bx2,t0_bx2 // dot eye ray with normal
  • mul r1,1-r0,1-r0 // complement and square
  • mul r0,r1,r1 // 4
  • mad r0,r0,c1,c0 // scale bias

48
Fresnel Comparison
1- cosq
(1- cosq)4
Measurement
45o
90o
0o
49
Fresnel Term
50
Fresnel Affects Diffuse Layer
  • Only light that was not reflected illuminates
    diffuse dye layer
  • In single light case, incident angle can be used
    to compute f
  • Then f is used to blend (lerp) between specular
    and diffuse
  • Not as useful for multi-light case
  • diffuse layer is illuminated by light from all
    directions in that case

51
Metallic Flake
  • Can used BEML with random Gaussian distribution
    of perturbation pixels
  • Can use similar trick for glass buildings
  • point sampled displacement map gives each window
    a separate normal
  • Or use filtering to get curved windows
  • then must mask seams with alphatest

52
MicroFlake
  • Use procedural specular term with low exponent
    8
  • Feasible with DirectX 8. pixel shader
  • Still need enviroment map for car finish enamel
    gloss coat

53
Metallic Flake Finish
Varnish
Flakes
Dye Layer
54
Sub-Surface Effects
  • Absorption
  • Light has to get inside
  • Re-emission
  • Light has to get out again

55
Subsurface Absorption
  • Can be impacted by Fresnel effects
  • Only non-reflected light penetrates
  • Simple term to model
  • Can be impacted by structure of surface

56
Skin
  • A layer of ketchup covered by tissue paper
  • Probably more translucent than real ketchup

57
Anisotropic Effects
  • Most visible in specular case
  • Brushed metal
  • Cloth fabrics
  • Wire spools

58
Anisotropic Hair
  • Hair Tufts
  • snip a lock, put it in scanner
  • Eyelashes
  • use alpha channel mask
  • per-vertex anisotropic
  • no per-pixel direction variation
  • Anti-aliased lines are too thick

59
Key References
  • Nelson Max
  • Christophe Schlick
  • Peter Shirley

60
Empiricism
  • Shading is not fully understood
  • Most efforts not based on pure physics
  • Equations are fit to measured data
  • Equations are chosen to look good

61
Empirical Process
  • Discern an effect
  • Measure how it varies
  • Curve fit some equation to it
  • Tweak it until it looks good

62
Empirical Process
Measure
Plot
Fit Eqn
Render
Tweak
Evaluate
63
Nelson Max
  • Horizon mapping shadows for bump-mapped
    surfaces
  • Basis of last years GDC talk on real-time
    self-shadowing bump maps
  • Available as sample in DX8.1 SDK
  • Most work is applicable and accessible

64
Christophe Schlick
  • A Customizable Reflectance Model for Everyday
    Rendering
  • Uses his procedurally generated BRDF
  • Generic Lighting Model
  • Single shader for specular vs diffuse, and
    isotropic vs anisotropic surfaces
  • Reduces state changes?
  • Requires 2.0 shaders

65
Peter Shirley
  • Real-time Ray-tracing
  • Hemisphere lighting model
  • A Practitioners Assessment of Light Reflection
    Models
  • Demonstrates process of identifying an effect and
    defining a technique to represent it
  • Includes good background material

66
Books
  • Foley Van Dam, Feiner, Hughes
  • Still lots of good background material
  • Fundamentals
  • Principles of Digital Image Synthesis by Andrew
    Glassner
  • Broad sampling of topics
  • Excellent detail in key areas
  • Concordance for much of literature

67
Miscellaneous
  • Graphics Gems
  • Game Programming Gems
  • Real-time Photorealistic Rendering
  • Eric Haines

68
Call to Action
  • Pick a unique Look and do it
  • Toon several methods
  • Cheesy unlit or flat shaded
  • Retro std FF pipelines
  • Radiosity soft lighting only
  • Shadows horror movie
  • Gritty ultra realistic
  • Uses photos for concept art
Write a Comment
User Comments (0)
About PowerShow.com