Real-time Shading with Filtered Importance Sampling
Download
Report
Transcript Real-time Shading with Filtered Importance Sampling
Real-time Shading with
Filtered Importance Sampling
Mark Colbert
University of Central Florida
Jaroslav Křivánek
Czech Technical University in Prague
Motivation
• Dynamic BRDF and lighting
• Applications
– Material design
– Gaming
• Production pipeline friendly
– Single GPU shader
– No precomputation
– Minimal code base
Real-time Shading with Filtered Importance Sampling
Demo
Our Approach
• BRDF proportional sampling
• Environment map filtering
Real-time Shading with Filtered Importance Sampling
Related Work
• A Unified Approach to
Prefiltered Environment Maps
[ Kautz et al. 2000 ]
• Efficient Rendering of Spatial Bi-directional
Reflectance Distribution Functions
[ McAllister et al. 2002 ]
• Efficient Reflectance and Visibility
Approximations for Environment Map Rendering
[ Green et al. 2007 ]
• Interactive Illumination with
Coherent Shadow Maps
[ Ritschel et al. 2007 ]
Real-time Shading with Filtered Importance Sampling
Illumination Integral
• Ignores visibility
[ Kozlowski and Kautz 2007 ]
• Computationally
expensive
Li
f
Incoming Radiance (Environment Map)
Material Function (BRDF)
Angle between normal and incoming direction
Real-time Shading with Filtered Importance Sampling
Importance Sampling
• Choose a few random samples
• Select according to the BRDF
Real-time Shading with Filtered Importance Sampling
Importance Sampling Result
Real-time Shading with Filtered Importance Sampling
40 samples per pixel
Random Numbers on the GPU
• Relatively expensive
– Random numbers per pixel (computation)
– Random number textures (memory/indirection)
• Quasi-random sequence
– Good sample distribution (no clumping)
– Use same sequence for each pixel
Real-time Shading with Filtered Importance Sampling
Same Sequence Result
Real-time Shading with Filtered Importance Sampling
40 samples per pixel
Filtered
Importance
Sampling
• Filter environment map
between samples over hemisphere
– Samples distributed by the BRDF
• Support approximately equivalent to:
Real-time Shading with Filtered Importance Sampling
N
Number of samples
p
Probability density function
Filtering
• Use MIP-maps
• Level proportional to
log of filter size
Real-time Shading with Filtered Importance Sampling
Implementation
• Auto-generated MIP-map
• Dual paraboloids
• Single GPU Shader
– Sum together filtered samples
Real-time Shading with Filtered Importance Sampling
Reference
Real-time Shading with Filtered Importance Sampling
No Filtering
Sphere – Grace Probe
Our Result
Stochastic
Results
Reference
Real-time Shading with Filtered Importance Sampling
No Filtering
Bunny – Ennis Probe
Our Result
Stochastic
Results
Approximations
• Constant BRDF across filter
• Isotropic filter shape
• Tri-linear filtering
Real-time Shading with Filtered Importance Sampling
RMS
Error
Phong Reflection - Ennis Light Probe
n=10
n=100
n=1000
Real-time Shading with Filtered Importance Sampling
Performance
512x512 Sphere
Real-time Shading with Filtered Importance Sampling
Conclusions
• Real-time glossy surface
reflections
• Signal Processing Theory
• Practical
• Affords new interfaces
• For more information:
GPU Gems 3
• Download the code now!
– graphics.cs.ucf.edu/gpusampling/
Real-time Shading with Filtered Importance Sampling
Questions
Additional Slides
Performance
Real-time Shading with Filtered Importance Sampling
Which distribution?
• Product of lighting and BRDF
– Requires bookkeeping
– Too expensive
• Lighting
• BRDF
Real-time Shading with Filtered Importance Sampling
Which distribution?
• Product of lighting and BRDF
• Lighting
– Too many samples for glossy surfaces
• BRDF
Real-time Shading with Filtered Importance Sampling
Which distribution?
• Product of lighting and BRDF
• Lighting
• BRDF
– Computationally efficient
Real-time Shading with Filtered Importance Sampling
Environment Mapping
• Dual Paraboloid
Error
Support Region
Real-time Shading with Filtered Importance Sampling
Environment Mapping
• Cube Maps
– Low distortion
– Accelerated by GPU
– Decimation/reconstruction
filters non-spherical
– Introduces Seams
Real-time Shading with Filtered Importance Sampling
Environment Mapping
• Latitude/Longitude
– Too much distortion at poles
Real-time Shading with Filtered Importance Sampling
Measured BRDF Data
• Fast primitive distribution for illustration
[ Secord et al. 2002 ]
• Efficient BRDF importance sampling using a
factored representation
[ Lawrence et al. 2004 ]
• Probability Trees
[ McCool and Harwood 1997 ]
Real-time Shading with Filtered Importance Sampling
Importance Sampling
Random Samples
on Unit Square
PDF-Proportional Samples
on Hemisphere
1
PDF Mapping
0
0
1
Real-time Shading with Filtered Importance Sampling
Pseudocode
float4 FilteredIS(float3 viewing : TEXCOORD1
uniform sampler2D env) : COLOR
{
float4 c = 0;
// sample loop
for (int k=0; k < N; k++) {
float2 xi = quasi_random_seq(k);
float3 u = sample_material(xi);
float pdf = p(u, viewing);
float lod = compute_lod(u, pdf);
float3 L = tex2Dlod(env,float4(u, lod));
c += L*f(u,viewing)/pdf;
}
return c/N;
}
Real-time Shading with Filtered Importance Sampling
Filter Support
• Ideal
• Isotropic approximation
– Assume sample points are perfectly stratified
– Implies area of 1 sample = 1 / N
– Use Jacobian approximation for warping
function (Inverted PDF)
– Support region of sample 1 / p(i, o) N
Real-time Shading with Filtered Importance Sampling
Ideal Sample Filter Design
Li ( ) f (k , o ) cos
S (k , o )
h(k ) d
p(k , o )
• h – Filter function
• More expensive than
illumination integral
Real-time Shading with Filtered Importance Sampling
Approximate Sample Filter
f (k , o ) cos k
S (k , o )
p(k , o )
Li ( ) h(k ) d
• Estimate for sample
• BRDF PDF
– PDF is normalized BRDF
– Near constant over single sample
• Low frequency cosine approximation
– Use multiple samples to estimate effect
Real-time Shading with Filtered Importance Sampling