* Added a button to the volume material controls 'Alpha' to generate an

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.
This commit is contained in:
Matt Ebb
2008-11-11 23:24:10 +00:00
parent 3b2f996c25
commit bf747a30af
3 changed files with 19 additions and 4 deletions

View 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

View 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];

View 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");
*/