building optix shaders from
play

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


  1. May 8-11, 2017 | Silicon Valley S7185 LEVERAGING NVRTC FOR BUILDING OPTIX SHADERS FROM MDL MATERIALS Detlef Röttger, NVIDIA Andreas Mank, ESI Group 2017-05-08 www.esi-group.com

  2. VISUALIZE REAL-WORLD LIGHTS AND MATERIALS 2

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

  4. INTRODUCTION 4

  5. 5

  6. 6

  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 7

  8. MDL NVIDIA 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 8

  9. volume scattering and dispersion OPTIX NVIDIA GPU Ray Casting API 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 on remote NVIDIA VCA cluster Develop "to the algorithm" hair intersection and shading 9

  10. EVOLUTION OF THE RENDERER ARCHITECTURE 10

  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. 11

  12. ray_gen closest_hit pinhole edf thin_lens lens shader material edf_diffuse fisheye traverser integrator edf_spot sphere eval EDF edf_measured output sample BSDF bsdf backscattering direct lighting? light_constant diffuse_reflection miss_null sample light light_env diffuse_transmission miss_constant light_mesh glossy eval BSDF measured miss_env specular any_hit beckmann_smith bounding_box beckmann_vcavities material intersection ggx_smith traverser ggx_vcavities cutout opacity? ward_geisler_moroder * rectangles are fixed-function code * round rectangles are bindless callable programs 12

  13. INTRODUCTION TO NVRTC 13

  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 14

  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 15

  16. NVRTC API CUDA C++ Runtime Compilation to PTX nvrtcProgram prog; Input CUDA C++ code nvrtcCreateProgram(&prog, src , NULL, 0, NULL, NULL); Compiler options nvrtcCompileProgram(prog, numOptions, options ); nvrtcGetProgramLogSize(prog, &logSize); if (1 < logSize) { Potential error log nvrtcGetProgramLog(prog, log ); } nvrtcGetPTXSize(prog, &ptxSize); if (1 < ptxSize) { Output PTX code nvrtcGetPTX(prog, ptx ); } nvrtcDestroyProgram(&prog); 16

  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(), optixIncludes.c_str(), rendererIncludes.c_str() }; 17

  18. SHADER GENERATION FROM MDL MATERIALS 18

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

  20. INTEGRATION INTO ESI IC.IDO 20

  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 21

  22. Helios Rendering Architecture Overview Application IC.IDO Helios Renderer RiXGL Back-End OptiX Back-End . . . (DLL) (DLL) 22

  23. Helios Rendering Architecture Interfaces Application API Helios 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 Back-End Set scene geometry and transformations (flattened two-level scene graph) Set rendering parameters (e.g., materials, lights, whitted ray tracing or GI) 23

  24. Helios OptiX Back-End Helios OptiX Back-End MDL Parser OptiX Builder • Reads MDL files • Generates material traversers (CUDA C++) • Generates material parameter lists • Compiles bindless callable programs MDL SDK OptiX NVRTC 24

  25. 4/28/2017 MDL IN CUSTOM RENDERERS MATERIAL DEFINITION IMPLEMENTATION MATERIAL TWEAKING CONSTRUCTION MDL SDK NVIDIA IRAY CUDA (Ray Tracer) MATERIAL SHARING (LIBRARY) 28.04.2017 25

  26. LIVE DEMONSTRATION 26

  27. START SD6 27

  28. 1. CREATE A NEW MDL MATERIAL 28

  29. 3. 2. 1. SET MDL MATERIAL PROPERTIES 29

  30. 3. 1. 2. LOAD MESH 30

  31. 1. ACTIVE MESH 31

  32. 1. ASSIGN NEW MATERIAL 32

  33. LOAD ADDITIONAL MATERIALS 1. 33

  34. 2. 1. 3. SHOW ENVIRONMENT 34

  35. 2. 1. 3. EXPORT MDL MATERIAL 35

  36. 1. 2. MDL FILE 36

  37. START ICIDO PROOF-OF-CONCEPT 37

  38. 1. 38

  39. 1. 3. 2. 4. ENABLE GLOBAL ILLUMINATION 39

  40. IMPORT LIBRARY 1. 40

  41. 2. 1. COMPILE 41

  42. 2. 1. ASSIGN MATERIALS FROM LIBRARY 42

  43. COMPARE 43

  44. 1. CHANGE COLOR 44

  45. 1. 45

  46. 2. 1. 3. EXPORT MDL MATERIAL 46

  47. 1. COMPILE 47

  48. 1. COMPILE 48

  49. May 8-11, 2017 | Silicon Valley THANK YOU droettger@nvidia.com andreas.mank@esi-group.com www.esi-group.com

  50. 50

  51. 51

  52. titanium aluminum_red_oxidized smooth_rubber_black silver metal_hammered_russet_copper cast_metal_vintage_brass paint_metallic_red_flakes 52

Recommend


More recommend