c-ray is a small, simple path tracer written in C
A portable, hackable, embeddable software path tracer.
(1000 samples, 1920x1080, 512 max bounces, 26min, scene by Scott Graham)
(256 samples, 2560x1440, 12 max bounces, 9min 37s, scene by MaTTeSr)
(512 samples, 2560x1600, 30 max bounces, 8min)
c-ray is a portable, hackable, offline CPU rendering engine built for learning. The core is in plain C99, with an emphasis on clarity and avoiding superfluous abstraction. Contributions are welcome. See the contributing section in the wiki for more details.
An incomplete list of features:
Things I’m looking to implement:
c-ray has been verified to work on the following architectures
A basic driver program can be used to run c-ray standalone (see ‘Stand-alone usage’ below), but the easiest way to try out c-ray is to build and install the Blender add-on, and trying it out there:
BLENDER_ROOT
in lib.mk
, make sure it points to the version of Blender you have installedmake fullblsync
will then compile the python bindings (cray_wrap.so
), and install under BLENDER_ROOT
as an add-on.c-ray for Blender
as your render engine.You can run the integrated test suite by invoking the test script like this:
./run-tests.sh
This will compile c-ray with the correct flags, and then run each test individually in separate processes. If you want to run them in a shared process, do
bin/c-ray --test
You can also run a single suite
./run-tests.sh mathnode
You can mostly ignore these instructions below if you’re only interested in running c-ray as a Blender add-on.
Linux:
make
to build the projectcmake .
and then try make
again.bin/c-ray input/hdr.json
. You can also pipe files into c-ray
and it will read from there. This is useful for scripts that invoke c-ray
.cat input/scene.json | bin/c-ray
stdin
, c-ray assumes that the asset path is ./
. This can be specified with --asset-path
macOS:
mkdir build && cd build && cmake -G Xcode ..
Windows:
Developer Command Prompt for VS 2019
, navigate to where you cloned c-ray and set path to SDL2DIR (where you extracted the files to, should have a few folders like ‘include’ and ‘lib’): set SDL2DIR=E:\sdl2\SDL2-devel-2.0.8-VC\SDL2-2.0.8
cmake -G "Visual Studio 16 2019" .
SDL2.dll
into bin\Release\
and bin\Debug\
msbuild c-ray.sln /p:Configuration=Release
bin\Release\c-ray.exe input\scene.json
or type input\scene.json | bin\Release\c-ray.exe
All the .json files in input/
are test scenes provided with c-ray, assets for those scenes are (mostly) bundled with the repository as well.
If you make a cool scene and have Python3 installed, you can bundle up the scene into a portable .zip file using the scripts/bundle.py
script.
3rd party libraries included in this project include:
Please file an issue detailing any improvements you’re planning on making. I openly welcome contributions!
You can also ping me on Discord: vkoskiv#3100