Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 03 October 2012 - 11:21 AM
Posted 03 October 2012 - 04:43 PM
“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”
Posted 03 October 2012 - 05:24 PM
Posted 03 October 2012 - 08:41 PM
This is a big vague -- are you talking about creating a linear gradient from and displaying it on an sRGB monitor, and then transforming that linear gradient into sRGB space and displaying it on an sRGB monitor?I'm wondering why sRGB gradients look "better" than linear space gradients. Fox example the gradient from black(0x000000) to white(0xFFFFFF) clearly lacks some black shades - http://scanline.ca/gradients. I tried to check it on different LCD's, but everywhere the sRGB one looks better. Additionally the CIELAB gradient looks just like the sRGB one. On the other hand examples like this one - http://filmicgames.com/archives/354 prove that the color in the middle of the gradient should be ~0.73 and not 0.5. So I'm quite lost here.
If you're working with mathematical brightness values, then you should always work in linear space, however the default assumption is that the user's monitor is in sRGB space (and most image files are also saved in sRGB space, so when they're displayed, no correction is required). So if you're creating a gradient of intensity values, you can first create a linear gradient, and then transform it using the sRGB curve for storage/display.I still don't see why linear space and gamma correction should be used while resizing images, but not when generating gradients.
The second one is a linear gradient (being viewed on an sRGB monitor). The first one is a linear gradient that's been "gamma corrected" into sRGB space (and then viewed on an sRGB monitor). The second one is obviously not going to appear as intended due to the "gamma mismatch" between intended brightness and actual displayed brightness.First one uses linear color space and gamma correction and the color in the middle is (187/255,187/255,187/255). Second one doesn't and color in it's middle is - (128/255,128/255,128/255)
Edited by Hodgman, 03 October 2012 - 08:44 PM.
Posted 04 October 2012 - 03:20 AM
This is a big vague -- are you talking about creating a linear gradient from and displaying it on an sRGB monitor, and then transforming that linear gradient into sRGB space and displaying it on an sRGB monitor?
vec3 colorA = vec3( 0, 0, 0 ); vec3 colorB = vec3( 1, 1, 1 ); vec3 linearColorA = pow( colorA, 2.2 ); vec3 linearColorB = pow( colorB, 2.2 ); for ( unsigned i = 0; i < 255; ++i ) { vec3 currColor = lerp( linearColorA, linearColorB, i / 255 ); result[ i ] = pow( currColor, 1.0 / 2.2 ); }And it looks like this:
vec3 colorA = vec3( 0, 0, 0 ); vec3 colorB = vec3( 1, 1, 1 ); for ( unsigned i = 0; i < 255; ++i ) { result[ i ] = lerp( colorA, colorB, i / 255 ); }And it looks like this:
So if you're creating a gradient of intensity values, you can first create a linear gradient, and then transform it using the sRGB curve for storage/display.
Posted 04 October 2012 - 03:53 AM
That's a linear gradient, as it's just a linear interpolation of two RGB values.The second one is created in sRGB space.
That's also a linear gradient approximately transformed to sRGB, because the sRGB curve is approximately equal to the "gamma 2.2" curve. This is what I'd call an sRGB gradient (except using the proper curve, instead of the pow2.2 approximation)First gradient is created in linear space and gamma corrected.
Theres a reason for this -- if your monitor is correctly calibrated as an sRGB device, then when standing back from a black/white checkerboard image and squinting, it will appear exactly the same as an image filled with 187 grey. An image filled with 128 grey will appear much darker than the (averaged due to distance/squinting) black/white checkerboard.Now according to http://filmicgames.com/archives/354 if you resize a 2 pixel image, where one pixel is white and second is black then the resulting pixel should have color (187,187,187). So the middle color of the gradient should be (187,187,187) - just like in the first gradient.
this isn't a fair visual comparison because you're skipping over a huge number of values in your first gradient. After 0/255, your second value is 21/255 (pow(1/255,1/2.2)*255), so you've skipped 19 shades in there! Your first gradient would have to be almost 200000 pixels wide for you to see all the unique 256 shades of grey in the 8-bit gamma 2.2 gradient.On the other hand second gradient looks better.
If this is the root problem, can you describe it a bit more -- e.g. what this gradient is for?when you set up a gradient on a button from black to white it looks bad and graphic artists don't like it
Edited by Hodgman, 04 October 2012 - 04:46 AM.
Posted 04 October 2012 - 10:18 AM
The second one might look better because it's made up of 256 unique shades, whereas your first is only made up of 183 shades.
Even though, as above there is a mathematical reason for 187 being "middle grey", if you're using this gradient for an artistic purpose, then the "best" gradient is going to be subjectively defined, not mathematically defined.
If this is the root problem, can you describe it a bit more -- e.g. what this gradient is for?
Posted 04 October 2012 - 11:19 PM
Posted 05 October 2012 - 09:36 AM
"Best" as the one with linear perceptual brightness change.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.