OptiX


Nvidia OptiX is a ray tracing API. The computations are offloaded to the GPUs through either the low-level or the high-level API introduced with CUDA. CUDA is only available for Nvidia's graphics products. Nvidia OptiX is part of Nvidia GameWorks. OptiX is a high-level, or "to-the-algorithm" API, meaning that it is designed to encapsulate the entire algorithm of which ray tracing is a part, not just the ray tracing itself. This is meant to allow the OptiX engine to execute the larger algorithm with great flexibility without application-side changes.
Commonly, video games use rasterization rather than ray-tracing for their rendering.
According to Nvidia, OptiX is designed to be flexible enough for "procedural definitions and hybrid rendering approaches." Aside from computer graphics rendering, OptiX also helps in optical & acoustical design, radiation and electromagnetic research, artificial intelligence queries and collision analysis.

Ray tracing with OptiX

OptiX works by using user-supplied instructions regarding what a ray should do in particular circumstances to simulate a complete tracing process.
A light ray might have a different behavior when hitting a particular surface rather than another one, OptiX allows to customize these hit conditions with user-provided programs. These programs are written in CUDA C or directly in PTX code and are linked together when used by the OptiX engine.
In order to use OptiX a CUDA-capable GPU must be available on the system and the CUDA toolkit must be installed.
Using the OptiX engine in a ray tracing application usually involves the following steps:
Several examples for these programs are available with the program's SDK

// Sample code using OptiX APIs //
/* Ray generation program */
rtProgramCreateFromPTXFile;
rtContextSetRayGenerationProgram;
/* Miss program */
rtProgramCreateFromPTXFile;
rtContextSetMissProgram;
/* Bounding box and intersection program */
rtProgramCreateFromPTXFile;
rtGeometrySetBoundingBoxProgram;
rtProgramCreateFromPTXFile;
rtGeometrySetIntersectionProgram;

Bounding box programs are used to define bounding volumes used to accelerate ray tracing process within acceleration structures as kd-trees or bounding volume hierarchies

// Sample code using OptiX APIs //
rtProgramCreateFromPTXFile;
rtProgramCreateFromPTXFile;
/* Associate closest hit and any hit program with a material */
rtMaterialCreate;
rtMaterialSetClosestHitProgram;
rtMaterialSetAnyHitProgram;

In order to render a complex scene or trace different paths for any ray OptiX takes advantage of GPGPU computing by exploiting NVIDIA CUDA platform.
Since the process of shooting rays and setting their behavior is highly customizable, OptiX may be used in a variety of other applications aside from ray tracing.

OptiX Prime

Starting from OptiX 3.5.0 a second library called OptiX Prime was added to the bundle which aims to provide a fast low-level API for ray tracing - building the acceleration structure, traversing the acceleration structure, and ray-triangle intersection. Prime also features a CPU fallback when no compatible GPU is found on the system. Unlike OptiX, Prime is not a programmable API, so lacks support for custom, non-triangle primitives and shading. Being non-programmable, OptiX Prime does not encapsulate the entire algorithm of which ray tracing is a part. Thus, Prime cannot recompile the algorithm for new GPUs, refactor the computation for performance, or use a network appliance like the Quadro VCA, etc.

Software using OptiX