ensisoft / detonator

2D game engine and editor 💥💣
GNU General Public License v3.0
310 stars 12 forks source link

Use depth buffering and inverse painting order to reduce overdraw #70

Open ensisoft opened 3 years ago

ensisoft commented 3 years ago

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.

ensisoft commented 1 year ago

Few other notes:

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?