Run a Sample with Intel® OSPRay
The sample application uses Intel® OSPRay to render a simple set of triangles and enhance the quality of the original rendering. This walkthrough demonstrates how to run the sample application with Intel® OSPRay from the
Intel® oneAPI Rendering Toolkit
(Render Kit
).
To run an Intel OSPRay sample application, do one of the following:
- Run pre-built sample applications delivered with theIntel® oneAPI Rendering Toolkit. Use the pre-built sample application to verify that theRender Kitinstallation is successful.
- Build the sample application manually using sources from the Intel OSPRay GitHub* repository and run it.
Run Pre-Built Samples
Prerequisites
- Intel® oneAPI Rendering Toolkitwith Intel OSPRay. By default, theIntel® oneAPI Rendering Toolkitis installed to/opt/intel/oneapi/directory. Replace<install-dir>with the default or your custom installation path.
- A.ppmimage viewer (for example, ImageMagick* or GIMP*)
Run the ospTutorial Sample Application
- Open a new terminal window. Open Spotlight* tool and enterTerminal.
- Go to a writable directory and create a directory to save the sample application results to.For example, create the:rk_gsgfoldercd ~mkdir rk_gsgcd rk_gsg
- Set environment variables so that programs can see Render Kit runtime libraries. From the terminal, do one of the following:
- Run the script to set the variables:source <install-dir>/setvars.sh
- Set theDYLD_LIBRARY_PATHmanually:export DYLD_LIBRARY_PATH=<install-dir>/rkcommon/latest/lib:<install-dir>/ospray/latest/lib:<install-dir>/oidn/latest/lib:<install-dir>/embree/latest/lib:<install-dir>/openvkl/latest/lib
- RunospTutorial:<install-dir>/ospray/latest/bin/ospTutorialIf the sample executes successfully, you should see two.ppmimages in the working directory:firstFrame.ppmandaccumulatedFrame.ppm.
- Open the resulting files with a preferred image viewer. For example,to convert and open the resulting images with ImageMagick:convert firstFrame.ppm firstFrame.jpgconvert accumulatedFrame.ppm accumulatedFrame.jpgopen firstFrame.jpgopen accumulatedFrame.jpg
Each image shows two triangles rendered by Intel® OSPRay:
- ThefirstFrame.ppmshows the image after one call to a renderer, which results in triangles with jagged edges and noise in the shadow.
- TheaccumulatedFrame.ppmshows the image after ten calls to a renderer, which results in triangles with antialiased edges and converged shadows. Multiple calls to a renderer enable progressive refinement and enhance image quality.
Run the ospExamples Sample Application
Run the
ospExamples
sample application as follows:
<install-dir>/ospray/latest/bin/ospExamples
A new GUI window will open with multiple simple scenes composed of basic geometry types, lights, and volumes. You can edit the scene by clicking the drop-down buttons. Move the camera by clicking and holding a mouse button, then dragging the mouse. See
https://www.ospray.org/tutorials.html for details about controls.

Build and Run a Sample
Prerequisites
- Intel® oneAPI Rendering Toolkit(Render Kit) with Intel OSPRay. The tutorial describes how to build a sample Intel OSPRay application, which is part ofIntel® oneAPI Rendering Toolkit. By default, theIntel® oneAPI Rendering Toolkitis installed to directory. Replace<install-dir>with the default or your custom installation path.
- A system compiler that supports C99 and C++11. This tutorial uses the included default C/C++ compiler with Xcode*.
- Git*
- CMake* 3.12 or higher
- A.ppmimage viewer (for example, ImageMagick* or GIMP*)
Build the ospTutorialFindospray Sample Application
- Open anew terminal.
- Create a directory for sample result files in a user-writeable location. For example, to create therk_gsgfolder in the:~home directorycd ~mkdir ~/rk_gsgcd rk_gsg
- Ensure that Git is available:which gitgit --versionYou should get the version of Git installed on your machine.
- Set environment variables so that programs can see Render Kit runtime libraries. From the terminal, do one of the following:
- Run the script to set the variables:source <install-dir>/setvars.sh
- Set theDYLD_LIBRARY_PATHmanually:export DYLD_LIBRARY_PATH=<install-dir>/rkcommon/latest/lib:<install-dir>/ospray/latest/lib:<install-dir>/oidn/latest/lib:<install-dir>/embree/latest/lib:<install-dir>/openvkl/latest/lib
- For corporate network users: Configure the Git proxy server if necessary:git config --global http.proxy http://<user>:<pass>@proxy.<server>.com:<port>git config --global https.proxy https://<user>:<pass>@proxy.<server>.com:<port>
- Ensure that CMake is available:which cmakecmake --versionYou should see the version of CMake installed on your machine. It should be 3.1 or higher.
- Clone the Intel OSPRay GitHub* project:git clone --no-checkout https://github.com/ospray/ospray.git ospraycd ospray
- Fetch the version tags:git fetch --tags
- Check out the tutorial sources for the Intel OSPRay. Pick the version from your deployment of the Intel oneAPI Rendering Toolkit release:git checkout tags/v2.5.0cd apps/ospTutorial/ospTutorialFindospray
- Configure and build the sample in a Release mode:export rkcommon_DIR=<install-dir>/rkcommon/latestexport embree_DIR=<install-dir>/embree/latestexport openvkl_DIR=<install-dir>/openvkl/latestexport ospray_DIR=<install-dir>/ospray/latestmkdir buildcd buildcmake ..cmake --build .
- Run the sample application:./ospTutorialFindosprayIf the sample executes successfully, you should see two.ppmimages in the working directory:firstFrame.ppmandaccumulatedFrame.ppm.
- Open the resulting files with a preferred image viewer. For example,to convert and open the resulting images with ImageMagick:convert firstFrame.ppm firstFrame.jpgconvert accumulatedFrame.ppm accumulatedFrame.jpgopen firstFrame.jpgopen accumulatedFrame.jpg
Each image shows two triangles rendered by Intel® OSPRay:
- ThefirstFrame.ppmshows the image after one call to a renderer, which results in triangles with jagged edges and noise in the shadow.
- TheaccumulatedFrame.ppmshows the image after ten accumulations, which result in triangles with antialiased edges and converged shadows. Multiple accumulations enable progressive refinement and enhance image quality.
Next Steps
- Review the API details provided in the Intel OSPRay documentation.
- Review other Intel OSPRay sample programs located in the<install-dir>/ospray/latest/bindirectory. Refer to the Intel OSPRay documentation for usage details.The default installation directory is/opt/intel/oneapi. If you installed theRender Kitto a custom directory, replace the<install-dir>with your custom installation path.
- Explore the to build and review the sample application.