             // (except if the current ray lies inside a dielectric, in which case there is no volumetric scattering, i.e. the dielectric displaces the volume)
             vec3 pScatter;
             float sigma_t;
-            bool scatter = false;
+            bool interacted = false;
             float segmentLength = length(pW_next - pW);
             float distanceMarched = -log(rand(rnd)) * inv_sigma_t_max;
             int steps = 0; 
-            while (!scatter && distanceMarched<segmentLength-eps && steps<maxWoodcockSteps)
+            while (distanceMarched<segmentLength-eps && steps<maxWoodcockSteps)
             {
                 pScatter = pW + distanceMarched*rayDir;
                 sigma_t = VOLUME_EXTINCTION(pScatter);
-                scatter = bool(rand(rnd) < sigma_t * inv_sigma_t_max);
-                if (!scatter) distanceMarched += -log(rand(rnd)) * inv_sigma_t_max;
+                interacted = bool(rand(rnd) < sigma_t * inv_sigma_t_max);
+                if (interacted) break;
+                distanceMarched += -log(rand(rnd)) * inv_sigma_t_max;
                 steps++;
             }
             
-            if (scatter) return 0.0; // on scattering, return zero visibility
+            if (interacted) return 0.0; // on absorption/scattering, return zero visibility
             else
             {
                 pW = pW_next;


vec3 sampleSunDir(inout vec4 rnd)
{
    float theta = sunAngularSize * M_PI/180.0 * sqrt(rand(rnd));
    float phi = 2.0 * M_PI * rand(rnd);
    float costheta = cos(theta);
    float sintheta = sin(theta);
    float cosphi = cos(phi);
    float sinphi = sin(phi);
    float x = sintheta * cosphi;

        pW = pW_next;
        vec3 nW = normal(pW, hitMaterial);
        Basis basis = makeBasis(nW);
      
        // Sample BSDF for the next bounce direction
        vec3 woL = worldToLocal(woW, basis);
        vec3 wiL;
