godotengine / godot-proposals

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

Make the emission visible outside of the albedo visible area #2030

Open 2plus2makes5 opened 3 years ago

2plus2makes5 commented 3 years ago

Describe the project you are working on

First person dungeon rpg

Describe the problem or limitation you are having in your project

I wanted to make the eyes of enemies glow in the dark but the glow is limited to the visible parts of the albedo texture.

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

The glow is usually bigger than the emitter, so it makes sense that the non-transparent area of the emitter is smaller than the one of the glow, hence it should be possible to specify the alpha for both the albedo and the emission, also a mix mode in addition to add and multiply would be good too.

Alternative and more advanced/complex solution: the emission texture specifies the shape and color of the emitter, not the glow, while Godot calculates the glow thanks to other parameters like glow range and attenuation curve similar to a Spotlight.

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

Simply make Godot take into account the alpha of the emission texture so it's visible outside of the albedo texture visible area, also a mix mode would be nice too.

For the alternative and more advanced/complex solution: there would be the emission texture representing the emitter, a range parameter and an attenuation curve similar to Spotlight to generate the glow

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

I'm actually using static Sprite3D so in my case a simple workaround is to use 2 sprites, one for the shaded albedo and one unshaded with the emission texture used as albedo, but it's not a good solution especially because i'll probably add small animations to the sprites, and definitively it's not good at all for meshes.

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

It seems to me this is a core issue, but i would also be happy with an add-on or other solutions.

Calinou commented 3 years ago

Can you upload a minimal reproduction project? It's kind of difficult to understand the context right now. (Are you using alpha-blended or alpha-tested transparency?)

2plus2makes5 commented 3 years ago

emission On the right there's the desired result, made with 2 Sprite3Ds one in front of the other, one is the shaded sprite for the enemy, the other is an unshaded sprite for the red glow. On the left there's the result using a single sprite and a material with an albedo texture(the enemy), an emission texture(the red glow) and transparency, all the rest is default, i tried changing various settings in the emission and parameter tabs but nothing.