PistonDevelopers / piston

A modular game engine written in Rust
https://www.piston.rs
MIT License
4.61k stars 235 forks source link

sRGB info and articles #1014

Closed bvssvni closed 8 years ago

bvssvni commented 8 years ago

http://gamedevelopment.tutsplus.com/articles/gamma-correction-and-why-it-matters--gamedev-14466

https://gamedevdaily.io/the-srgb-learning-curve-773b7f68cf7a#.fw5rmjel2

http://www.geeks3d.com/20101001/tutorial-gamma-correction-a-story-of-linearity/

https://en.wikipedia.org/wiki/SRGB

http://www.ryanjuckett.com/programming/rgb-color-space-conversion/

Thumb rule: If humans receive a picture from aliens using linear color space, it will appear darker on our screens than we are used to. This might make us believe the aliens have dark skin. (It is because our screens are not linearly calibrated and image editors, scanners, cameras etc. compensate for it by storing brighter color values).

Tip: The term "gamma corrected" is used about non-linear color space, which can be confusing. The linear color space is "mathematically correct". "Gamma corrected" means changing color values to compensate for the non-linear calibration of computer monitors.

sRGB can be enabled for rendering, which means the GPU uses hardware to convert colors back to linear space in the shaders. If you try to display a picture with sRGB enabled, telling it is RGB, then it will appear brighter. When you pass a uniform color to a shader with sRGB enabled, the color is treated as linear color space. This makes the color turn brighter than expected because the color codes are often copied from an image editor (which uses sRGB).

The colors people are used to are usually in sRGB, so when they do math with it is often wrong.

gaborigloi commented 8 years ago

Relevant OpenGL wiki section about sRGB: https://www.opengl.org/wiki/Image_Format#sRGB_colorspace