INTRODUCTION TO OPTIX - NVIDIA · 2017. 5. 8. · 5 RELEASE TIMELINE Jan 2016 Summer 2016 TODAY!...

Post on 17-Oct-2020

6 views 0 download

Transcript of INTRODUCTION TO OPTIX - NVIDIA · 2017. 5. 8. · 5 RELEASE TIMELINE Jan 2016 Summer 2016 TODAY!...

Martin Stich, Engineering Manager

INTRODUCTION TO OPTIX

2

AGENDA

OptiX Basics

Advanced Topics

Case Studies

Feature Outlook

3

OPTIX BASICS

4

IN A NUTSHELL

State-of-the-art performance: 500M+ rays/sec

Algorithm and hardware agnostic

Shaders with single-ray programming model, recursion

Available free for private and commercial use

The OptiX Ray Tracing SDK

5

RELEASE TIMELINE

Jan 2016 Summer 2016 TODAY!

OptiX 3.9Pascal Support

OptiX 4.0LLVM PipelineNVLINK Scaling

OptiX 4.1Performance

CUDA 8, VS2015

2009

OptiX 1.0Hello World!

...

6

MODERN RAY TRACING

Rasterization:

7

MODERN RAY TRACING

Rasterization:

Ray Tracing:

8

THE RAY TRACING PIPELINE

Programmable:

Ray Generation

Closest Hit, Any Hit, Miss

Intersection

← Launch entry

← Shading

← GeometryRAY GENERATION

INTERSECTIONANY-HIT

INTERSECTIONANY-HIT

CLOSEST-HIT

9

MAIN OPERATIONS

RAY GEN INTERSECT ANY HIT CLOSEST HIT MISS

rtTrace ✔ ✔ ✔

rtPotentialIntersection ✔

rtReportIntersection ✔

rtIgnoreIntersection ✔

rtTerminateRay ✔

10

SHADER COMMUNICATION

Variables

similar to uniforms in other systems

constants, system values, buffers, textures, …

Example:

Textures

Current ray

11

SHADER COMMUNICATION

Variables

similar to uniforms in other systems

constants, system values, buffers, textures, …

Ray Payload

arbitrary data associated with ray

in/out from rtTrace to Any-hit, Closest-hit, Miss

Example:

Textures

Current ray

Example:

Color data

12

SHADER COMMUNICATION

Variables

similar to uniforms in other systems

constants, system values, buffers, textures, …

Ray Payload

arbitrary data associated with ray

in/out from rtTrace to Any-hit, Closest-hit, Miss

Attributes

arbitrary data associated with hit

generated in Intersection program

consumed by Any-hit, Closest-hit

Example:

Color data

Example:

Barycentrics

Example:

Textures

Current ray

13

EXAMPLE

See optixPathTracer SDK sample for a slightly less minimalistic version

Miniature Path Tracer

14

GLOBAL ILLUMINATION

15

GLOBAL ILLUMINATION

16

GLOBAL ILLUMINATION

17

GLOBAL ILLUMINATION

18

HOWEVER…

19

RAY PAYLOAD

struct RayPayload{

float3 radiance; // stores contribution after we hit the light source

float3 attenuation; // accumulated attenuation of radiance due to materials

float3 next_origin; // reflection ray to be traced for the nextfloat3 next_direction; // ..segment of the path

unsigned seed; // random number generator state

bool done; // whether we’re done tracing this path

};

Path State Definition

20

INTEGRATIONRT_PROGRAM void ray_generation(){

unsigned int seed = tea<16>( launch_index.x + launch_index.y*output_buffer.size().x, frame_number );float3 ray_origin = eye;float3 ray_direction = compute_jittered_ray_dir( seed );

RayPayload payload;payload.radiance = make_float3(0,0,0);payload.attenuation = make_float3(1,1,1);payload.seed = seed;payload.done = false;int depth = 0;

while( !payload.done && depth++ < 10 ){

Ray ray = make_Ray( ray_origin, ray_direction, 0, 0.001f, RT_DEFAULT_MAX );

rtTrace( scene, ray, payload );

ray_origin = payload.next_origin;ray_direction = payload.next_direction;

}

const float3 result = payload.radiance * payload.attenuation;

const float lerp_t = frame_number > 1 ? 1.0f / frame_number : 1.0f;const float3 prev_col = make_float3( output_buffer[launch_index] );output_buffer[launch_index] = make_float4( lerp( prev_col, result, lerp_t ), 1.0f );

}

1

2

3

4

21

rtDeclareVariable( float3, diffuse_color, , );rtDeclareVariable( float3, normal, attribute normal, );rtDeclareVariable( optix::Ray, ray, rtCurrentRay, );rtDeclareVariable( float, t_hit, rtIntersectionDistance, );rtDeclareVariable( RayPayload, current_payload, rtPayload, );

RT_PROGRAM void closest_hit_diffuse(){

const float3 hitpoint = ray.origin + t_hit * ray.direction;

const float z1 = rnd( current_payload.seed );const float z2 = rnd( current_payload.seed );float3 dir;cosine_sample_hemisphere( z1, z2, dir );optix::Onb onb( normal );onb.inverse_transform( dir );

current_payload.next_origin = hitpoint;current_payload.next_direction = dir;

current_payload.attenuation *= diffuse_color;}

DIFFUSE MATERIAL

22

rtDeclareVariable( RayPayload, current_payload, rtPayload, );rtDeclareVariable( float3, emission_color, , );

RT_PROGRAM void closest_hit_light(){

current_payload.radiance = emission_color;current_payload.done = true;

}

RT_PROGRAM void miss(){

current_payload.radiance = make_float3(0,0,0);current_payload.done = true;

}

LIGHT MATERIAL AND MISS

23

rtDeclareVariable( float3, anchor, , );rtDeclareVariable( float3, v1, , );rtDeclareVariable( float3, v2, , );rtDeclareVariable( float4, plane, , );rtDeclareVariable( float3, normal, attribute normal, ); rtDeclareVariable( optix::Ray, ray, rtCurrentRay, );

RT_PROGRAM void intersect( int primIdx ){

const float3 n = make_float3( plane );const float dt = dot( ray.direction, n );const float t = (plane.w - dot(n, ray.origin)) / dt;const float3 p = ray.origin + ray.direction * t;const float3 vi = p - anchor;const float a1 = dot( v1, vi );const float a2 = dot( v2, vi );

if( a1 >= 0 && a1 <= 1 && a2 >= 0 && a2 <= 1 ){

if( rtPotentialIntersection( t ) ){

normal = n;rtReportIntersection( 0 );

}}

}

SCENE GEOMETRY

24

RESULTAccumulation Over Time

25

NEXT STEP IDEAS

Next event estimation

Russian roulette

Sphere primitives

Mirror material

Glass material

Triangle meshes

Environment maps

...

Mini Path Tracer Reader Exercises

26

NODE GRAPH

Context

Geometry Group

Geometry

Instance

Geometry

Material

Group

Variables

Intersection Program

Any Hit +Closest Hit

27

ADVANCED TOPICS

28

INTEROPShare CUDA and OpenGL Resources

CUDA

Share CUDA allocations

rtBufferSetDevicePointerrtBufferGetDevicePointer

OpenGL

Share textures and vertex buffers

rtBufferCreateFromGLBOrtTextureSamplerCreateFromGLImage

29

BINDLESS OBJECTS

“Bindless”: powerful concept to dynamically select textures, buffers, and programs at runtime

Allows efficient implementation of large shading networks

Reduces code size, compile times, and number of compiles

Pixar Animation Studio’s “Flow” material editing tool. Visit the NVIDIA website to watch a SIGGRAPH 2015 talk describing the system in detail.

30

PTX GENERATIONOptions

OptiX

nvcc.exe

nvrtc.dll

NVVM/

NVPTX

CUDA-C++

CUDA-C++

LLVM-IR

PTX

Offline

JIT

31

MULTI-GPU AND NVLINKAutomatic Scaling

110M Triangles

23M Grass Blades

15GB Textures

2 x GP100

Monsters University data set courtesy of Pixar Studios

32

REMOTE RENDERINGOn Quadro VCA or DGX-1

Progressive

video stream

Incremental

updates

OptiX App

OptiX Server(s)

ETHERNET

INTERNET

33

OPTIX PRIME

Supports instancing, async operations, ray masks

Performance similar to OptiX

Same semantics via OptiX: See optixRaycasting sample

Simple intersection-only API

Rays

Triangles

OptiX

Prime

GPU or CPU

Intersections(primIdx, t, u, v)

34

CASE STUDIES

35

PERFORMANCERaw Traversal on Titan X Pascal

+16% in OptiX 4.1+3% in OptiX 4.1

36

NVIDIA: IRAY & MENTAL RAY

37

NVIDIA: GVDB

Image Property of DreamWorks AnimationOpenVDB format support

Live interaction with multiple-bounce GI scattering, 10x-30x faster than CPU

Introduction and Techniques with NVIDIA GVDB VoxelsMonday, 9:00 AM – Room 231

Sparse Volume Rendering

38

AAA-STUDIO: FURRYBALL PRODUCTION RENDERING

39

VISUAL MOLECULAR DYNAMICS (VMD)

Molecular Visualization package with hundreds of thousands of users

Developed by John Stone of U Illinois

Cutting Edge OptiX Ray Tracing Techniques for Visualization of Biomolecular and Cellular Simulations in VMDTuesday, 3:30 PM – Room 230C

40

OLCF: SCIENTIFIC VISUALIZATION

Visualizing laser interaction with metals, hundreds of millions of primitives on DGX-1

Developed by Benjamin Hernandez, OLCF-ORNL

Exploratory Visualization of Petascale Particle Data in NVIDIA DGX-1Tuesday, 3:30 PM – Room 212B

Simulation: OLCF INCITE 2017 "Petascale Simulations of Short Pulse Laser Interaction with Metals" PI Leonid Zhigilei, University of Virginia

41

NVIDIA: VRWORKS AUDIO

Sound waves reflect off of the environment

Path traced audio

NVIDIA VRWORKS AUDIO - Improving VR Immersion with acoustic fidelity

Thursday, 11:00 AM – Room 230B

42

BUNGIE: LIGHT BAKING FOR GAMES

Light and occlusion baking is a major bottleneck in game design

Workflow-changing speedups by switching from CPU render farms to OptiX

43

LIGHTMASSLight baking in Unreal Engine 4

Total Time on Titan X

CPU 1638sGPU 1X 426sGPU 2X 298s

44

ADVANCED SAMPLESMaintained on Github

A collection of larger, more sophisticated sample applications than the ones that come with the SDK

Available at:

https://github.com/nvpro-samples/optix_advanced_samples

45

FEATURE OUTLOOK

46

PERFORMANCEMOTION BLURSEPARATE

COMPILATION

UNDER DEVELOPMENT

Shorter per-shadercompile times

Fast incremental addition and removal of programs

Overall speedup through parallel compilation

Performance is always a focus

Tackling some big ticket ideas over the next ~year

Transform and deformation blur

47

THANK YOU!

Related Talks:

S7185 - LEVERAGING NVRTC RUNTIME COMPILATION FOR DYNAMICALLY BUILDING OPTIX SHADERS FROM MDL MATERIALS

S7454 - NVIDIA ADVANCED RENDERING

S7452 - CUTTING EDGE OPTIX RAY TRACING TECHNIQUES FOR VISUALIZATION OF BIOMOLECULAR AND CELLULAR SIMULATIONS IN VMD

S7175 - EXPLORATORY VISUALIZATION OF PETASCALE PARTICLE DATA IN NVIDIA DGX-1

S7400 - GPU-CLOUD PHOTOREALISTIC RENDERING FOR THE NEXT GENERATION OF CLOUD CAD TOOLS

H7106 - PHYSICALLY BASED RAY TRACING WITH OPTIX

S7391 - TURBOCHARGING VMD MOLECULAR VISUALIZATIONS WITH STATE-OF-THE-ART RENDERING AND VR TECHNOLOGIES

S7424 - INTRODUCTION AND TECHNIQUES WITH NVIDIA GVDB VOXELS

S7135 - NVIDIA VRWORKS AUDIO - IMPROVING VR IMMERSION WITH ACOUSTIC FIDELITY