* Added a button to the volume material controls 'Alpha' to generate an
authorMatt Ebb <matt@mke3.net>
Tue, 11 Nov 2008 23:24:10 +0000 (23:24 +0000)
committerMatt Ebb <matt@mke3.net>
Tue, 11 Nov 2008 23:24:10 +0000 (23:24 +0000)
alpha channel based on the volume's transmission properties, allowing you
to use it in comp etc.

I'd rather not have this button at all, and make it just work properly
by default, however it causes problems with overlapping volumes when
'premul' is on (stoopid thing..) so for the time being, there's the
button. I'll try and fix this up later on when I have more time.

source/blender/makesdna/DNA_material_types.h
source/blender/render/intern/source/volumetric.c
source/blender/src/buttons_shading.c

index 66f23c7905d618f00e9a1abc7f81c96553597867..f332537e9a89c87a265473a0ec14a4e8d8183e52 100644 (file)
@@ -359,6 +359,7 @@ typedef struct Material {
 #define MA_VOL_ATTENUATED      2
 #define MA_VOL_RECVSHADOW      4
 #define MA_VOL_PRECACHESHADING 8
+#define MA_VOL_USEALPHA                16
 
 /* vol_phasefunc_type */
 #define MA_VOL_PH_ISOTROPIC            0
index 02ebbd83c3173908b7a116ea4587d1c90d6e20f2..52d23de45ff690199cb499d93f425d3a1153708d 100644 (file)
@@ -656,8 +656,12 @@ void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr)
                shr->combined[1] = col[1];
                shr->combined[2] = col[2];
                
-               //if (col[3] > 1.0f)
-               col[3] = 1.0f;
+               if (shi->mat->vol_shadeflag & MA_VOL_USEALPHA) {
+                       if (col[3] > 1.0f)
+                               col[3] = 1.0f;
+               }
+               else
+                       col[3] = 1.0f;
                shr->combined[3] = col[3];
                shr->alpha = col[3];
                
@@ -683,8 +687,12 @@ void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr)
                shr->combined[1] = col[1];
                shr->combined[2] = col[2];
                
-               //if (col[3] > 1.0f) 
-               col[3] = 1.0f;
+               if (shi->mat->vol_shadeflag & MA_VOL_USEALPHA) {
+                       if (col[3] > 1.0f)
+                               col[3] = 1.0f;
+               }
+               else
+                       col[3] = 1.0f;
                shr->combined[3] = col[3];
                shr->alpha = col[3];
                
index 5ed39764af048e21d9bb699cf5ddcbb47ea670d9..3e5f530503314d3552a1613713b595bc65981fae 100644 (file)
@@ -4447,6 +4447,12 @@ static void material_panel_material_volume(Material *ma)
                uiBlockEndAlign(block);
        }
        
+       yco -= YSPACE;
+       
+       uiDefButBitS(block, TOG, MA_VOL_USEALPHA, B_MATPRV, "Alpha",
+               X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_shadeflag), 0, 0, 0, 0, "Generate an alpha channel (causes problems with Premul)");
+       
+       
        /*uiDefButBitS(block, TOG, MA_VOL_RECVSHADOW, B_MATPRV, "Receive Shadows",
                X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_shadeflag), 0, 0, 0, 0, "Receive shadows from external objects");
        */