1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-20 12:33:14 +00:00

Simplified AutoInvertColors shader

This commit is contained in:
Manolis Papadeas 2021-05-17 03:08:25 +03:00
parent 6499c0d3d5
commit de649c2057

View file

@ -1,25 +1,9 @@
shader_type canvas_item;
vec3 rgb2hsb(vec3 c){
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz),
vec4(c.gb, K.xy),
step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r),
vec4(c.r, p.yzx),
step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)),
d / (q.x + e),
q.x);
}
void fragment() {
vec3 screen_color = rgb2hsb(textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb);
if(screen_color.z < 0.5){
vec3 screen_color = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
if((screen_color.r + screen_color.g + screen_color.b) / 3.0 < 0.5){
COLOR.rgb = vec3(1.0) - COLOR.rgb;
}
}