Coplanar surfaces blending with dual depth peeling
When coincident surfaces are rendered, I have observed differences whether you use alpha blending, legacy or dual depth peeling. The example is using a composite dataset and mapper. I also tested with separated mappers/actors with same results. When rendering surfaces from vertices sharing the same coordinates, it seems that the colors are just summed up leading to lighter result instead of expected darker result.
I am testing with 3 cubes all with opacity (0.3) and overlapping in different ways:
- cube1 is blue/green (0., 0.8, 0.8)
- cube2 is red (0.8, 0., 0.) and translated in a way that some of its vertices are perfectly overlapping cube1's
- cube3 is light grey (0.8, 0.8, 0.8) translated and rotated in a way that its vertices are not overlapping other cubes' but still have co-planar surfaces with cube2
Here are the results. I am not really interested in cube3 artifacts. To me the blending of cube1 and cube2 is more worrying:
- Top-left alpha blending: seems like the correct blending to me between cube1 and cube2. I guess that both cubes are rendered separately and the renders blent together at the end?
- Top-right legacy depth peeling: cube2 is taking over cube1. Is it because the depth buffer keeps the last fragments if it finds two at the same place?
- Bottom-left dual depth peeling: The overlapping area is (0.8, 0.8, 0.8). This is surprising as I would expect the front peel to be red, same for the back peel, resulting in red like legacy depth peeling
- Bottom-right dual depth peeling, cube1 is slightly offset: offset can be x, y or z. Now we have the correct color but with artifacts
By using dual depth peeling, I was hoping to render with the correct color hopefully without artifacts. Is the render bottom-left expected?
Here is a script. You can set the transparency methods at the top. Offset can be applied easily to each cubes distinctly. mini_coplanar.py