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 /source/blender/blenloader
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.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c65
1 files changed, 12 insertions, 53 deletions
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;