The new "transmissivity" option for ray-transparent now can be controlled.

By default it is disabled (depth 0.0), so rendering is as usual.

The meaning of "depth" and "falloff" will be extensively shown in the
release log pages. Coming soon!

(Patch provided by Ed Halley)
This commit is contained in:
Ton Roosendaal
2006-06-16 13:11:21 +00:00
parent a33798d697
commit 3356c4ba2f
4 changed files with 28 additions and 15 deletions

View File

@@ -136,6 +136,8 @@ void init_material(Material *ma)
ma->fresnel_tra= 0.0;
ma->fresnel_tra_i= 1.25;
ma->fresnel_mir_i= 1.25;
ma->tx_limit= 100.0;
ma->tx_falloff= 1.0;
ma->rampfac_col= 1.0;
ma->rampfac_spec= 1.0;

View File

@@ -67,7 +67,8 @@ typedef struct Material {
float fresnel_mir, fresnel_mir_i;
float fresnel_tra, fresnel_tra_i;
float filter; /* filter added, for raytrace transparency */
float filter; /* filter added, for raytrace transparency and transmissivity */
float tx_limit, tx_falloff;
short ray_depth, ray_depth_tra;
short har;
char seed1, seed2;

View File

@@ -1542,19 +1542,30 @@ static void color_combine(float *result, float fac1, float fac2, float *col1, fl
static float shade_by_transmission(Isect *is, ShadeInput *shi, ShadeResult *shr)
{
float dx, dy, dz, d;
float dx, dy, dz, d, p;
if (0 == (shi->mat->mode & (MA_RAYTRANSP|MA_ZTRA)))
return -1;
if (shi->mat->tx_limit <= 0.0) {
d= 0.0;
} else {
/* shi.co[] calculated by shade_ray() */
dx= shi->co[0] - is->start[0];
dy= shi->co[1] - is->start[1];
dz= shi->co[2] - is->start[2];
d= sqrt(dx*dx+dy*dy+dz*dz);
if (d > shi->mat->tx_limit)
d= shi->mat->tx_limit;
shr->alpha *= d;
if (shr->alpha > 1.0) shr->alpha= 1.0;
p = shi->mat->tx_falloff;
if(p < 0.0) p= 0.0;
else if (p > 10.0) p= 10.0;
shr->alpha *= pow(d, p);
if (shr->alpha > 1.0)
shr->alpha= 1.0;
}
return d;
}

View File

@@ -2821,23 +2821,21 @@ static void material_panel_tramir(Material *ma)
uiDefButF(block, NUM, B_MATPRV, "Filt:", 10,110,150,20, &(ma->filter), 0.0, 1.0, 10, 0, "Amount of filtering for transparent raytrace");
uiDefButBitI(block, TOG, MA_RAYTRANSP, B_MATRAYTRANSP,"Ray Transp",160,110,150,20, &(ma->mode), 0, 0, 0, 0, "Enables raytracing for transparency rendering");
uiBlockBeginAlign(block);
/* uiBlockBeginAlign(block); */
uiDefButF(block, NUMSLI, B_MATPRV, "IOR ", 10,90,200,20, &(ma->ang), 1.0, 3.0, 100, 2, "Sets the angular index of refraction for raytrace");
uiDefButS(block, NUM, B_MATPRV, "Depth:", 210,90,100,20, &(ma->ray_depth_tra), 0.0, 10.0, 100, 0, "Amount of refractions calculated maximal ");
uiDefButF(block, NUMSLI, B_MATPRV, "Fresnel ", 10,70,160,20, &(ma->fresnel_tra), 0.0, 5.0, 10, 2, "Power of Fresnel for transparency");
uiDefButF(block, NUMSLI, B_MATPRV, "Fac ", 170,70,140,20, &(ma->fresnel_tra_i), 1.0, 5.0, 10, 2, "Blending factor for Fresnel");
uiDefButF(block, NUMSLI, B_MATPRV, "Limit ", 10,70,160,20, &(ma->tx_limit), 0.0, 100.0, 10, 2, "Depth limit for transmissivity (0.0 is disabled)");
uiDefButF(block, NUMSLI, B_MATPRV, "Falloff ", 170,70,140,20, &(ma->tx_falloff), 0.1, 10.0, 10, 2, "Falloff power for transmissivity (1.0 is linear)");
uiDefButF(block, NUMSLI, B_MATPRV, "Fresnel ", 10,50,160,20, &(ma->fresnel_tra), 0.0, 5.0, 10, 2, "Power of Fresnel for transparency");
uiDefButF(block, NUMSLI, B_MATPRV, "Fac ", 170,50,140,20, &(ma->fresnel_tra_i), 1.0, 5.0, 10, 2, "Blending factor for Fresnel");
uiBlockBeginAlign(block);
uiDefButF(block, NUMSLI, B_MATPRV, "SpecTra ", 10,40,150,20, &(ma->spectra), 0.0, 1.0, 0, 0, "Makes specular areas opaque on transparent materials");
uiDefButF(block, NUMSLI, B_MATPRV, "Add ", 160,40,150,20, &(ma->add), 0.0, 1.0, 0, 0, "Sets a glow factor for transparant materials");
uiDefButF(block, NUMSLI, B_MATPRV, "SpecTra ", 10,20,150,20, &(ma->spectra), 0.0, 1.0, 0, 0, "Makes specular areas opaque on transparent materials");
uiDefButF(block, NUMSLI, B_MATPRV, "Add ", 160,20,150,20, &(ma->add), 0.0, 1.0, 0, 0, "Sets a glow factor for transparant materials");
uiBlockBeginAlign(block);
uiDefButBitI(block, TOG, MA_NOMIST, 0, "No Mist", 10,10,150,20, &(ma->mode), 0, 0, 0, 0, "Sets the material to ignore mist values");
uiDefButBitI(block, TOG, MA_ENV, 0, "Env", 160,10,150,20, &(ma->mode), 0, 0, 0, 0, "Causes faces to render with alpha zero: allows sky/backdrop to show through (only for solid faces)");
uiBlockEndAlign(block);
}
@@ -3093,7 +3091,8 @@ static void material_panel_material(Material *ma)
uiDefButBitI(block, TOG, MA_VERTEXCOLP, B_REDR, "VCol Paint", 82,166,74,20, &(ma->mode), 0, 0, 0, 0, "Replaces material's colours with vertex colours");
uiDefButBitI(block, TOG, MA_FACETEXTURE, B_REDR, "TexFace", 156,166,74,20, &(ma->mode), 0, 0, 0, 0, "Sets UV-Editor assigned texture as color and texture info for faces");
uiDefButBitI(block, TOG, MA_SHLESS, B_MATPRV, "Shadeless", 230,166,73,20, &(ma->mode), 0, 0, 0, 0, "Makes material insensitive to light or shadow");
uiDefButBitI(block, TOG, MA_NOMIST, 0, "No Mist", 8,146,146,20, &(ma->mode), 0, 0, 0, 0, "Sets the material to ignore mist values");
uiDefButBitI(block, TOG, MA_ENV, 0, "Env", 158,146,145,20, &(ma->mode), 0, 0, 0, 0, "Causes faces to render with alpha zero: allows sky/backdrop to show through (only for solid faces)");
}
uiBlockSetCol(block, TH_AUTO);
uiBlockBeginAlign(block);