ControlParent.modulate is affecting Control children, but not Node2D children

Godot Version



tl;dr - I have found that Sprite2Ds with ShaderMaterials will not modulate when a parent Control modulates (indeed, they won’t modulate or self-modulate at all). Is this a bug? Is there a workaround?

I have a scene like so:


I’d like to be able to call my standard fade-to-black Tween on the Control, and have the whole scene fade to black. When I do this, only the PanelContainer fades to black. Sprite2D doesn’t change. In the 2D editor, manually adjusting the modulate property of either Control, or Sprite2D, does not change Sprite2D’s modulation.

This is super weird because I have other, very-similarly constructed scenes that are working fine with the same function calls. Combing through the inspector and the scripts, I cannot figure out what might be causing the problem. Are there any known gotchas here? Many thanks for any advice!

EDIT: I should add, I added more Sprite2Ds to the scene, just to see if it was something specific to the Sprite. Doesn’t seem so - other Sprites exhibit the same odd behavior.

EDIT EDIT: Oop, I tried adding yet another Sprite2D, and this one fades down normally. So, it’s definitely got something to do with the properties of the Sprite.

EDIT EDIT EDIT: lol, ok, the Sprites that don’t work, all have ShaderMaterials. Is this a bug?

I think it is this bug.

1 Like

Yep, that’s it. Thanks very much for the peace of mind on that!

Luckily, I only need modulation at the beginning and end of my scenes, and shading throughout, so I just loaded the shader via code after I was done modulating, and set_material(null) towards the end, after I was done shading.