DebugDraw.bsl 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. technique DebugDraw
  2. {
  3. variations
  4. {
  5. LINE = { 0, 1 };
  6. WIRE = { 0, 1 };
  7. SOLID = { 0, 1 };
  8. };
  9. #if LINE
  10. raster
  11. {
  12. multisample = false; // This controls line rendering algorithm
  13. lineaa = true;
  14. };
  15. blend
  16. {
  17. target
  18. {
  19. enabled = true;
  20. color = { srcA, srcIA, add };
  21. };
  22. };
  23. #endif
  24. #if WIRE
  25. raster
  26. {
  27. fill = wire;
  28. };
  29. #endif
  30. code
  31. {
  32. cbuffer Params
  33. {
  34. float4x4 gMatViewProj;
  35. float4 gViewDir;
  36. }
  37. #if LINE || WIRE
  38. void vsmain(
  39. in float3 inPos : POSITION,
  40. in float4 color : COLOR0,
  41. out float4 oPosition : SV_Position,
  42. out float4 oColor : COLOR0)
  43. {
  44. oPosition = mul(gMatViewProj, float4(inPos.xyz, 1));
  45. oColor = color;
  46. }
  47. float4 fsmain(in float4 inPos : SV_Position, in float4 color : COLOR0) : SV_Target
  48. {
  49. return color;
  50. }
  51. #else
  52. void vsmain(
  53. in float3 inPos : POSITION,
  54. in float3 inNormal : NORMAL,
  55. in float4 color : COLOR0,
  56. out float4 oPosition : SV_Position,
  57. out float3 oNormal : NORMAL,
  58. out float4 oColor : COLOR0)
  59. {
  60. oPosition = mul(gMatViewProj, float4(inPos.xyz, 1));
  61. oNormal = inNormal;
  62. oColor = color;
  63. }
  64. float4 fsmain(in float4 inPos : SV_Position, in float3 normal : NORMAL, in float4 color : COLOR0) : SV_Target
  65. {
  66. float4 outColor = color * dot(normalize(normal), -gViewDir);
  67. outColor.a = color.a;
  68. return outColor;
  69. }
  70. #endif
  71. };
  72. };