All Projects → sniklaus → wasm-raytracer

sniklaus / wasm-raytracer

Licence: GPL-3.0 license
a performance comparison of a simple raytracer in JavaScript, asm.js, WebAssembly, and GLSL

Programming Languages

HTML
75241 projects
javascript
184084 projects - #8 most used programming language
C++
36643 projects - #6 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to wasm-raytracer

Glchaos.p
3D GPUs Strange Attractors and Hypercomplex Fractals explorer - up to 256 Million particles in RealTime
Stars: ✭ 590 (+273.42%)
Mutual labels:  glsl, emscripten
Ouzel
C++ game engine for Windows, macOS, Linux, iOS, tvOS, Android, and web browsers
Stars: ✭ 607 (+284.18%)
Mutual labels:  glsl, emscripten
Webassembly Raytracer
a performance comparison of a simple raytracer in JavaScript, asm.js, WebAssembly, and GLSL
Stars: ✭ 102 (-35.44%)
Mutual labels:  glsl, emscripten
glisph
Glyph rendering engine using OpenGL shading language for Common Lisp.
Stars: ✭ 32 (-79.75%)
Mutual labels:  glsl
NobleRT
A Minecraft shaderpack that enhances one's experience with the help of good-looking graphics and light simulations.
Stars: ✭ 76 (-51.9%)
Mutual labels:  glsl
webgl
http://gam0022.net/webgl/
Stars: ✭ 43 (-72.78%)
Mutual labels:  emscripten
rogue.js
JavaScript porting of original Rogue source code using Emscripten
Stars: ✭ 33 (-79.11%)
Mutual labels:  emscripten
rust-tracer
Simple Ray tracer written in Rust
Stars: ✭ 14 (-91.14%)
Mutual labels:  raytracer
FNode
Tool based in nodes to build GLSL shaders without any programming knowledge written in C using OpenGL and GLFW.
Stars: ✭ 81 (-48.73%)
Mutual labels:  glsl
C-Raytracer
A CPU raytracer from scratch in C
Stars: ✭ 49 (-68.99%)
Mutual labels:  raytracer
glsl-editor
💾 A simple WebGL shader editor
Stars: ✭ 20 (-87.34%)
Mutual labels:  glsl
alia
a declarative UI library for C++
Stars: ✭ 76 (-51.9%)
Mutual labels:  emscripten
ofxShadertoy
Addon for openFrameworks that sets up and loads Shadertoy (http://www.shadertoy.com) shaders
Stars: ✭ 77 (-51.27%)
Mutual labels:  glsl
Voxel Cone Tracing
Converting vertex meshes to voxel data and visualizing using VCT
Stars: ✭ 74 (-53.16%)
Mutual labels:  raytracer
qml-glsl-coder
live editor of GLSL fragment shaders based on Qt / QML
Stars: ✭ 19 (-87.97%)
Mutual labels:  glsl
osgw
Real-Time Ocean Animation with Gerstner Waves
Stars: ✭ 51 (-67.72%)
Mutual labels:  glsl
ModularMusicVisualizer
Project in Hiatus, unmaintained, being rewritten privately. Will Open Source when stuff is ready. Project will be Renamed.
Stars: ✭ 81 (-48.73%)
Mutual labels:  glsl
frag3d.js
WebGL shader tools
Stars: ✭ 58 (-63.29%)
Mutual labels:  glsl
glNoise
A collection of GLSL noise functions for use with WebGL with an easy to use API.
Stars: ✭ 185 (+17.09%)
Mutual labels:  glsl
webassembly-webgl-shaders
Demo project for using WebGL shaders in WebAssembly
Stars: ✭ 107 (-32.28%)
Mutual labels:  glsl

wasm-raytracer

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.

Screenshot

For a live demo, please see: https://sniklaus.com/wasmray
For a discussion, see Reddit: https://www.reddit.com/r/programming/comments/7k4v5t/

benchmark

Unsurprisingly, the version using GLSL / Shader is significantly faster than the others, showing that it is always important to use the right technology for the right purpose. However, this was not the point of this experiment. Instead, it shows how WebAssembly can potentially be used for an improved performance. To accelerate WebAssembly further, threads could be leveraged. Of course, one could make the argument that a different task could have shown the performance advantages of WebAssembly better. However, I also simply wanted to implement a raytracer.

Browser JavaScript asm.js WebAssembly GLSL / Shader
Firefox 57 ~407.3 ms ~112.3 ms ~87.4 ms ~1.9 ms
Firefox 58 ~358.9 ms ~103.2 ms ~82.7 ms ~1.9 ms
Chrome 62 ~191.7 ms ~167.2 ms ~115.7 ms ~2.1 ms
Chrome 63 ~181.4 ms ~154.2 ms ~120.7 ms ~2.2 ms

Note that the JavaScript performance of Firefox 57 is significantly affected by a bug that has since been fixed. One might also wonder why asm.js in Chrome is slower than JavaScript, which is due to Chrome not having accelerated support for asm.js in the first place.

license

Please refer to the appropriate file within this repository.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].