Assorted small volume render related fixes.
authorMatt Ebb <matt@mke3.net>
Wed, 28 Jul 2010 08:06:46 +0000 (08:06 +0000)
committerMatt Ebb <matt@mke3.net>
Wed, 28 Jul 2010 08:06:46 +0000 (08:06 +0000)
source/blender/render/intern/source/rayshade.c
source/blender/render/intern/source/shadeinput.c
source/blender/render/intern/source/shadeoutput.c
source/blender/render/intern/source/volumetric.c

index ed52f37fcfa337cb7271b242538389bc0c9de5b2..b4a43373ef490e9574709676a1973e274709b213 100644 (file)
@@ -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);
        }       
index 2f0f5c72070f5290c6c60d1644de0bdff4db37a3..fc9aba208703b3c9c789b9d4bb03097f827957f9 100644 (file)
@@ -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 */
index 806cafaf89b4cadf9215481592fa343f0eba4969..81de553b20909361860cc06b2259980198fa5f7b 100644 (file)
@@ -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
index 21a0ab1d2a8e1a3469cb92b5740c7b380cc59d59..4ddbc079e91255b4e66274fcc9423480c64e61fb 100644 (file)
@@ -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);