Building The Monolith: Composable Rendering Systems for a 13-Scene WebGL Epic Demo
Creating engaging web experiences often requires sophisticated rendering techniques. In this blog post, we’ll explore the development of a monolithic project featuring 13 distinct scenes, demonstrating the power of composable rendering systems using React Three Fiber.
Overview of the Project
To construct this expansive project, several reusable and composable components were developed:
Key Systems Utilized
- Deferred Rendering & Outlines
- Composable Materials
- Composable Particle System
- Scene Transition System
Concept Art and Team Collaboration
Concept Development
Kehan reached out to us with a vision, having engaged Lin to illustrate several scenes. Our team expanded to include talented freelancers passionate about bringing this project to life.
Lin’s illustrations inspired us to translate them into 3D with endless collaboration, resulting in a collection of over 50 shared references.
1. Deferred Rendering & Outlines
Colored Outlines
Creating colored outlines was vital for the art style. We explored three methods for implementing outlines:
- Edge detection based on depth and normals
- Inverse hull
- Edge detection based on material IDs
We chose the first method to maintain consistent outline thickness across varying camera distances.
Key Normals Implementation
To incorporate deferred rendering in Three.js, we configured WebGLRenderTarget to set a G-Buffer for storing normals. An effective memory optimization technique, octahedron normal vector encoding, allows the encoding of normals into fewer bits.
2. Composable Materials
Material Architecture
This project relies heavily on a GBufferMaterial component, a ShaderMaterial enhanced with useful uniforms and insertion points for modules to add shader code.
Example Code
javascript
uniform float uTime;
void main() {
vec2 st = vUv;
// insert
}
Material Modules
Reusability is achieved through a variety of material modules like MaterialModuleColor, which adds color uniforms and controls output.
3. Composable Particle System
Core Particle System Component
Our ParticleSystem component is designed using WebGL logic for attributes like position, velocity, and life data. It includes the capability for dynamic features, allowing particles to have a natural lifecycle.
Example Emission Modules
We developed modules for emission shapes such as EmissionPlane and EmissionSphere, broadening the versatility for various effects.
4. Scene Transition System
Transition Techniques
This system supports diverse transitions between scenes including wipes and zoom blur effects.
The transition process includes rendering scenes A and B and applying a fullscreen triangle with specific mix materials.
Conclusion
By utilizing composable and encapsulated systems, we made the development process smoother, allowing for isolated features to be added and tested efficiently. The React framework we employed provided rapid hot reloading, enhancing the overall development experience.
Related Keywords
- WebGL
- React Three Fiber
- Deferred Rendering
- Composable Systems
- JavaScript Animation
- Particle Systems
- Scene Transitions

