The joy of building a ray tracer, for fun, in Rust

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • lisp-sandbox

  • When I wrote my ray tracer, I set up a simple websocket server to stream pixels to a canvas element.[1] itโ€™s a trivial way to do this without a ton of GUI code.

    [1]: https://github.com/fiddlerwoaroof/lisp-sandbox/blob/master/r...

  • tev

    High dynamic range (HDR) image viewer for graphics people

  • In the decade I spent working on RenderMan at Pixar, I learned just how immensely useful it was to have an image viewer running in a separate process talking to the renderer over a socket or pipe. (The Image Tool, or "It" is RenderMan's viewer.) Having it stay up even if you kill the render or it crashes for some reason and being able to flip back and forth to easily compare test renders across recompiles is game changing.

    If I were to start writing a new renderer, the first thing I'd do is to hook it up to an external image viewer over some protocol. These days, I find myself liking TEV (https://github.com/Tom94/tev) a lot as a simple open-source image viewer that supports this. See the links in the README for Python and Rust implementations of its protocol.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • RayTracingWeekend.jl

    Ray Tracing in a week-end, implemented in Julia

  • keikan

    An elegant (imo) rendering engine written in Rust.

  • Oh, I did something like this a while back as well! Aside from ray tracing, my renderer also supports ray marching, so it can render some cool fractals[1]. Writing path tracers is so much fun, love the write-up!

    [1]: https://github.com/slightknack/keikan#readme

  • raytracer-exp

    A simple raytracer built as an exercise to learn some Rust

  • I took a bit of time over the summer to familiarize myself with the language by writing a (super simple) ray tracer.

    https://github.com/mschaef/rust-rt

    After spending as much time lately as I have in Scala and Python, my immediate reaction to Rust was quite positive. Python has performance issues from 1985 and the build ecosystem seems borderline chaotic. (Made me seriously miss Maven, etc.) Scala seems a lot like C++ - an amazing intellectual accomplishment, a great place to spend all of your time, but not so good as a part time language. (I spend a bunch of my time in Scala mentally expanding out shorthand notation the way I might be mentally macroexpanding in a Lisp.)

    Rust, in contrast, seems to have struck a nice balance between expressive power and runtime performance. Expressively, it has a lot of what I like about Scala with a syntax that makes more sense to my C-style upbringing. Performance seems to be everything I'd expect from the fully compiled language that it is. (In terms of performance, there's no way Python would've let me get away with some of what I got away with in my Rust ray tracer.)

    Given that the language gave such a positive initial impression, the questions I still have are more about what it feels like in the large. ie: Working with a significantly sized team jointly on a codebase that might last 1, 5, 10 or more years. (Even then, I'm pretty optimistic.)

  • minifb

    MiniFB is a small cross platform library to create a frame buffer that you can draw pixels in

  • the-ray-tracer-challenge-fsharp

    F# implementation of the ray tracer found in The Ray Tracer Challenge by Jamis Buck

  • Yes, the book has both implementations of the required functions (for all the complicated ones you need) and tests all written in pseudocode.

    The book is really good. I have a half-finished implementation in F#, and what I find striking is just how close the F# code is to the pseudocode. I have also started an idiomatic port to Racket but have only done the tuples, vector, and point implementations so far. I need to pick these up again.

    https://github.com/bmitc/the-ray-tracer-challenge-fsharp

    https://github.com/bmitc/the-ray-tracer-challenge-racket

    I mean, check this out: https://github.com/bmitc/the-ray-tracer-challenge-fsharp/blo...

    I have also worked through pieces of Ray Tracing in One Weekend (what was referenced in this post). They get you going much faster, but the code is written in C++. I found the translation to a functional style was harder (was just using Racket and F#'s mutability features), whereas the way The Ray Tracer Challenge is laid out and specified, I found it much easier to translate to an idiomatic functional style.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • the-ray-tracer-challenge-racket

    Racket implementations of the ray tracer found in The Ray Tracer Challenge book by Jamis Buck.

  • Yes, the book has both implementations of the required functions (for all the complicated ones you need) and tests all written in pseudocode.

    The book is really good. I have a half-finished implementation in F#, and what I find striking is just how close the F# code is to the pseudocode. I have also started an idiomatic port to Racket but have only done the tuples, vector, and point implementations so far. I need to pick these up again.

    https://github.com/bmitc/the-ray-tracer-challenge-fsharp

    https://github.com/bmitc/the-ray-tracer-challenge-racket

    I mean, check this out: https://github.com/bmitc/the-ray-tracer-challenge-fsharp/blo...

    I have also worked through pieces of Ray Tracing in One Weekend (what was referenced in this post). They get you going much faster, but the code is written in C++. I found the translation to a functional style was harder (was just using Racket and F#'s mutability features), whereas the way The Ray Tracer Challenge is laid out and specified, I found it much easier to translate to an idiomatic functional style.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts