Skip to content

Commit

Permalink
chromakey.frag: Fix color distance equation
Browse files Browse the repository at this point in the history
The equation for calculating the distance from the key color to a
pixels color was missing the red channel component.
  • Loading branch information
ThomasWilshaw committed Sep 19, 2023
1 parent b04d16c commit 8ce00fd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/shaders/chromakey.frag
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ vec4 CIExyz_to_Lab(vec4 CIE) {

float colorclose(vec4 col, vec4 key, float tola,float tolb) {
// Decides if a color is close to the specified hue
float temp = sqrt(((key.g-col.g)*(key.g-col.g))+((key.b-col.b)*(key.b-col.b)));
float temp = sqrt(((key.g-col.g)*(key.g-col.g))+((key.b-col.b)*(key.b-col.b))+((key.b-col.r)*(key.b-col.r)));
if (temp < tola) {return (0.0);}
if (temp < tolb) {return ((temp-tola)/(tolb-tola));}
return (1.0);
Expand Down

0 comments on commit 8ce00fd

Please sign in to comment.