Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing transparency of a whole Node2D with overlapping textured children #401

Closed
DeRobyJ opened this issue Jan 22, 2020 · 1 comment
Closed
Milestone

Comments

@DeRobyJ
Copy link

DeRobyJ commented Jan 22, 2020

(TL:DR; pictures at the bottom)

Describe the project you are working on:
2D top-down videogame, undertale style

Describe the problem or limitation you are having in your project:
I need to change the transparency of "Room" nodes, which contain 3 tilemap nodes with overlapping tiles. Right now, the the "Room" parent node transfers its modulate to the children, thus changing its modulate.a property won't result in a homogeneous transparency, since overlapping sprites will have a different transparency than non-overlapping ones, because they are separate layer with that alpha value.

Describe how this feature / enhancement will help you overcome this problem or limitation:
This feature would allow me to change the overall transparency of the "Room", like if it were a ViewportTexture. I'm not using ViewportTexture because it gets overly complicated for just a graphical change. My character will have to interact to tiles based on their position, and using Viewports might affect existing game logic.

Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
image

Describe implementation detail for your proposal (in code), if possible:
Not applicable

If this enhancement will not be used often, can it be worked around with a few lines of script?:
Workarounds require the use of viewports, and it's not possible to work around the problem with shaders. You can find a discussion regarding this problem here: https://www.reddit.com/r/godot/comments/ertdgm/2d_transparency_of_overlapping_nodes_how_to/

Is there a reason why this should be core and not an add-on in the asset library?:
I believe this behavior is the expected behavior from the user's point of view. When changing the transparency of a node, we expect the whole node to become transparent, not its children.

For instance, open GIMP and do the following:

  • Create an image
  • Fill the background layer with black
  • Create two layers with alpha channel turned on
  • Draw two objects of different color, one per layer, and make sure they overlap
  • Create a layer group
  • Put the two layers with the drawings in the group
  • Select the group
  • Change transparency

This is the expected behavior.

Opacity 100% on all layers:
image

Opacity 50% on Layer Group, expected behavior:
image

Emulating Godot modulate.a behavior:
image

@Calinou
Copy link
Member

Calinou commented Jan 31, 2021

This was implemented by godotengine/godot#43167, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants