Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-18 21:52:20 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-19 15:36:42 +0300
commit7aaa7aa9dd79b8c6e37f351fd67a93ba07fbb883 (patch)
tree6d64084b9b104ad3d9f2bbff2b3d0404ec356862 /source/blender/blenkernel
parent3b23b5c638feae0ad6319440771b83a64a1f9ebe (diff)
Images: change alpha settings to support channel packing
This also replaces the Use Alpha setting. We now have these alpha modes: * Straight: store RGB and alpha channels separately with alpha acting as a mask, also known as unassociated alpha. * Premultiplied: transparent RGB pixels are multiplied by the alpha channel. The natural format for renders. * Channel Packed: different images are packed in the RGB and alpha channels, and they should not influence each other. Channel packing is commonly used by game engines to save memory. * None: ignore alpha channel from the file and make image fully opaque. Cycles OSL does not correctly support Channel Packed and None yet, we are missing fine control over the OpenImageIO texture cache to do that. Fixes T53672
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenkernel/intern/image.c24
2 files changed, 17 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 5d659d63e27..077bbce2264 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -27,7 +27,7 @@
* \note Use #STRINGIFY() rather than defining with quotes.
*/
#define BLENDER_VERSION 280
-#define BLENDER_SUBVERSION 69
+#define BLENDER_SUBVERSION 70
/** Several breakages with 280, e.g. collections vs layers. */
#define BLENDER_MINVERSION 280
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index d59ead25396..9960994400f 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -502,6 +502,12 @@ static void image_init_color_management(Image *ima)
if (ibuf->flags & IB_alphamode_premul) {
ima->alpha_mode = IMA_ALPHA_PREMUL;
}
+ else if (ibuf->flags & IB_alphamode_channel_packed) {
+ ima->alpha_mode = IMA_ALPHA_CHANNEL_PACKED;
+ }
+ else if (ibuf->flags & IB_alphamode_ignore) {
+ ima->alpha_mode = IMA_ALPHA_IGNORE;
+ }
else {
ima->alpha_mode = IMA_ALPHA_STRAIGHT;
}
@@ -3592,16 +3598,18 @@ static void image_initialize_after_load(Image *ima, ImBuf *UNUSED(ibuf))
static int imbuf_alpha_flags_for_image(Image *ima)
{
- int flag = 0;
-
- if (ima->flag & IMA_IGNORE_ALPHA) {
- flag |= IB_ignore_alpha;
- }
- else if (ima->alpha_mode == IMA_ALPHA_PREMUL) {
- flag |= IB_alphamode_premul;
+ switch (ima->alpha_mode) {
+ case IMA_ALPHA_STRAIGHT:
+ return 0;
+ case IMA_ALPHA_PREMUL:
+ return IB_alphamode_premul;
+ case IMA_ALPHA_CHANNEL_PACKED:
+ return IB_alphamode_channel_packed;
+ case IMA_ALPHA_IGNORE:
+ return IB_alphamode_ignore;
}
- return flag;
+ return 0;
}
/* the number of files will vary according to the stereo format */