ich habe versucht einen PixelShader für meine Font-Engine zu programmieren.
Leider funktioniert er nicht so richtig. Die Font-Texture hat einen Schwarzen Hintergrund, die Zeichen sind Weiß.
Wenn ich Zeichen rendere, wird der schwarze Hintergrund aber trotzdem angezeigt.
Kann mir jemand sagen, was ich falsch mache?
Code: Alles auswählen
Texture2D shaderTexture;
SamplerState SampleType;
float4 PShader(float4 position : SV_POSITION, float4 color : COLOR, float2 tex : TEXCOORD0) : SV_TARGET
{
	float4 texturecolor;
	// Sample the texture pixel at this location.
	texturecolor = shaderTexture.Sample(SampleType, tex);
	// If the color is black on the texture then treat this pixel as transparent.
	if (texturecolor.r == 0.0f)
	{
		texturecolor.a = 0.0f;
	}
	else
	{
		texturecolor.a = 1.0f;
		texturecolor = texturecolor * color;
	}
	return texturecolor;
}
Gruß