-
Notifications
You must be signed in to change notification settings - Fork 910
Bug? Colors are specified in linear color space #1033
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
Comments
Sort of. Colors given are stated as-is, without any intent of being linear or sRGB. We don't discuss the difference between linear color spaces and gamma color spaces too much. And ultimately that's not the point of the book. We could add some text specifying if a designated color is in linear or in sRGB. What exactly would you recommend? Keep on mind that it's ultimately more important that the book be a good learning tool than perfectly correct |
Since there is a chapter about gamma correction (book 1, chapter 8.3), I would at least mention it. You are switching from a gamma workflow (sRGB colors in -> calculations in nonlinear space-> sRGB colors out) to a linear workflow without changing the values of the colors (sRGB colors in -> [missing linearization] -> calculations in linear space -> gamma conversion -> sRGB colors out). You can do "linear colors in -> calculations in linear space -> gamma conversion -> sRGB colors out", but the problem is that before chapter 8.3 you are interpreting the values as sRGB colors and after chapter 8.3 you are interpreting the same values as linear colors. However, to do it correctly, you'd have to either adjust all the color values after chapter 8.3 or change all the pictures (everything becomes darker). So maybe just add a paragraph and mention that it's not entirely correct. |
By the way, the problem is even more obvious when sampling the texture in book 2, chapter 6.1. jpegs are usually in sRGB color space. For example, with DirectX, you'd usually load the texture as DXGI_FORMAT_R8G8B8A8_UNORM_SRGB format and the hardware would to the linearization for you when sampling it in the shader. But since you are doing it in software, you'd have to do it manually (or just use stbi_loadf instead of stbi_load). |
Closing this out. There is a separate issue to track fixing this in book 2 |
I've noticed that all given colors are linear (non-SRGB).
I don't know if this is intentional, but usually colors are assumed to be SRGB colors and must be linearized before you make any calculations with them.
See for example Unity:
https://docs.unity3d.com/ScriptReference/Color-linear.html
https://docs.unity3d.com/ScriptReference/MaterialPropertyBlock.SetColor.html
The text was updated successfully, but these errors were encountered: