Fix for texture preview render with show alpha enabled, now it shows no
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 4 Mar 2013 16:37:05 +0000 (16:37 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 4 Mar 2013 16:37:05 +0000 (16:37 +0000)
transparency when use alpha and calculate alpha are disabled.

It's a bit arbitrary as it's not possible to fully visualize the output
of a texture, that depends on how it's used in the texture stack, but this
is a bit more in line with what you might expect.

source/blender/editors/render/render_preview.c

index dfc80e4..3bf09cb 100644 (file)
@@ -425,15 +425,16 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
                                                
                                                if (tex && sp->slot)
                                                        mat->mtex[0]->which_output = sp->slot->which_output;
-                                               
+
+                                               mat->mtex[0]->mapto &= ~MAP_ALPHA;
+                                               mat->alpha = 1.0f;
+
                                                /* show alpha in this case */
                                                if (tex == NULL || (tex->flag & TEX_PRV_ALPHA)) {
-                                                       mat->mtex[0]->mapto |= MAP_ALPHA;
-                                                       mat->alpha = 0.0f;
-                                               }
-                                               else {
-                                                       mat->mtex[0]->mapto &= ~MAP_ALPHA;
-                                                       mat->alpha = 1.0f;
+                                                       if (!(tex && tex->type == TEX_IMAGE && (tex->imaflag & (TEX_USEALPHA|TEX_CALCALPHA)) == 0)) {
+                                                               mat->mtex[0]->mapto |= MAP_ALPHA;
+                                                               mat->alpha = 0.0f;
+                                                       }
                                                }
                                        }
                                }