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:
authorCampbell Barton <ideasman42@gmail.com>2011-06-15 05:56:49 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-06-15 05:56:49 +0400
commit1d41694e6974ee870fdeef2a5516d8368a2b9853 (patch)
tree37722d5423f557f732e31a4bdda23275fb379830 /source/blender/editors/object
parent62ba2d4c6811c1b2b27163c46f9bbc0e696f63ee (diff)
fix [#27662] Storing png/tga images ignore Alpha settings
- don't clear alpha when baking RGB images - when baking results in partial alpha. set the depth to 32.
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/object_bake.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index 565c5810cff..c669a69b157 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -854,10 +854,14 @@ static void finish_images(MultiresBakeRender *bkr)
Image *ima= (Image*)link->data;
int i;
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
+ short is_new_alpha;
if(ibuf->x<=0 || ibuf->y<=0)
continue;
+ /* must check before filtering */
+ is_new_alpha= (ibuf->depth != 32) && BKE_alphatest_ibuf(ibuf);
+
/* Margin */
if(bkr->bake_filter) {
char *temprect;
@@ -882,6 +886,18 @@ static void finish_images(MultiresBakeRender *bkr)
IMB_filter_extend(ibuf, (char *)ibuf->userdata);
}
+ /* if the bake results in new alpha then change the image setting */
+ if(is_new_alpha) {
+ ibuf->depth= 32;
+ }
+ else {
+ if(bkr->bake_filter) {
+ /* clear alpha added by filtering */
+ IMB_rectfill_alpha(ibuf, 1.0f);
+ }
+ }
+
+
ibuf->userflags|= IB_BITMAPDIRTY;
if(ibuf->mipmap[0]) {
ibuf->userflags|= IB_MIPMAP_INVALID;
@@ -1028,7 +1044,8 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l
static void clear_images(MTFace *mtface, int totface)
{
int a;
- float vec[4]= {0.0f, 0.0f, 0.0f, 0.0f};
+ const float vec_alpha[4]= {0.0f, 0.0f, 0.0f, 0.0f};
+ const float vec_solid[4]= {0.0f, 0.0f, 0.0f, 1.0f};
for(a= 0; a<totface; a++)
mtface[a].tpage->id.flag&= ~LIB_DOIT;
@@ -1039,7 +1056,7 @@ static void clear_images(MTFace *mtface, int totface)
if((ima->id.flag&LIB_DOIT)==0) {
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
- IMB_rectfill(ibuf, vec);
+ IMB_rectfill(ibuf, (ibuf->depth == 32) ? vec_alpha : vec_solid);
ima->id.flag|= LIB_DOIT;
}
}