A deep dive into implementing surfel-based global illumination in WebGPU, showcasing how advanced rendering techniques are becoming accessible on the web through clever approximations and optimizations.
The web graphics landscape is undergoing a quiet revolution. What was once limited to simple triangle rendering is now pushing the boundaries of real-time global illumination, with surfel-based techniques leading the charge. This approach, once confined to high-end game engines and research papers, is now making its way into browsers through the power of WebGPU.
The trend is clear: developers are increasingly bringing sophisticated graphics techniques to the web. Surfel-based global illumination, presented at SIGGRAPH 2021 by EA's SEED research division and recently adapted for the web by Jure Triglav, represents a significant step forward. This technique decouples lighting from screen resolution, allowing developers to achieve rich, dynamic indirect lighting in real-time even on modest hardware.
The evidence of this shift is compelling. Triglav's implementation demonstrates that a complex 13+ compute pass pipeline can run at 60fps on reasonably complex scenes directly in the browser. The project includes interactive visualizations that allow users to explore each component of the pipeline, from surfelization to the final resolve pass. This level of transparency and interactivity is becoming increasingly common in web-based graphics projects, suggesting a maturation of both the technology and the community around it.
However, this transition isn't without challenges. The implementation battles against browser limitations, particularly Chrome's restriction of only 10 storage buffers per compute pass. This forced creative solutions like using read-write float storage textures instead of buffers, which then created compatibility issues with other browsers. Such constraints highlight the tension between innovation and platform limitations that web developers constantly navigate.
Counter-perspectives to the optimism around web-based advanced graphics are worth considering. Some argue that these techniques remain impractical for production due to performance constraints on lower-end devices and the lack of hardware ray tracing support. The current implementation is limited to static geometry's diffuse reflections from a single directional light and environment map, without specular reflections, transparency, or ambient occlusion. Additionally, the system struggles with fast-moving lights, high-frequency detail, and thin geometry.
Despite these limitations, the community sentiment appears largely positive. The fact that such a complex pipeline works at all in a browser is seen as a significant achievement. The project's GitHub repository has garnered interest, and the live demo runs successfully across multiple browsers, including mobile Safari. This suggests that while the technology may not be production-ready for all use cases, it's rapidly advancing and inspiring further experimentation.
The surfel-based approach offers several advantages over traditional global illumination techniques. By using surfels (surface elements represented as position, normal, and radius), the system can cache expensive lighting calculations across frames, decoupling lighting from screen resolution. This allows for efficient representation of indirect lighting even with limited computational resources.
The pipeline itself is a marvel of engineering:
- Surfelization: Converting geometry into a collection of surfels through screen-space analysis
- Grid Building: Creating a cascaded 3D spatial index for efficient surfel lookup
- Integration: Ray tracing from each surfel to gather indirect lighting information
- Guiding: Using learned directional distributions to optimize sampling
- Temporal Stability: Implementing multi-scale mean estimation for stable results
- Light Leak Prevention: Using radial depth atlases to prevent incorrect light transmission
- Resolution: Transferring surfel irradiance to screen pixels
Each component addresses specific challenges in real-time rendering while maintaining interactivity. The guiding system, for example, balances exploration of new lighting information with exploitation of known bright regions, using a mixture of guided and cosine-weighted sampling.
The temporal stability solution is particularly innovative. Instead of simple exponential moving averages, the implementation uses a multi-scale mean estimator (MSME) that tracks both short-term and long-term averages. This allows the system to react quickly to actual changes while remaining stable during static periods, effectively solving the common real-time rendering dilemma between responsiveness and stability.
Looking at the broader context, this project represents a significant step forward for web-based graphics. WebGPU has opened doors for compute-intensive graphics applications that were previously impossible in browsers. The fact that physically-plausible light bounce and temporal stability can run in real-time on a web page—even on a phone—suggests we're entering a new era of web graphics.
The limitations shouldn't be understated, though. The lack of hardware ray tracing support forces reliance on software solutions like three-mesh-bvh, which can't match the performance of dedicated ray tracing hardware. Browser-specific constraints further complicate development, requiring workarounds that may limit cross-platform compatibility.
Despite these challenges, the project demonstrates what's possible when pushing the boundaries of web technologies. It serves as both a technical achievement and an educational resource, with detailed explanations of each component and interactive visualizations that help demystify complex rendering concepts.
As web technologies continue to evolve, we can expect to see more sophisticated graphics techniques becoming accessible to web developers. Projects like this surfel-based global illumination implementation pave the way for richer, more immersive web experiences that were once the exclusive domain of native applications.
For developers interested in exploring this technology further, the project repository and live demo provide comprehensive resources. The implementation, written in approximately 3000 lines of TypeScript and WGSL, offers a solid foundation for further experimentation and development.
The journey from the birth of photons in stars to real-time global illumination in browsers is a testament to the rapid advancement of web graphics technologies. As we continue to push these boundaries, the line between web and native applications will continue to blur, opening new possibilities for interactive experiences on the platform.

Comments
Please log in or register to join the discussion