SpriteText.bsl 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. Parameters =
  2. {
  3. mat4x4 gWorldTransform;
  4. float gInvViewportWidth;
  5. float gInvViewportHeight;
  6. float gViewportYFlip;
  7. color gTint;
  8. Sampler2D gMainTexSamp : alias("gMainTexture");
  9. Texture2D gMainTexture;
  10. };
  11. Blocks =
  12. {
  13. Block GUIParams : auto("GUIParams");
  14. };
  15. Technique =
  16. {
  17. Pass =
  18. {
  19. Target =
  20. {
  21. Blend = true;
  22. Color = { SRCA, SRCIA, ADD };
  23. WriteMask = RGB;
  24. };
  25. DepthRead = false;
  26. DepthWrite = false;
  27. Common =
  28. {
  29. cbuffer GUIParams
  30. {
  31. float4x4 gWorldTransform;
  32. float gInvViewportWidth;
  33. float gInvViewportHeight;
  34. float gViewportYFlip;
  35. float4 gTint;
  36. }
  37. };
  38. Vertex =
  39. {
  40. void main(
  41. in float3 inPos : POSITION,
  42. in float2 uv : TEXCOORD0,
  43. out float4 oPosition : SV_Position,
  44. out float2 oUv : TEXCOORD0)
  45. {
  46. float4 tfrmdPos = mul(gWorldTransform, float4(inPos.xy, 0, 1));
  47. float tfrmdX = -1.0f + (tfrmdPos.x * gInvViewportWidth);
  48. float tfrmdY = (1.0f - (tfrmdPos.y * gInvViewportHeight)) * gViewportYFlip;
  49. oPosition = float4(tfrmdX, tfrmdY, 0, 1);
  50. oUv = uv;
  51. }
  52. };
  53. Fragment =
  54. {
  55. SamplerState gMainTexSamp : register(s0);
  56. Texture2D gMainTexture : register(t0);
  57. float4 main(in float4 inPos : SV_Position, float2 uv : TEXCOORD0) : SV_Target
  58. {
  59. float4 color = float4(gTint.rgb, gMainTexture.Sample(gMainTexSamp, uv).r * gTint.a);
  60. return color;
  61. }
  62. };
  63. };
  64. };