Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-Leo-Smith committed Apr 17, 2024
1 parent 47f5983 commit 0402e44
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/textures/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,17 @@ class ImageTextureInstance final : public Texture::Instance {
auto encoding = texture->encoding();
auto scale = texture->scale();
if (encoding == ImageTexture::Encoding::SRGB) {
auto rgb = rgba.xyz();
auto linear = ite(
rgba <= 0.04045f,
rgba * (1.0f / 12.92f),
pow((rgba + 0.055f) * (1.0f / 1.055f), 2.4f));
return make_float4(scale * linear);
rgb <= 0.04045f,
rgb * (1.0f / 12.92f),
pow((rgb + 0.055f) * (1.0f / 1.055f), 2.4f));
return make_float4(scale * linear, rgba.w);
}
if (encoding == ImageTexture::Encoding::GAMMA) {
auto rgb = rgba.xyz();
auto gamma = texture->gamma();
return scale * pow(rgba, gamma);
return make_float4(scale * pow(rgb, gamma), rgba.w);
}
return scale * rgba;
}
Expand Down

0 comments on commit 0402e44

Please sign in to comment.