#include "common.h"

struct vf
{
	float4 hpos	: POSITION;
	float2 tc0	: TEXCOORD0;
	float3 c0	: COLOR0;		// c0=all lighting
	float  fog	: FOG;
};

vf main (v_vert v)
{
	vf 		o;

	o.hpos 		= mul			(m_VP, v.pos);			// xform, input in world coords
	o.tc0		= unpack_tc_base	(v.tc);				// copy tc

	float3 	L_rgb 	= L_lmap_color*v.color.xyz;				// precalculated RGB lighting
	float3 	L_hemi 	= L_hemi_color*v.norm.w;				// hemisphere
	float 	L_dir 	= max(0,dot(unpack_normal(v.norm),-L_sun_dir_w));	// directional lighting
	float3 	L_sun 	= L_sun_color*v.color.w*L_dir;				// sun
	float3 	L_final	= L_rgb + L_hemi + L_sun + L_ambient;

	o.c0		= L_final;
	o.fog 		= calc_fogging 		(v.pos);			// fog, input in world coords

	return o;
}
