Godot Shader 07- screen coloring

Default image


2068504-9e79c2f8b49cbc44.png

SCREEN_TEXTURE built-in Texture

void fragment() {}
    COLOR = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0);
}
2068504-70c9558c28e0ade4.png

An invisible object because it just shows what is behind.

Highlights process for the saturation of its objects behind

uniform float brightness = .5;
uniform float contrast = .5;
uniform float saturation = .5;

void fragment() {
    vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;

    c.rgb = mix(vec3(0.0), c.rgb, brightness);
    c.rgb = mix(vec3(0.5), c.rgb, contrast);
    c.rgb = mix(vec3(dot(vec3(0.2125, 0.7154 ,0.0721), c.rgb) ), c.rgb, saturation);

    COLOR.rgb = c;
}

The official formula is an example of the wrong ~ ~

2068504-c2b56224b32c37ae.png

Description:
brightness = original pixel luminance percentage
contrast ratio = (0.5 to original pixels)
contrast percentage + original pixel
saturation (official error) = (dot (1, original pixels) / 3- original pixels) % saturation + original pixel
saturation (actual) = (dot ((0.2125,0.7154,0.0721, original pixels) - original pixels)
% saturation + original pixel
official saturation although wrong, but also has the effect

Guess you like

Origin blog.csdn.net/weixin_34178244/article/details/90923514