RobustToolbox icon indicating copy to clipboard operation
RobustToolbox copied to clipboard

Add support for drawdepths per sprite layer

Open EmoGarbage404 opened this issue 1 year ago • 4 comments
trafficstars

scrungles some sprite code to enable individual layers to specify drawdepths.

Main change is that ProcessSpriteEntities now gets and sorts individual sprite layers rather than entire sprites.

EmoGarbage404 avatar Feb 17 '24 18:02 EmoGarbage404

Why do we need to have per-layer draw depths? I know its mentioned in #4803, but why is it actually useful, and how would it work with shaders or eventual support for advanced sprite rendering options (layer groups / byond style "draw together", or drawing an entity's sprite within another entity's layers, etc)? And would it be worthwhile given it would probably appreciably slow down the sorting step while rendering?

I do think layers should have a depth/sorting (e.g. #2970), but I'm not sure about having them sort across different entities

ElectroJr avatar Apr 16 '24 19:04 ElectroJr

Why do we need to have per-layer draw depths? I know its mentioned in #4803, but why is it actually useful, and how would it work with shaders or eventual support for advanced sprite rendering options (layer groups / byond style "draw together", or drawing an entity's sprite within another entity's layers, etc)? And would it be worthwhile given it would probably appreciably slow down the sorting step while rendering?

I do think layers should have a depth/sorting (e.g. #2970), but I'm not sure about having them sort across different entities

Chairs are an easy example, currently they're missing an overlay they're supposed to have which would make it so the armrest draws over the player.

moonheart08 avatar Apr 16 '24 19:04 moonheart08

Chairs are an easy example, currently they're missing an overlay they're supposed to have which would make it so the armrest draws over the player.

I think that should be done by allowing a sprite to get drawn as a layer of some other sprite, as mentioned in my previous comment. I.e., the whole mob should just become a layer within the chair's sprite. If you just changed the armrest's drawdepth to get drawn over mobs, it would be drawn over any mob that moves near the chair, not just the mob that is currently in the chair.

My vague wishlist/todolist for sprites is:

  • Move logic out of sprite component and into the system
  • Move clickmaps from content to engine
  • Rework ISpriteLayer and add layer groups (collections of other layers or layer groups), and allow each group to have its own shader & color modulation
  • Change sprites component to basically just be a kind of layer group, and allow sprites to use the sprites of other entities as a layer.
    • Would requires somehow updating clickmaps so that you can still click on an entity that is in a chair.
  • Add support for multiple "PostShader"s
  • Add direction dependent drawdepths for 4/8-dir sprites to fix things like inhands being rendered incorrectly

ElectroJr avatar Apr 19 '24 15:04 ElectroJr

Is there anything significant blocking this? Would be useful on downstreams.

Doctor-Cpu avatar Sep 09 '24 01:09 Doctor-Cpu

not good code and not a good approach to be worth really considering

EmoGarbage404 avatar May 10 '25 05:05 EmoGarbage404