/*=============================================================================
	EmissiveVertexShader.hlsl: Emissive vertex shader
	Copyright © 2005 Epic Games, Inc. All Rights Reserved.
=============================================================================*/

#define NEEDS_LIGHTMAP_COORDINATE TEXTURE_LIGHTMAP

#include "Common.usf"
#include "Material.usf"
#include "VertexFactory.usf"

float4x4 ViewProjectionMatrix REGISTER(252);
float4 CameraPosition;

#if VERTEX_LIGHTMAP
float3 LightMapScale[NUM_LIGHTMAP_COEFFICIENTS];
#endif

void Main(
	FVertexFactoryInput Input,
	out float4 Position : POSITION,
	out FVertexFactoryInterpolants FactoryInterpolants,
#if VERTEX_LIGHTMAP
	float3 InLightMapA : TEXCOORD5,
	float3 InLightMapB : TEXCOORD6,
	float3 InLightMapC : TEXCOORD7,
	out float3 LightMapA : TEXCOORD2,
	out float3 LightMapB : TEXCOORD3,
	out float3 LightMapC : TEXCOORD4,
#endif
	out float4 ScreenPosition : TEXCOORD5,
	out float3 CameraVector : TEXCOORD6,
	out float3 SkyVector : TEXCOORD7
	)
{
	float4	WorldPosition = VertexFactoryGetWorldPosition(Input,FactoryInterpolants);
	ScreenPosition = Position = MulMatrix(ViewProjectionMatrix,WorldPosition);
	CameraVector = VertexFactoryWorldToTangentSpace(Input,CameraPosition.xyz - WorldPosition.xyz * CameraPosition.w);
	SkyVector = VertexFactoryWorldToTangentSpace(Input,float3(0,0,1));
#if VERTEX_LIGHTMAP
	LightMapA = pow( InLightMapA * LightMapScale[0], 2.2 );
	LightMapB = pow( InLightMapB * LightMapScale[1], 2.2 );
	LightMapC = pow( InLightMapC * LightMapScale[2], 2.2 );
#endif
}
