Intro

Naive CPU Ray tracer implemented in Rust.

Features

  • multi-thread ray tracing
  • loading gltf and obj models
  • using Javascript to describe the scene
  • supporting microfacet brdf

Build

You can manually build or use Docker.

Manually build

  1. Install Rust toolchain
  1. Compile the project
cargo build -p toy_ray_tracer --release
  1. Running
mkdir -p output/cg
./target/release/toy_ray_tracer render --project-file=./assets/projects/cg/cornell_box.js -vvv
  1. Output

The output image is located in

Docker

  1. Run following command
docker buildx build . -t icstp-ray-tracer:v1
  1. Run the image
mkdir -p output/cg
docker run -v $(shell pwd)/output:/app/output icstp-ray-tracer:v1 render -vvv --project-file=assets/projects/cg/cornell_box.js

Usage

Example scene files are located in dir assets/projects/cg/**

Render

Rendered images will be put into output dir

# -vvv to show the progress
mkdir -p output/cg
./target/release/toy_ray_tracer render --project-file=<scene-file> -vvv

Demo

cornell_box

rtw_scene2

Inspired By

Thanks to the following projects