godotengine / godot-proposals

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

Add more 2D blend modes #470

Open Torguen opened 4 years ago

Torguen commented 4 years ago

Describe the project you are working on: It is a kind of presentation in which I would like to use the sprites of my game with the "Destination in" blend, but this blend does not exist in Godot.

Describe the problem or limitation you are having in your project: There is no blend mode "Destination in"

Describe the feature / enhancement and how it helps to overcome the problem or limitation: Add this basic blend modes to Godot to get new effects.

1

Actual blend modes in Godot: 2

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams: It consists of adding new blend modes to Godot

Normal sprite 1

With "Destination in" blend mode 2

If this enhancement will not be used often, can it be worked around with a few lines of script?: No, these effects cannot be emulated by code.

Is there a reason why this should be core and not an add-on in the asset library?: They are basic effects in most engines.

clayjohn commented 4 years ago

In order for a proposal to be considered you must have a valid use case. That means you must have something that you need to do that you cannot do with this feature being added.

Additionally, you must answer all questions in the template. "No" is not a sufficient answer.

Torguen commented 4 years ago

My valid use case is that I can't get the "Destination in" blend because Godot doesn't include it.

I edited the proposal, I hope it is enough.

Calinou commented 4 years ago

See also the discussion in #96. This most likely won't be accepted in the engine for performance reasons (among other things), but nothing prevents someone from creating a shader pack and distributing it on the asset library.

Torguen commented 4 years ago

Really? I'm surprised by the performance aspect. These blends are included by an engine that works by soft, without opengl, and I never saw any performance problems. Well, I think they are very useful and I don't know why it has additive, subtractive and others, but it doesn't have the ones that I indicated (those blends of the first image are of construct 2 for the sprite object).

clayjohn commented 4 years ago

@Torguen it's because hardware acceleration works well with the basic blend modes. We can rely on the hardware to do them incredibly fast. While with the others you need to write a custom shader and they will slow down in unexpected ways.

In software, all blending is slower, but the difference between types isn't so pronounced.

Torguen commented 4 years ago

https://stackoverflow.com/questions/11633950/opengl-blend-modes-vs-shader-blending

clayjohn commented 4 years ago

@Torguen you seem to have mixed up OpenGl and Godot. :)

When I refer to hardware blending I am referring to the limited blending that OpenGL offers. But Godot allows you to write custom blending using shaders see: http://docs.godotengine.org/en/latest/tutorials/shading/screen-reading_shaders.html

Torguen commented 4 years ago

https://github.com/nobuyukinyuu/Godot-EasyBlend

I think this package covers a part of this request (some modes are missing in the asset). I have suggested that the user add the rest but I don't know if this user is still active.

ghost commented 4 years ago

Would be nice to have more for the purposes of particle effects, interesting side effects happen with certain types of blends that overlap. Additionally would probably be good to have some other parameters like strength.

bojidar-bg commented 4 years ago

The "Destination In" blending mode was also discussed in https://github.com/godotengine/godot/issues/35167.

Xrayez commented 4 years ago

Is the existence of those additional blending modes decrease the performance of built-in ones? If yes, it makes sense to not to include this by default, else I don't see a reason why this can't be added, except for the "plugin vs core" debate. 😛

In the module we're developing for Godot, we implemented an ImageBlender class which does all kinds of stuff on the image editing level (using CPU). Perhaps implementing this proposal would remove the need to implement such a class in the first place. The shading language is not the beginner stuff (at least not at the first steps a beginner learns about Godot development).

@Torguen it's not stated in the documentation, but I think that Godot aims to become something akin the Linux kernel but in gamedev (please do correct me if I'm wrong). I wouldn't put your hopes high on getting this implemented in core, this goes against the very development philosophy Godot currently follows...

See reduz response on Reddit.

Godot in contrast aims for mostly high-level only rendering backend that looks pretty, covers most common use cases and only allows some tweaking [emphasis mine]. The idea is that out of the box it looks as good as Unreal, is much easier to use, but of course may lack the ability to tweak performance for corner use cases (though it should still be good for most games). The vision here is that this can be achievable with a relatively simple renderer (there is not as much rendering code in there as you migt think), and that if a large company ever wants to use it, they have the money to hire a render engineer and tweak it themselves.

Again, would be nice to document this ~to prevent such proposals~? If that's the case, this should go to Godot Ideas repo as suggested in #91.

LordBrkica commented 1 year ago

The moment you start working on anything more complicated then 1 character platformer is the moment Godot limitations really kick in.

Sadly something simple as this or this is simply not supported in Godot 4.1.

I am always surprised to see thousands new features added to the engine but then some "basic" stuff like this is missing.

Calinou commented 1 year ago

Sadly something simple as this or this is simply not supported in Godot 4.1.

This can be done using a CanvasGroup node since 4.0. Keep the child Sprite nodes opaque, but modulate the CanvasGroup node's color to a translucent color.

LordBrkica commented 1 year ago

I tried to do this but I failed, probably I am just a bad dev. image

But adding to this topic - what is also missing are different blend modes for the light as well, you are simply unable to make such effects with current light system.

There is no easy way to use the light to make fog of war akin to the one from RTS games (from 90s onwards).

Calinou commented 1 year ago

I tried to do this but I failed, probably I am just a bad dev.

I forgot to mention the property you need to change on the CanvasGroup is Self Modulate, not Modulate. Otherwise, children are affected by the modulation as well.

But adding to this topic - what is also missing are different blend modes for the light as well, you are simply unable to make such effects with current light system.

See https://github.com/godotengine/godot-proposals/issues/7367.

mr11stein commented 2 weeks ago

@Torguen you seem to have mixed up OpenGl and Godot. :)

When I refer to hardware blending I am referring to the limited blending that OpenGL offers. But Godot allows you to write custom blending using shaders see: http://docs.godotengine.org/en/latest/tutorials/shading/screen-reading_shaders.html

I'm pretty sure the example can be implemented using glBlendFunc with SRC_ALPHA_MINUS_ONE and ZERO for the source and destination factor respectively. Unity supports it . I used it heavily when working on a mobile game 10 years ago. I need this asap, will probably hack it in an engine fork.