Open ensisoft opened 3 years ago
Few other notes:
This could also be used to reduce material state changes by sorting the draw packets into material buckets instead of depth layer buckets before painting.
draw packets with transparent surface setting still need proper layer depth sorting
One problem is that so far sprite cutoff materials have to use "trasparent" material setting for proper function. So if everything is transparent then we're still back to having to sort by layer depth value. So the problem with "opaque alpha cutouts" must be solved first. It might be possible to implement a feature with "alpha cutoff" which clips the material in the texture sampling so that any non opaque pixel is discarded.
This would allow alpha cutout sprites to work with "opaque" material setting.
Mip mapped texture filitering might cause issues though if border line pixels get combined to semi transparent pixels. Should premultipliying alpha fix this?
When the scene contains no (semi-)transparent objects it should be possible to reduce overdraw by inversing the scene panting order so that the nearest layer is drawn first and the lowest (furthest away) layer is painted last. Combined with depth buffering this should take advantage of (early) z testing to discard fragments that would not be visible.
The steps.