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

ImageryLayer Gamma calculations are wrong #7707

Open
thw0rted opened this issue Apr 3, 2019 · 3 comments
Open

ImageryLayer Gamma calculations are wrong #7707

thw0rted opened this issue Apr 3, 2019 · 3 comments

Comments

@thw0rted
Copy link
Contributor

thw0rted commented Apr 3, 2019

Compare behavior between the Adjustment demo in 1.52 and 1.53. You will have to switch to a different baselayer, per #7706. The Gamma slider in 1.52 makes the image slightly darker when moved to the left (say, 0.9) and slightly lighter when moved to the right (say, 1.1). In 1.53, any value over about 0.5 makes the image lighter, except 1.0 exactly, which behaves as you'd expect it to. Experimentally, 0.45 looks almost identical to 1.0.

Something introduced in 1.53 must have changed the calculation for gamma, and it no longer behaves as intended.

@hpinkos
Copy link
Contributor

hpinkos commented Apr 3, 2019

@bagnell can you look into this?

Possibly related to #7425

@emackey
Copy link
Contributor

emackey commented Apr 11, 2019

I noticed this during a recent Cesium upgrade to one of my projects. Also, @MattPetry reported this to me this morning. In both cases, the "Natural Earth II" imagery is the default, with some custom saturation & gamma settings for style.

Playing with the gamma slider in the 1.53 demo, set to Natural Earth II, you can see that if the slider is exactly at 1.0 it looks correct, but if you move even one pixel in either direction, the image changes radically. There should not be a discontinuity like that at 1.0. Really the correct behavior is shown in 1.52.

@emackey
Copy link
Contributor

emackey commented Apr 11, 2019

Also, there are some strong indicators of what's happened here. The "fast" approximation for converting between linear and sRGB color spaces uses a power of 2.2, such as:

linear = pow(sRGB, vec3(2.2));

The reverse of that uses power of 1.0 / 2.2, or about 0.454545. If you paste that 0.454545 value into the gamma slider of the 1.53 demo, you'll see it exactly matches the 1.0 value.

So I'm thinking that in 1.53 and later, if the user sets a gamma value to anything other than exactly 1.0, then the software assumes that the user is somehow responsible for doing the gamma conversion to get themselves back into sRGB space at the end of the shader. This seems incorrect to me, as the colorspace conversion should be happening independently of (and in addition to) the user's artistic gamma correction settings.

The other controls seem less impacted, but I think they are applying their effects in sRGB space now instead of applying them in linear space. I guess that's OK, except that it was an unannounced breaking change. The gamma behavior is not OK, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment