Fix channel packed images display in the Image/Node editor

Channel packed images should not have their RGB affected by alpha.
rendering in Cycles and Eevee was fine already, but displaying these was
not right in the Image and Node editors.

Not 100% sure what to do for the "Color and Alpha" mode, but I guess
this should stay like it was before (applying the alpha).

"Color", "R", "G", and "B" modes were changed to not have color be
affected by alpha though.

ref. T89034

Maniphest Tasks: T89034

Differential Revision: https://developer.blender.org/D11871
This commit is contained in:
Philipp Oeser 2021-07-09 16:51:46 +02:00
parent d7f88982a8
commit 53cf8e83b3
Notes: blender-bot 2023-02-14 01:57:12 +01:00
Referenced by commit 5f3f5db95d, Cleanup: Clang format
Referenced by issue #88449, Blender LTS: Maintenance Task 2.93
Referenced by issue #89034, TGA Images with any alpha value smaller than one behaves unexpected
1 changed files with 31 additions and 8 deletions

View File

@ -31,6 +31,7 @@
#include "DNA_camera_types.h"
#include "DNA_screen_types.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "ED_image.h"
@ -222,19 +223,30 @@ static void image_cache_image(IMAGE_Data *vedata, Image *image, ImageUser *iuser
copy_v4_fl4(shuffle, 1.0f, 0.0f, 0.0f, 0.0f);
}
else if ((sima_flag & SI_SHOW_R) != 0) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA | IMAGE_DRAW_FLAG_SHUFFLING;
draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
if (IMB_alpha_affects_rgb(ibuf)) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
}
copy_v4_fl4(shuffle, 1.0f, 0.0f, 0.0f, 0.0f);
}
else if ((sima_flag & SI_SHOW_G) != 0) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA | IMAGE_DRAW_FLAG_SHUFFLING;
draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
if (IMB_alpha_affects_rgb(ibuf)) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
}
copy_v4_fl4(shuffle, 0.0f, 1.0f, 0.0f, 0.0f);
}
else if ((sima_flag & SI_SHOW_B) != 0) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA | IMAGE_DRAW_FLAG_SHUFFLING;
draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
if (IMB_alpha_affects_rgb(ibuf)) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
}
copy_v4_fl4(shuffle, 0.0f, 0.0f, 1.0f, 0.0f);
}
else /* RGB */ {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
if (IMB_alpha_affects_rgb(ibuf)) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
}
}
}
if (space_type == SPACE_NODE) {
@ -248,19 +260,30 @@ static void image_cache_image(IMAGE_Data *vedata, Image *image, ImageUser *iuser
copy_v4_fl4(shuffle, 0.0f, 0.0f, 0.0f, 1.0f);
}
else if ((snode->flag & SNODE_SHOW_R) != 0) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA | IMAGE_DRAW_FLAG_SHUFFLING;
draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
if (IMB_alpha_affects_rgb(ibuf)) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
}
copy_v4_fl4(shuffle, 1.0f, 0.0f, 0.0f, 0.0f);
}
else if ((snode->flag & SNODE_SHOW_G) != 0) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA | IMAGE_DRAW_FLAG_SHUFFLING;
draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
if (IMB_alpha_affects_rgb(ibuf)) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
}
copy_v4_fl4(shuffle, 0.0f, 1.0f, 0.0f, 0.0f);
}
else if ((snode->flag & SNODE_SHOW_B) != 0) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA | IMAGE_DRAW_FLAG_SHUFFLING;
draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
if (IMB_alpha_affects_rgb(ibuf)) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
}
copy_v4_fl4(shuffle, 0.0f, 0.0f, 1.0f, 0.0f);
}
else /* RGB */ {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
if (IMB_alpha_affects_rgb(ibuf)) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
}
}
}