BUILDING OPTIX SHADERS FROM MDL MATERIALS Detlef Rttger, NVIDIA - - PowerPoint PPT Presentation

building optix shaders from
SMART_READER_LITE
LIVE PREVIEW

BUILDING OPTIX SHADERS FROM MDL MATERIALS Detlef Rttger, NVIDIA - - PowerPoint PPT Presentation

May 8-11, 2017 | Silicon Valley S7185 LEVERAGING NVRTC FOR BUILDING OPTIX SHADERS FROM MDL MATERIALS Detlef Rttger, NVIDIA Andreas Mank, ESI Group 2017-05-08 www.esi-group.com VISUALIZE REAL-WORLD LIGHTS AND MATERIALS 2 Introduction


slide-1
SLIDE 1

May 8-11, 2017 | Silicon Valley www.esi-group.com

Detlef Röttger, NVIDIA Andreas Mank, ESI Group 2017-05-08

LEVERAGING NVRTC FOR BUILDING OPTIX SHADERS FROM MDL MATERIALS

S7185

slide-2
SLIDE 2

2

VISUALIZE REAL-WORLD LIGHTS AND MATERIALS

slide-3
SLIDE 3

3

Introduction Evolution of the Renderer Architecture Introduction to NVRTC Shader Generation from MDL Materials Integration into ESI IC.IDO Live Demonstration

AGENDA

slide-4
SLIDE 4

4

INTRODUCTION

slide-5
SLIDE 5

5

slide-6
SLIDE 6

6

slide-7
SLIDE 7

7

MOTIVATION

Scene exchange among applications often loses material information Use the NVIDIA Material Definition Language (MDL) to exchange materials Take advantage of existing MDL material libraries Create new MDL materials with available third-party tools Renderer goal: Handle MDL materials at runtime on end-user target system

slide-8
SLIDE 8

8

MDL

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

NVIDIA Material Definition Language

slide-9
SLIDE 9

9

OPTIX

High-level GPU accelerated ray-casting API C-API to setup scene and data Multiple program domains and per ray payload under developer‘s control Flexible single ray programming model Supports multi-GPU and progressive rendering

  • n remote NVIDIA VCA cluster

Develop "to the algorithm"

NVIDIA GPU Ray Casting API

volume scattering and dispersion hair intersection and shading

slide-10
SLIDE 10

10

EVOLUTION OF THE RENDERER ARCHITECTURE

slide-11
SLIDE 11

11

RENDERER IMPLEMENTATION

Goal: Handle MDL Materials at Runtime

Represent complex layered material hierarchies as CUDA C++ code

Templated classes for layered material construction from "fixed-function" building blocks (BSDFs, EDFs, VDFs, Layers, Mixers, Modifiers, Conditionals)

Connect user defined parameter calculations with building blocks

Derive from generated "getter" classes which fill building block input parameters. All functions inlined into material hierarchy traverser function.

Generate high-level CUDA C++ code

Easy prototyping and debugging before writing the code generator. Benefit from all optimizations inside the CUDA compiler.

slide-12
SLIDE 12

12

ray_gen lens shader integrator

  • utput

any_hit material traverser cutout opacity? closest_hit material traverser eval EDF sample BSDF eval BSDF sample light direct lighting? bounding_box intersection

edf edf_diffuse edf_spot edf_measured light_constant light_env light_mesh bsdf backscattering diffuse_reflection diffuse_transmission glossy measured specular beckmann_smith beckmann_vcavities ggx_smith ggx_vcavities ward_geisler_moroder

pinhole thin_lens fisheye sphere

miss_null miss_constant miss_env

* rectangles are fixed-function code * round rectangles are bindless callable programs

slide-13
SLIDE 13

13

INTRODUCTION TO NVRTC

slide-14
SLIDE 14

14

NVRTC vs. NVCC

CUDA Compilation

NVRTC standalone library

Translates CUDA C++ source to PTX device code End-users do not need a full development environment (e.g. MSVS) Three times faster compile times compared to NVCC

NVCC CUDA Compiler

Supports host and device code Works in combination with a host compiler of a full development environment

slide-15
SLIDE 15

15

NVRTC

Advantages of Runtime Compilation

OptiX shaders can be compiled on-demand

Applications do not have to provide a large number of individual shaders upfront Materials can be created and changed at runtime

Specialized shaders improve performance

No large „uber-shaders“ necessary Shader code can be kept compact

slide-16
SLIDE 16

16

NVRTC API

CUDA C++ Runtime Compilation to PTX

nvrtcProgram prog; nvrtcCreateProgram(&prog, src, NULL, 0, NULL, NULL); nvrtcCompileProgram(prog, numOptions, options); nvrtcGetProgramLogSize(prog, &logSize); if (1 < logSize) { nvrtcGetProgramLog(prog, log); } nvrtcGetPTXSize(prog, &ptxSize); if (1 < ptxSize) { nvrtcGetPTX(prog, ptx); } nvrtcDestroyProgram(&prog);

Input CUDA C++ code Compiler options Potential error log Output PTX code

slide-17
SLIDE 17

17

NVRTC

Compilation Options

const std::string cudaIncludes = std::string("-I") + m_cudaIncludePath; const std::string optixIncludes = std::string("-I") + m_optixIncludePath; const std::string rendererIncludes = std::string("-I") + m_rendererIncludePath; const char* options[] = { "--gpu-architecture=compute_30", "--use_fast_math", "--device-as-default-execution-space", "--relocatable-device-code=true", "-D__x86_64", cudaIncludes.c_str(),

  • ptixIncludes.c_str(),

rendererIncludes.c_str() };

slide-18
SLIDE 18

18

SHADER GENERATION FROM MDL MATERIALS

slide-19
SLIDE 19

19

OPTIX SHADER GENERATION

Using the MDL SDK and NVRTC

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

slide-20
SLIDE 20

20

INTEGRATION INTO ESI IC.IDO

slide-21
SLIDE 21

21

“ESI Rendering Innovations with NVIDIA DesignWorks™”

Andreas Mank, Team Leader Visualization, ESI Group Markus Tavenrath, Senior Developer Technology Engineer , NVIDIA — Source: GTC 2016, s6306

“MDL Materials to GLSL Shaders – Theory and Practice”

Andreas Süßenbach , Senior Developer Technology Engineer , NVIDIA Andreas Mank, Team Leader Visualization, ESI Group — Source: GTC 2016, s6311

“Implementing MDL Materials with Support for IES Lights

and AxF Appearance Representations”

Detlef Roettger, Senior Developer Technology Engineer, NVIDIA Andreas Dietrich, Senior Software Developer Visualization, ESI Group — Source: GTCEU 2016, s6135

slide-22
SLIDE 22

22

Helios Rendering Architecture

Overview

IC.IDO RiXGL Back-End (DLL)

. . .

OptiX Back-End (DLL) Helios Application Renderer

slide-23
SLIDE 23

23

Helios Rendering Architecture

Interfaces

Application API

Load and unload rendering back-ends (DLLs can be loaded at run-time) Switch between back-ends (e.g., ray tracing or rasterization based) Render graph control (e.g., hybrid rendering, frame composition) Provide original (unoptimized) scene data

Back-end API

Set scene geometry and transformations (flattened two-level scene graph) Set rendering parameters (e.g., materials, lights, whitted ray tracing or GI)

Helios Back-End

slide-24
SLIDE 24

24

Helios OptiX Back-End

OptiX Back-End Helios OptiX MDL SDK NVRTC MDL Parser

  • Reads MDL files
  • Generates material parameter lists

OptiX Builder

  • Generates material traversers (CUDA C++)
  • Compiles bindless callable programs
slide-25
SLIDE 25

25

MDL IN CUSTOM RENDERERS

4/28/2017

28.04.2017

MATERIAL TWEAKING MATERIAL CONSTRUCTION

MATERIAL SHARING (LIBRARY)

NVIDIA IRAY

DEFINITION

MDL SDK

IMPLEMENTATION

CUDA (Ray Tracer)

slide-26
SLIDE 26

26

LIVE DEMONSTRATION

slide-27
SLIDE 27

27

START SD6

slide-28
SLIDE 28

28

CREATE A NEW MDL MATERIAL

1.

slide-29
SLIDE 29

29

SET MDL MATERIAL PROPERTIES

1. 2. 3.

slide-30
SLIDE 30

30

LOAD MESH

1. 2. 3.

slide-31
SLIDE 31

31

ACTIVE MESH

1.

slide-32
SLIDE 32

32

ASSIGN NEW MATERIAL

1.

slide-33
SLIDE 33

33

LOAD ADDITIONAL MATERIALS

1.

slide-34
SLIDE 34

34

SHOW ENVIRONMENT

2. 1. 3.

slide-35
SLIDE 35

35

EXPORT MDL MATERIAL

1. 2. 3.

slide-36
SLIDE 36

36

MDL FILE

1. 2.

slide-37
SLIDE 37

37

START ICIDO PROOF-OF-CONCEPT

slide-38
SLIDE 38

38

1.

slide-39
SLIDE 39

39

ENABLE GLOBAL ILLUMINATION

2. 3. 1. 4.

slide-40
SLIDE 40

40

IMPORT LIBRARY

1.

slide-41
SLIDE 41

41

COMPILE

1. 2.

slide-42
SLIDE 42

42

ASSIGN MATERIALS FROM LIBRARY

1. 2.

slide-43
SLIDE 43

43

COMPARE

slide-44
SLIDE 44

44

CHANGE COLOR

1.

slide-45
SLIDE 45

45

1.

slide-46
SLIDE 46

46

1. 2. 3.

EXPORT MDL MATERIAL

slide-47
SLIDE 47

47

COMPILE

1.

slide-48
SLIDE 48

48

COMPILE

1.

slide-49
SLIDE 49

May 8-11, 2017 | Silicon Valley www.esi-group.com

THANK YOU

droettger@nvidia.com andreas.mank@esi-group.com

slide-50
SLIDE 50

50

slide-51
SLIDE 51

51

slide-52
SLIDE 52

52

smooth_rubber_black cast_metal_vintage_brass aluminum_red_oxidized paint_metallic_red_flakes metal_hammered_russet_copper titanium silver