//
// Asura_D3D_VS_Object_PlanarShadow.cpp
//
// Created by KJFL - 2004-02-19 17:43:39
//
// Copyright (C) 2004 Rebellion, All Rights Reserved.
//

#include "Core/Asura.h"

// This file's header.
#include "Rendering/Asura_Direct3D_Shaders.h"


static Direct3D_VertexElement g_axObject_Order2SH_Vertex_Uncompressed_Decl[] = 
{
	{0,  0,  D3DDECLTYPE_FLOAT3,	D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION,	0},
	{0,  12, D3DDECLTYPE_FLOAT3,	D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL,		0},
	{0,  24, D3DDECLTYPE_FLOAT2,	D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,	0},

	D3DDECL_END()
};

static Direct3D_VertexElement g_axObject_Order2SH_Vertex_Compressed_Decl[] = 
{
	{0,  0,  D3DDECLTYPE_FLOAT3,	D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION,	0},
	{0,  12, D3DDECLTYPE_D3DCOLOR,	D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL,		0},
	{0,  16, D3DDECLTYPE_SHORT2,	D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,	0},

	D3DDECL_END()
};

static char* g_szObjectPlanarShadowVertexShader =
{
	"vs.1.1 \n"

	"dcl_position v0 \n"

	// move vertex from object space to world space
	// for x & z rotate and translate by object's model->world matrix
	"dp4 r1.x, v0, c[4] \n"
	"dp4 r1.z, v0, c[5] \n"

	// set the y position (fixed because planar shadow) and w value (nominally 1.0f)
	"mov r1.yw, c[6] \n"

	// move in the colour and alpha info
	"mov oD0, c[7] \n"

	// rotate the position into world space
	"dp4 oPos.x, r1, c[0] \n"
	"dp4 oPos.y, r1, c[1] \n"
	"dp4 oPos.z, r1, c[2] \n"
	"dp4 oPos.w, r1, c[3] \n"
};

static Asura_Direct3D_VertexShader CompressedShader(ASURA_D3D_VS_OBJECT_PLANARSHADOW, g_szObjectPlanarShadowVertexShader, g_axObject_Order2SH_Vertex_Compressed_Decl);
static Asura_Direct3D_VertexShader UncompressedShader(ASURA_D3D_VS_OBJECT_PLANARSHADOW_UNCOMPRESSED, g_szObjectPlanarShadowVertexShader, g_axObject_Order2SH_Vertex_Uncompressed_Decl);
