C Ray

c-ray is a small, simple path tracer written in C
Alternatives To C Ray
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Json35,02782 days ago11August 22, 2022100mitC++
JSON for Modern C++
3 days ago657otherC++
A fast JSON parser/generator for C++ with both SAX/DOM style API
Cjson8,84613 days ago1March 03, 2021170mitC
Ultralightweight JSON parser in ANSI C
Poco7,06315 days ago6August 09, 2022267otherC
The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.
Json C2,648152 months ago1February 27, 201833otherC
https://github.com/json-c/json-c is the official code repository for json-c. See the wiki for release tarballs for download. API docs at http://json-c.github.io/json-c/
8 hours ago426gpl-2.0C++
Widelands is a free, open source real-time strategy game with singleplayer campaigns and a multiplayer mode. The game was inspired by Settlers II™ (© Bluebyte) but has significantly more variety and depth to it.
3 months ago24mitC
Your high performance web application C framework
C Ray680
7 days ago17mitC
c-ray is a small, simple path tracer written in C
Json Schema Validator386
12 days ago1May 17, 202127otherC++
JSON schema validator for JSON for Modern C++
5 days ago20bsd-3-clauseC
YANG data modeling language library
Alternatives To C Ray
Select To Compare

Alternative Project Comparisons

Example renders

(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)


Build Status justforfunnoreally.dev badge


C-ray is a research oriented, hackable, offline CPU rendering engine built for learning. The source code is intended to be readable wherever possible, so feel free to explore and perhaps even expand upon the current functionality. See the contributing section in the wiki for more details.

C-ray currently has:

  • Cluster rendering support (on *nix systems)
  • A node-based material system
  • A simple unidirectional Monte Carlo integrator
  • Real-time render preview using SDL2
  • Easy scene compositing using a JSON interface
  • Multithreading (using pthreads or WIN32 threads)
  • Wavefront OBJ support
  • Object instancing
  • PNG and BMP file output
  • Two levels of BVH acceleration structures (by @madmann92)
  • Antialiasing (MSAA)
  • HDR environment maps for realistic lighting
  • Gouraud interpolated smooth shading
  • Benchmarking metrics

The default integrator supports:

  • Metal
  • Glass
  • Lambertian diffuse
  • Plastic
  • Triangles and spheres
  • Depth of field
  • Russian Roulette path optimization
  • Diffuse textures
  • Normal maps

Things I'm looking to implement:

  • Proper physically based materials in place of the current ad-hoc implementations
  • Built a more robust API with an interactive scene state.
  • Some procedural textures
  • Python API wrapper
  • Volumetric rendering
  • Subsurface scattering
  • Spectral rendering


C-ray has been verified to work on the following architectures

  • x86 & x86_64 (Primarily developed on x86_64)
  • ARMv6, ARMv7 and ARMv8 (Various Raspberry Pi systems)
  • PowerPC 7xx and 74xx (PowerPC G3 and G4 systems)
  • MIPS R5000 (1996 SGI O2)
  • SuperSPARC II (1992 SUN SparcStation 10)


Please see the Wiki for details on how to use the JSON scene interface.


  • CMake for the build system (Optional, a basic makefile is provided for *nix systems)
  • SDL2 (Optional, CMake will link and enable it if it is found on your system.)
  • Python3 (Optional, it's used for some utility scripts)
  • Standard C99/GNU99 with some standard libraries

All other dependencies are included as source


macOS: Either follow these instructions, or the instructions for Linux below. Both work fine.

  1. Install SDL2 (See installing SDL below)
  2. Open the .xcodeproj file in Xcode
  3. Edit scheme by clicking C-Ray in top left, make sure 'Use custom working directory' is ticked and set it to the root directory of this project.
  4. Go into the Arguments tab, and add by clicking +. Type in ./input/scene.json, then click close
  5. Build&Run with CMD+R


  1. (Optional) Install SDL2 (See installing SDL below)
  2. (Optional, this tends to work nicer) Run cmake ., or optionally cmake . -DNO_SDL2=True to disable SDL2.
  3. Run make to build the project
  4. Run binary: bin/c-ray input/scene.json (Making sure the working dir is the root directory). You can also pipe files into C-ray and it will read from there. This is useful for scripts that invoke C-ray. Example: cat input/scene.json | bin/c-ray Note: Reading the json from stdin assumes that the asset path is ./, can be specified with --asset-path


  1. Install Build Tools for Visual Studio
  2. Optional: Download SDL2 Development libaries from here and extract: https://www.libsdl.org/download-2.0.php (https://www.libsdl.org/release/SDL2-devel-2.0.8-VC.zip)
  3. Open a 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
  4. Run cmake: cmake -G "Visual Studio 16 2019" .
  5. (Optional) Copy your SDL2.dll into bin\Release\ and bin\Debug\
  6. Build the generated solution: msbuild c-ray.sln /p:Configuration=Release
  7. Run: 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.

Installing SDL

On macOS, use homebrew to install SDL. brew install sdl2

On Windows, download from https://www.libsdl.org/release/SDL2-devel-2.0.8-VC.zip

On Linux using APT, run sudo apt install libsdl2-dev


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

In either case, you will get a log of all the tests, and their status.


3rd party libraries included in this project

lodePNG PNG compression library: http://lodev.org/lodepng/

stb_image.h by Sean Barrett: https://github.com/nothings/stb/blob/master/stb\_image.h

SDL2: https://www.libsdl.org/index.php (Optional)

JSON parsing library: DaveGamble/cJSON

PCG random number generator: http://www.pcg-random.org


  • Huge thanks to @madmann91 for the new BVH accelerator and overall ~60% performance improvement!

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

Popular Json Projects
Popular Cmake Projects
Popular Data Formats Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Ray Tracing
Path Tracer