Implement Physically Based Ray Tracing with OptiX and MDL Detlef - - PowerPoint PPT Presentation

implement physically based ray
SMART_READER_LITE
LIVE PREVIEW

Implement Physically Based Ray Tracing with OptiX and MDL Detlef - - PowerPoint PPT Presentation

April 4-7, 2016 | Silicon Valley Implement Physically Based Ray Tracing with OptiX and MDL Detlef Rttger, 4/4/2016 OptiX Material Definition Language AGENDA MDL SDK Shader Code Generation Path Tracer Implementation 2 OptiX 3 NVIDIA


slide-1
SLIDE 1

April 4-7, 2016 | Silicon Valley

Detlef Röttger, 4/4/2016

Implement Physically Based Ray Tracing with OptiX and MDL

slide-2
SLIDE 2

2

AGENDA

OptiX Material Definition Language MDL SDK Shader Code Generation Path Tracer Implementation

slide-3
SLIDE 3

3

OptiX

slide-4
SLIDE 4

4

NVIDIA OptiX SDK

GPU ray tracing „to the algorithm“

OptiX is a ray casting engine, not a renderer C-API to setup scene graph and data on host CUDA C++ to implement ray tracing algorithms on device OptiX does the heavy lifting!

Acceleration Structures, Recursions, GPU resource management Multi-GPU and NVIDIA VCA support

Get it here: https://developer.nvidia.com/designworks

4/3/2016

slide-5
SLIDE 5

5

OptiX Scene Hierarchy

Use the OptiX C-API to create and connect scene data

4/3/2016

GeometryGroup GeometryInstance Geometry Material Acceleration

Instancing with Transforms Sharing Geometry and Acceleration Structures

Group Transform Transform Acceleration

slide-6
SLIDE 6

6

OptiX Program Domains

Developer controls the algorithm via CUDA C++ programs

RayGeneration

4/3/2016

Intersection BoundingBox ClosestHit Miss AnyHit

slide-7
SLIDE 7

7

Material Definition Language

slide-8
SLIDE 8

8

Material Definition Language

A domain-specific language for abstract declarative material description Independent of a specific rendering system Procedural programming language to customize texture image lookups

  • r procedural textures

MDL Handbook and Specifications: http://www.mdlhandbook.com More Information: https://developer.nvidia.com/designworks

4/3/2016

slide-9
SLIDE 9

9

MDL Code Example

mdl 1.2; import df::*; export material my_diffuse( uniform float par_roughness = 0.0, uniform color par_color = color(0.5) ) = material( surface: material_surface( scattering: df::diffuse_reflection_bsdf( roughness: par_roughness, tint: par_color ) ) );

Name Parameters Definition Version and Imports

slide-10
SLIDE 10

10

MDL Basic Building Blocks

Bidirectional Scattering Distribution Functions (BSDF)

diffuse reflection diffuse transmission specular(reflect) specular(transmit) specular(reflect_transmit) measured glossy backscattering glossy(reflect) glossy(transmit) glossy(reflect_transmit)

slide-11
SLIDE 11

11

MDL Basic Building Blocks

Layers

weighted_layer fresnel_layer custom_curve_layer measured_curve_layer

slide-12
SLIDE 12

12

MDL Basic Building Blocks

Modifiers

tint thin_film directional_factor measured_curve_factor

slide-13
SLIDE 13

13

MDL Basic Building Blocks

Mixers

normalized_mix clamped_mix

0.25/0.25 0.5/0.5 0.75/0.75 1.0/1.0

slide-14
SLIDE 14

14

MDL Basic Building Blocks

Emission Distribution Functions (EDF)

diffuse_edf spot_edf measured_edf (IES profiles) mixer on edf_component[]

slide-15
SLIDE 15

15

MDL Basic Building Blocks

Volume Distribution Functions (VDF)

anisotropic_vdf

0.0 1.0 0.75 0.5

  • 1.0
  • 0.75
  • 0.5

Henyey-Greenstein phase function vdf()

slide-16
SLIDE 16

16

Material Definition Language SDK

slide-17
SLIDE 17

17

MDL SDK

Compiler and API

Compile materials into internal data structures (Directed Acyclic Graph, DAG) Different compilation methods

instance compilation, class compilation

Optimizations

Inlining, dead code elimination, complete evaluation of uniform sub-graphs

Easy to inspect view on the material definition, full traversal of the DAG Code generation backends for use on GPU or CPU (LLVM, PTX, GLSL) More information: https://developer.nvidia.com/designworks

4/3/2016

slide-18
SLIDE 18

18

Shader Code Generation

slide-19
SLIDE 19

19

Shader Code Generation

4/3/2016

<name>.mdl MDL SDK Compiled Material Builder Class DAG Nodes Texture References Parameter Interface Parameter Macros Header Traverser Code Getter Classes Hierarchy Typedefs Material Constructor Description <name>.txt Traverser <hash>.cu

Using the MDL SDK

slide-20
SLIDE 20

20

Parameter Macros and Getter Classes

4/3/2016

#define par_color_macro (make_float3(sys_Parameters[index].u.f4[0])) #define par_roughness_macro (sys_Parameters[index].u.f1[3]) class DiffuseReflectionGetter_1 // df::diffuse_reflection_bsdf { public: RT_FUNCTION float3 getTint(State const& state, const int index) const { return par_color_macro; } RT_FUNCTION float getRoughness(State const& state, const int index) const { return par_roughness_macro; } };

Connecting variable expressions with hardcoded building blocks

slide-21
SLIDE 21

21

Material Hierarchy as Typedefs

typedef bsdf_diffuse_reflection< DiffuseReflectionGetter_1 > DiffuseReflection_6; typedef material_emission< edf, EmissionGetter_2 > Emission_7; typedef material_surface< DiffuseReflection_6, Emission_7 > Surface_8; typedef material_emission< edf, EmissionGetter_3 > Emission_9; typedef material_surface< bsdf, Emission_9 > Surface_10; typedef material_volume< vdf, VolumeGetter_4 > Volume_11; typedef material_geometry< GeometryGetter_5 > Geometry_12; typedef material< Surface_8, Surface_10, Volume_11, Geometry_12, MaterialGetter_0 > Material_13;

Match MDL material structure with C++ class implementation

slide-22
SLIDE 22

22

Material Hierarchy Traversal Function

RT_CALLABLE_PROGRAM void traverser(State, Traversal, PerRayData, modifier, probability, normal) { const Material_13 theMaterial = Material_13( Surface_8( DiffuseReflection_6(), Emission_7( edf() ) ), Surface_10( bsdf(), Emission_9( edf() ) ), Volume_11( vdf() ), Geometry_12() ); theMaterial.traverse(state, traversal, prd, modifier, probability, normal); }

Single function to evaluate material hierarchy and parameters

slide-23
SLIDE 23

23

Material Hierarchy Traversal

Traversal and Data Storage (layered example)

4/3/2016

weighted layer material glossy bsdf diffuse reflection bsdf material surface

base layer theMaterial.traverse()

Traversal.nodes[] data array

(Inner nodes‘ data stored at end, BSDF and EDF node data stored at begin)

...

dfIndex dataIndex

slide-24
SLIDE 24

24

Forward Path Tracer Implementation

slide-25
SLIDE 25

25

Ray Generation

4/3/2016

Per Launch-Index Initialization Lens Shader Integrator Accumulate Result

slide-26
SLIDE 26

26

Closest Hit Program

4/3/2016

State Calculation, Traversal Setup Material Hierachy Traversal (for parameters, emission, estimation, calculation) BSDF Sampling Inlined Code Bound Callable Program (per material shader, called multiple times) Bindless Callable Programs (per BSDF) Bindless Callable Programs (per light type) Bindless Callable Programs (per diffuse BSDF) Light Sampling BSDF Evaluation Diffuse Reflection BSDF?

A single program for all materials!

slide-27
SLIDE 27

27

Any Hit Program

4/3/2016

State Calculation, Traversal Setup Material Hierachy Traversal (for cutout opacity value only) Inlined Code Bound Callable Program (per material shader) Stochastic Transparency if (opacity < RNG) ignore intersection;

A single program only present for cutout opacity materials!

slide-28
SLIDE 28

28 4/3/2016

slide-29
SLIDE 29

29 4/3/2016

slide-30
SLIDE 30

30

EDF examples

Blackbody Radiation

1900 K 3000 K 5000 K 7000 K

slide-31
SLIDE 31

31 4/3/2016

slide-32
SLIDE 32

32

Future Development

„Cameras? Lights? Shading!“

Add MDL 1.3 BSDFs Runtime compilation of generated code Use MDL SDK PTX backend for code generation measured_bsdf sampling measured_edf evaluation Different camera implementations

4/3/2016

slide-33
SLIDE 33

33

Summary

Takeaways from this Presentation

Overview of the MDL material features and capabilities Example how to use the MDL SDK to convert MDL materials to a custom renderer Implementing an MDL-capable global illumination renderer with OptiX

Single ClosestHit and AnyHit programs configured by callable programs Easy to extend with more distribution functions

4/3/2016

slide-34
SLIDE 34

April 4-7, 2016 | Silicon Valley

THANK YOU

JOIN THE NVIDIA DEVELOPER PROGRAM AT developer.nvidia.com/join droettger@nvidia.com Hangout session H6140: OptiX, Physically Based Ray Tracing, and the Material Definition Language Wednesday, April 6th at 4:00 pm in Pod C