Assorted small volume render related fixes.

This commit is contained in:
Matt Ebb 2010-07-28 08:06:46 +00:00
parent 79dd2cc8e9
commit 4ddcb65399
4 changed files with 10 additions and 17 deletions

@ -558,19 +558,9 @@ void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
shi->mat= vlr->mat; /* shi->mat is being set in nodetree */
}
else {
int tempdepth;
/* XXX dodgy business here, set ray depth to -1
* to ignore raytrace in shade_material_loop()
* this could really use a refactor --Matt */
if (shi->volume_depth == 0) {
tempdepth = shi->depth;
shi->depth = -1;
shade_material_loop(shi, shr);
shi->depth = tempdepth;
} else {
shade_material_loop(shi, shr);
}
shade_material_loop(shi, shr);
}
/* raytrace likes to separate the spec color */
VECSUB(shr->diff, shr->combined, shr->spec);
}

@ -130,7 +130,7 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr)
}
/* depth >= 1 when ray-shading */
if(shi->depth==0) {
if(shi->depth==0 || shi->volume_depth > 0) {
if(R.r.mode & R_RAYTRACE) {
if(shi->ray_mirror!=0.0f || ((shi->mat->mode & MA_TRANSP) && (shi->mat->mode & MA_RAYTRANSP) && shr->alpha!=1.0f)) {
/* ray trace works on combined, but gives pass info */

@ -1644,7 +1644,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
if(((passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT)))
|| (passflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) {
/* AO was calculated for scanline already */
if(shi->depth)
if(shi->depth || shi->volume_depth)
ambient_occlusion(shi);
VECCOPY(shr->ao, shi->ao);
VECCOPY(shr->env, shi->env); // XXX multiply

@ -193,7 +193,7 @@ static void vol_trace_behind(ShadeInput *shi, VlakRen *vlr, float *co, float *co
isect.labda = FLT_MAX;
isect.mode= RE_RAY_MIRROR;
isect.skip = RE_SKIP_VLR_NEIGHBOUR | RE_SKIP_VLR_RENDER_CHECK;
isect.skip = RE_SKIP_VLR_NEIGHBOUR;
isect.orig.ob = (void*) shi->obi;
isect.orig.face = (void*)vlr;
isect.last_hit = NULL;
@ -446,7 +446,7 @@ static void vol_get_transmittance(ShadeInput *shi, float *tr, float *co, float *
const float stepd = (t0 - pt0) * d;
float sigma_t[3];
vol_get_sigma_t(shi, sigma_t, co);
vol_get_sigma_t(shi, sigma_t, p);
tau[0] += stepd * sigma_t[0];
tau[1] += stepd * sigma_t[1];
@ -609,7 +609,10 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float
/* transmittance component (alpha) */
vol_get_transmittance_seg(shi, tr, stepsize, co, density);
if (luminance(tr) < shi->mat->vol.depth_cutoff) break;
if (t0 > t1 * 0.25) {
/* only use depth cutoff after we've traced a little way into the volume */
if (luminance(tr) < shi->mat->vol.depth_cutoff) break;
}
vol_get_emission(shi, emit_col, p);