SpriteLine.bsl 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. layout (binding = 0) uniform VertUBO
  75. {
  76. float invViewportWidth;
  77. float invViewportHeight;
  78. mat4 worldTransform;
  79. };
  80. layout (location = 0) in vec2 bs_position;
  81. out gl_PerVertex
  82. {
  83. vec4 gl_Position;
  84. };
  85. void main()
  86. {
  87. vec4 tfrmdPos = worldTransform * vec4(bs_position, 0, 1);
  88. float tfrmdX = -1.0f + (tfrmdPos.x * invViewportWidth);
  89. float tfrmdY = 1.0f - (tfrmdPos.y * invViewportHeight);
  90. gl_Position = vec4(tfrmdX, tfrmdY, 0, 1);
  91. }
  92. };
  93. Fragment =
  94. {
  95. layout (binding = 1) uniform FragUBO
  96. {
  97. vec4 tint;
  98. };
  99. out vec4 fragColor;
  100. void main()
  101. {
  102. fragColor = tint;
  103. }
  104. };
  105. };
  106. };