logoalt Hacker News

Show HN: a Rust ray tracer that runs on any GPU – even in the browser

80 pointsby tchauffiyesterday at 1:45 PM22 commentsview on HN

I’ve been experimenting with Rust lately and wanted a project that would help me explore some of its lower-level and performance-oriented features. Inspired by Sebastian Lague’s videos, I decided to implement my own ray tracer from scratch.

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.


Comments

eek2121yesterday at 4:03 PM

In Firefox, open about:config and set this to true: `dom.webgpu.enabled`.

show 1 reply
_bentyesterday at 6:05 PM

Why did you call the project rasterizer when it is not using rasterization but raytracing?

show 1 reply
skrrtwwyesterday at 5:03 PM

In Safari 26 on an M1 with WebGPU enabled I get "InvalidStateError: GPUCommandEncoder.beginComputePass: Unable to begin compute pass."

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!

show 3 replies
swiftcoderyesterday at 4:03 PM

Very cool. Enjoyed playing with the "bounces" slider - it's fascinating how little improvement each additional bounce contributes after about 3 bounces. Severely diminishing returns in terms of the final image quality.

show 2 replies
WhitneyLandyesterday at 3:23 PM

It looks cool, nice project.

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.

show 1 reply
gunalxyesterday at 3:57 PM

Dosent work in firefox, because of missing webgpu.

show 1 reply
goodpointyesterday at 3:33 PM

It does not run: "unreachable executed"

show 1 reply
CyberDildonicsyesterday at 5:09 PM

runs on any GPU – even in the browser

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.

show 1 reply
knowhistoryyesterday at 3:49 PM

https://www.jsweet.org/examples/#Ray_tracer

Written in Java then transpiled to JavaScript, been around for years.

show 1 reply