Shade - WebGPU graphics

Working on shadows. I looked into various shadow mapping techniques, including virtual shadow maps. I was originally going to go for virtual shadow maps, but after working on them for a while, I came to a realization that they are very complex and it’s difficult to avoid drawing parts of the scene multiple times. I didn’t like that, and I didn’t like the complexity involved.

For the past few days I’ve been dusting off my path tracing code from meep when I was working on global illumination and with a little bit of effort I got ray tracing to work.

Here are a few shots with ray-traced shadows:

Here’s are a few close-ups:



Here’s an even closer zoom on the spider’s leg:



As you can see - shadows are pixel-perfect and there’s no peterpanning going on.

All in all - I’m pretty happy with the results. Performance seems to be a bit of an issue as my BVH traversal was not optimized for GPU. My path tracer was originally written for the CPU, and it shows :slight_smile:

That said, performance is okay in most scenes. I feel this is a good approach overall, even if there is no RTX api available in WebGPU at the moment. We can get within ~20% of the dedicated API’s performance, according to some numbers I read in an Intel paper a while ago. And considering that hard shadows only require a single ray per pixel - it’s quite cheap.

I’m thinking to add SDF and ray marched shadows later on, as that should be significantly cheaper and it’s proven to work well in production as Unreal have been using that tech for a number of years now.

The goal is to offer shadowing solution that requires no tweaking and looks good, and I think I’m close to achieving that already.

PS

For sharp-eyed of you, you’ll notice that some of the screenshots show 42 FPS, that was a software cap I introduced for prototyping, to keep my room a bit less hot.

Why 42? - why not? :person_shrugging:

8 Likes