                 float sunPdf;
                 vec3 woutputW;
                 vec3 Li = sampleSunAtSurface(basis, rnd, woutputW, sunPdf);
-                vec3 TrToLight = transmittanceOverSegment(pW_hit+dPw, woutputW, maxLengthScale);
                 if (averageComponent(Li) > RADIANCE_EPSILON)
-                    Ldirect += f * TrToLight * Li / max(PDF_EPSILON, sunPdf) * abs(dot(woutputW, nW));
+                {
+                    Li *= Transmittance(pW+dPw, woutputW);
+                    Ldirect += f * Li/max(PDF_EPSILON, sunPdf) * abs(dot(woutputW, nW));
+                }
             }
-#ifdef HAS_ATMOSPHERE
-            vec3 TrToHit = transmittanceOverFreeSegment(primaryStart, primaryDir, rayLength);
-#else
-            vec3 TrToHit = vec3(1.0);
-#endif
-            L += TrToHit * Ldirect;
-
-#ifdef HAS_ATMOSPHERE
-            // Add term for single-scattering in the homogeneous atmosphere over the segment up to the closest hit
-            vec3 Lscatter = atmosphericInscatteringRadiance(primaryStart, primaryDir, rayLength, rnd);
-            L += Lscatter;
-#endif
-
-#ifdef HAS_VOLUME_EMISSION
-            // Add volumetric emission at the surface point, if present (treating it as an isotropic radiance field)
-            L += TrToHit * VOLUME_EMISSION_EVAL(pW_hit);
-#endif
+            RGB += Ldirect;
         }
-
-        // Miss logic
-        else
-        {
-            vec3 TrToInfinity = vec3(1.0);
-#ifdef HAS_ATMOSPHERE
-            // Add term for single-inscattering in the homogeneous atmosphere over the segment to infinity
-            vec3 Lscatter = atmosphericInscatteringRadiance(primaryStart, primaryDir, maxLengthScale, rnd);
-            L += Lscatter;
-            TrToInfinity = transmittanceOverFreeSegment(primaryStart, primaryDir, maxLengthScale);
-#endif
-            if (envMapVisible)      L += TrToInfinity * environmentRadiance(primaryDir);
-            if (sunVisibleDirectly) L += TrToInfinity * sunRadiance(primaryDir);
-        }
-
-    } // sample n of __MAX_SAMPLES_PER_FRAME__
-
-    L /= float(__MAX_SAMPLES_PER_FRAME__);
-
-    vec3 XYZ = rgbToXyz(L);
+        else if (envMapVisible)
+            RGB += environmentRadiance(primaryDir);
+    } // sample n
+    RGB /= float(__MAX_SAMPLES_PER_FRAME__);
+
+    vec3 XYZ = rgbToXyz(RGB);
 
     // Write updated radiance and sample count
     vec4 oldL = texture(Radiance, vTexCoord);

    INIT();

    vec2 pixel = gl_FragCoord.xy;
    vec3 L = vec3(0.0);
    for (int n=0; n<__MAX_SAMPLES_PER_FRAME__; ++n)
    {
        // Jitter over pixel

    return sunRadiance(woutputW);
}

////////////////////////////////////////////////////////////////////////////////
// Ambient occlusion integrator
////////////////////////////////////////////////////////////////////////////////
