Font.ps 753 B

12345678910111213141516171819202122232425262728293031323334353637
  1. Texture2D shaderTexture;
  2. SamplerState SampleType;
  3. cbuffer PixelBuffer
  4. {
  5. float4 pixelColor;
  6. };
  7. struct PixelInputType
  8. {
  9. float4 position : SV_POSITION;
  10. float2 tex : TEXCOORD0;
  11. };
  12. float4 FontPixelShader(PixelInputType input) : SV_TARGET
  13. {
  14. float4 color;
  15. // Sample the texture pixel at this location.
  16. color = shaderTexture.Sample(SampleType, input.tex);
  17. // If the color is black on the texture then treat this pixel as transparent.
  18. if(color.r == 0.0f)
  19. {
  20. color.a = 0.0f;
  21. }
  22. // If the color is other than black on the texture then this is a pixel in the font so draw it using the font pixel color.
  23. else
  24. {
  25. color.a = 1.0f;
  26. color = color * pixelColor;
  27. }
  28. return color;
  29. }