Skip to content

Simple ray tracer based off an online guide. Built with WebAssembly. [Demo inside]

License

Notifications You must be signed in to change notification settings

ngynkvn/wasm-raytracer

Repository files navigation

Raytracer 🔴

Based off https://www.gabrielgambetta.com/computer-graphics-from-scratch/introduction.html

Play with at https://unhealthy-vacation.surge.sh

Sample render

Requires LibPNG and png++ to run.

Used Emscripten / WASM and Vue.js for web rendering

Used C++ and LibPNG / png++ for image rendering

Raytracing is implemented C++ and compiled with the Emscripten toolchain to permit running on web.

To run

mkdir -p build

cd build

cmake ../

make

Outputs a binary named raytracer.

Run with ./raytracer < test.scene

Web assembly

Have the Emscripten SDK tools available to use from your terminal and simply run the two commands below:

make
make run

Should be viewable at localhost:8080

Technical details

This is kind of a hodgepodge of a lot of things that I was interested in playing with including but not limited to:

  • Raytracing and computer graphics
  • Javascript Canvas API's
  • VueJS
  • Communication and messaging between different programming environments / processes.
  • Parsing data into usable data structures.

Todo

  • 🚧 Add parameterization (both from command line and JS environment).
  • ✔️ Make a DSL for specifying the scene to render.
  • 🤔 Encoding + Decoding schemes
  • 🤔 Comparing different ways of wasm - native communications and performance benchmarking.
    • Compare speeds between native + wasm as rendering complexity increases (will need to enable flags for rendering techniques to use)