r/GraphicsProgramming • • Mar 05 '26

Video Built a real-time PBR renderer from scratch in Rust/WebGPU/WASM

Built a real-time PBR renderer from scratch in Rust/WASM, running entirely in the browser via WebGPU.

I am in love with Rust + WebGPU + WASM!

Cook-Torrance BRDF · GGX specular · Fresnel-Schlick · HDR IBL (prefiltered env + irradiance + BRDF LUT) · PCF shadow mapping · GTAO ambient occlusion · bloom · FXAA · chromatic aberration · tone mapping · glTF 2.0 (metallic-roughness + specular-glossiness + clearcoat + sheen + anisotropy + iridescence + transmission) · progressive texture streaming.

371 Upvotes

20 comments sorted by

16

u/jalopytuesday77 Mar 05 '26

Thats a thing of beauty! Great work! Runs like butter too!

7

u/cleverredditjoke Mar 05 '26

wow thats super cool, do you have a link to your repo?

6

u/cihanozcelik Mar 05 '26

I built this for a web based customized cad project. Maybe in the future.

4

u/cleverredditjoke Mar 05 '26

Oh I see, no worries, good luck with that!

1

u/Horror-Drawer-3895 Jun 26 '26

can you like, give me the source code? pls, I'm building my own thing, and I don't wanna work with webgpu from scratch...

5

u/geon Mar 05 '26

Is it entirely rasterized? I couldn’t see any refraction.

8

u/cihanozcelik Mar 05 '26

Good catch — I missed that when recording the video. It does support refraction, the ship in a bottle was downloaded from Sketchfab where refraction settings are tweaked in their editor but don't get exported in the glb file. Here's DragonAttenuation with full volume refraction running in the engine: https://imgur.com/a/yI3CvZ6

3

u/zshift Mar 05 '26

Incredible! When implementing the different techniques in rust, what were the pain points you ran into?

8

u/cihanozcelik Mar 05 '26

Thanks! Honestly the techniques are nothing new, Khronos has reference implementations for most of it. The hard part was Rust. I'm still fairly new to it and it's a very different way of thinking compared to JS. You have to be explicit about who owns what, how long it lives, whether it's shared or not. Things that would be a one-liner in JS can get surprisingly verbose, but it catches real bugs at compile time that you'd only discover at runtime in JS.

But once it clicks you stop fighting it and start appreciating it. Especially when you're doing real-time stuff.

3

u/gibson274 Mar 05 '26

This is freaking beautiful, amazing work!

I’ve been digging rust recently too. Would love to see it be the foundation for the next big real-time engine.

4

u/cihanozcelik Mar 05 '26

Wow, thanks! But nothing new here, really. The Khronos sample viewer is open source and contains most of the math, algorithms, and implementation details behind these techniques.

Much respect to the computer scientists and researchers who developed the techniques and mathematics behind them.

2

u/TrishaMayIsCoding Mar 09 '26

Nice nice.. any good reading or reference link on your implementation ?

2

u/cihanozcelik Mar 09 '26

Thanks! Khronos sample viewer source code and Sketchfab blog posts abut their pbr implementation.

3

u/winterpeach355 Mar 05 '26

I didn’t know you were a mega chad.

1

u/tebjan Mar 06 '26

Is Claude Code?

2

u/[deleted] Mar 06 '26

[removed] — view removed comment

1

u/cihanozcelik Mar 06 '26

Thanks! Reddit and LinkedIn probably. I will be posting about the real project that this renderer is built for.