Skip to content

Raytracer in a Weekend series implemented in a few different languages

Notifications You must be signed in to change notification settings

bzztbomb/raytracer_in_every_language

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

Ray Tracer in Every Language

The goal of this project is to implement the ray tracer described in the mini books Ray Tracing in One Weekend and Ray Tracing the Next Week in languages I don't use all of the time but I am interested in learning more about. I've only done Python and Rust so far, but on the horizon are:

  • Go
  • Ruby
  • Racket
  • ChezScheme

Rust

Final

Been meaning to learn Rust for a while, this was a fun project to use for it. The borrow checker isn't as bad as people say, and if you want to not think about it too much, just make everything reference counted with Arc<>/Rc<>, heh. I was able to add threading very easily with the Rayon crate. I also took a quick detour and made a WebAssembly port of the raytracer using RustWasm. I haven't maintained it, so you may need to go back a few commits if you want a working version. Overall, I enjoyed writing code in Rust and hope to do more in the future.

This time through I noticed a typo in the book for the final image, the metal sphere needs to have a fuzz of 1.0, not 10.0. 10.0 is basically diffuse. Also, in contrast the python version, I'm outputting PFM file in HDR and then viewing the results in HDRView so I could play with tonemapping and get away from my hack to bring everything down to 0..1 range.

Python

Cornell Final

This was a pretty straightforward port of the C++ code over to Python. I've used Python a bit, but I always feel like I'm just writing C in Python. With all of the machine learning libraries available for Python that I'm interested in I decided I wanted to try and dive deeper into it. Python seems pretty slow if you don't use numpy to accelerate everything. I did end up adding some parallelism via forking so that the render times were only days instead of weeks. I also had to avoid NAN situations that the C++ code just dealt with by being careful with the comparisons that were being done. The spots were in the Dielectric material and AABB hit function. But it was pretty pleasnt language to use. I would have liked to explore generators a bit more, but I'll find another project for that.

About

Raytracer in a Weekend series implemented in a few different languages

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published