///////////////////////////////////////////////////////////////////////  
//  Sky.hlsl
//
//	This file contains the shaders used for the sky.  These shaders 
//	will compile with HLSL and Cg compilers.
//
//
//	*** INTERACTIVE DATA VISUALIZATION (IDV) CONFIDENTIAL AND PROPRIETARY INFORMATION ***
//
//	This software is supplied under the terms of a license agreement or
//	nondisclosure agreement with Interactive Data Visualization, Inc. and
//  may not be copied, disclosed, or exploited except in accordance with 
//  the terms of that agreement.
//
//      Copyright (c) 2003-2010 IDV, Inc.
//      All rights reserved in all media.
//
//      IDV, Inc.
//      http://www.idvinc.com

#ifndef SPEEDTREE_USING_EFFECTS
	#include "Global.hlsl"
	#include "UniformVariables.hlsl"
	#include "Utility.hlsl"
#endif


///////////////////////////////////////////////////////////////////////  
//  Shader input/output structures

struct SSkyVertexOutput
{
    float4 m_vPosition		: SPEEDTREE_VS_OUTPUT;
    float3 m_vWorldPosition	: TEXCOORD0;
};


///////////////////////////////////////////////////////////////////////  
//  SkyVertex

SSkyVertexOutput SkyVertex(float4 vPosition : SPEEDTREE_ATTR0)
{
	SSkyVertexOutput sOut;

#ifdef SPEEDTREE_WORLD_TRANSLATE
	sOut.m_vPosition = mul(g_mModelViewProj, float4(vPosition.xyz * g_fFarClip, 1.0));
#else
	sOut.m_vPosition = mul(g_mModelViewProj, float4(vPosition.xyz * g_fFarClip + g_vCameraPosition, 1.0));
#endif
	
	sOut.m_vWorldPosition = vPosition.xyz;

	return sOut;
}


///////////////////////////////////////////////////////////////////////  
//  SkyPixel

float4 SkyPixel(SSkyVertexOutput sIn) : SPEEDTREE_PS_OUTPUT
{
	return float4(SkyColor(normalize(sIn.m_vWorldPosition)), 1.0);
}


