// $LastChangedDate: 2009-05-15 14:25:58 -0500 (Fri, 15 May 2009) $

    // Apply shadow.
    if ( uni_shadowMode != SHADOW_MODE_DISABLED )
    {
        const float SHADOW_FACTOR = 0.3;  // dark gray instead of black
        float f;

        if ( uni_shadowMode == SHADOW_MODE_SAMPLE4 )
        {
            const float b = 0.0015;  // bias
            const vec4 i = gl_TexCoord[TEXTURE_UNIT_SHADOW];
            f = 0.0;
            f += shadow2DProj( uni_texture_shadow, vec4(i.x-b, i.y-b, i.z, i.w) ).r;
            f += shadow2DProj( uni_texture_shadow, vec4(i.x-b, i.y+b, i.z, i.w) ).r;
            f += shadow2DProj( uni_texture_shadow, vec4(i.x+b, i.y-b, i.z, i.w) ).r;
            f += shadow2DProj( uni_texture_shadow, vec4(i.x+b, i.y+b, i.z, i.w) ).r;
            f *= 0.25;
        }
        else  // SHADOW_MODE_SAMPLE1
        {
            f = shadow2DProj( uni_texture_shadow, gl_TexCoord[TEXTURE_UNIT_SHADOW] ).r;
        }

        f = max( SHADOW_FACTOR, f );            // dark gray instead of solid black
        gl_FragColor.rgb *= vec3( f, f, f );    // apply shadow to color fragment
    }
