├── emscripten.bash ├── README.md ├── javascript.html ├── shader.html ├── javascript.js ├── shader.js ├── emscripten.cpp ├── emscripten.html └── LICENSE /emscripten.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ~/emscripten/emsdk activate latest 4 | 5 | source ~/emscripten/emsdk_env.sh 6 | 7 | emcc -O2 --memory-init-file 0 -s WASM=0 --bind -s MODULARIZE=1 -s EXPORT_NAME="'Assembly'" -s EXTRA_EXPORTED_RUNTIME_METHODS="['cwrap', '_render', '_uniform1i', '_uniform1f', '_uniform3fv']" emscripten.cpp -o emscripten-asm.js 8 | emcc -O2 --memory-init-file 0 -s WASM=1 --bind -s MODULARIZE=1 -s EXPORT_NAME="'Webassembly'" -s EXTRA_EXPORTED_RUNTIME_METHODS="['cwrap', '_render', '_uniform1i', '_uniform1f', '_uniform3fv']" emscripten.cpp -o emscripten-wasm.js -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wasm-raytracer 2 | While teaching a web development class, I wanted to present some benchmarks that show the performance benefits of asm.js as well as WebAssembly. I was unfortunately not able to find a suitable reference. Therefore, I implemented a simplistic raytracer in JavaScript as well as in C++ with a similar code structure while utilizing Emscripten to compile the C++ raytracer to asm.js as well as WebAssembly. For fun, I also translated the code to GLSL and am utilizing WebGL to leverage GPU computing. 3 | 4 |
5 | 6 | For a live demo, please see: https://sniklaus.com/wasmray 7 |