Normal Mapping for Precomputed Radiance Transfer

Download Report

Transcript Normal Mapping for Precomputed Radiance Transfer

Normal Mapping for
Precomputed Radiance Transfer
Peter-Pike Sloan
Microsoft
Inspiration
• [McTaggart04] Half-Life 2 “Radiosity
Normal Mapping”
Related Work
• [Willmott99] Vector irradiance formulation
of radiosity (for accelerating computation)
• [Tabellion04] Lighting model similar to
above (dominant light direction)
• [Good2005] “Spherical Harmonic Light
Maps”
Goal
• Develop lightweight techniques to
decouple normal variation (ala HL2)
– From parameterized models of lighting (PRT)
– For rigid objects
• Non goals
– Modeling “local GI” of the bumps [Sig05]
– Masking effects
– Glossy materials
PRT
PRT
PRT
Bi-Scale Radiance Transfer
Global Lighting: l
Local Lighting: l'=M p l
meso
structure
Macro-Scale Radiance
Transfer by PRT
Meso-Scale Radiance
Transfer by RTT
Bi-Scale Radiance Transfer
e( p, v p )  b(q( x p ), v p ) (M p l)
• l : vector = source radiance spherical function
• Mp : 25x25 transfer matrix at point p (source → transferred incident)
• q(xp) : ID map (2D → 2D, maps RTT patch over surface)
• b(x,v) : RTT (4D → 25D, tabulated over small spatial patch)
applies macro-scale transferred radiance to meso-scale RTT
Bi-Scale Radiance Transfer
e( p, v p )  b(q( x p ), v p ) (M p l)
• l : vector = source radiance spherical function
• Mp : 25x25 transfer matrix at point p (source → transferred incident)
• q(xp) : ID map (2D → 2D, maps RTT patch over surface)
• b(x,v) : RTT (4D → 25D, tabulated over small spatial patch)
applies macro-scale transferred radiance to meso-scale RTT
Bi-Scale Radiance Transfer
e( p, v p )  b(q( x p ), v p ) (M p l)
• l : vector = source radiance spherical function
• Mp : 25x25 transfer matrix at point p (source → transferred incident)
• q(xp) : ID map (2D → 2D, maps RTT patch over surface)
• b(x,v) : RTT (4D → 25D, tabulated over small spatial patch)
applies macro-scale transferred radiance to meso-scale RTT
Limitations
• Expensive
– Stores 64 “response vectors” that are 9-36D
(x3 for spectral)
• Parallax mapping cheaper way of getting masking
– Local radiance is too much data (9 – 36 x 3)
for low res textures/per-vertex
• Add constraints
– Just model normal variation
– Diffuse only
Diffuse + Normal Maps
• Quadratic SH [Ramamoorthi2001]
e  n   y  n  CM p l
T
Distant Lighting Environment
Diffuse + Normal Maps
• Quadratic SH [Ramamoorthi2001]
e  n   y  n  CM p l
T
Distant Radiance to Transferred Incident Radiance
In local frame
Diffuse + Normal Maps
• Quadratic SH [Ramamoorthi2001]
e  n   y  n  CM p l
T
Diagonal Convolution Matrix
Clamped cosine kernel
Diffuse + Normal Maps
• Quadratic SH [Ramamoorthi2001]
e  n   y  n  CM p l
T
Irradiance Environment Map
Diffuse + Normal Maps
• Quadratic SH [Ramamoorthi2001]
e  n   y  n  l
T
Irradiance Environment Map
Diffuse + Normal Maps
• Quadratic SH [Ramamoorthi2001]
e  n   y  n  l
T
Evaluate SH basis with normal
Concerns
• Lot of data at low res
– 9xO2 matrices (x3 with color bleeding)
– Can compress using CPCA [Sig03]
• Too much data passed from low res to
high res
– Irradiance emap (27 numbers, 7 interpolators)
• Alternatives
– Project into analytic basis
– Separable approximation
Analytic Basis
e  n   b  n  BCM p l
T
Project into new basis (fewer rows)
Shifted Associated Legendre
Polynomials
[Gautron2005]
H
1
1

y z  z2
1 z
2
(2 z  1)
H 
2 
0
1
H 
1
1
x z  z2
1 z2
Half-Life 2 Basis
1 1 
 1
b0  
,
, 
2 3
 6
 1 1 1 
b1  
,
, 
 6 2 3
 2
1 
b2   , 0,

3
3


Comparison
PRT
Gold Standard
HL2
SAL
Comparison
PRT
Gold Standard
HL2
SAL
Normal Mapping for PRT
• Use same ideas as BRDF factorization
[Kautz and McCool1999]
e  n  b  n A l
b  n
A
Bi-linear basis functions over hemisphere (4 non-zero)
Matrix, rows “normal directions” columns quadratic
SH light Aij equals evaluating convolved light basis
function “j” in normal direction “i”
Normal Mapping for PRT
 A 00


 Ai 0


 A N 0
A 08 


Ai8 


A N 8 
Normal Mapping for PRT
• Compute SVD of A
A  USV
U
S
t
V
t
Nx9 matrix (each column is a “normal basis” texture)
9x9 diagonal matrix (singular values)
9x9 matrix
Normal Mapping for PRT
• Old equation
e  n   y  n  CM l
T
• New equation
e  n   U  n  SV CM l
T
Normal Mapping for PRT
• Use first M singular values
e  n   U  n  SV CM l
T
• MxO2 matrix
• M channel “normal direction” texture
Pixel Shader
StandardSVDPS( VS_OUT In, out float3 rgb : COLOR )
{
float2 Normal = tex2D(NormalSampler, In.TexCoord);
float2 vTex = Normal*0.5 + float2(0.5,0.5);
float4 vU = tex2D(USampler,vTex);
rgb.r = dot(In.cR,vU);
rgb.g = dot(In.cG,vU);
rgb.b = dot(In.cB,vU);
rgb *= tex2D(AlbedoSampler, In.TexCoord);
}
Comparison
Accuracy
1
0.9
0.8
Accuracy
0.7
0.6
No Convolution
0.5
With Convolution
0.4
0.3
0.2
0.1
0
1
2
3
4
5
6
# Singular Vectors
7
8
9
Demo
Conclusions
• Lightweight form of normal mapping for PRT
– Inspired by Half-Life 2
– For static objects, diffuse only
• HL2 basis and separable basis seem to be best
• Experiment with CPCA more [Sig03]
• Integrate with other techniques
– Parallax mapping for masking
– Ambient Occlusion for local effects
Acknowledgments
• Gary McTaggart for HL2 images
• Shanon Drone for Models
• Paul Debevec for Light Probes