SpriteText.bsl 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. technique SpriteText
  2. {
  3. blend
  4. {
  5. target
  6. {
  7. enabled = true;
  8. color = { srcA, srcIA, add };
  9. writemask = RGB;
  10. };
  11. };
  12. depth
  13. {
  14. read = false;
  15. write = false;
  16. };
  17. code
  18. {
  19. cbuffer GUIParams
  20. {
  21. float4x4 gWorldTransform;
  22. float gInvViewportWidth;
  23. float gInvViewportHeight;
  24. float gViewportYFlip;
  25. float4 gTint;
  26. }
  27. void vsmain(
  28. in float3 inPos : POSITION,
  29. in float2 uv : TEXCOORD0,
  30. out float4 oPosition : SV_Position,
  31. out float2 oUv : TEXCOORD0)
  32. {
  33. float4 tfrmdPos = mul(gWorldTransform, float4(inPos.xy, 0, 1));
  34. float tfrmdX = -1.0f + (tfrmdPos.x * gInvViewportWidth);
  35. float tfrmdY = (1.0f - (tfrmdPos.y * gInvViewportHeight)) * gViewportYFlip;
  36. oPosition = float4(tfrmdX, tfrmdY, 0, 1);
  37. oUv = uv;
  38. }
  39. [alias(gMainTexture)]
  40. SamplerState gMainTexSamp;
  41. Texture2D gMainTexture;
  42. float4 fsmain(in float4 inPos : SV_Position, float2 uv : TEXCOORD0) : SV_Target
  43. {
  44. float4 color = float4(gTint.rgb, gMainTexture.Sample(gMainTexSamp, uv).r * gTint.a);
  45. return color;
  46. }
  47. };
  48. };