Skip to content

egnchen/rustyray

Repository files navigation

rustyray

This is Ray Tracing in One Weekend implemented in Rust.

TODO

one weekend

  • Output an image
  • Vector utilities
  • Basic skybox rendering
  • Rendering a sphere in normal vectors
  • Rendering multiple spheres
  • Multi-sampling
  • Diffuse materials
  • Gamma correction filter
  • Reflective materials
  • Reflective materials with fuzziness
  • Dielectric materials
  • Positionable camera
  • Depth of field

next week

  • Motion blur
  • Bounding volume hierarchies
  • Various perlin noise texture
  • Image texture
  • Light sources
  • Rectangles
  • Fog objects
  • Volume
  • Instance translation
  • Instance rotation
  • Cornell box scene
  • Final scene

"One more thing"s

  • Scene configuration
  • Material configuration
  • Quality presets
  • Multi-threaded rendering
  • SIMD support
  • WASM support

Running the program

Prerequisites

There shouldn't be any limitation on the operating system you use as long as you have Rust toolchain installed on it. For those who doesn't have any experience in Rust, google for rustup.

Running

In the project directory, use cargo run --release to build the project. release is recommended here because it activates all compile-time optimizations, and ray traces are computationally-intensive programs.

$ cargo run --release -- -c RandomSpheresNightScene -p 2
    Finished release [optimized] target(s) in 0.62s
    Running `target\release\ray_tracer.exe -c RandomSpheresNightScene -p 2`
Start rendering scene RandomSpheresNightScene...
Configuration: Picture size = 768 * 512, sample = 1024, recursion depth = 16
Initializing threads... Thread count = 4
Thread 0 initiated
Thread 1 initiated
Thread 2 initiated
Thread 3 initiated
Thread 1 exit.
Thread 0 exit.
Thread 3 exit.
Thread 2 exit.
Done, time elapsed = 271.4306073s
Writing to out.png...

Which gives you this beautiful image(colors & materials are randomized):

Or the cornell box scene(render this with -c CornellBoxScene):

About

Multithreaded simple ray-tracer in Rust.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages