// force vc7 to group all shader related stuff into the Shader namespace
#ifdef WIN32
namespace Shader {
#endif

// define inputs from vertex program
struct in_fragment
{
  float4 color     : COLOR0;
  float2 texCoord0 : TEXCOORD0;
  float2 texCoord1 : TEXCOORD1;
  float3 texCoord2 : TEXCOORD2;
};

// define outputs from fragment program
struct out_fragment
{
	float4 color : COLOR0;
};

float3 expand(float3 v)
{
  return (v - 0.5) * 2;
}

// fragment program
out_fragment main
(
  // varying parameters
	in_fragment f_in,

	// uniform samplers (textures)
  uniform sampler2D   diffuseMap : TEXUNIT0,
  uniform sampler2D   lightMap   : TEXUNIT1,
  uniform samplerCUBE cubeMap    : TEXUNIT2,
		
	// modulate value for the final color output
	uniform float modulate_value
)
{
	out_fragment f_out;

  f_out.color    = tex2D(diffuseMap, f_in.texCoord0.xy);
  float4 lmColor = tex2D(lightMap,   f_in.texCoord1.xy);

  modulate_value = 2;
  lmColor       *= modulate_value;
  f_out.color   *= lmColor;
  float4 reflectedColor = texCUBE(cubeMap, f_in.texCoord2);
  float reflectivity = 0.2;

  f_out.color = lerp(f_out.color,reflectedColor,reflectivity)*lmColor;

	return f_out;
}

#ifdef WIN32
}
#endif

