godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Make CanvasGroup render all children on the same layer, similar to the Unity SortingGroup #11038

Open Pyrocreep opened 4 days ago

Pyrocreep commented 4 days ago

Describe the project you are working on

Im working on a 2D game with skeletal animations. Each body part of the characters is its own sprite and is being snapped to the skeleton using RemoteTransforms. I also have an outline shader on the character. I worked a lot in Unity before switching to Godot, even though I'm aware both engines function completely differently I feel a feature like the Unity SortingGroups is essential for animators. image

Describe the problem or limitation you are having in your project

Im quite limited in how I can animate the characters because I'm not able to dynamically change the ordering of the individual body parts. The animation below is made in Unity, notice how the arm and the staff thats behind the character moves to the front. wizardattack

While the animation can be recreated in Godot, there are various issues I've run into. Firstly, in the example below you'll see the characters head rendered above the rectangle, this isnt the behavior I expect since the head is apart of the characters CanvasGroup while the rectangle is outside of it. image

The next issue I'm not too sure of since I'm not too familiar with shaders, but as you'll see in the image above the characters head has no outline simply because I changed the Z-Index of it. This is quite unintuitive since I would expect any shader applied to a CanvasGroup to work whether or not the Z-Indexes of the children are changed.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The same way the Unity SortingGroup works.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The CanvasGroup would render all children as a single sprite. The Z-Index of the children would only dictate the relative sorting between other children.

If this enhancement will not be used often, can it be worked around with a few lines of script?

As far as I'm aware, there isnt any kind of workaround for this. I've asked a friend more knowledgable on shaders and he came to the conclusion that there isn't a workaround for the outlines.

Is there a reason why this should be core and not an add-on in the asset library?

I feel It's a pretty essential feature for any kind of skeletal animation.

AThousandShips commented 4 days ago

See also: