Demonstration of depth peeling in three.js in support for adding re-assignable depth buffers for render targets.
Drone model by T Flex CAD on SketchFab. Robot model by artjamayka on SketchFab.
Possible Improvements
- Try stenciling the model area to see if performance improves with lots of layers
- Composite into a common buffer on every layer render
- Perform a depth prepass per layer to avoid discarding expensive fragments
- Limit render viewport to avoid copying and blending of of unused pixels
- Add an epsilon to reduce z fighting on depth comparisons on certain hardware