This repository is a fork of Will Usher's ChameleonRT, enhanced with Slang shader language integration. The primary goal of this fork is to enable unified shader development across multiple ray tracing backends using Slang, eliminating the need to write and maintain separate shader code for each platform.
Key additions in this fork:
- Slang-based shader compilation for DXR and Vulkan backends (tested on Windows)
- Unified shader codebase in
shaders/unified_render.slang
Current Status: Slang integration is currently implemented and tested for DirectX Ray Tracing (DXR) and Vulkan backends on Windows only. Support for additional backends and platforms may be added in the future.
Original ChameleonRT: An example path tracer supporting multiple ray tracing backends (Embree, Embree+SYCL, DXR, OptiX, Vulkan, Metal, OSPRay). This fork maintains compatibility with the original backends while adding Slang integration options for DXR and Vulkan.
The project uses tinyobjloader for OBJ files, tinygltf for glTF files, and optionally pbrt-parser for PBRTv3 files. Example models (San Miguel, Sponza, Rungholt) are from Morgan McGuire's Computer Graphics Data Archive.
The camera is an arcball camera that moves around the camera's focal point.
- Zoom in/out using the mousewheel. (Two-finger scroll motion on MacBook Pro etc. trackpad.)
- Click and drag to rotate.
- Right-click and drag to pan. (Two-finger click and drag on MacBook Pro etc. trackpad.)
Keys while the application window is in focus:
- Print the current camera position, center point, up vector and field of view (FOV) to the terminal by pressing the
pkey. - Save image by pressing the
skey.
-eye <x> <y> <z> Set the camera position
-center <x> <y> <z> Set the camera focus point
-up <x> <y> <z> Set the camera up vector
-fov <fovy> Specify the camera field of view (in degrees)
-camera <n> If the scene contains multiple cameras, specify which
should be used. Defaults to the first camera
-img <x> <y> Specify the window dimensions. Defaults to 1280x720
This fork adds Slang shader language support for unified shader development across the DXR and Vulkan backends on Windows.
- Windows 10/11 (required for current Slang backend support)
- Slang compiler (tested with version v2025.12.1)
- SDL2 for window management
- GLM (automatically downloaded by CMake)
- For DXR: Windows 10 1809 or higher, latest Windows 10 SDK, DXR-capable GPU
- For Vulkan: Vulkan SDK 1.2.162 or higher, Vulkan ray tracing capable GPU
This fork has been built and tested against Slang version v2025.12.1. Build Slang first:
git clone https://github.com/shader-slang/slang.git
cd slang
git checkout v2025.12.1
# Follow Slang's build instructions for Windows
# Typical build: cmake -B build -S . && cmake --build build --config ReleaseTo build ChameleonRT with Slang support for DXR and/or Vulkan:
# Build with DXR + Slang backend
cmake -B build -S . \
-DENABLE_SLANG=ON \
-DSlang_ROOT=C:/path/to/slang/build/Release \
-DENABLE_DXR_SLANG=ON \
-DSDL2_DIR=C:/path/to/SDL2/cmake
cmake --build build --config Release# Build with Vulkan + Slang backend
cmake -B build -S . \
-DENABLE_SLANG=ON \
-DSlang_ROOT=C:/path/to/slang/build/Release \
-DENABLE_VULKAN_SLANG=ON \
-DSDL2_DIR=C:/path/to/SDL2/cmake \
-DVULKAN_SDK=C:/path/to/VulkanSDK/version
cmake --build build --config Release# Build with both DXR and Vulkan Slang backends
cmake -B build -S . \
-DENABLE_SLANG=ON \
-DSlang_ROOT=C:/path/to/slang/build/Release \
-DENABLE_DXR_SLANG=ON \
-DENABLE_VULKAN_SLANG=ON \
-DSDL2_DIR=C:/path/to/SDL2/cmake \
-DVULKAN_SDK=C:/path/to/VulkanSDK/version
cmake --build build --config ReleaseENABLE_SLANG=ON- Enable Slang shader compilation support (required for Slang backends)Slang_ROOT=<path>- Path to Slang build directory (e.g.,C:/dev/slang/build/Release)ENABLE_DXR_SLANG=ON- Build DXR backend with Slang shaders (Windows only)ENABLE_VULKAN_SLANG=ON- Build Vulkan backend with Slang shaders (Windows only)
Note: The Slang_ROOT should point to the Slang build directory containing the compiled binaries and headers. The Slang DLL will be automatically copied to the executable directory during the build process.
After building, run ChameleonRT with the Slang-enabled backends:
# Using DXR with Slang shaders
./chameleonrt.exe dxr path/to/scene.obj
# Using Vulkan with Slang shaders
./chameleonrt.exe vulkan path/to/scene.objThe Slang-based backends use the same command-line interface as the original backends, with shader compilation handled transparently by Slang at runtime or build time.
The currently implemented backends are: Embree, DXR, OptiX, Vulkan, and Metal. When running the program, you can pick which backend you want from those you compiled with on the command line. Running the program with no arguments will print help information.
./chameleonrt <backend> <mesh.obj/gltf/glb>
All five ray tracing backends use SDL2 for window management
and GLM for math.
If CMake doesn't find your SDL2 install you can point it to the root
of your SDL2 directory by passing -DSDL2_DIR=<path>. GLM will be automatically
downloaded by CMake during the build process.
To track statistics about the number of rays traced per-second
run CMake with -DREPORT_RAY_STATS=ON. Tracking these statistics can
impact performance slightly.
ChameleonRT only supports per-OBJ group/mesh materials, OBJ files using per-face materials can be reexported from Blender with the "Material Groups" option enabled.
To build with PBRT file support set the CMake option CHAMELEONRT_PBRT_SUPPORT=ON and pass
-DpbrtParser_DIR=<path> with <path> pointing to the CMake export files for
your build of Ingo Wald's pbrt-parser.
Dependencies: Embree 4, TBB and ISPC.
To build the Embree backend run CMake with:
cmake .. -DENABLE_EMBREE=ON \
-Dembree_DIR=<path to embree-config.cmake> \
-DTBB_DIR=<path TBBConfig.cmake> \
-DISPC_DIR=<path to ispc>
You can then pass embree to use the Embree backend. The TBBConfig.cmake will
be under <tbb root>/cmake, while embree-config.cmake is in the root of the
Embree directory.
Dependencies: Embree 4, TBB and Intel's oneAPI toolkit and the nightly SYCL compiler. Currently (4/4/2023) the Embree4 + SYCL backend requires the 20230304 nightly build of the oneAPI SYCL compiler and the latest Intel Arc GPU drivers. I have tested with driver version 31.0.101.4255 on Windows, it seems that the Ubuntu drivers are on an older version with their last release showing as being in Oct 2022. The regular oneAPI Base Toolkit is also required to provide additional library dependencies, and the build must be run within the oneAPI tools command line (or with the build environment scripts source'd).
After opening the oneAPI command prompt you can start powershell within it, then to build the Embree4 + SYCL backend run CMake with:
cmake .. -G Ninja `
-DCMAKE_C_COMPILER=<path to dpcpp nightly>/bin/clang.exe `
-DCMAKE_CXX_COMPILER=<path to dpcpp nightly>/bin/clang++.exe `
-DENABLE_EMBREE_SYCL=ON `
-Dembree_DIR=<path to embree-config.cmake> `
-DTBB_DIR=<path TBBConfig.cmake>
cmake --build . --config relwithdebinfo
You can then pass embree_sycl to use the Embree4 + SYCL backend. The TBBConfig.cmake will
be under <tbb root>/cmake, while embree-config.cmake is in the root of the
Embree directory.
Note that building the Embree4 + SYCL backend is currently incompatible with OptiX since the compiler is not supported by CUDA. You can simply build the OptiX backend (or the Embree4 + SYCL) backend in a separate build directory to get builds of both.
Dependencies: OptiX 7.2, CUDA 11.
To build the OptiX backend run CMake with:
cmake .. -DENABLE_OPTIX=ON
You can then pass optix to use the OptiX backend.
If CMake doesn't find your install of OptiX you can tell it where
it's installed with -DOptiX_INSTALL_DIR.
If you're on Windows 10 1809 or higher, have the latest Windows 10 SDK installed and a DXR capable GPU you can also run the DirectX Ray Tracing backend.
To build the DXR backend run CMake with:
cmake .. -DENABLE_DXR=ON
You can then pass dxr to use the DXR backend.
Dependencies: Vulkan (SDK 1.2.162 or higher)
To build the Vulkan backend run CMake with:
cmake .. -DENABLE_VULKAN=ON
You can then pass vulkan to use the Vulkan backend.
If CMake doesn't find your install of Vulkan you can tell it where it's
installed with -DVULKAN_SDK. This path should be to the specific version
of Vulkan, for example: -DVULKAN_SDK=<path>/VulkanSDK/<version>/
Dependencies: Metal and a macOS 11+ device that supports ray tracing.
To build the Metal backend run CMake with:
cmake .. -DENABLE_METAL=ON
You can then pass metal to use the Metal backend.
Dependencies: OSPRay 2.0, TBB.
To build the OSPRay backend run CMake with:
cmake .. -DENABLE_OSPRAY=ON -Dospray_DIR=<path to osprayConfig.cmake>
You may also need to specify OSPRay's dependencies, ospcommon and OpenVKL, depending on how you got or built the OSPRay binaries. If you downloaded the OSPRay release binaries, you just need to specify that path.
You can then pass ospray to use the OSPRay backend.
If you use this Slang-integrated fork in your work, please cite both this fork and the original ChameleonRT:
@misc{chameleonrt-slang-fork,
author = {Krishnan, C. R.},
year = {2025},
howpublished = {\url{https://github.com/krishnancr/ChameleonRT}},
title = {{ChameleonRT - Slang Integration Fork}},
note = {Fork of ChameleonRT with Slang shader language support for DXR and Vulkan}
}Please also cite the original ChameleonRT project:
@misc{chameleonrt,
author = {Will Usher},
year = {2019},
howpublished = {\url{https://github.com/Twinklebear/ChameleonRT}},
title = {{ChameleonRT}}
}This fork builds upon the excellent foundation provided by Will Usher's ChameleonRT. The Slang integration demonstrates the power of unified shader languages for cross-platform ray tracing development.
