// Software pixel shader generated by Wild Magic.
//
// var float4          kVertexColor     $vin.COLOR
// var float4          kTCoord          $vin.TEXCOORD0
// var float4          kPixelColor      $vout.COLOR
// var sampler2DSHADOW ProjectorSampler texunit 0

#include "Wm4SoftRenderer.h"
#include "Wm4ColorRGBA.h"
#include "Wm4Vector2.h"

namespace Wm4
{

ColorRGBA p_ProjectedTexture (const float*, SoftSampler** apkSampler,
    const float* afInPixel)
{
    // Get samplers.
    SoftSampler& rkBaseSampler = *apkSampler[0];

    // Get input values.
    const ColorRGBA& rkVertexColor = *(const ColorRGBA*)&afInPixel[0];
    const float* afTCoord = &afInPixel[4];

    // *** program ***

    // The sampler performs the perspective divide in the texture coordinate.
    ColorRGBA kProjectorColor = rkBaseSampler(afTCoord);

    ColorRGBA kPixelColor = kProjectorColor*rkVertexColor;
    return kPixelColor;
}

WM4_IMPLEMENT_PPROGRAM(ProjectedTexture);
WM4_REGISTER_PPROGRAM(ProjectedTexture);

}
