view Data/Shaders/TexturedQuad.fx @ 28:13e53b74aed7

More drag and drop work
author koryspansel
date Mon, 19 Sep 2011 11:27:34 -0700
parents 7e3a0ae9c016
children efd2b1ca5b77
line wrap: on
line source

extern uniform float4x4	kProjection;
extern uniform float4x4 kWorld;
extern uniform texture	kTexture;
extern uniform float4	kColor;

/*
 * TextureSampler
 */
sampler TextureSampler = sampler_state
{
	Texture		= <kTexture>;
	MinFilter	= POINT;
	MagFilter	= POINT;
	AddressU	= CLAMP;
	AddressV	= CLAMP;
};

/*
 * VertexInput
 */
struct VertexInput
{
	/*
	 * Position
	 */
	float3 Position : POSITION0;

	/*
	 * TextureCoordinate
	 */
	float2 TextureCoordinate : TEXCOORD0;
};

/*
 * VertexOutput
 */
struct VertexOutput
{
	/*
	 * Position
	 */
	float4 Position : POSITION0;

	/*
	 * TextureCoordinate
	 */
	float2 TextureCoordinate : TEXCOORD0;
};

/*
 * PixelInput
 */
struct PixelInput
{
	/*
	 * TextureCoordinate
	 */
	float2 TextureCoordinate : TEXCOORD0;

	/*
	 * Color
	 */
	float4 Color : COLOR0;
};

/*
 * PixelOutput
 */
struct PixelOutput
{
	/*
	 * Color
	 */
	float4 Color : COLOR0;
};

/*
 * TexturedQuadVS
 */
VertexOutput TexturedQuadVS(VertexInput kInput)
{
	VertexOutput kOutput;

	kOutput.Position			= mul(float4(kInput.Position, 1.0f), mul(kWorld, kProjection));
	kOutput.TextureCoordinate	= kInput.TextureCoordinate;

	return kOutput;
}

/*
 * TexturedQuadPS
 */
PixelOutput TexturedQuadPS(PixelInput kInput)
{
	PixelOutput kOutput;

	float4 kTexture = tex2D(TextureSampler, kInput.TextureCoordinate);

	kOutput.Color = float4(kTexture.rgb * kColor.rgb, kTexture.a);
	//kOutput.Color = kColor;

	return kOutput;
}

technique Default
{
	pass Opaque
	{
		vertexShader		= compile vs_2_0 TexturedQuadVS();
		pixelShader			= compile ps_2_0 TexturedQuadPS();

		/*
		ZEnable				= true;
		ZWriteEnable		= true;
		ZFunc				= LessEqual;
		*/

		AlphaBlendEnable	= true;
		AlphaFunc			= LessEqual;
		SrcBlend			= SrcAlpha;
		DestBlend			= InvSrcAlpha;
	}
}