// Software vertex shader generated by Wild Magic.
//
// var float3   kModelPosition    $vin.POSITION
// var float4   kClipPosition     $vout.POSITION
// var float4   kVertexColor      $vout.COLOR
// var float4x4 WVPMatrix         c[0]
// var float3   MaterialEmissive  c[4]
// var float3   MaterialAmbient   c[5]
// var float3   Light0Ambient     c[6]
// var float4   Light0Attenuation c[7]

#include "Wm4SoftRendererPCH.h"
#include "Wm4SoftRenderer.h"
#include "Wm4Matrix4.h"
#include "Wm4ColorRGBA.h"

namespace Wm4
{

//----------------------------------------------------------------------------
void v_L1a (const float* afRegister, const float* afInVertex,
    float* afOutVertex)
{
    // Get the register items.
    const Matrix4f& rkWVPMatrix = *(const Matrix4f*)&afRegister[0];
    const ColorRGB& rkMatEms = *(const ColorRGB*)&afRegister[16];
    const ColorRGB& rkMatAmb = *(const ColorRGB*)&afRegister[20];
    const ColorRGB& rkL0Amb = *(const ColorRGB*)&afRegister[24];
    const float* afL0Atten = &afRegister[28];

    // Get the input items.
    Vector4f kModelPosition(afInVertex[0],afInVertex[1],afInVertex[2],1.0f);

    // Access the output items.
    Vector4f& rkClipPosition = *(Vector4f*)&afOutVertex[0];
    ColorRGB& rkVertexColor = *(ColorRGB*)&afOutVertex[4];
    float& rfVertexAlpha = afOutVertex[7];

    // *** program ***

    // Transform the position from model space to clip space.
    rkClipPosition = kModelPosition*rkWVPMatrix;

    ColorRGB kLAmb = afL0Atten[3]*rkL0Amb;
    rkVertexColor = rkMatEms + rkMatAmb*kLAmb;
    rfVertexAlpha = 1.0f;
}
//----------------------------------------------------------------------------

WM4_IMPLEMENT_VPROGRAM(L1a);

}
