april 4-7, 2016 | silicon valley implement physically ......april 4-7, 2016 | silicon valley detlef...

Post on 26-Apr-2021

2 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

April 4-7, 2016 | Silicon Valley

Detlef Röttger, 4/4/2016

Implement Physically Based Ray Tracing with OptiX and MDL

2

AGENDA

OptiX

Material Definition Language

MDL SDK

Shader Code Generation

Path Tracer Implementation

3

OptiX

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

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

6

OptiX Program Domains Developer controls the algorithm via CUDA C++ programs

RayGeneration

4/3/2016

Intersection

BoundingBox

ClosestHit

Miss

AnyHit

7

Material Definition Language

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 or procedural textures

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

4/3/2016

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

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)

11

MDL Basic Building Blocks Layers

weighted_layer fresnel_layer custom_curve_layer measured_curve_layer

12

MDL Basic Building Blocks Modifiers

tint thin_film directional_factor measured_curve_factor

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

14

MDL Basic Building Blocks Emission Distribution Functions (EDF)

diffuse_edf spot_edf

measured_edf (IES profiles)

mixer on edf_component[]

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()

16

Material Definition Language SDK

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

18

Shader Code Generation

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

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

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

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

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

24

Forward Path Tracer Implementation

25

Ray Generation

4/3/2016

Per Launch-Index Initialization

Lens Shader

Integrator

Accumulate Result

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!

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!

28 4/3/2016

29 4/3/2016

30

EDF examples Blackbody Radiation

1900 K 3000 K 5000 K 7000 K

31 4/3/2016

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

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

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

top related