Open ActuallyaDeviloper opened 6 years ago
I suggest also sorting by blending mode (for this, we must merge my ex-bumpmaps branch), because current renderer seemingly not suitable for switching blend states and assumes all alpha-blended faces use additive blending.
Most of the issues with transparency were caused by incorrect room drawing order. They were drawn front-to-back, which is incorrect. After reversing drawing order, most of the issues with transparency are now gone.
However, sorting rooms by their "center point" is very flawed, as in some cases distance to room centerpoint which is in front of camera could be higher than distance to room centerpoint which is on the edge of the visibility. In such cases, visible effect is sudden corruption of alpha-blended faces.
Currently we only sort entire rooms but not the content within rooms.
I suggest to sort the polygons inside rooms occasionally. We can sort them along the camera direction and store the camera direction inside RenderingDrawingRoom. If the direction changes to much, we schedule a sort in one of the next frames. (We should try to only sort a few rooms every frame to avoid stutter)
Maybe we could sort the data on the GPU using ComputeShaders so that we don't need to transfer them back to the CPU?