[HN Gopher] Show HN: a Rust ray tracer that runs on any GPU - ev...
       ___________________________________________________________________
        
       Show HN: a Rust ray tracer that runs on any GPU - even in the
       browser
        
       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.
        
       Author : tchauffi
       Score  : 77 points
       Date   : 2025-11-03 13:45 UTC (9 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | WhitneyLand wrote:
       | 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.
        
         | tchauffi wrote:
         | Thanks! It should work on mobile, you can hide the right panel
         | using the button at the bottom of the screen. That said,
         | performance on mobile is pretty limited because of hardware
         | limitations.
        
           | jasonjmcghee wrote:
           | performance was 60fps on my phone / worked fine, but as
           | parent said - the sidebar covers 90% of the screen. Worth
           | collapsing by default imo.
        
       | goodpoint wrote:
       | It does not run: "unreachable executed"
        
         | tchauffi wrote:
         | Maybe your browser do not support webgpu. Try using Chrome.
        
       | knowhistory wrote:
       | https://www.jsweet.org/examples/#Ray_tracer
       | 
       | Written in Java then transpiled to JavaScript, been around for
       | years.
        
         | nogridbag wrote:
         | The OP is real time ray tracing which is running between
         | 30-60FPS on my macbook air while moving the camera and objects
         | around.
         | 
         | 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.
        
       | gunalx wrote:
       | Dosent work in firefox, because of missing webgpu.
        
         | tormeh wrote:
         | Works on mobile Firefox Nightly
        
       | swiftcoder wrote:
       | 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.
        
         | tormeh wrote:
         | Demonstrates how important it is to match the scenes with the
         | rendering techniques. You can easily create a corridor with a
         | light at one end that requires lots of bounces for the light to
         | get to the end. But in a game you can just decide to not create
         | that kind of scene. Cyberpunk 2077 basically has no rooms
         | without direct light in them, which makes the game look good
         | even without ray tracing.
        
         | Maken wrote:
         | That's why virtually every renderer stochastically discards
         | indirect paths with low contribution. Looking at the source
         | code, this one computes every subsequent bounce, even those
         | hitting the perfectly blue sphere after hitting the perfectly
         | green one.
        
       | eek2121 wrote:
       | In Firefox, open about:config and set this to true:
       | `dom.webgpu.enabled`.
        
         | nomel wrote:
         | In Safari < 26:
         | 
         | Settings... -> Advanced -> tick Show features for web
         | developers
         | 
         | Settings... -> Feature Flags -> tick WebGPU*
        
       | skrrtww wrote:
       | 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!
        
         | almostgotcaught wrote:
         | works for me just fine on 26; i get
         | 
         | ```
         | 
         | 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
        
         | iknowstuff wrote:
         | Works fine on M4. M1 didn't have mesh shaders, maybe that's
         | why?
        
       | CyberDildonics wrote:
       | _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.
        
         | cptroot wrote:
         | If you click into the code you can see that it depends on
         | `wgpu`, which is a wrapper that uses whichever native API would
         | be appropriate for the platform you're working with. If you run
         | the native compiled version you won't be using WebGPU.
        
           | CyberDildonics wrote:
           | wgpu is based on webgpu, what is your point here?
           | 
           | 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?
        
       | _bent wrote:
       | Why did you call the project rasterizer when it is not using
       | rasterization but raytracing?
        
         | SR2Z wrote:
         | Rasterization is just the process of converting an image to a
         | raster, which you also have to do in raytracing. It does sound
         | strange though.
        
       ___________________________________________________________________
       (page generated 2025-11-03 23:01 UTC)