OptiX Documentation (for 759 students)
Here is a summary of the steps to get OptiX running on a computer and an explanation of the software for reference
- Register as a developer on Nvidia’s website: https://developer.nvidia.com/user
- Download OptiX 7.6 SDK (only available on Windows or Linux): https://developer.nvidia.com/designworks/optix/download
- Open a terminal window and change to the directory you downloaded the Nvidia-OptiX-SDK…sh file in
- install the SDK on your machine using the following commands (NOTE: you can use tab to autocomplete the name of the shell script) [source: https://www.cyberciti.biz/faq/run-execute-sh-shell-script/]
chmod +x NVIDIA-OptiX-SDK-7.6.0-linux64-x86_64-31894579.sh ./ NVIDIA-OptiX-SDK-7.6.0-linux64-x86_64-31894579.sh
- scroll down using the down arrow and type
yto accept the license and type
yagain to adding a subdirectory
- Move the folder into a better directory, I moved mine into my home directory.
Then open up the folder and follow the instructions in SDK/INSTALL-LINUX.txt
i. cd into the SDK directory, make a new build directory, and cd into that directory
1 2 3
cd NVIDIA-OptiX-SDK-7.6.0-linux64-x86_64/SDK mkdir build cd build
ii. run cmake to build files
iii. once in cmake interface, type in
c, and type
eonce the process is done. For now, we are just going to generate the release build. We will generate the debug build at a later time. iv. type
- Now make the files by running:
- cd to the
SDK/build/binfolder, right click the optixHair file and select
runto see if it was successful.
- Set the environment variable OptiX_INSTALL_DIR to where you installed the SDK:
- You should now be able to move the OptiX sample files into any directory (if you also copy over the CMake, build, data, cuda, sutil folders) and build; however, you may need to change CMake/FindOptiX.cmake line 32:
set(OptiX_INSTALL_DIR "/home/matthew/NVIDIA-OptiX-SDK-7.6.0-linux64-x86_64") #where the path in quotations is the path to the folder where you installed OptiX.
- Open a new terminal window and clone this repository
git clone https://git.doit.wisc.edu/MJMULLIN/repo759.git
- cd to FinalProject759/owl and make a build folder and cd into that
1 2 3
cd repo759/FinalProject759/owl mkdir build cd build
change set(OptiX_INSTALL_DIR “/home/matthew/OptiX”) in repo759/FinalProject759/owl/owl/cmake/FindOptiX.cmake to wherever your OptiX Install Directory is. NOTE: You may have to also export OptiX_INSTALL_DIR as an environment variable. This step is tricky.
- In your build folder, type cmake .., followed by make
cmake .. make
- Run ./render_helio or ./render_field to make sure you built them correctly
- If successful, you should see .png files in your build folder.
- The code that generated this is under FinalProject759/owl/samples/cmdline/s33-render_field
OptiX is a Nvidia GPU-optimized ray tracing toolkit. It is fairly lowlevel API and requires explicit control of memory management. Because ray tracing is an “embarassingly parallel problem” (i.e. each ray operates independent of one another), each ray is assigned a ray tracing pipeline. Within the pipeline, there are programs (other toolkits often refer to these programs as shaders). Each program does something to a ray: ray generation, ray intersection, ray hits, etc. Here’s an explanation of all the jargon that is used:
- shader binding table (SBT) as mentioned before, a shader is a program that does something to a ray. The shader binding table assigns shaders to specific rays, and records the parameters of each shader. A filled out chunk of the shader binding table that is being read/written to at runtime (when the program is running) for a specified ray is called a record. primitives are shapes that rays can intersect. These shapes include triangles, spheres, curves, etc. They need explicit equations/solutions for determining the points in 2D or 3D space for where a line (a ray) intersects that shape. These primitives form a geometry.
- acceleration structures are algorithms used to reduce the number of intersection tests a given ray has to compute. An example of one acceleraiton structure is the Bounding Volume Heirarchy (BVH) where the entire scene is divided in a binary fashion into ever smaller boxes. Therefore, when a ray is traversing the scene, it firsts tests if it is in one of 2 boxes, and then gets into smaller and smaller boxes until it either hits an object or flies out of the scene. This reduces the number of hit tests from O(N) to O(log N).
- A collection of programs, geometries, and acceleration structures forms a node graph.
- buffers are chunks of memory that get sent to the GPU. A frame buffer (fb) is 1 rendered frame or image (think fps or frames per second).
Because OptiX 7.x is very low level (and somewhat indecipherable to the unannointed), it instead makes sense to use a higher level wrapper API built on top of Optix 7, which is OWL.
OWL (Optix Wrapper Library) Documentation (for 759 students)
Link to repo: https://github.com/owl-project/owl
- clone repo
- modify owl/Cmake/FindOptiX.cmake
- variables are parameters for programs (ray generation, miss, etc.) and geoemetries. Instead of populating a shader binding table (SBT), you set variables in OWL and OWL takes care of that.
In order to build with OptiX, you will need to understand the basics of Cmake. Good resources are found here: https://www.youtube.com/watch?v=_yFPO1ofyF0&list=PLK6MXr8gasrGmIiSuVQXpfFuE1uPT615s. The following instructions will be from a Linux perspective (use WSL2 if on Windows)
- check what cmake version you have (if you don’t have one, install it)
- if out of date, download the newest version here: https://cmake.org/download/ and install like OptiX