Accelerating Ray Tracing Using Optix

Accelerating Ray Tracing Using Optix

RAY TRACING WITH OPTIX A TUTORIAL FOR DEVELOPERS David McAllister, James Bigler, Brandon Lloyd RAY TRACING IN THE ABSTRACT . Given a ray (O, D) and a geometric dataset find — any hit — closest hit ? — all hits . Current datasets ~1M -> 100M primitives, usually triangles . Use a spatial data structure optimized for these operations . Datasets can also include GB of other data like textures OPTIX RAY TRACING TALKS AT GTC . Nvidia Keynote – Tue. 9:00 . Pixar Keynote – Wed. 11:00 . S4260 - Game Physics and Graphics APIs for Scientific Computing – Tue. 16:00 . S4359 - EM Wave Propagation Using OptiX for Simulation of Car-to-Car-Comm – Wed. 14:00 . S4697 - Realtime Preview For VFX: Challenges and Rewards – Wed. 14:00 . S4690 - Implementing OptiX Ray Tracing Features into FurryBall GPU Renderer – Wed. 17:30 . S4597 - Advanced OptiX Programming – Thur. 9:00 . S4400 - Petascale Molecular Ray Tracing: Accelerating VMD/Tachyon with OptiX – Thur. 10:00 . S4312 - QUIC EnvSim: Radiative Heat Transfer in Vegetative and Urban Environments with NVIDIA OptiX, Thur. 14:30 RENDERING WITH RAY TRACING RAY CASTING (APPEL, 1968) RECURSIVE RAY TRACING (WHITTED, 1980) 6 DISTRIBUTION RAY TRACING (COOK, 1984) 7 PATH TRACING (KAJIYA, 1986) 8 WHY RAY TRACING? . Ray tracing unifies rendering of visual phenomena — fewer algorithms with fewer interactions between algorithms . Easier to combine advanced visual effects robustly — soft shadows — subsurface scattering — indirect illumination — transparency — reflective & glossy surfaces — depth of field — … 9 REAL TIME PATH TRACING . What would it take? . GeForce GTX Titan: — 4 rays / sample — 400M rays / second — 50 samples / pixel — Need 30X speedup — 2M pixels / frame — 30 frames / second — 12B rays / second 1 shading sample 9 shading samples 18 shading samples 36 shading samples 72 shading samples 144 shading samples 1 AA sample 1 AA sample 2 AA samples 4 AA samples 8 AA samples 16 AA samples RAY TRACING REGIMES Real-time Interactive Batch Computational Power today HOW TO OPTIMIZE RAY TRACING .Better hardware (GPUs) .Better software (Algorithmic improvement) .Better middleware (Tune for the architecture) GPUS – THE PROCESSOR FOR RAY TRACING . Abundant parallelism, massive computational power . GPUs excel at shading . Opportunity for hybrid algorithms ACCELERATION STRUCTURES OPTIX PRIME . Specialized for ray tracing (no shading) . Replaces rtuTraversal (rtuTraversal is still supported) . Improved performance — Uses latest algorithms from NVIDIA Research . ray tracing kernels [Aila and Laine 2009; Aila et al. 2012] . Treelet Reordering BVH (TRBVH) [Karras 2013] — Can use CUDA buffers as input/output — Support for asynchronous computation . Designed with an eye towards future features API OVERVIEW . C API with C++ wrappers . API Objects — Context — Buffer Descriptor — Model — Query CONTEXT . Context tracks other API objects and encapsulates the ray tracing backend . Creating a context RTPresult rtpContextCreate(RTPcontexttype type, RTPcontext* context) . Context types RTP_CONTEXT_TYPE_CPU RTP_CONTEXT_TYPE_CUDA . Default for CUDA backend uses all available GPUs — Selects “Primary GPU” and makes it the current device — Primary GPU builds acceleration structure CONTEXT . Selecting devices: rtpContextSetCudaDeviceNumbers( RTPcontext context, int deviceCount, const int* deviceNumbers ) — First device is used as the primary GPU . Destroying the context — destroys objects created by the context — synchronizes the CPU and GPU BUFFER DESCRIPTOR . Buffers are allocated by the application . Buffer descriptors encapsulate Context information about the buffers rtpBufferDescCreate( RTPcontext context, BufferDesc RTPbufferformat format, RTPbuffertype type, void* buffer, RTPbufferdesc* desc ) . Specify region of buffer to use (in elements) rtpBufferDescSetRange( RTPbufferdesc desc, int begin, int end ) BUFFER DESCRIPTOR . Variable stride supported for vertex format rtpBufferDescSetStride — Allows for vertex attributes BUFFER DESCRIPTOR . Formats RTP_BUFFER_FORMAT_INDICES_INT3 RTP_BUFFER_FORMAT_VERTEX_FLOAT3, RTP_BUFFER_FORMAT_RAY_ORIGIN_DIRECTION, RTP_BUFFER_FORMAT_RAY_ORIGIN_TMIN_DIRECTION_TMAX, RTP_BUFFER_FORMAT_HIT_T_TRIID_U_V RTP_BUFFER_FORMAT_HIT_T_TRIID … . Types RTP_BUFFER_TYPE_HOST RTP_BUFFER_TYPE_CUDA_LINEAR MODEL . A model is a set of triangles combined with an acceleration data structure Context rtpModelCreate rtpModelSetTriangles indices rtpModelUpdate BufferDesc Model . Asynchronous update vertices BufferDesc rtpModelFinish rtpModelGetFinished QUERY . Queries perform the ray tracing on a model rtpQueryCreate Context rtpQuerySetRays rtpQuerySetHits indices BufferDesc rtpQueryExecute Model . Query types vertices BufferDesc RTP_QUERY_TYPE_ANY RTP_QUERY_TYPE_CLOSEST rays BufferDesc . Asynchronous query Query hits BufferDesc rtpQueryFinish rtpQueryGetFinished BUILD PERFORMANCE 200 180 160 140 120 100 80 60 40 Speedup over SBVH Speedup 20 0 RAY TRACING PERFORMANCE 3.0 2.5 2.0 rtuTraversal 1.5 1.0 0.5 Speedup over Speedup 0.0 RAYTRACING PERFORMANCE 350.0 300.0 250.0 200.0 150.0 /s for diffuse rays diffuse /s for 100.0 50.0 Mrays 0.0 FUTURE . Features we want to implement — Animation support (refit/refine) — Instancing — Large-model optimizations ART AND ANIMATION STUDIOS . Jan Tománek, CEO . FurryBall 4.6 .6 OPTIX GOALS . High performance ray tracing . Simpler ray tracing . Hide GPU-specific details . Express most ray tracing algorithms . Leverage CUDA architecture and compiler infrastructure GENERAL PURPOSE RAY TRACING . Rendering, baking, collision detection, A.I. queries, etc. Modern shader-centric, stateless and bindless design . Is not a renderer but can implement many types of renderers . Algorithm agnostic — User defined ray data — Programmable intersection — Interoperate with rasterization pipeline HIGHLY PROGRAMMABLE . Shading with arbitrary ray payloads . Ray generation/framebuffer operations — cameras, data unpacking, etc. Programmable intersection — triangles, NURBS, implicit surfaces, etc. EASY TO PROGRAM . Write single ray code (no exposed ray packets) . No need to rewrite shaders to target different hardware OTHER OPTIX FEATURES . OptiX node graph — Programmable traversal — Instancing — Dynamic scenes . Double precision arithmetic . Interop with CUDA, OpenGL and D3D — Textures, VBOs, etc. — Hybrid rasterization and ray tracing DOCS.NVIDIA.COM HOW OPTIX LINKS YOUR CODE Ray Generation Acceleration Structures DRAM I/F DRAM Material Shading Material I/F DRAM Material Shading JIT I/F DRAM HOST I/F HOST Compiler L2 I/F DRAM Object Intersection Thread Giga Material I/F DRAM Material Shading Scheduling I/F DRAM CUDA C shaders from OptiX API GPU Execution via user programs CUDA OVERVIEW – API OBJECTS Acceleration Program Group Variable GeometryGroup Context Transform GeometryInstance Selector Buffer Geometry TextureSampler Material API OBJECTS – CONTEXT . Manages API Object State — Program Loading Context — Validation and Compilation Ray Gen Programs . Manages Acceleration Structures Callable Programs Exception Programs — Building and Updating Miss Programs User Variables . Provides Entry Points into the system — rtContextLaunch*D() ENTRY POINTS AND RAY TYPES Context Entry Point 1 Entry Point 2 Ray Generation 1 Ray Generation 2 Exception 1 Exception 2 Trace ENTRY POINTS AND RAY TYPES Trace Material Ray Type Ray Shading 0 Closest Hit Any Hit 1 Closest Hit Any Hit Material Programs 2 Closest Hit Any Hit 3 Closest Hit Any Hit API OBJECTS – NODES . Nodes contain children Group — Other nodes — Geometry Instances GeometryGroup . Transforms hold matrices — Applied to all children Transform . Selectors have Visit programs — Provide programmable selection of children Selector — Similar to “switch nodes” — Can implement LOD systems Acceleration . Acceleration Structures — Builds over children of attached node THE OBJECT HIERARCHY Context Group GeometryGroup GeometryGroup GeometryInstance GeometryInstance GeometryInstance GeometryInstance API OBJECTS – GEOMETRY . GeometryInstance binds: — Geometry object GeometryInstance — A collection of Materials . Indexed by argument from intersection . Geometry — A collection of primitives Geometry Material — Intersection Program — Bounding Box Program Material . Material — Any Hit Program Material — Closest Hit Program DEFORMABLE OBJECTS 2. Groups and Acceleration Marked Dirty Context Group Acceleration GeometryGroup 1. Primitives Deform GeometryInstance 3. Context updates Acceleration Structures API OBJECTS – DATA MANAGEMENT . Supports 1D, 2D and 3D buffers . Buffer formats — RT_FORMAT_FLOAT3 Buffer — RT_FORMAT_UNSIGNED_BYTE4 — RT_FORMAT_USER, etc. TextureSampler . Other API Interoperability — e.g. create buffers from CUDA, OpenGL or D3D buffer objects . TextureSamplers reference Buffers — Attach buffers to MIP levels, array slices, etc. API OBJECTS – PROGRAMMABILITY . Runs on CUDA Program — Cg-like vectors plus pointers — Uses PTX, CUDA’s virtual assembly language Variable — C++ wrapper for use with NVCC compiler . Implements recursion and dynamic dispatch Callable — Intrinsic functions: rtTrace(), rtReportIntersection(), etc. Programs reference variables by name . Variables are defined by — Static initializers — Binding to API Objects in the hierarchy VARIABLES . Variables are one of: — A small primitive type (float4, matrix, ...) — A small user defined type — A handle to a buffer (1D, 2D, 3D) — A texture — A handle to a callable program — A buffer ID — A program ID VARIABLE SCOPING Context Context Definition: Color = blue GI GI Material Material GeometryInstance Definition: Color

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    68 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us