Git Product home page Git Product logo

raytracer's Introduction

Ray Tracer

A simple ray tracer following the amazing tutorial by Peter Shirley et al. "Ray Tracing in One Weekend". Implementation is done in Rust.

Examples

Runtime Performance

Rendering the final scene (1200x675 image with 500 samples per pixel and 50 max depth) on an AMD Ryzen 9 5900HX CPU and 16GB of RAM:

Implementation Time
Rust (multi-threaded) 2min 21sec
Rust (single-threaded) 16min 53sec
C++ (single-threaded) 27min 31sec
  • Multi-threading in Rust is done through Rayon, which shows an excellent scaling on an 8-core CPU. The current code is multi-threaded, and the single-threaded code can be obtained by changing into_par_iter to into_iter and ParallelProgressIterator to ProgressIterator inside camera.rs.
  • The C++ is the reference implementation complied with GCC 11.4 (which was ~10% faster than the code complied with Clang 14). This implementation prioritizes simplicity and having fewer dependencies over performance.
  • A notable difference between the implementations is that the C++ one uses float64 while I use float32 in Rust. Further, the C++ implementation allows the same material to be referenced by more than one object in the scene.

raytracer's People

Contributors

meshal-h avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.