defold / defold

Defold is a completely free to use game engine for development of desktop, mobile and web games.

Home Page:https://www.defold.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow sorting front-to-back

JCash opened this issue · comments

It's currently not possible to render meshes front-to-back.

  • it is also be beneficial to skip sorting (fair performance boost) for e.g. alpha blended particles.
    See exploration-particle-no-sort

  • Another useful sort is the y-sort, allowing for objects hiding behind other objects the higher the Y value is.

I think that a material property is the most frequent use case, but I wonder if it's also useful to have it as a render script override as well? We need to find a use case for that before adding it to the render script api.

but I wonder if it's also useful to have it as a render script override as well? We need to find a use case for that before adding it to the render script api.

There are scenarios where you have sprites with several different materials, but all of them should be y-sorted. Possibly also mixed with labels and maybe particle effects. Setting the sort order on each material might be ok though? It's not like the sort order will be changed all the time.

Having it as a render script override is not an MVP I think.

Since a render.draw(predicate) will produce batches with different types of renderables, I no longer think the sorting should be set on the material(s).
Instead, it feels more like it should be an option to the render.draw(predicate, options={...}) function.

But then again, I don't think it's relevent to "not sort" e.g. a mix of sprites, models and particles 🤔

Having the ability to Y-sort a given predicate (ignoring Z) would be great to solve some otherwise difficult quirks for my card game. Or even sort based on a custom property I can set myself. (I'm working in perspective, so I can't just use Z for this)