// Pass 4 (make shadows): fragment program.
void main (float4 projRect                : TEXCOORD0,
           out half4 color                : COLOR,
           uniform samplerRECT shadowMap  : TEXUNIT0,
           uniform samplerRECT smDepthMap : TEXUNIT1,
           uniform samplerRECT smAlphaMap : TEXUNIT2,
           uniform sampler1D sinFalloff   : TEXUNIT3)

{
    // Use hardware shadow map depth comparison and
    // 2x2 filtering support (ARB_shadow).  All
    // textures set to GL_LINEAR filter mode.
    fixed u = texRECTproj(shadowMap, projRect).x;
    fixed p = texRECTproj(smDepthMap, projRect).x;
    fixed a = texRECTproj(smAlphaMap, projRect).x;

    // Are we in shadow?
    fixed v = 1;         // assume not in shadow
    if (p < 1) v = a;    // if in penumbra, use alpha
    if (u < 1) v = 0;    // if in umbra, all shadow

    // Add sinusoidal falloff.
    v = tex1D(sinFalloff, v);

    // ... optional shading calculations go here ...

    color = v; // in practice, modulate shading by v
}
