Forking the Web: Charting a New Internet Landscape
Discussion on the concept of forking the web, exploring its implications for decentralization, control, and the future of the internet.

The web, once a realm of flat colors and simple animations, is rapidly transforming into a vibrant canvas for stunning, lifelike visual experiences. From interactive product visualizations to immersive browser-based games, the demand for photorealistic graphics is no longer confined to desktop applications. At the forefront of this revolution in web rendering lies a powerful technique for achieving truly dynamic and physically plausible lighting: Surfel-Based Global Illumination.
For years, achieving realistic indirect lighting—the soft, ambient glow that bounces off surfaces, illuminating shadowed areas—on the web has been a significant hurdle. Traditional methods like static lightmaps are brittle, breaking with any scene dynamism. Irradiance probes offer a low-resolution approximation, and screen-space techniques, while impressive, are inherently limited by what’s visible on screen, often introducing artifacts and failing to capture true global effects. Surfel-based GI, however, offers a compelling, GPU-accelerated approach that brings desktop-quality global illumination to your browser, even on mobile devices.
The magic of surfel-based GI on the web is its heavy reliance on the GPU, primarily through the modern WebGPU API. This isn’t just about rendering; it’s about a compute-driven pipeline where virtually every step of the global illumination process happens on the graphics card. This paradigm shift is crucial for achieving real-time performance with complex lighting calculations.
At its core, this technique discretizes the scene’s lighting into a dynamic collection of “surfels” – small, textured patches representing a point on a surface with associated lighting information. The pipeline typically unfolds in several key stages, all orchestrated on the GPU:
G-Buffer Generation: Before any lighting magic can happen, the scene geometry needs to be understood. A multi-pass process generates a G-buffer, which essentially captures per-pixel information like depth, surface normals, and albedo (base color). This data forms the foundation for subsequent calculations.
Surfel Spawning and Management: This is where the “surfel” concept comes alive. New surfels are spawned dynamically on visible surfaces. These surfels are not static entities; they are managed within a dedicated GPU buffer, complete with attributes like position, normal, and crucially, temporal “age.” Older surfels are gradually recycled, ensuring the system is always working with fresh lighting data and avoiding accumulating stale information. This intelligent management is key to both performance and stability.
Spatial Indexing: To efficiently query lighting information from neighboring surfels and the scene itself, a spatial data structure is essential. A cascaded 3D spatial hash grid is often employed. This grid partitions the scene into cells, allowing for rapid lookups of nearby surfels. For ray intersections with the scene geometry (e.g., to determine if a surfel’s light can reach another point), a robust Bounding Volume Hierarchy (BVH), such as the one provided by three-mesh-bvh, is integrated.
Surfel Ray Tracing and Integration: This is the heart of the global illumination calculation. For each surfel, rays are traced to sample the environment and gather incoming light. This isn’t brute-force ray tracing; it’s guided by techniques like MSME (Moment-based Spherical-Ellipsoidal) approximations and leveraging a radial depth atlas for efficient visibility queries. The goal is to accumulate irradiance – the total light energy falling on a surface—for each surfel.
Resolve Pass: Finally, a resolve pass gathers the computed irradiance from the surfels to reconstruct the final lit image. This might involve blending surfel contributions, applying temporal anti-aliasing for noise reduction, and integrating with the direct lighting to produce the final rendered output.
Libraries like Three.js play a vital role in orchestrating this complex GPU pipeline. They provide the scene graph, mesh management, and rendering framework, allowing developers to integrate the surfel GI system seamlessly into their existing web applications.
One of the most significant advantages of surfel-based GI is its ability to decouple lighting calculations from screen resolution. Unlike screen-space techniques that are inherently tied to the number of pixels being rendered, surfels represent discrete points in 3D space. This means that the quality of the indirect lighting remains consistent regardless of whether the user is on a high-resolution desktop monitor or a smaller mobile screen.
Furthermore, surfel systems are designed for temporal stability. By aging and recycling surfels, they effectively cache lighting information over time. This means that as the scene changes – objects move, lights are added or removed – the indirect lighting can update smoothly and coherently, avoiding the flickering and jarring artifacts often seen with less sophisticated dynamic lighting solutions. This temporal coherence is paramount for a believable and comfortable visual experience.
When compared to alternatives, surfel GI shines:
The sentiment surrounding surfel-based GI on platforms like Hacker News and Reddit is overwhelmingly positive. Developers are hailing it as “amazing” and “incredible” for bringing physically-plausible, stable GI to the web, even demonstrating impressive performance on mobile devices.
While the capabilities of surfel-based global illumination on the web are undeniably impressive, it’s crucial to acknowledge its demanding nature. This is not a “set it and forget it” solution; it requires a deep understanding of its computational costs and careful optimization.
The primary bottleneck is compute intensity. Even a demo with a modest number of surfels, perhaps around 512, can put a significant strain on GPU resources. Scaling this to the tens of thousands of surfels required for a full-fledged engine in a complex scene is a considerable challenge. This means that robust WebGPU support is a non-negotiable prerequisite. If your target audience primarily uses browsers that lag in WebGPU adoption, this technique might be out of reach.
The pipeline itself is complex, with numerous moving parts. Grid maintenance—ensuring the spatial hash grid accurately reflects surfel distribution—can introduce overhead. Visibility bottlenecks can emerge when dealing with millions of surfels in large, intricate scenes, as efficiently determining which surfels are visible to each other becomes a significant task.
Furthermore, noise and lag can be persistent issues without sophisticated temporal blending and advanced ray guiding techniques. Achieving that smooth, artifact-free visual fidelity requires careful tuning and often involves a trade-off between visual quality and performance.
It’s also important to note that surfel-based GI, in its common implementations, primarily focuses on diffuse global illumination. Achieving realistic reflections, refractions, or specular indirect lighting typically requires integrating additional rendering techniques, adding another layer of complexity.
Therefore, you should avoid surfel-based GI when:
Surfel-based global illumination represents a significant leap forward in real-time graphics for the web. It offers a powerful, GPU-accelerated solution for achieving high-fidelity indirect lighting with a level of temporal stability previously unseen in browser-based applications. The ability to dynamically discretize scene lighting and cache irradiance effectively provides tangible advantages over older, static, or screen-space-limited techniques.
However, this power comes at a cost. The complexity of the pipeline, its high compute demands, and the requirement for modern hardware capabilities mean that it’s not a universally applicable solution. Developers must be prepared to invest significant effort in optimization, tuning, and potentially integrating complementary techniques to achieve their desired results.
For those who can meet its demands, surfel-based GI is a game-changer. It unlocks a new level of visual fidelity for web experiences, making truly realistic lighting a tangible reality. It’s a testament to the evolving capabilities of web graphics and a tantalizing glimpse into the future of immersive, dynamic content delivered directly through the browser. As the technique matures and hardware continues to improve, we can expect to see even more breathtaking applications of surfel-based global illumination shaping the visual landscape of the web.