SpriteLine.bsl 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. Parameters =
  2. {
  3. mat4x4 worldTransform;
  4. float invViewportWidth;
  5. float invViewportHeight;
  6. color tint;
  7. };
  8. Technique =
  9. {
  10. Language = "HLSL11";
  11. Pass =
  12. {
  13. Target =
  14. {
  15. Blend = true;
  16. Color = { SRCA, SRCIA, ADD };
  17. WriteMask = RGB;
  18. };
  19. DepthRead = false;
  20. DepthWrite = false;
  21. Multisample = false; // This controls line rendering algorithm
  22. AALine = true;
  23. Common =
  24. {
  25. struct VStoFS
  26. {
  27. float4 position : SV_POSITION;
  28. };
  29. };
  30. Vertex =
  31. {
  32. float invViewportWidth;
  33. float invViewportHeight;
  34. float4x4 worldTransform;
  35. struct VertexInput
  36. {
  37. float2 position : POSITION;
  38. };
  39. VStoFS main(VertexInput input)
  40. {
  41. float4 tfrmdPos = mul(worldTransform, float4(input.position, 0, 1));
  42. float tfrmdX = -1.0f + (tfrmdPos.x * invViewportWidth);
  43. float tfrmdY = 1.0f - (tfrmdPos.y * invViewportHeight);
  44. VStoFS output;
  45. output.position = float4(tfrmdX, tfrmdY, 0, 1);
  46. return output;
  47. }
  48. };
  49. Fragment =
  50. {
  51. float4 tint;
  52. float4 main(VStoFS input) : SV_Target
  53. {
  54. return tint;
  55. }
  56. };
  57. };
  58. };
  59. Technique =
  60. {
  61. Language = "GLSL";
  62. Pass =
  63. {
  64. Target =
  65. {
  66. Blend = true;
  67. Color = { SRCA, SRCIA, ADD };
  68. WriteMask = RGB;
  69. };
  70. DepthRead = false;
  71. DepthWrite = false;
  72. Vertex =
  73. {
  74. uniform float invViewportWidth;
  75. uniform float invViewportHeight;
  76. uniform mat4 worldTransform;
  77. in vec2 bs_position;
  78. out gl_PerVertex
  79. {
  80. vec4 gl_Position;
  81. };
  82. void main()
  83. {
  84. vec4 tfrmdPos = worldTransform * vec4(bs_position, 0, 1);
  85. float tfrmdX = -1.0f + (tfrmdPos.x * invViewportWidth);
  86. float tfrmdY = 1.0f - (tfrmdPos.y * invViewportHeight);
  87. gl_Position = vec4(tfrmdX, tfrmdY, 0, 1);
  88. }
  89. };
  90. Fragment =
  91. {
  92. uniform vec4 tint;
  93. out vec4 fragColor;
  94. void main()
  95. {
  96. fragColor = tint;
  97. }
  98. };
  99. };
  100. };