Includes = {
	"constants.fxh"
	"standardfuncsgfx.fxh"
	"tiled_pointlights.fxh"
}

PixelShader =
{
	Samplers =
	{	
		Diffuse =
		{
			Index = 0
			MagFilter = "Linear"
			MinFilter = "Linear"
			MipFilter = "Linear"
			AddressU = "Wrap"
			AddressV = "Wrap"
		}	
		EnvironmentMap =
		{
			Index = 4
			MagFilter = "Linear"
			MinFilter = "Linear"
			MipFilter = "Linear"
			AddressU = "Clamp"
			AddressV = "Clamp"
			Type = "Cube"
		}
		LightIndexMap =
		{
			Index = 5
			MagFilter = "Point"
			MinFilter = "Point"
			MipFilter = "Point"
			AddressU = "Clamp"
			AddressV = "Clamp"
		}
		LightDataMap =
		{
			Index = 6
			MagFilter = "Point"
			MinFilter = "Point"
			MipFilter = "Point"
			AddressU = "Clamp"
			AddressV = "Clamp"
		}	
	}
}

VertexStruct VS_INPUT
{
    float3 	vPosition				: POSITION;
	float2 	vUV						: TEXCOORD0;
	float 	vAlpha					: TEXCOORD1;
};

VertexStruct VS_OUTPUT
{
    float4 	vPosition	: PDX_POSITION;
	float2 	vUV			: TEXCOORD0;
	float 	vAlpha		: TEXCOORD1;
};

VertexShader =
{
	MainCode VertexShader
	[[
		VS_OUTPUT main(const VS_INPUT v )
		{
			VS_OUTPUT Out;
					
			float4 vPosition = float4( v.vPosition.xyz, 1.0f );	
			Out.vPosition = mul( ViewProjectionMatrix, vPosition );
			
			Out.vUV = v.vUV;
			Out.vAlpha = v.vAlpha;
			return Out;
		}
		
	]]
}

PixelShader =
{
	MainCode PixelShaderShip
	[[
		float4 main( VS_OUTPUT In ) : PDX_COLOR
		{		
			float4 vColor = tex2D( Diffuse, In.vUV );			

			//clip( vColor.a - 0.5f );
			return float4( vColor.rgb, max( 0.f, vColor.a * 5.0f * pow( In.vAlpha, 4 ) ) );
			
		}
	]]
	
	MainCode PixelShaderStrikeCraft
	[[
		float4 main( VS_OUTPUT In ) : PDX_COLOR
		{
			float vAlpha = In.vAlpha;
			const float vAlphaBreakVal = 1.31f;
			const float vPadding = 0.81f;
			if( vAlpha > vAlphaBreakVal )
			{
				vAlpha = smoothstep( 1.0f - vPadding, vAlphaBreakVal, vAlpha );
			}
			else
			{
				vAlpha = smoothstep( vPadding, vAlphaBreakVal, vAlpha );
			}
			
			vAlpha *= smoothstep( 0.15f, 0.0f, abs( In.vUV.x - 0.5f ) * 0.8f );	

			vAlpha *= clamp(smoothstep(0.20f, 0.35f, vAlpha) * 100.0f, 1.0f, 50.0f);
			
			return float4( 0.3f, 0.7f, 1.1f, vAlpha );
		}
	]]
}

BlendState BlendState
{
	BlendEnable = yes
	SourceBlend = "SRC_ALPHA"
	DestBlend = "ONE"
	WriteMask = "RED|GREEN|BLUE"
}

RasterizerState RasterizerState
{
	FillMode = "FILL_SOLID"
	CullMode = "CULL_NONE"
	FrontCCW = no
}

DepthStencilState DepthStencilState
{
	DepthEnable = yes
	DepthWriteMask = "depth_write_zero"
}

Effect ShipTrail
{
	VertexShader = "VertexShader"
	PixelShader = "PixelShaderShip"
}

Effect StrikeCraftTrail
{
	VertexShader = "VertexShader"
	PixelShader = "PixelShaderStrikeCraft"
}