///////////////////////////////////////////////////////////////////////  
//  Overlay.fx
//
//	This file contains the shaders used for the diagnostic overlays.  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.
//      Web: http://www.idvinc.com

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


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

struct SOverlayVertexInput
{
	float4	m_vPosition		: SPEEDTREE_ATTR0;
	float2	m_vTexCoords	: SPEEDTREE_ATTR8;
};

struct SOverlayVertexToPixel
{
    float4  m_vPosition     : SPEEDTREE_VS_OUTPUT;
	float2	m_vTexCoords	: TEXCOORD0;
};


///////////////////////////////////////////////////////////////////////  
//  OverlayVertex

SOverlayVertexToPixel OverlayVertex(SOverlayVertexInput sIn)
{
    SOverlayVertexToPixel sOut;

	// pass texcoords through
	sOut.m_vTexCoords = sIn.m_vTexCoords;

	// final screen projection
	sOut.m_vPosition = ProjectToScreen_NoTranslation(sIn.m_vPosition.xyz);

    return sOut;
}


///////////////////////////////////////////////////////////////////////  
//  OverlayPixel

float4 OverlayPixel(SOverlayVertexToPixel sIn) : SPEEDTREE_PS_OUTPUT
{
#if defined(SPEEDTREE_DIRECTX9) || defined(SPEEDTREE_DIRECTX10) || defined(SPEEDTREE_PS3)
	float fLookup = SampleTextureCompare(g_tOverlay, samOverlay, float4(sIn.m_vTexCoords.x, 1.0 - sIn.m_vTexCoords.y, 1.0, 1.0)).x;
	return float4(fLookup.xxx, 1.0);
#else
	return float4(SampleTexture(Overlay, sIn.m_vTexCoords.xy).rgb, 1.0);
#endif
}



