godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Modulate blending modes #2834

Closed 2plus2makes5 closed 3 years ago

2plus2makes5 commented 3 years ago

Describe the project you are working on

Dungeon crawler

Describe the problem or limitation you are having in your project

I would like to achieve the old school hit effect with the sprite(2d and 3d) becoming white or red for an instant, it would also be useful in other cases like selecting an option for example.

Here's a famous example: Jbxw

Or another example from a dungeon crawler source

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

I think adding blending modes(add, sub ,multiply, mix) to modulate would help achieving cool effects effortless.

EDIT2: multiply would obviously be the default mode

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

There should be an option that let us choose the blending mode, after all now modulate is already using the multiply mode.

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

I think blending modes would help achieving many little but common effects easily. It is already possible to achieve this with shaders, but it can get clunky especially if the target already has a shader on it like in my case.

EDIT: i forgot to say that modifying a parameter in a shader modifies all the sprites with the same shader unless i make it unique for each sprite.

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

Modulate is core so i think that its blending modes should be core too, but i'm not against an add-on.

Calinou commented 3 years ago

Duplicate of https://github.com/godotengine/godot-proposals/issues/470 and https://github.com/godotengine/godot-proposals/issues/1972. As a workaround, you can overlay several sprites and apply different CanvasItemMaterials to them. You can also use overbright colors to brighten a sprite with the Modulate property. (Color(10000, 10000, 10000) should make any sprite fully white while taking its alpha channel into account.)

EDIT: i forgot to say that modifying a parameter in a shader modifies all the sprites with the same shader unless i make it unique for each sprite.

Godot 4.0 will have global and per-instance shader uniforms, which makes it possible to override uniforms with having to make each shader unique.

2plus2makes5 commented 3 years ago

Thanks for the workaround, it's not really perfect for me since i'm working in 3d with billboards but i guess i can adapt, but as someone already pointed in one of the links overbright doesn't work with all colors.

EDIT: in order to mantain the billboarding maybe i can add a next pass material when needed.