Gradual darkening of the screen.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DimitriyPS
:warning: Old Version Published before Godot 3 was released.

I want to do such a thing. After selecting in the main menu, the screen gradually dims, then loaded another scene, the screen is gradually lightened. How is this implemented?

:bust_in_silhouette: Reply From: Akien

The simplest way would be to put a dark texture on top of your scene (with the highest Z), make it visible and with opacity 0 at first, and gradually increase its opacity in _process.

Then change the scene, and do the same the other way around (full opacity → opacity 0).

AFAIK the highest Z is what is shown on top, not the lowest.

vnen | 2016-07-19 15:20

Right, fixed :slight_smile:

Akien | 2016-07-19 15:22

Why not doing it with a polygon node? You don’t need a texture and it saves texture lookups in the shader.
Also, a CanvasModulate node could work too and involves less overdraw :stuck_out_tongue:
I do that in my game with an AnimationPlayer so I don’t even have to script it.

Zylann | 2016-07-19 18:40

Don’t hesitate to post your suggestion as an answer instead of a comment. This is the purpose of a Q&A: everyone proposes their answer and the OP can select the most fitting one. Here I just gave a quick and dirty solution, if you have a better one we’ll all be happy to read it and maybe learn from it :slight_smile:

Akien | 2016-07-19 19:42

Sorry sometimes I put things in comments that could be an answer, and I forget to use Answer. I posted it then :slight_smile:

Zylann | 2016-07-19 19:48

I have finally done it. Thanks, I took your advice.

DimitriyPS | 2016-08-01 08:16

:bust_in_silhouette: Reply From: Zylann

You can also do it with a polygon node, you don’t need a texture and it saves texture lookups in the shader.
Also, a CanvasModulate node could work too and involves less overdraw :stuck_out_tongue:
I do that in my game with an AnimationPlayer so I don’t even have to script it.

Node that currently Polygon2D opacity does not work.

vnen | 2016-07-19 19:59

Gaaah yes Polygon transparency doesn’t works in 2.1… a little shader tinkering and it should work I guess.

Zylann | 2016-07-19 20:33