Questions about light-linear space

First I'd like to thank Casey for starting this series, have been following since Day 1, I've really benefited a lot from this, really wish there was something like this 10 years ago.

I've been rewatching some of the past episodes on topics that I'm totally unfamiliar with, and on day 94 Casey talked about light-linear space. He mentioned that it wouldn't make any noticeable difference with what he's doing in Handmade Hero, but are there any examples where this sort of gamma correction is necessary? Can someone point me to some examples where there is a problem with non-gamma correction vs gamma correction? 2D or 3D?

Thanks.
This link explains it pretty well: http://filmicgames.com/archives/299

It seems like it's mostly an issue when doing 3D lighting.
Thanks for the link.

I've tried reading it and there are a few things I don't understand.

It says the gray represented by 127 is not the middle gray you'd expect, but it's 187 instead. So does it mean that if you set a pixel as 187, the monitor outputs it as 127 instead?

Also, the article mentions about gamma-space and linear-space. What are the operations that must be done in linear-space in order to be gamma-correct and what are the operations that can be done in gamma-space?
culver_fly
Thanks for the link.

I've tried reading it and there are a few things I don't understand.

It says the gray represented by 127 is not the middle gray you'd expect, but it's 187 instead. So does it mean that if you set a pixel as 187, the monitor outputs it as 127 instead?


In a way. 127 is what our eyes perceive as being "halfway" between black and white. 187 is the actual "50% as many photons as white" halfway point.

Here's a pretty good video, showing what happens if you do color blending without gamma correction: https://www.youtube.com/watch?v=LKnqECcg6Gw
Here's a nice demonstration of the difference:
https://www.shadertoy.com/view/llBGz1
Sizik
127 is what our eyes perceive as being "halfway" between black and white.

From the filmicgames.com link you posted it looks that 187 is what eyes perceive as being halfway between black and white. Look at the second picture in that post and move back from monitor for ~1 meter or so. The bottom square (which is 187) will have almost exactly same gray shade as sides. Top one will look much more darker (which is 128).

Edited by Mārtiņš Možeiko on
mmozeiko
Sizik
127 is what our eyes perceive as being "halfway" between black and white.

From the filmicgames.com link you posted it looks that 187 is what eyes perceive as being halfway between black and white. Look at the second picture in that post and move back from monitor for ~1 meter or so. The bottom square (which is 187) will have almost exactly same gray shade as sides. Top one will look much more darker (which is 128).


You misunderstand. 187 gray is what the monitor displays as being halfway between black and white (i.e. 50% as many photons as white). This is demonstrated with alternating black and white lines, which also give an average 50% as many photons. This is contrasted with 128 gray, which is halfway between black (0) and white (255) in RGB space. Since our eyes see brightness relatively instead of absolutely (i.e. going from 1 light bulb to 2 is a larger brightness change than going from 99 light bulbs to 100), we see 128 gray (which is only 22% as bright) as being halfway, not 187 gray.

See pic:
[attachment=47]grays.png[/attachment]
Thanks for the video, so does it mean that if I want to blend a gray of 64 and a gray of 191, simply adding them up and getting 255 is wrong and I have to square them and root again to get the correct value of 201?

Just to make sure I'm getting it correct, when the monitor displays the color of 64 and 191, the color that our eyes perceive doesn't result to a pure white when they're blended together?

Edited by Culver Fly on
culver_fly
Thanks for the video, so does it mean that if I want to blend a gray of 64 and a gray of 191, simply adding them up and getting 255 is wrong and I have to square them and root again to get the correct value of 201?

Just to make sure I'm getting it correct, when the monitor displays the color of 64 and 191, the color that our eyes perceive doesn't result to a pure white when they're blended together?


Both values are wrong; why would blending a dark shade of gray with a light shade of gray produce an even lighter shade of gray (or white)?

The naive way is to average the two values, which gives you 128 (rounded up). The correct way is to convert both values to the 0-1 range (divide by 255), square both of them, average them, square root the average, and multiply back by 255, which gives you the final value of ~159. The squaring/rooting only works in the 0-1 range (since the result will also be within the 0-1 range), and the 0-255 value of a color channel is meant to represent a value within that range.

(Note: you can do the 0-1 conversion with the naive way too, but it doesn't change the result)

Edited by Mattie on
Ah totally got the math wrong there, but I think I do get it now, thanks a lot.
Sizik
Since our eyes see brightness relatively instead of absolutely (i.e. going from 1 light bulb to 2 is a larger brightness change than going from 99 light bulbs to 100), we see 128 gray (which is only 22% as bright) as being halfway, not 187 gray.



I do not see 128 as "being halfway." On the Filmicgames image, the fields on the side are half black and half white which I would call "being halfway", 187 is definitely the better match on my screen. Even on your image, 187 is the better relative "being halfway" for me.


Is your monitors gamma calibrated to 2.2? This will have a HUGE effect on what you are seeing. Check http://www.lagom.nl/lcd-test/gamma_calibration.php to test.

Is your monitor a TN LCD panel that has poor viewing angles that effect the gamma test as you move around? Again this will have a huge effect on what you see. Check http://www.lagom.nl/lcd-test/viewing_angle.php to test.
Useful link: https://en.wikipedia.org/wiki/Middle_gray
Sizik
Useful link: https://en.wikipedia.org/wiki/Middle_gray


Yes, this is useful to people that think having six or seven different definitions of a middle grey is a good thing.