nobuyukinyuu / Godot-EasyBlend

Custom blending mode shader for Godot
MIT License
35 stars 5 forks source link

Complete the pack #1

Open Torguen opened 4 years ago

Torguen commented 4 years ago

Hello, could you add the blend modes that would be missing to have the basic package of most engines?

For example, these are the modes that Construct 2 brings by default. Those in the red box are the ones missing. 3

nobuyukinyuu commented 4 years ago

I'm not familiar with these blend modes. Is there a page which describes what they do? It should be noted that evaluation can only occur within the same color channel with EasyBlend, so if the input or output relies on any combination of channels to produce a correct result, this is out of scope for the shader. Examples would include "lighter/darker", "hue" and similar.

If these blend modes are related to openGL 1.x logical operation blends, it may be possible to replicate them, but i would need to know their proper names. Otherwise, you can replicate a blend yourself by creating the texture on your own. This can be done by overlaying two 256x256 gradient textures at 90° from each other using the specified blend mode (darkest values in the upper-left). EasyBlend treats this as a lookup table to map the values of the input pixels in a given channel to a specified output.

Torguen commented 4 years ago

Hi, I don't know much of Godot's shader language although I could try to do what you say, I mean adding textures manually but I don't know if that would work for these blend modes.

Here is information, I don't know if it will be useful for you

2

https://www.w3.org/TR/compositing-1/#porterduffcompositingoperators_dstin

nobuyukinyuu commented 4 years ago

Ah yes, these are compositing blend modes and aren't supported by the shader because they rely on using the alpha channel input to determine a color output (ie: some channels depend on other channels values).

In EasyBlend, rgb is independently calculated per channel using the LUT texture and alpha blending is always done as normal with the strength of that channel determining the strength of the effect on the underlying pixel. In your link, these are called "separable blend modes". Compositing and non-separable modes can't be represented by a simple, single texture.

nobuyukinyuu commented 4 years ago

Also it should be noted that additive and xor blend modes as they exist in EasyBlend aren't the same as compositing versions of these blends, but seperate modes which independently per-channel blend the source and destination rgb values together using those respective operators.

Alquimista commented 3 years ago

I'm not familiar with these blend modes. Is there a page which describes what they do? It should be noted that evaluation can only occur within the same color channel with EasyBlend, so if the input or output relies on any combination of channels to produce a correct result, this is out of scope for the shader. Examples would include "lighter/darker", "hue" and similar.

If these blend modes are related to openGL 1.x logical operation blends, it may be possible to replicate them, but i would need to know their proper names. Otherwise, you can replicate a blend yourself by creating the texture on your own. This can be done by overlaying two 256x256 gradient textures at 90° from each other using the specified blend mode (darkest values in the upper-left). EasyBlend treats this as a lookup table to map the values of the input pixels in a given channel to a specified output.

I'ts not an issue, but thanks to this explanation I do more blending colors (adding & halving) and (subtracting & halving), Where can I learn how and why this lookup table work (the 90° thing)?

nobuyukinyuu commented 3 years ago

The source code may be easy enough to follow. The principle of the lookup table is that 8 bit color channels have only 256 values, so every possible blending mode that can be naively expressed between 2 of these values can fit in a 256x256 texture (or 2d array).

Rajbir98 commented 1 year ago

add softlight blend mode plz

nobuyukinyuu commented 1 year ago

add softlight blend mode plz

done