SpriteLine.bsl 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. Parameters =
  2. {
  3. mat4x4 worldTransform;
  4. float invViewportWidth;
  5. float invViewportHeight;
  6. color tint;
  7. };
  8. Technique =
  9. {
  10. Pass =
  11. {
  12. Target =
  13. {
  14. Blend = true;
  15. Color = { SRCA, SRCIA, ADD };
  16. WriteMask = RGB;
  17. };
  18. DepthRead = false;
  19. DepthWrite = false;
  20. Multisample = false; // This controls line rendering algorithm
  21. AALine = true;
  22. Common =
  23. {
  24. struct VStoFS
  25. {
  26. float4 position : SV_POSITION;
  27. };
  28. };
  29. Vertex =
  30. {
  31. cbuffer VertParams
  32. {
  33. float invViewportWidth;
  34. float invViewportHeight;
  35. float4x4 worldTransform;
  36. };
  37. struct VertexInput
  38. {
  39. float2 position : POSITION;
  40. };
  41. VStoFS main(VertexInput input)
  42. {
  43. float4 tfrmdPos = mul(worldTransform, float4(input.position, 0, 1));
  44. float tfrmdX = -1.0f + (tfrmdPos.x * invViewportWidth);
  45. float tfrmdY = 1.0f - (tfrmdPos.y * invViewportHeight);
  46. VStoFS output;
  47. output.position = float4(tfrmdX, tfrmdY, 0, 1);
  48. return output;
  49. }
  50. };
  51. Fragment =
  52. {
  53. cbuffer VertParams
  54. {
  55. float4 tint;
  56. };
  57. float4 main(VStoFS input) : SV_Target
  58. {
  59. return tint;
  60. }
  61. };
  62. };
  63. };