Gamma slider in AAA games


Many AAA games have gamma slider in options.
What value range would I have to use in glfwSetGamma to implement similar slider?


I would try this out and see what range you like. I think 1.0f is normal, and in my (albeit brief) testing a range of 0.1f to 3.0f is probably sufficient to cater to most people’s needs.


I would definitely have to play with it. There is really nothing I like or dislike about the range, because I’ve never really used such slider, and would not know what is good or bad.

I probably don’t understand how the values scale, with 0 (exclusive) being minimum, 1.0f being normal and FLT_MAX being maximum. I would guess the range is not linear at all. Slider would usually mean linear range.

Would you say 0.1 - 3.0 range is linear (with 1.0 being a bit off centre - but it’s fine)?


I’ve read quite a few materials on gamma correction. I also understand that implementing gamma slider with glfwSetGamma wouldn’t be ideal, as it would only work for fullscreen windows, but not for windowed windows, because essentially it changes gamma for the whole monitor.

I understand that to display all my colours in linear space, I would have to apply sRGB correction with GL_FRAMEBUFFER_SRGB.

Now, I have an idea of writing gamma correction in shaders. So to implement a gamma slider with 1.0 being sRGB space, I would change all colours in the final image from array that I would produce with similar function to glfwSetGamma? And then do the GL_FRAMEBUFFER_SRGB to make sure my gamma correction is in linear space. So basically I’m creating gamma space (non-sRGB) myself, then making sure GL_FRAMEBUFFER_SRGB makes my values as if they are in linear space.

Does what I said above make sense? Would this be a valid way to do this?


I think that makes sense.

Note that you don’t necessarily need to make a lookup table to implement a gamma curve in a shader, since you’re most likely dealing with 0-1 floats; you can write the conversion directly, e.g. output = pow(output, gamma). That might be faster or slower than a whole load of texture lookups; it would need benchmarking.


Thanks for your input, @tombsar. Yes, having to handle colours with floats makes lookup a bad solution. I’ll try calculating new values on the fly, when I’m doing the rendering part.