// Software vertex shader generated by Wild Magic.
//
// var float3   kModelPosition      $vin.POSITION
// var float3   kModelNormal        $vin.NORMAL
// var float3   kInLightDir         $vin.COLOR
// var float2   kInBaseTCoord       $vin.TEXCOORD0
// var float2   kInNormalTCoord     $vin.TEXCOORD1
// var float4   kClipPosition       $vout.POSITION
// var float3   kOutLightDir        $vout.COLOR
// var float2   kOutBaseTCoord      $vout.TEXCOORD0
// var float2   kOutNormalTCoord    $vout.TEXCOORD1
// var float4x4 WVPMatrix           c[0]

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

namespace Wm4
{

//----------------------------------------------------------------------------
void v_SimpleBumpMap (const float* afRegister, const float* afInVertex,
    float* afOutVertex)
{
    // Get the register items.
    const Matrix4f& rkWVPMatrix = *(const Matrix4f*)&afRegister[0];

    // Get the input items.
    Vector4f kModelPosition(afInVertex[0],afInVertex[1],afInVertex[2],1.0f);
    const Vector3f& rkModelNormal = *(const Vector3f*)&afInVertex[3];
    const ColorRGB& rkInLightDir = *(const ColorRGB*)&afInVertex[6];
    const Vector2f& rkInBaseTCoord = *(const Vector2f*)&afInVertex[9];
    const Vector2f& rkInNormalTCoord = *(const Vector2f*)&afInVertex[11];

    // Access the output items.
    Vector4f& rkClipPosition = *(Vector4f*)&afOutVertex[0];
    ColorRGB& rkOutLightDir = *(ColorRGB*)&afOutVertex[4];
    Vector2f& rkOutBaseTCoord = *(Vector2f*)&afOutVertex[7];
    Vector2f& rkOutNormalTCoord = *(Vector2f*)&afOutVertex[9];

    // *** program ***

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

    // Pass through the parameters.
    rkOutBaseTCoord = rkInBaseTCoord;
    rkOutNormalTCoord = rkInNormalTCoord;
    rkOutLightDir = rkInLightDir;
}
//----------------------------------------------------------------------------

WM4_IMPLEMENT_VPROGRAM(SimpleBumpMap);
WM4_REGISTER_VPROGRAM(SimpleBumpMap);

}
