DebugDraw.bsl 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. technique DebugDraw
  2. {
  3. #ifdef LINE
  4. raster
  5. {
  6. multisample = false; // This controls line rendering algorithm
  7. lineaa = true;
  8. };
  9. blend
  10. {
  11. target
  12. {
  13. enabled = true;
  14. color = { srcA, srcIA, add };
  15. };
  16. };
  17. #endif
  18. #ifdef WIRE
  19. raster
  20. {
  21. fill = wire;
  22. };
  23. #endif
  24. code
  25. {
  26. #ifndef LINE
  27. #define LINE 0
  28. #endif
  29. #ifndef WIRE
  30. #define WIRE 0
  31. #endif
  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. };