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@pandora.be>2013-03-04 17:18:14 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-03-04 17:18:14 +0400
commit42ca1c8dcd8d148124b9d5fcf262887cac9909c1 (patch)
tree963f762d9a16a4fb4f60604efbda99258b6113e0
parent7a1086d9a19152ec986e350a0db9a02398bd4761 (diff)
Fix for image transparency backwards compatibility. Now the texture datablock has
a Use Alpha option again. This makes the case where you enabled Premultiply on the image and disabled Use Alpha on the texture work again. That's mostly useful when you have a straight alpha image file which has no useful RGB colors in zero alpha regions (e.g. renders). Then sometimes you don't want to use the alpha for the texture stack mixing, but you still want to multiply it into the RGB channels to avoid a blocky transition into zero alpha regions. This also removes the version patch that copied image datablocks because it's not reliable and might be causing bug #34434. This does mean we are no longer backwards compatible for cases where two different texture datablocks with Use Alpha enabled and disabled where using the same image.
-rw-r--r--release/scripts/startup/bl_ui/properties_texture.py3
-rw-r--r--source/blender/blenkernel/BKE_blender.h2
-rw-r--r--source/blender/blenkernel/intern/texture.c2
-rw-r--r--source/blender/blenloader/intern/readfile.c65
-rw-r--r--source/blender/gpu/intern/gpu_material.c2
-rw-r--r--source/blender/makesdna/DNA_texture_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_texture.c5
-rw-r--r--source/blender/render/intern/source/imagetexture.c6
8 files changed, 27 insertions, 60 deletions
diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py
index dd30627abff..2d064404828 100644
--- a/release/scripts/startup/bl_ui/properties_texture.py
+++ b/release/scripts/startup/bl_ui/properties_texture.py
@@ -448,6 +448,9 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, Panel):
col = split.column()
col.label(text="Alpha:")
+ row = col.row()
+ row.active = tex.image and tex.image.use_alpha
+ row.prop(tex, "use_alpha", text="Use")
col.prop(tex, "use_calculate_alpha", text="Calculate")
col.prop(tex, "invert_alpha", text="Invert")
col.separator()
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index d66909449e4..74f20e265e1 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 266
-#define BLENDER_SUBVERSION 0
+#define BLENDER_SUBVERSION 1
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 262
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 55a0f3752a1..2ae76ea6d1c 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -440,7 +440,7 @@ void default_tex(Tex *tex)
tex->type = TEX_CLOUDS;
tex->stype = 0;
tex->flag = TEX_CHECKER_ODD;
- tex->imaflag = TEX_INTERPOL | TEX_MIPMAP;
+ tex->imaflag = TEX_INTERPOL | TEX_MIPMAP | TEX_USEALPHA;
tex->extend = TEX_REPEAT;
tex->cropxmin = tex->cropymin = 0.0;
tex->cropxmax = tex->cropymax = 1.0;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 9c6e82cf998..48e2814e018 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -8663,8 +8663,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 5)) {
Scene *scene;
- Image *image, *nimage;
- Tex *tex, *otex;
+ Image *image;
+ Tex *tex;
bNodeTreeType *ntreetype;
bNodeTree *ntree;
@@ -8711,67 +8711,17 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
else {
BKE_image_alpha_mode_from_extension(image);
}
-
- image->flag &= ~IMA_DONE_TAG;
}
- /* use alpha flag moved from texture to image datablock */
for (tex = main->tex.first; tex; tex = tex->id.next) {
if (tex->type == TEX_IMAGE && (tex->imaflag & TEX_USEALPHA) == 0) {
image = blo_do_versions_newlibadr(fd, tex->id.lib, tex->ima);
- /* skip if no image or already tested */
- if (!image || (image->flag & (IMA_DONE_TAG|IMA_IGNORE_ALPHA)))
- continue;
-
- image->flag |= IMA_DONE_TAG;
-
- /* we might have some textures using alpha and others not, so we check if
- * they exist and duplicate the image datablock if necessary */
- for (otex = main->tex.first; otex; otex = otex->id.next)
- if (otex->type == TEX_IMAGE && (otex->imaflag & TEX_USEALPHA))
- if (image == blo_do_versions_newlibadr(fd, otex->id.lib, otex->ima))
- break;
-
- /* no duplication if the texture and image datablock are not
- * from the same .blend file, the image datablock may not have
- * been loaded from a library file otherwise */
- if (otex && (tex->id.lib == image->id.lib)) {
- /* copy image datablock */
- nimage = BKE_image_copy(main, image);
- nimage->flag |= IMA_IGNORE_ALPHA|IMA_DONE_TAG;
- nimage->id.us--;
-
- /* we need to do some trickery to make file loading think
- * this new datablock is part of file we're loading */
- blo_do_versions_oldnewmap_insert(fd->libmap, nimage, nimage, 0);
- nimage->id.lib = image->id.lib;
- nimage->id.flag |= (image->id.flag & LIB_NEED_LINK);
-
- /* assign new image, and update the users counts accordingly */
- for (otex = main->tex.first; otex; otex = otex->id.next) {
- if (otex->type == TEX_IMAGE && (otex->imaflag & TEX_USEALPHA) == 0) {
- if (image == blo_do_versions_newlibadr(fd, otex->id.lib, otex->ima)) {
- if (!(otex->id.flag & LIB_NEED_LINK)) {
- image->id.us--;
- nimage->id.us++;
- }
- otex->ima = nimage;
- break;
- }
- }
- }
- }
- else {
- /* no other textures using alpha, just set the flag */
+ if (image && (image->flag & IMA_DO_PREMUL) == 0)
image->flag |= IMA_IGNORE_ALPHA;
- }
}
}
- for (image = main->image.first; image; image = image->id.next)
- image->flag &= ~IMA_DONE_TAG;
-
ntreetype = ntreeGetType(NTREE_COMPOSIT);
if (ntreetype && ntreetype->foreach_nodetree)
ntreetype->foreach_nodetree(main, fd, do_version_node_straight_image_alpha_workaround);
@@ -8779,6 +8729,15 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
do_version_node_straight_image_alpha_workaround(fd, NULL, ntree);
}
+ else if (main->versionfile < 266 || (main->versionfile == 266 && main->subversionfile < 1)) {
+ /* texture use alpha was removed for 2.66 but added back again for 2.66a,
+ * for compatibility all textures assumed it to be enabled */
+ Tex *tex;
+
+ for (tex = main->tex.first; tex; tex = tex->id.next)
+ if (tex->type == TEX_IMAGE)
+ tex->imaflag |= TEX_USEALPHA;
+ }
if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 7)) {
Curve *cu;
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index d7ac6febfb7..636c44d3e80 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -1035,7 +1035,7 @@ static void do_material_tex(GPUShadeInput *shi)
GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser, FALSE), &tin, &trgb);
rgbnor= TEX_RGB;
- talpha = (tex->ima->flag & IMA_IGNORE_ALPHA) == 0;
+ talpha = ((tex->imaflag & TEX_USEALPHA) && tex->ima && (tex->ima->flag & IMA_IGNORE_ALPHA) == 0);
}
else {
continue;
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index ea4f281efd6..dd63e6aad59 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -340,7 +340,7 @@ typedef struct ColorMapping {
/* imaflag */
#define TEX_INTERPOL 1
-#define TEX_USEALPHA 2 /* deprecated, used for versioning only */
+#define TEX_USEALPHA 2
#define TEX_MIPMAP 4
#define TEX_IMAROT 16
#define TEX_CALCALPHA 32
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index e007fe67c0b..2d1b75afe5b 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -1196,6 +1196,11 @@ static void rna_def_texture_image(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Flip Axis", "Flip the texture's X and Y axis");
RNA_def_property_update(prop, 0, "rna_Texture_update");
+ prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_USEALPHA);
+ RNA_def_property_ui_text(prop, "Use Alpha", "Use the alpha channel information in the image");
+ RNA_def_property_update(prop, 0, "rna_Texture_update");
+
prop = RNA_def_property(srna, "use_calculate_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_CALCALPHA);
RNA_def_property_ui_text(prop, "Calculate Alpha", "Calculate an alpha channel based on RGB values in the image");
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index 12286fc9999..60f554675ee 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -224,7 +224,7 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
}
/* keep this before interpolation [#29761] */
- if (tex->ima && (tex->ima->flag & IMA_IGNORE_ALPHA) == 0) {
+ if ((tex->imaflag & TEX_USEALPHA) && tex->ima && (tex->ima->flag & IMA_IGNORE_ALPHA) == 0) {
if ((tex->imaflag & TEX_CALCALPHA) == 0) {
texres->talpha = TRUE;
}
@@ -1098,7 +1098,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
/* mipmap test */
image_mipmap_test(tex, ibuf);
- if (tex->ima && (tex->ima->flag & IMA_IGNORE_ALPHA) == 0) {
+ if ((tex->imaflag & TEX_USEALPHA) && tex->ima && (tex->ima->flag & IMA_IGNORE_ALPHA) == 0) {
if ((tex->imaflag & TEX_CALCALPHA) == 0)
texres->talpha = 1;
}
@@ -1514,7 +1514,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
/* mipmap test */
image_mipmap_test(tex, ibuf);
- if (tex->ima && (tex->ima->flag & IMA_IGNORE_ALPHA) == 0) {
+ if ((tex->imaflag & TEX_USEALPHA) && tex->ima && (tex->ima->flag & IMA_IGNORE_ALPHA) == 0) {
if ((tex->imaflag & TEX_CALCALPHA) == 0) {
texres->talpha = TRUE;
}