diff --git a/src/Shaders/AutoInvertColors.shader b/src/Shaders/AutoInvertColors.shader index 13ee6b5c6..5ed9a08c8 100644 --- a/src/Shaders/AutoInvertColors.shader +++ b/src/Shaders/AutoInvertColors.shader @@ -2,8 +2,8 @@ shader_type canvas_item; void fragment() { + vec3 inverted = vec3(1.0) - COLOR.rgb; 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; - } + float avg = (screen_color.r + screen_color.g + screen_color.b) / 3.0; + COLOR.rgb = inverted * step(avg, 0.5); }