FR: Suggestions for WebGLRenderer refactor
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 249
- PR merge metrics
- No merged PRs in 30d
Description
Having heard the GL side of things is slated for a major refactor, as well as having seen some of the [writing](https://github.com/Famous/engine/issues/288) on the [wall](https://github.com/Famous/engine/issues/313), I figured now might be a good time to request certain features that might otherwise be untenable if not for an impending refactor.
So without further ado, here's my wish list:
### 1. Decouple the cutout system from WebGLRenderer
I would argue that the cutout system should not be an intrinsic part of WebGLRenderer. Per [issue 313](https://github.com/Famous/engine/issues/313), barring a major leap like rasterization of DOM content (which is a long, long ways off), the only way complex cutouts can be reliably achieved is if the cutout system is exposed to the user, and the user is free to define the cutout representing their DOM content.
### 2. Eschew vertex-based cutouts in favor of a fragment-based system with blending support
Currently, the cutout system is based on vertex data (geometry). While this might be somewhat more efficient than alternatives, it's also not as capable. DOM images containing alpha opacity are the most glaring argument against the current system.
### 3. The cutout/blending system should support _n_ layers
Specifically, _n_ GL layers. Imagine the following scenario:
You have DOM content containing alpha opacity, some Famous GL content, as well as foreign (i.e. non-Famous) GL content. All of it needs to play nicely together.
1. Tell the cutout system about your complex DOM content so it can render a correct cutout.
2. Create a new layer within this same system, passing in the appropriate color and depth buffers that represent said foreign GL content.
Ideally, the system would first perform fragment depth testing across all layers, followed by a blending pass. The end result is you'd have DOM + _n_ GL layers all coexisting peacefully, all respecting the same cutout state, with a single Canvas element.
### 4. Ability to specify a custom depth buffer precision for each layer
For my use case, I require a logarithmic depth buffer. Moreover, the aforementioned depth testing is worthless unless the depth value scale is homogenous across all tested layers.
### 5. Post-processing pipeline
I know this is already planned, so I'll just say I'm really looking forward to it. :-)
## Conclusion
If nothing else, having the first item would make it such that those of us wishing to implement our own cutout system wouldn't have to rewrite most of WebGLRenderer to do so.
Thanks for reading! Looking forward to any input.
Contributor guide
Assessment
This issue has not been assessed yet.