// AUTOGENERATED COPYRIGHT HEADER START
// Copyright (C) 2021-2023 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
// AUTOGENERATED COPYRIGHT HEADER END

#include "shared.effect"

uniform texture2d InputA<
	bool automatic = true;
>;

uniform texture2d InputB<
	bool automatic = true;
>;

//------------------------------------------------------------------------------
// Technique: Texture
//------------------------------------------------------------------------------
// Parameters:
// - InputA: RGBA Texture

float4 PSTexture(VertexData vtx) : TARGET {
	return InputA.Sample(BlankSampler, vtx.uv);
};

technique Draw
{
	pass
	{
		vertex_shader = DefaultVertexShader(vtx);
		pixel_shader = PSTexture(vtx);
	};
};
technique Texture
{
	pass
	{
		vertex_shader = DefaultVertexShader(vtx);
		pixel_shader = PSTexture(vtx);
	};
};

//------------------------------------------------------------------------------
// Technique: TextureColor
//------------------------------------------------------------------------------
// Parameters:
// - InputA: RGBA Texture

float4 PSTextureColor(VertexColorData vtx) : TARGET {
	return InputA.Sample(BlankSampler, vtx.uv) * vtx.clr;
};

technique TextureColor
{
	pass
	{
		vertex_shader = ColorVertexShader(vtx);
		pixel_shader = PSTextureColor(vtx);
	};
};

//------------------------------------------------------------------------------
// Technique: Texture Premultiplied
//------------------------------------------------------------------------------
// Parameters:
// - InputA: RGBA Texture

float4 PSTexturePremultiplied(VertexData vtx) : TARGET {
	float4 rgba = InputA.Sample(BlankSampler, vtx.uv);
	rgba.rgb /= rgba.a > (1. / 1024.) ? rgba.a : 1.0;
	return rgba;
};

technique DrawPremultiplied
{
	pass
	{
		vertex_shader = DefaultVertexShader(vtx);
		pixel_shader = PSTexturePremultiplied(vtx);
	};
};
technique TexturePremultiplied
{
	pass
	{
		vertex_shader = DefaultVertexShader(vtx);
		pixel_shader = PSTexturePremultiplied(vtx);
	};
};

//------------------------------------------------------------------------------
// Technique: Restore Alpha
//------------------------------------------------------------------------------
// Parameters:
// - InputA: RGBX Texture
// - InputB: XXXA Texture

float4 PSRestoreAlpha(VertexData vtx) : TARGET {
	float4 rgbx = InputA.Sample(BlankSampler, vtx.uv);
	float4 xxxa = InputB.Sample(BlankSampler, vtx.uv);
	rgbx.a = xxxa.a;
	return rgbx;
};

technique RestoreAlpha
{
	pass
	{
		vertex_shader = DefaultVertexShader(vtx);
		pixel_shader = PSRestoreAlpha(vtx);
	};
};

//------------------------------------------------------------------------------
// Technique: Color
//------------------------------------------------------------------------------
// Parameters:

float4 PSColor(VertexColorData vtx) : TARGET {
	return vtx.clr;
};

technique Color
{
	pass
	{
		vertex_shader = ColorVertexShader(vtx);
		pixel_shader = PSColor(vtx);
	};
};
