Sprites are not sorted from top to bottom
marnel-estrada opened this issue · comments
I finally got the time to play with this framework. It is indeed very fast.
However, I've observed that sprites are not sorted from top to bottom:
How could I go to fix this? I still don't understand the code that much, but my initial look is that I probably need to sort the buffer of SpriteIndexBuffer by using the y position at its MatrixBuffer. Although I'm not sure if scrambling the array of SpriteIndexBuffer would affect the rendering. Like if I should also move the corresponding MatrixBuffer.
Hello, the sorting system, is the classic way of sorting sprites, so the bigger the "y" the bigger the "sorting layer", if you want this to be reversed you have to change
float3 worldPosition = float3(transform.x,transform.y,-transform.y/10) + (v.vertex.xyz * transform.w);
to
float3 worldPosition = float3(transform.x,transform.y,transform.y/10) + (v.vertex.xyz * transform.w);
In a later version, I will create a new component "SpriteSheetSortingLayer" that will let you choose a specific sorting layer like the classic unity way of doing it.