-
Notifications
You must be signed in to change notification settings - Fork 920
[The Next Week] Image texture is gamma compressed twice #842
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
This issue is relevant to book 1, so I'm putting it in v4.0.0-book1 milestone |
hollasch
added a commit
that referenced
this issue
Mar 21, 2024
We were using the STBI `stbi_load()` function, which loads gamma-corrected byte data from the given image. Instead, we want our image data to be in linear space for internal computation, with a final gamma=2 correction applied when we write the rendered result. Happily, there's an `stbi_loadf()` function that loads linearly-encoded image data as triples of 32-bit floating-point values. We don't really need to explain all the machinery, as we kind of just plop `rtw_stb_image.h` down for the readers to use. I do add some explanation though that we want loaded images to be in linear color space. Resolves #842
hollasch
added a commit
that referenced
this issue
Mar 23, 2024
We were using the STBI `stbi_load()` function, which loads gamma-corrected byte data from the given image. Instead, we want our image data to be in linear space for internal computation, with a final gamma=2 correction applied when we write the rendered result. Happily, there's an `stbi_loadf()` function that loads linearly-encoded image data as triples of 32-bit floating-point values. We don't really need to explain all the machinery, as we kind of just plop `rtw_stb_image.h` down for the readers to use. I do add some explanation though that we want loaded images to be in linear color space. Resolves #842
Done. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Telling whether a random image employs linear or sRGB color values is usually a hard task. However, linear space is certainly the rarest.
In the more common case that the texture image is gamma corrected already, color values are gamma compressed a second time in the
write_color
function, and the resulting texture appears brighter than the original image, like in the example from the book.I suggest to gamma decode colors after the image is loaded, or at least to mention the issue because it is very common.
The text was updated successfully, but these errors were encountered: