Upload
sandip-desai
View
221
Download
0
Embed Size (px)
Citation preview
8/13/2019 Surface Material Physics for Shader Writers
1/68
Surface Material Physics
for Shader Writers
Chas. Boyd
DirectX Graphics Architect
Windows Gaming & Graphics Technology
Microsoft Corporation
8/13/2019 Surface Material Physics for Shader Writers
2/68
Motivation
Lighting and surface effects areclearly discernable to end-users
Enables novelty for them, anddifferentiation for you
Enable a title to have a distinctlook
See other talks on lighting models,this one focuses on surfaces
8/13/2019 Surface Material Physics for Shader Writers
3/68
Overview
Surfaces vs. LightingSurface Types
Metal
Rough
Specular
Subsurface
Layered Materials
Maya, SOFTIMAGE, Renderman
8/13/2019 Surface Material Physics for Shader Writers
4/68
Assumptions
For all surfaces:
Other effects such as shadows will
be applied in the lighting modelThese are independent of thesurface effects described here
8/13/2019 Surface Material Physics for Shader Writers
5/68
Surfaces and Lighting
Key participant in visual Look
Interacts with lighting environment
in various waysNeed to take both into account inany given situation
Design content to have surfacesthat look best in the lightingenvironment they will be used inand vice versa
8/13/2019 Surface Material Physics for Shader Writers
6/68
8/13/2019 Surface Material Physics for Shader Writers
7/68
Fundamentals of Surfaces
Surfaces often contain multipleconstituents
Absorptive dies, reflective layers,scattering particles of various sizes
This talk proceeds from simplest tomore complex surface structures
8/13/2019 Surface Material Physics for Shader Writers
8/68
Polished Metal Surface
Process
Light comes in
Some colors are absorbedRemaining light reflects
Atomically smoothmirror finish
Structured highlightsimage of environment are visible inthem
8/13/2019 Surface Material Physics for Shader Writers
9/68
STM Micrograph
8/13/2019 Surface Material Physics for Shader Writers
10/68
Polished Metal
8/13/2019 Surface Material Physics for Shader Writers
11/68
Map-Based Technique
Apply environment map forreflection
Scale it by metal colorAccounts for some colors absorbed
That is the final color for the screen
C = envmap*base
Gamma Note: no effect
8/13/2019 Surface Material Physics for Shader Writers
12/68
Modulate Environment Map
8/13/2019 Surface Material Physics for Shader Writers
13/68
Procedural Technique
Use very high specular exponent
~100 or higher
Accurate model for single constantcolor round light source
C = light*dot(N,H)^100 * base
Gamma Note: picking exponent
8/13/2019 Surface Material Physics for Shader Writers
14/68
Use in Games
Works for gold, copper, bronzesome anodized effects
Ideal for weapons
Gun metal blue
Not appropriate for enameled metal
More metallic than any metallic auto-
body enamelNor for oxidized e.g. verdigris
These are too rough for this model
8/13/2019 Surface Material Physics for Shader Writers
15/68
Rougher Surfaces
Smudges, scuffs, dust, oxides
At high magnification we see:
8/13/2019 Surface Material Physics for Shader Writers
16/68
Rough Surface
Reduced
Specular
Diffuse
Scattering
8/13/2019 Surface Material Physics for Shader Writers
17/68
Map-based Technique
Roughness varies per-pixel ingloss map e.g. alpha of base tex
Scale down environment map
c = gloss*envmap*base
Blur environment map in areas oflow gloss
MIP LOD or post-process effect
MIP LOD is per-pixel in ps.2.0
Blur is partial integral of map
8/13/2019 Surface Material Physics for Shader Writers
18/68
Procedural Technique
Use procedural specular
spec = light*dot(N,H)**25
but with same gloss term
c = gloss*spec*base
Decrease exponent to achieve blur
8/13/2019 Surface Material Physics for Shader Writers
19/68
Both Techniques
Add diffuse scattering term
8/13/2019 Surface Material Physics for Shader Writers
20/68
8/13/2019 Surface Material Physics for Shader Writers
21/68
Increased Roughness Surface
8/13/2019 Surface Material Physics for Shader Writers
22/68
Fully Rough Surface
8/13/2019 Surface Material Physics for Shader Writers
23/68
Fully Rough Surface
No Specular
Diffuse
Scattering
8/13/2019 Surface Material Physics for Shader Writers
24/68
Rough Surfaces
Concrete
Sand
ClothPlaster
Marble, non-polished
Pavement
Stone
8/13/2019 Surface Material Physics for Shader Writers
25/68
Moon Photograph
8/13/2019 Surface Material Physics for Shader Writers
26/68
Moon Rendering
8/13/2019 Surface Material Physics for Shader Writers
27/68
Rough Surfaces
Diffuse reflector
Lambertian or Oren-Nayar effects
8/13/2019 Surface Material Physics for Shader Writers
28/68
Map-based Technique
Blur map across very large scale
Integrate entire hemisphere
8/13/2019 Surface Material Physics for Shader Writers
29/68
Cube Map And Its Integral
8/13/2019 Surface Material Physics for Shader Writers
30/68
Diffuse only
8/13/2019 Surface Material Physics for Shader Writers
31/68
Procedural Technique
Model only Diffuse term
For directional light:
c = light * dot(N,L) * baseOr use hemisphere light
Gamma Note:Correct using sqrt or 1-(1-x)**2
for non-CAD applications
8/13/2019 Surface Material Physics for Shader Writers
32/68
Layered Surface
Varnish
Dye Layer
8/13/2019 Surface Material Physics for Shader Writers
33/68
Layered Surface Larger
Varnish
Dye Particles
8/13/2019 Surface Material Physics for Shader Writers
34/68
Layered Surface
Thin layer of smooth clear material
Over rough dye particles
Underlayer is rough becauseparticles may be suspended
Plastics
Linoleum
Enameled metalcar finish
Varnished surfacewood
8/13/2019 Surface Material Physics for Shader Writers
35/68
Map-Based Technique
Envt. map scaled by gloss term
spec = gloss*envmap
Added to diffuse term:c = dot(N,L)*base + spec
Base color does not tint highlight
Gamma Note: add should be linearCorrect to linear, add, convert back
if have enough precision and time
8/13/2019 Surface Material Physics for Shader Writers
36/68
Add Environment + Diffuse
8/13/2019 Surface Material Physics for Shader Writers
37/68
Specular Only
8/13/2019 Surface Material Physics for Shader Writers
38/68
Procedural Technique
Base color does not modulatespecular, only light color does
spec = light*dot(N,H)**100
c = dot(N,L)*base + spec*gloss
Top layer + bottom layer
8/13/2019 Surface Material Physics for Shader Writers
39/68
Summary
Polished specular*gloss*base
Rough diffuse*base
Varnished spec*gloss
+ diffuse*base
8/13/2019 Surface Material Physics for Shader Writers
40/68
Fresnel Effect
At top layer interface
Some light is reflected,
Remainder is transmitted through
Depends on surface material
And on incident angle!
Fresnel term fis proportionreflection
grazing angles: 100% reflected
normal angles: 5% reflected
8/13/2019 Surface Material Physics for Shader Writers
41/68
Fresnel Mid
Material
Air
60% reflected
40% transmitted
8/13/2019 Surface Material Physics for Shader Writers
42/68
Fresnel Normal
Material
Air
10% reflected
90% transmitted
8/13/2019 Surface Material Physics for Shader Writers
43/68
Fresnel Grazing
Material
Air
90% reflected
10% transmitted
8/13/2019 Surface Material Physics for Shader Writers
44/68
8/13/2019 Surface Material Physics for Shader Writers
45/68
Fresnel Term Approximation
Use f = 1 - cosq= (1 - E dot N)Raise to power for betterapproximation
f = (1cosq)4[Schlick] used 5thpower
Hack curve fit to Glassner
F l V t Sh d
8/13/2019 Surface Material Physics for Shader Writers
46/68
Fresnel Vertex Shader
m4x4 oPos,v0,c8; // xform pos. to output spacem4x4 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.xyzrsq 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 colormul 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
F l Pi l Sh d
8/13/2019 Surface Material Physics for Shader Writers
47/68
Fresnel Pixel Shader
ps.1.1
; def v0 // eye ray
def c0 // 5% biasdef c1 // 95% scaletex t0 // normal map
dp3 r0,v0_bx2,t0_bx2; // dot eye ray with normal
mul r1,1-r0,1-r0 // complement and squaremul r0,r1,r1 // **4mad r0,r0,c1,c0 // scale & bias
8/13/2019 Surface Material Physics for Shader Writers
48/68
Fresnel Comparison
45o 90o0o
1- cosq
Measurement(1- cosq 4
8/13/2019 Surface Material Physics for Shader Writers
49/68
Fresnel Term
8/13/2019 Surface Material Physics for Shader Writers
50/68
Fresnel Affects Diffuse Layer
Only light that was not reflectedilluminates diffuse dye layer
In single light case, incident anglecan be used to compute f
Then fis used to blend (lerp)between specular and diffuse
Not as useful for multi-light case
diffuse layer is illuminated by lightfrom all directions in that case
8/13/2019 Surface Material Physics for Shader Writers
51/68
Metallic Flake
Can used BEML with randomGaussian distribution ofperturbation pixels
Can use similar trick for glassbuildings
point sampled displacement map gives
each window a separate normalOr use filtering to get curved windows
then must mask seams with alphatest
8/13/2019 Surface Material Physics for Shader Writers
52/68
MicroFlake
Use procedural specular term withlow exponent ~8
Feasible with DirectX 8.* pixel shader
Still need enviroment map for carfinish enamel gloss coat
8/13/2019 Surface Material Physics for Shader Writers
53/68
Metallic Flake Finish
Varnish
Dye Layer
Flakes
8/13/2019 Surface Material Physics for Shader Writers
54/68
Sub-Surface Effects
Absorption
Light has to get inside
Re-emission
Light has to get out again
8/13/2019 Surface Material Physics for Shader Writers
55/68
Subsurface Absorption
Can be impacted by Fresnel effects
Only non-reflected light penetrates
Simple term to model
Can be impacted by structure ofsurface
8/13/2019 Surface Material Physics for Shader Writers
56/68
Skin
A layer of ketchup covered bytissue paper
Probably more translucent than realketchup
8/13/2019 Surface Material Physics for Shader Writers
57/68
Anisotropic Effects
Most visible in specular case
Brushed metal
Cloth fabricsWire spools
8/13/2019 Surface Material Physics for Shader Writers
58/68
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
8/13/2019 Surface Material Physics for Shader Writers
59/68
Key References
Nelson Max
Christophe Schlick
Peter Shirley
8/13/2019 Surface Material Physics for Shader Writers
60/68
Empiricism
Shading is not fully understood
Most efforts not based on purephysics
Equations are fit to measured data
Equations are chosen to look good
8/13/2019 Surface Material Physics for Shader Writers
61/68
Empirical Process
Discern an effect
Measure how it varies
Curve fit some equation to itTweak it until it looks good
8/13/2019 Surface Material Physics for Shader Writers
62/68
Empirical Process
Measure
Fit Eqn
Plot
Render
Evaluate
Tweak
8/13/2019 Surface Material Physics for Shader Writers
63/68
Nelson Max
Horizon mapping: shadows forbump-mapped surfaces
Basis of last years GDC talk on real-
time self-shadowing bump mapsAvailable as sample in DX8.1 SDK
Most work is applicable and
accessible
8/13/2019 Surface Material Physics for Shader Writers
64/68
Christophe Schlick
A Customizable Reflectance Modelfor Everyday Rendering
Uses his procedurally generated BRDF
Generic Lighting Model
Single shader for specular vs diffuse, andisotropic vs anisotropic surfaces
Reduces state changes?Requires 2.0 shaders
8/13/2019 Surface Material Physics for Shader Writers
65/68
Peter Shirley
Real-time Ray-tracing
Hemisphere lighting model
A Practitioners Assessment ofLight Reflection Models
Demonstrates process of identifyingan effect and defining a technique to
represent itIncludes good background material
8/13/2019 Surface Material Physics for Shader Writers
66/68
Books
Foley & Van Dam, Feiner, Hughes
Still lots of good background material
Fundamentals
Principles of Digital ImageSynthesis by Andrew Glassner
Broad sampling of topics
Excellent detail in key areas
Concordance for much of literature
8/13/2019 Surface Material Physics for Shader Writers
67/68
Miscellaneous
Graphics Gems
Game Programming Gems
Real-time Photorealistic RenderingEric Haines
8/13/2019 Surface Material Physics for Shader Writers
68/68
Call to Action
Pick a unique Look and do it
Toon several methods
Cheesy unlit or flat shadedRetro std FF pipelines
Radiosity soft lighting only
Shadows horror movieGritty ultra realistic
Uses photos for concept art