|
|
|
|
|
by o11c
704 days ago
|
|
Reverse-painter's-order beats painter's-order since it lets you skip fully-occluded objects: Start with a buffer that's fully transparent (α=0.0)
for each face from front to back:
for each pixel of the face:
draw the pixel, blending 1.0-buffer.α of the new pixel into whatever's already in the buffer
(if buffer.α == 1.0 you can just skip it entirely, just like for depth buffering)
go back and double check your math relating to transparent objects behind other transparent objects
The tricky part is if you have faces that overlap in a cycle (can happen legitimately), or that penetrate each other (often avoidable if you think about it). |
|
It is generally good to render opaque geometry back to front to reduce overdraw, but not going so far as sorting the objects. We would do stuff like render the hands first in an FPS or render the skybox last in most games.
Now for the transparent layer: First occlusion is handled by the z-buffer as usual. If you render from front to back I assume you render to another buffer first and then composite to the framebuffer? If you render from back to front you don't need alpha in your framebuffer and can assume each rendered pixel is opaque, not needing that composite.
There's also order independent transparency stuff though which IIRC does need another buffer, which requires a composite but then saves you having to sort the objects.