Walter Course Sig 11 v 2

download Walter Course Sig 11 v 2

of 51

Transcript of Walter Course Sig 11 v 2

  • 7/29/2019 Walter Course Sig 11 v 2

    1/51

    Automatic Shader Bounding fEfficient Global Illumination

    Bruce WalterCornell University

    Course: Compiler Techniques for

    Thursday August 11, 20

  • 7/29/2019 Walter Course Sig 11 v 2

    2/51

    Credit Based on group project:

    Automatic Bounding of Programmable Shaders for EfficieGlobal Illumination, SIGGRAPH 2009 Edgar Velzquez-Armendriz

    Shuang Zhao

    Milo Haan

    Bruce Walter Kavita Bala

  • 7/29/2019 Walter Course Sig 11 v 2

    3/51

    Motivation

    Programmable shading Physically-based rend

    Artistic control, flexibility

    Manual lighting design

    The Pumpkin Factory 2008

    Limited material mod

    Global illumination

    Veach and

  • 7/29/2019 Walter Course Sig 11 v 2

    4/51

    About the Shaders

    surface matte(colorKd) {

    return Kd * max(dot(N,L),0);

    }

    Shader

    Simple RenderMan-like example language

    Material (surface) shader that implements a BRDFAllows arbitrary code within shader

    Extensible to new material models

  • 7/29/2019 Walter Course Sig 11 v 2

    5/51

    Challenge

    shade (point, light) color

    sample (point) direction and probability

    bound (points, lights) max color

    G.I. needs additional related functions

    surface matte(colorKd) {

    return Kd * max(dot(N,L),0);

    }

    Shader

  • 7/29/2019 Walter Course Sig 11 v 2

    6/51

    Contributions First step towards closing the gap

    InterfaceProvides the functions G.I. needsInterval arithmetic

    Automated compilerConverts the shaders to interval form

    DemonstrationPhoton mapping

    Multidimensional lightcuts

  • 7/29/2019 Walter Course Sig 11 v 2

    7/51

    Result PreviewPhoton mapping Multidimensional lightcu

    Procedural Textures

    Procedural varyingmaterial

    Environment map lightingIndirect Illumination

    Measured materiaPCA Reconstruc

    Procedural varyingnormal

  • 7/29/2019 Walter Course Sig 11 v 2

    8/51

    Outline Introduction

    Background and related work Interface between shaders and G.I.

    Compiler

    Results

    Conclusions and future work

  • 7/29/2019 Walter Course Sig 11 v 2

    9/51

    Related Work Production shaders

    Simplified G.I. [Tabellion and Lamorlette 2004]

    Automatic simplification [Pellacini 2005]

    GPU translation for relighting

    [Pellacini et al. 2005, Ragan-Kelley et al. 2007]

  • 7/29/2019 Walter Course Sig 11 v 2

    10/51

    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]

  • 7/29/2019 Walter Course Sig 11 v 2

    11/51

    Related Work Heidrich et al. 1998

    High quality rasterization of textures

    Hasselgren et al. 2009Subdivison surfaces pre-tessellation culling

    Compiler with type propagation

    Clarberg et al. 2010Performance optimization of interval code

    Our focus is on enabling global illumination

    , , ,

    . . . .

    . . . .

    . . . .

    . . . .

    . . . .

    . . . .

    . . . .

    . .

    :

    .

    ;

    .

    .

  • 7/29/2019 Walter Course Sig 11 v 2

    12/51

    Outline Introduction

    Background and related work Interface between shaders and G.I.

    Compiler

    Results

    Conclusions and future work

  • 7/29/2019 Walter Course Sig 11 v 2

    13/51

    Interface Functions needed

    shade (point, viewDir, lightDir)

    colorsample (point, viewDir) direction

    bound (points, viewDirs, lightDirs) max color

    Covers most Monte Carlo global illumination algorithneed versions for both eye and light tracing

    multiple importance sampling needs related prob f

  • 7/29/2019 Walter Course Sig 11 v 2

    14/51

    Interface Shade (point, viewDir, lightDir)

    Evaluate shading for single point and lightWritten by the user as shader program

    Sample (point, viewDir)

    Select outgoing direction with low noise

    Needed by virtually all Monte Carlo rendering algo Bound (points, viewDirs, lightDirs)

    Compute upper bound on shade for range of input

    Used to construct our sample function and by Ligh

  • 7/29/2019 Walter Course Sig 11 v 2

    15/51

    Importance Sampling

    Importance sampling needed for:

    Distribution Ray TracingPath tracing

    Bidirectional path tracing

    Metropolis

    Photon Mappingand many more

  • 7/29/2019 Walter Course Sig 11 v 2

    16/51

    Importance Sampling Generate directions with probability related to shade

    Minimize weights (f/p ratio) to reduce noise

  • 7/29/2019 Walter Course Sig 11 v 2

    17/51

    Importance Sampling Shader is an unknown function

  • 7/29/2019 Walter Course Sig 11 v 2

    18/51

    Importance Sampling Shader is an unknown function

    Construct piecewise-constant bounding function

  • 7/29/2019 Walter Course Sig 11 v 2

    19/51

    Importance Sampling Use bound to obtain piecewise values

    Subdivide regions for better approximation

  • 7/29/2019 Walter Course Sig 11 v 2

    20/51

    Importance Sampling Use bound to obtain piecewise values

    Subdivide regions for better approximation

  • 7/29/2019 Walter Course Sig 11 v 2

    21/51

    Guaranteed sampling quality

    f/p ratio

  • 7/29/2019 Walter Course Sig 11 v 2

    22/51

    Multidimensional Lightcuts Scalable rendering [Walter et al. 2006]

    Works on clusters of lights and shading points

    Uses bounding functions (S2 and S3)

    Bound direction (S2) Bound direction and location

    D i

  • 7/29/2019 Walter Course Sig 11 v 2

    23/51

    Design

    Compiler

    ImportSamp

    Runtime

    shade bound sam

    O tli

  • 7/29/2019 Walter Course Sig 11 v 2

    24/51

    Outline Introduction

    Background and related work

    Interface between shaders and G.I.

    Compiler

    Results

    Conclusions and future work

    I t l A ith ti R i

  • 7/29/2019 Walter Course Sig 11 v 2

    25/51

    Interval Arithmetic Review

    0 1 2 3 4 5 6 7

    0 1 2 3 4 5 6 7

    0 1 2 3 4 5 6 7

    1

    4

    5

    +

    =

    I t l A ith ti R i

  • 7/29/2019 Walter Course Sig 11 v 2

    26/51

    Interval Arithmetic Review

    0 1 2 3 4 5 6 7

    0 1 2 3 4 5 6 7

    0 1 2 3 4 5 6 7

    [0,2]

    [3,6]

    [3,8]

    +

    =

    I t l A ith ti

  • 7/29/2019 Walter Course Sig 11 v 2

    27/51

    Interval Arithmetic Define interval versions of basic operations

    +, -, *, /, sqrt, pow, etc.

    Composable for compound operationsSuch as f(x) = sqrt(x*x - x)

    Replace each basic operation with interval version

    I t l A ith ti

  • 7/29/2019 Walter Course Sig 11 v 2

    28/51

    Interval Arithmetic Simple and general

    Simple conversion even for complex functions

    Cost typically 2-4x more than original non-interval version

    Result intervals are often larger than necesaryIntervals are conservative

    always contain all possible outputs but may also include other vDoes not track correlation among values

    Interval for x*x can contain negative values

    Worse with large starting intervals Subdividing initial intervals can help

    I t l A ith ti

  • 7/29/2019 Walter Course Sig 11 v 2

    29/51

    Interval Arithmetic Higher order variants can track value correlation

    Affine and Taylor Interval Methods

    Tighter result intervals

    More expensive to compute

    Not cost effective in our testsYour milage may vary

    Lifting the Shaders

  • 7/29/2019 Walter Course Sig 11 v 2

    30/51

    Lifting the Shaderssurface matte(colorKd) {

    return Kd * max(dot(N,L),0);

    }

    Kd

    N

    L

    dot(N,L)

    max(dot(N,L),0)

    Kd*max()

    vector3

    vector3

    vector3

    real

    real

    vector3

    shade

    vector3

    vector3

    interval3

    interval

    interval

    interval3

    bound s2

    interva

    interva

    interva

    interva

    interva

    interva

    bound

    Static Single Assignment For

  • 7/29/2019 Walter Course Sig 11 v 2

    31/51

    Static Single Assignment For

    Standard compiler technique

    [Cytron et al. 1991] Simplifies analysis and control flow

    y = 1.0;y = 2.0;

    x = y;x = x + 1.0;

    y1 = 1.0;y2 = 2.0;

    x1 = y2;x2 = x1 + 1.0;

    Convert to SSA

    Translating Branches

  • 7/29/2019 Walter Course Sig 11 v 2

    32/51

    Translating Branches

    if(x > 0.0)

    y = 0.0;elsey = 1.0;

    return y;

    y1 = 0.0;y2 = 1.0;y3 = Psi(Greater(x,0.0), y1, y2);return y3;

    ? -1 0 1x =

    -1 0 1y =

    Translating Branches

  • 7/29/2019 Walter Course Sig 11 v 2

    33/51

    Translating Branchesy = 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);

    -1 0 1x =

    -1 0 1y =

    -1 0 1z =

    Using the Interface

  • 7/29/2019 Walter Course Sig 11 v 2

    34/51

    Using the Interface

    Photon Mapp

    MultidimensioLightcuts

    Compiler

    Runtime API

    shader

    Outline

  • 7/29/2019 Walter Course Sig 11 v 2

    35/51

    Outline Introduction

    Background and related work

    Interface between shaders and G.I.

    Compiler

    Results

    Conclusions and future work

    Results

  • 7/29/2019 Walter Course Sig 11 v 2

    36/51

    Results Highlight complex shading

    SystemMostly unoptimized Java implementation

    Dual quad-core Xeon E5440 2.83 GHz, 16 GB RAM

    Sun Java 1.6.0-11 64 bit

    Bounds Comparison

  • 7/29/2019 Walter Course Sig 11 v 2

    37/51

    Bounds Comparison Compare our bounds with hand-crafted

    ones

    Use multidimensional lightcuts asreferenceAnalytic materials

    Depth of field

    Antialiasing

    Environment map lighting[Walter et a

    Bounds Comparison

  • 7/29/2019 Walter Course Sig 11 v 2

    38/51

    Bounds Comparison

    Our automatic bounds Hand-crafted bounds

    Time: 459 s Time: 176 s

    640x480 images, 256 eye rays per pixel, 55,000 lights

    Importance Sampling

  • 7/29/2019 Walter Course Sig 11 v 2

    39/51

    Importance Sampling

    Automatic Importance sampling Cosine-weighted (equal tim

    Time: 1,830 s Time: 2,031 s

    Importance Sampling

  • 7/29/2019 Walter Course Sig 11 v 2

    40/51

    Importance Sampling

    Cosine-weighted (3x time)

    Time: 6,134 s

    Automatic Importance sampling

    Time: 1,830 s

    Results Big Buck Bunny

  • 7/29/2019 Walter Course Sig 11 v 2

    41/51

    Results Big Buck Bunny bershader

    32 eye rays per pixel55,000 lights

    10+ M triangles

    Time: 648 sSize: 852x480

    Time: 516 sSize: 512x5

    Results Big Buck Bunny

  • 7/29/2019 Walter Course Sig 11 v 2

    42/51

    Results Big Buck Bunny bershader Blender materials

    Multiple branches 86 lines of code

    Kajiya-Kay hair shader

    Environment map andsun lighting

    32 eye rays per pixel55,000 lights

    10+ M triangles

    Time: 648 sSize: 852x480

    Time: 516 sSize: 512x5

    Results Elephants Dream

  • 7/29/2019 Walter Course Sig 11 v 2

    43/51

    Results Elephants Dream

    bershaderFully automated G.I.Multidimensional lightcuts

    852x432 eye rays

    55,

    Results Pillow

  • 7/29/2019 Walter Course Sig 11 v 2

    44/51

    Results Pillow Measured material shader

    PCA Decompression

    83 data textures 243 lines of code

    Time: 2,413 s

    Results Pillow

  • 7/29/2019 Walter Course Sig 11 v 2

    45/51

    Results Pillow

    Lightcuts vs Brute Force

  • 7/29/2019 Walter Course Sig 11 v 2

    46/51

    Lightcuts vs Brute Force

    Scene Time Speed-up

    Tableau 459.2 s 601 x

    Big Buck Bunny 647.6 s 311 x

    Chinchilla 516.3 s 282 x

    Elephants Dream 464.0 s 834 x

    Pillow 2,412.5 s 8 x

    Conclusions

  • 7/29/2019 Walter Course Sig 11 v 2

    47/51

    Conclusions First step to automatically combine

    programmable shading and physically

    based rendering

    Compiler generates interval versions ofshaders

    Prototype enables multiple Monte Carloglobal illumination algorithms

    Limitations and Future Work

  • 7/29/2019 Walter Course Sig 11 v 2

    48/51

    Limitations and Future Work Expensive importance function creation

    Use known good sampling when possible

    Improve tightness of the bounds

    Higher level primitives in language

    Generalize shading language

    Arbitrary loops

    Port to other languages, OpenSL?

    Support other types of shadersLight, displacement, etc.

    Acknowledgements

  • 7/29/2019 Walter Course Sig 11 v 2

    49/51

    Acknowledgements NSF

    CAREER 0644175, CPA 0811680, CNS 0403340

    Intel Microsoft

    CONACYT-Mexico 228785

    NVIDIA

    Autodesk

    The End

  • 7/29/2019 Walter Course Sig 11 v 2

    50/51

  • 7/29/2019 Walter Course Sig 11 v 2

    51/51