5 ms·
This is one of the most fascinating articles I've come across on HN, and so well explained, so thank you. But I wonder about what the "right" way to blend grad
by crazygringo 10y ago
This is one of the most fascinating articles I've come across on HN, and so well explained, so thank you.
But I wonder about what the "right" way to blend gradients really is -- the article shows how linear blending of bright hues results in an arguably more natural transition.
Yet a linear blending from black to white would actually, perceptually, feel too light -- exactly what Fig. 1 looks like -- the whole point is that a black-to-white gradient looks more even if calculated in sRGB, and not linearly.
So for gradients intended to look good to human eyes, or more specifically that change at a perceptually constant rate, what is the right algorithm when color is taken into account?
I wonder if relying just on gamma (which maps only brightness) is not enough, but whether there are equivalent curves for hue and saturation? For example, looking at any circular HSV color picker, we've very sensitive to changes around blue, and much less so around green -- is there an equivalent perceptual "gamma" for hue? Should we take that into an account for even better gradients, and calculate gradients as linear transitions in HSV rather than RGB?
- nitrogen 10y agoMaybe gradients should be computed in a more perceptually oriented colorspace like LAB, YCbCr, YIQ, XYZ, etc.
- jjgreen 10y agoLike this? http://tristen.ca/hcl-picker/#/hlc/6/1/20313E/EFEE68 http://tristen.ca/hcl-picker/#/hlc/6/1/20313E/EFEE68
- tangent128 10y agoAs I read it, for "physical correctness" gamma is the most important consideration. When selecting your initial color palette, though, it is true hue and saturation do have nonlinear perception. There are (somewhat complicated) color spaces designed to deal with that: https://en.wikipedia.org/wiki/Lab_color_space https://en.wikipedia.org/wiki/Lab_color_space http://www.husl-colors.org/ http://www.husl-colors.org/ lets you play with a compromise color space.
- johnnovak 10y agoI'm glad you enjoyed reading the article. I completely agree on not really having a "right" way to blend gradients. For that reason I almost ended up omitting the gradient example from the article because doing it "correctly" in linear space does not always yield the most pleasant looking results. Generating perceptually fine looking gradients is another huge (and very interesting!) topic in itself, so maybe I'll discuss that in another post in the future. Until then, have a look at this online gradient generator tools that can use five different algorithms (there's some explanation provided as well for each method): http://davidjohnstone.net/pages/lch-lab-colour-gradient-picker http://davidjohnstone.net/pages/lch-lab-colour-gradient-pick... I also recommend reading the superb 'Subtleties of Color' NASA article series on the matter: http://earthobservatory.nasa.gov/blogs/elegantfigures/2013/08/05/subtleties-of-color-part-1-of-6/ http://earthobservatory.nasa.gov/blogs/elegantfigures/2013/0... PS: I'm slightly confused about your comment on the black to white gradient though. Are you saying the gradient on Figure 1 looks more even to you than on Figure 2? In that case, I think your monitor is miscalibrated, so try gamma-calibrating it first then have another look. Your opinion might change :)
- nshepperd 10y agoOn the greyscale gradient- the other way around: Figure 2 looks more even, being a perceptually linear gradient, ie. calculated "gamma incorrectly". Which is to say it's not what a real light would look like (if a light had linear falloff in illumination of this surface?).
- ars 10y agoI think you are supposed to add the colors then divide by two to keep the brightness constant. This is not how light behaves (it doesn't divide by two on a wall), but it's what you need to make a gradient.
- johnnovak 10y agoNot divide by two; you have to use the gamma transfer curve.
- mark-r 10y ago