Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinterpretation of vibrance? #121

Open
chenglou opened this issue Oct 15, 2021 · 0 comments
Open

Reinterpretation of vibrance? #121

chenglou opened this issue Oct 15, 2021 · 0 comments

Comments

@chenglou
Copy link

Hello @RedQueenCoder! Followed your blog post http://redqueengraphics.com/2018/08/24/metal-shaders-vibrance/ to here =)

The negative vibrance uniform and the linear interpolation threw me off a bit:

half amt = (mx - average) * (-uniform.vibrance * 3.0);
color.rgb = mix(color.rgb, half3(mx), amt);

If we remove the negative uniform by propagating it into mix, things go from:

a(1 - x) + bx // definition of mix

to:

a(1 + x) - bx
<=> a + ax - bx
<=> a + (a - b)x
<=> a - (b - a)x // a - b is counterintuitive since in context, it'd be a negative delta. See code below

In the context of the code:

half amt = (mx - average) * uniform.vibrance * 3.0;
color.rgb = color.rgb - (mx - color.rgb) * amt;

Which gives an interpretation of vibrance as a function of the original color, minus the deltas (max - self) and (max - average).

I was wondering if this is a bit more intuitive. Or at least, it surfaces a curious mx^2 if we expand amt for some reason. The parallel with saturation's mix is lost though.

Feel free to close if not!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant