Fix T92416: First render with unknown image colorspace looks different

The issue here was that the Barbershop benchmark scene was saved with a
custom OCIO config, which leads to some textures having a unknown
colorspace when loading with a default installation.

This is automatically fixed by Blender during image loading, but since
Cycles queried the colorspace before actually loading the image, it
didn't get the updated value in the first render.

To fix this, just re-query the colorspace after the image is loaded.

Note that non-packed images still get treated as raw data if the
colorspace is unknown, but this is at least consistent and doesn't
magically change when you press F12 a second time.

Differential Revision: https://developer.blender.org/D16427
This commit is contained in:
Lukas Stockner 2022-11-08 22:05:20 +01:00 committed by Thomas Dinges
parent 5bbef85bc8
commit 15b2b53b87
Notes: blender-bot 2023-02-14 07:31:34 +01:00
Referenced by issue #100749, Blender LTS: Maintenance Task 3.3
Referenced by issue #92416, First render of barbershop appears different
1 changed files with 5 additions and 0 deletions

View File

@ -72,6 +72,11 @@ bool BlenderImageLoader::load_metadata(const ImageDeviceFeatures &, ImageMetaDat
metadata.colorspace = u_colorspace_raw;
}
else {
/* In some cases (e.g. T94135), the colorspace setting in Blender gets updated as part of the
* metadata queries in this function, so update the colorspace setting here. */
PointerRNA colorspace_ptr = b_image.colorspace_settings().ptr;
metadata.colorspace = get_enum_identifier(colorspace_ptr, "name");
if (metadata.channels == 1) {
metadata.type = IMAGE_DATA_TYPE_BYTE;
}