/********************************************************************************
FILE		:	SkyDome.fx
AUTHOR		:	Chad Taylor
DATE		:	12/7/06
TEAM		:	Double Hawk Games

All content (c) 2006-2007 DigiPen (USA) Corporation, all rights reserved.
********************************************************************************/
uniform extern float4x4 matViewProject;
uniform extern float4x4 matWorld;
uniform extern float4	colAmbient;
//uniform extern float3 vecLightPos;
uniform extern texture	txTexture;

sampler TexSample = sampler_state
{
    Texture   = <txTexture>;
    MinFilter = LINEAR; 
    MagFilter = LINEAR;
    MipFilter = LINEAR;
    AddressU  = CLAMP;
    AddressV  = CLAMP;
};

struct VS_OUTPUT
{
	float4 posH:	POSITION;
	float3 tex0:	TEXCOORD0;
};

VS_OUTPUT VS( float3 posL : POSITION0 )
{
	VS_OUTPUT outVS = (VS_OUTPUT)0;

	// Transform position to world space
	outVS.posH = mul(float4(posL, 1.0f), matWorld);

	// Transform to position to homogeneous clip space
	outVS.posH = mul(outVS.posH,  matViewProject).xyww;

    // Use skymesh vertex position, in local space, as index into cubemap. 
    outVS.tex0 = posL;
    
    return outVS;
}

float4 PS(float3 texCoord : TEXCOORD0) : COLOR
{
	float4 texColor = texCUBE(TexSample, texCoord);
    return float4( texColor.xyz * colAmbient.x, colAmbient.y );
}

technique SkyDomeTech
{
    pass P0
    {
        vertexShader = compile vs_2_0 VS();
        pixelShader  = compile ps_2_0 PS();
		CullMode = None;
		AlphaBlendEnable = True;
		SrcBlend = SRCALPHA;
		DestBlend = INVSRCALPHA;
    }
}

