Professional Documents
Culture Documents
Bruce Walter
Cornell University
Credit
Based on group project:
Automatic Bounding of Programmable Shaders for Efficient Global Illumination, SIGGRAPH 2009
Edgar Velzquez-Armendriz Shuang Zhao Milo Haan Bruce Walter Kavita Bala
2
2
Motivation
Programmable shading Physically-based rendering
Challenge
Shader
?
5
Contributions
First step towards closing the gap Interface
Provides the functions G.I. needs Interval arithmetic
Automated compiler
Converts the shaders to interval form
Demonstration
Photon mapping Multidimensional lightcuts
Result Preview
Photon mapping
Indirect Illumination
Multidimensional lightcuts
Environment map lighting
Procedural varying material Procedural varying normal Measured material with PCA Reconstruction Procedural Textures
Outline
Introduction Background and related work Interface between shaders and G.I. Compiler Results Conclusions and future work
Related Work
Production shaders
Simplified G.I.
[Tabellion and Lamorlette 2004]
Automatic simplification
[Pellacini 2005]
Related Work
Interval methods
Ray Tracing
[Synder 1992, Bala et al. 1999, Heidrich and Seidel 1998]
Tesselation
[Moule and McCool 2002]
Culling
[Hasselgren and Akenine-Mller 2007, Hasselgren et al. 2009]
Affine Arithmetic
[Comba and Stolfi 1993]
10
Related Work
Heidrich et al. 1998
High quality rasterization of textures
!"#$
s(x, i ) before after 3.4 2.8 2.2 2.1 3.4 2.4 3.5 2.5 2.8 2.3 4.2 2.8 3.2 2.5
s( , i ) x before after 6.7 4.9 4.8 4.0 4.9 3.2 5.4 3.7 3.8 3.0 4.6 3.1 5.0 3.7
Steiner
Mitchell
Kummer
Table 2: Instruction count compared to the original shaders using SSE for double-sided bounding shaders, before and after optimization. A prime application is importance sampling. The number of instructions is reduced by on average 23.8% and 27.1%, respectively. All numbers exclude the overhead of NaN propagation.
Figure 4: Examples of implicit surfaces evaluated using interval arithmetic to nd the rst intersection along each ray. code specialized for single-sided intervals, only saves on average 5%. With our optimizations, the savings are 27%. For Fractal, the difference is smaller due to control ow making it harder to eliminate long computations chains, but there is still plenty of optimization potential locally.
To measure the performance of optimized bounding code on the GPU, we have implemented a simple ray tracer for im-
11
Outline
Introduction Background and related work Interface between shaders and G.I. Compiler Results Conclusions and future work
12
Interface
Functions needed shade (point, viewDir, lightDir) color sample (point, viewDir) direction bound (points, viewDirs, lightDirs) max color Covers most Monte Carlo global illumination algorithms need versions for both eye and light tracing multiple importance sampling needs related prob function
13
Interface
Shade (point, viewDir, lightDir) Evaluate shading for single point and light Written by the user as shader program Sample (point, viewDir) Select outgoing direction with low noise Needed by virtually all Monte Carlo rendering algorithms Bound (points, viewDirs, lightDirs) Compute upper bound on shade for range of input Used to construct our sample function and by Lightcuts
14
Importance Sampling
Importance sampling needed for: Distribution Ray Tracing Path tracing Bidirectional path tracing Metropolis Photon Mapping and many more
15
Importance Sampling
Generate directions with probability related to shade Minimize weights (f/p ratio) to reduce noise
16
Importance Sampling
Shader is an unknown function
17
Importance Sampling
Shader is an unknown function Construct piecewise-constant bounding function
18
Importance Sampling
Use bound to obtain piecewise values Subdivide regions for better approximation
19
Importance Sampling
Use bound to obtain piecewise values Subdivide regions for better approximation
20
Importance Sampling
Guaranteed sampling quality f/p ratio <= volume of bounding function Stored as a cubemap over directions
-Z -X
-Y +Y
+Z +X
21
Multidimensional Lightcuts
Scalable rendering [Walter et al. 2006] Works on clusters of lights and shading points Uses bounding functions (S2 and S3)
Design
Importance Sampling Compiler shade bound Runtime sample
23
Outline
Introduction Background and related work Interface between shaders and G.I. Compiler Results Conclusions and future work
24
=
5
0 1 2 3 4 5 6 7 8
25
=
[3,8]
0 1 2 3 4 5 6 7 8
26
Interval Arithmetic
Define interval versions of basic operations
+, -, *, /, sqrt, pow, etc.
27
27
Interval Arithmetic
Simple and general
Simple conversion even for complex functions Cost typically 2-4x more than original non-interval version
Interval Arithmetic
Higher order variants can track value correlation
Affine and Taylor Interval Methods Tighter result intervals More expensive to compute
29
29
31
Translating Branches
if (x > 0.0) y = 0.0; else y = 1.0; return y;
x= y=
-1
-1
32
Translating Branches
y = z = 0.0; if (x > 0.0) y = 1.0; else z = 1.0; y1 = 0.0; y2 = 1.0; z1 = 0.0; z2 = 1.0; y3 = Psi(Greater(x,0.0), y2, y1); z3 = Psi(Greater(x,0.0), z1, z2);
x= y= z=
-1
-1
-1
33
shader
Photon Mapping
Compiler
Sample
Bound
Multidimensional Lightcuts
Runtime
API
34
Outline
Introduction Background and related work Interface between shaders and G.I. Compiler Results Conclusions and future work
35
Results
Highlight complex shading System
Mostly unoptimized Java implementation Dual quad-core Xeon E5440 2.83 GHz, 16 GB RAM Sun Java 1.6.0-11 64 bit
36
Bounds Comparison
Compare our bounds with hand-crafted ones Use multidimensional lightcuts as reference
Analytic materials Depth of field Antialiasing Environment map lighting
[Walter et al. 2006]
37
Bounds Comparison
Our automatic bounds Hand-crafted bounds
10,000 8,000 6,000 4,000 2,000 0
Time: 459 s
Time: 176 s
Importance Sampling
Automatic Importance sampling Cosine-weighted (equal time)
Time: 1,830 s
Time: 2,031 s
39
Importance Sampling
Automatic Importance sampling Cosine-weighted (3x time)
Time: 1,830 s
Time: 6,134 s
40
Time: 516 s Size: 512x512 32 eye rays per pixel 55,000 lights 10+ M triangles
41
Time: 516 s Size: 512x512 32 eye rays per pixel 55,000 lights 10+ M triangles
42
Results Pillow
Measured material shader
PCA Decompression 83 data textures 243 lines of code
Time: 2,413 s
Results Pillow
45
46
Conclusions
First step to automatically combine programmable shading and physically based rendering Compiler generates interval versions of shaders Prototype enables multiple Monte Carlo global illumination algorithms
47
Acknowledgements
NSF
CAREER 0644175, CPA 0811680, CNS 0403340
49
The End
50
51