Fix T101850: Cycles DDS oversaturation when alpha is in use

DDS files coming through OIIO needed a similar treatment as TGA in
T99565; just for DDS OIIO just never set the "unassociated alpha"
attribute. Fixes T101850.

Reviewed By: Brecht Van Lommel
Differential Revision: https://developer.blender.org/D16270
This commit is contained in:
Aras Pranckevicius 2022-10-17 21:03:17 +03:00 committed by Philipp Oeser
parent eca95d35ba
commit 427b0a0ab2
Notes: blender-bot 2023-02-14 08:45:09 +01:00
Referenced by issue #100749, Blender LTS: Maintenance Task 3.3
Referenced by issue #101850, Cycles DDS oversaturation when alpha is in use
1 changed files with 10 additions and 5 deletions

View File

@ -197,11 +197,16 @@ bool OIIOImageLoader::load_pixels(const ImageMetaData &metadata,
if (associate_alpha) {
do_associate_alpha = spec.get_int_attribute("oiio:UnassociatedAlpha", 0);
/* Workaround OIIO not detecting TGA file alpha the same as Blender (since #3019).
* We want anything not marked as premultiplied alpha to get associated. */
if (!do_associate_alpha && spec.alpha_channel != -1 &&
strcmp(in->format_name(), "targa") == 0) {
do_associate_alpha = spec.get_int_attribute("targa:alpha_type", -1) != 4;
if (!do_associate_alpha && spec.alpha_channel != -1) {
/* Workaround OIIO not detecting TGA file alpha the same as Blender (since #3019).
* We want anything not marked as premultiplied alpha to get associated. */
if (strcmp(in->format_name(), "targa") == 0) {
do_associate_alpha = spec.get_int_attribute("targa:alpha_type", -1) != 4;
}
/* OIIO DDS reader never sets UnassociatedAlpha attribute. */
if (strcmp(in->format_name(), "dds") == 0) {
do_associate_alpha = true;
}
}
}