     return environmentRadiance(woutputW);
 }
 
-#ifdef HAS_ATMOSPHERE
-vec3 sampleSkyInVolume(inout vec4 rnd,
-                       inout vec3 woutputW, inout float pdfDir)
-{
-    if (skyPower<RADIANCE_EPSILON)
-        return vec3(0.0);
-    woutputW = sampleSphereUniformly(rnd);
-    pdfDir = 1.0/(4.0*M_PI);
-    return environmentRadiance(woutputW);
-}
-#endif
-
 //////////////////////////////////////////////
 // Sun
 //////////////////////////////////////////////

    return vec3(x, y, z);
}

#ifdef HAS_ATMOSPHERE
vec3 sampleSphereUniformly(inout vec4 rnd)
{
    float z = 1.0 - 2.0*rand(rnd);
    float r = sqrt(max(0.0, 1.0 - z*z));
    float phi = 2.0*M_PI*rand(rnd);
    float x = cos(phi);
    float y = sin(phi);
    // pdf = 1.0/(4.0*M_PI);
    return vec3(x, y, z);
}
#endif

vec3 SURFACE_DIFFUSE_REFL_RGB(in vec3 X, in vec3 nW, in vec3 woW)
{
    vec3 reflRGB = SURFACE_DIFFUSE_REFLECTANCE(surfaceDiffuseAlbedoRGB, X, nW, woW);
    return reflRGB;
}

#ifdef HAS_VOLUME_EMISSION
vec3 VOLUME_EMISSION_EVAL(in vec3 X)
{
    vec3 emission = VOLUME_EMISSION(volumeEmissionColorRGB * volumeEmission, X);
    return emission;
}
#endif // HAS_VOLUME_EMISSION

#ifdef HAS_SURFACE_NORMALMAP
vec3 perturbNormal(in vec3 X, in Basis basis, int material)

uniform vec3 sunDir;
uniform bool sunVisibleDirectly;


#define DENOM_TOLERANCE 1.0e-7
#define PDF_EPSILON 1.0e-6
