
// this line is needed to get the associated xml files
#define SW_PARAMETER_FILES "global.xml, envmapcommon.xml"
#define SW_INCLUDE "utils.glsl"


varying vec3 v_lDirection;

#define PI			3.141592
#define INVERSE_PI	0.318309

#ifdef _VERTEX_PROGRAM
void main()
{
	gl_Position=vec4(gl_Vertex.xy,0.5,1.0);
	v_lDirection=gl_MultiTexCoord0.xyz; // gl_MultiTexCoord0.xyz is the eye direction
}
#endif //_VERTEX_PROGRAM



#ifdef _FRAGMENT_PROGRAM


vec4 GetEnvBackGround(int envmapType, vec3 envCoord)
{
	//return textureCube(envCubicSpecular, envCoord);
	if(envmapType==e_EnvMapType_Cubic)
	{
		return textureCube(envCubicBackground, envCoord);
	}
	else
	{
		return texture2D(envSphericalBackground, Flip(SphereMapCoord(envCoord),g_envmapFlip));
	}
}

void main()
{
	gl_FragColor.xyz = GetEnvBackGround(g_envmaptype,v_lDirection).xyz;
	gl_FragColor.w = 0.75;
}
#endif //_FRAGMENT_PROGRAM
