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)));

This comment has been minimized.

Copy link
@scottcjt

scottcjt Sep 24, 2023

@ThomasWilshaw I am just a passer-by browsing OSS video editing projects, and I know it is bad to comment on unfamiliar code base. But is it a kind of distance in a 3-dimensional space ? If so, the third part should be key.r-col.r ... ?

This comment has been minimized.

Copy link
@ThomasWilshaw

ThomasWilshaw Sep 24, 2023

Author Collaborator

Yes you are correct, I think that was a copy paste error. Thanks for pointing that out

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.