mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Optimize AutoInvertColors shader
Not sure if that single if statement counts as branching code, but it's generally a good idea to avoid if statements in shader code, so I used step instead.
This commit is contained in:
parent
08dc639e5a
commit
1b286a95ab
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue