Hi, this is a small (or large?) issue with all transparent objects (glass elements, for example) - looks like their quads are rendered in unsorted order which causes rendering issues - sometimes quads behind current one will not render at all. This will happen for all transparent quad in game and affect glass panes and visual effects (like fire). Implementation of quad sorting can solve these issues
Transparent Quads Depth Sorting
- paulevs
- Thread is marked as Resolved.
-
-
Proper transparency sorting is indeed a historically tricky thing in video games
One issue with the glass panes is that they're merged to a single mesh, so we can't sort individual elements while rendering. And specifying an order beforehand doesn't work either, because this indeed depends on the view angle.
One solution would be to do pixel accurate transparency sorting, but that's expensive, even on modern hardware. That would also be extremely tricky to implement in Unitys HDRP, considering the lack of custom shader support (it's possible, but a nightmare).
We could render the glass in mutliple passes though - panes of glass will mostly render correctly then, but overlapping glass or walls consisting of glass blocks may even look worse...
I guess we're between a rock and a hard place
-
One issue with the glass panes is that they're merged to a single mesh, so we can't sort individual elements while rendering. And specifying an order beforehand doesn't work either, because this indeed depends on the view angle.
There is also additional solution - it is possible to re-build mesh based on player position. For example if player position was changed on 8 units all meshes can be updated. Meshed with larger distance can have less updates (with just scaling amount of units that will require update). As all triangles are same sorting will be just re-ordering vertex indecies
-
There is also additional solution - it is possible to re-build mesh based on player position. For example if player position was changed on 8 units all meshes can be updated. Meshed with larger distance can have less updates (with just scaling amount of units that will require update). As all triangles are same sorting will be just re-ordering vertex indecies
That's a good idea! And that would indeed solve the issue. The only problem so far is that modifying the index buffer would probably also require us to update and rebake the mesh collider (because the game expects it to match the original mesh). These things happen in separate threads, but it still takes some time if there are lots of transparent construction elements in a chunk. And if a player frequently changes his position, this could result in a lot of overhead... we definitely have to tinker with that a bit
Participate now!
Don’t have an account yet? Create a new account now and be part of our community!