Posted by tchauffi 20 hours ago
The initial goal was just to render a simple 3D scene in the browser at a reasonable frame rate. It evolved into a small renderer that can: • Run locally or on the web using wgpu and WebAssembly • Perform mesh rendering with a Bounding Volume Hierarchy (BVH) for acceleration • Simulate both direct and indirect illumination for photorealistic results • Be deployed easily as a free web demo using GitHub Pages
The project is far from perfect, but it’s been a fun way to dig deeper into graphics programming and learn more about Rust’s ecosystem. I’m also planning to experiment with Rust for some ML projects next.
GitHub: https://github.com/tchauffi/rust-rasterizer Web demo (desktop browsers): https://tchauffi.github.io/rust-rasterizer/
Would love feedback from anyone who’s built similar projects or has experience with wgpu or ray tracing in Rust.
Settings... -> Advanced -> tick Show features for web developers
Settings... -> Feature Flags -> tick WebGPU*
In Chrome I get "Failed to start: Failed to create State. Caused by: failed to find GPU adapter."
So I guess it runs on "some" GPUs, in "some" browsers!
```
live_raytracer-bffaca82311af1dd.js:1484 Uncaught Error: Using exceptions for control flow, don't mind me. This isn't actually an error! at imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 (
```
but everything else is fine
I cannot run the demo on Firefox, but you might get better performance with an 8x4 thread group.
Also, mega-kernels of this sort are generally bad for occupancy. Wavefront path tracing improves this at the expense of additional IO and a more involved implementation. https://research.nvidia.com/publication/2013-07_megakernels-...
Overall your code looks easy to read. Too bad I couldn't run it.
Recommend taking a few minutes to make the web page work on mobile.
For example on iPhone the actual webgpu/ray tracing seems to work fine but html formatting is shoving things over to be barely visible.
Seems pretty clickbaity and dishonest when that's just what webgl and webgpu means. Just say webgpu.
Also the roughness doesn't apply to the environment map.
The title implies that the reason this exists is because it "runs on any gpu, even in the browser". People have been making raytracers using gpu apis in the browser over and over for the last decade.
That would be like someone claiming their program "multiplies huge matrices using SIMD" and then wrapping eigen. Why make a claim that is just happening because you call the same library as everyone else?
The irony is that it does not actually run on my GPU, nor much of other people's, judging by the comments. I don't know where people get this idea that WASM and WebGPU are the holy grail of portability; they are the opposite and the whole ecosystem is a fucking disaster. No offense to OP, though; I can understand the temptation to target that platform.
Anyway, I left more positive feedback in another comment.
Written in Java then transpiled to JavaScript, been around for years.
Your link appears to be a basic ray tracer which anyone who has taken an intro to computer graphics course in college is likely required to implement and would only need a javascript canvas. To be honest I have no idea how much OPs real-time ray tracing differs in complexity from traditional ray tracing.