#include "../../../compat_includes.inc"
uniform COMPAT_Texture2D(decal) : TEXUNIT0;
uniform float4x4 modelViewProj;

#pragma parameter GAMMA_INPUT "Gamma Input" 2.4 0.1 5.0 0.01

#ifdef PARAMETER_UNIFORM
uniform float GAMMA_INPUT;
#else
#define GAMMA_INPUT 2.4
#endif

struct out_vertex
{
  float4 position : COMPAT_POS;
  float2 texCoord : TEXCOORD0;
#ifndef HLSL_4
	float4 Color    : COLOR;
#endif
};

out_vertex main_vertex(COMPAT_IN_VERTEX)
{
	out_vertex OUT;
#ifdef HLSL_4
	float4 position = VIN.position;
	float2 texCoord = VIN.texCoord;
#else
	OUT.Color = color;
#endif
    OUT.position = mul(modelViewProj, position);
    OUT.texCoord = texCoord;
	
	return OUT;
}

float4 linearize(uniform COMPAT_Texture2D(decal), float2 texCoord)
{
    return pow(COMPAT_SamplePoint(decal, texCoord), GAMMA_INPUT);
}

float4 main_fragment(COMPAT_IN_FRAGMENT) : COMPAT_Output
{
	return linearize(decal, VOUT.texCoord);
}
COMPAT_END