8000 [The Next Week] Image texture is gamma compressed twice · Issue #842 · RayTracing/raytracing.github.io · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[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

Closed
stal12 opened this issue Dec 21, 2020 · 2 comments
Closed

[The Next Week] Image texture is gamma compressed twice #842

stal12 opened this issue Dec 21, 2020 · 2 comments
Assignees

Comments

@stal12
Copy link
stal12 commented Dec 21, 2020

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.

@hollasch hollasch added this to the Backlog milestone Apr 12, 2021
@trevordblack trevordblack self-assigned this Jan 8, 2022
@trevordblack trevordblack modified the milestones: Backlog, v4.0.0 Jan 8, 2022
@trevordblack trevordblack modified the milestones: v4.0.0, v4.0.0-book1 Jun 19, 2023
@trevordblack
Copy link
Collaborator

This issue is relevant to book 1, so I'm putting it in v4.0.0-book1 milestone

@trevordblack trevordblack modified the milestones: v4.0.0-alpha, v4.0.0 Jul 23, 2023
@hollasch hollasch modified the milestones: v4.0.0, v4.0.0-alpha.2 Aug 23, 2023
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 hollasch assigned hollasch and unassigned trevordblack Mar 21, 2024
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
@hollasch
Copy link
Collaborator

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0