ParticleDraw_VS.hlsl 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s
  2. // CHECK: bufferLoad
  3. // CHECK: storeOutput
  4. //--------------------------------------------------------------------------------------
  5. // File: ParticleDraw.hlsl
  6. //
  7. // Shaders for rendering the particle as point sprite
  8. //
  9. // Copyright (c) Microsoft Corporation. All rights reserved.
  10. //--------------------------------------------------------------------------------------
  11. struct VSParticleIn
  12. {
  13. float4 color : COLOR;
  14. uint id : SV_VERTEXID;
  15. };
  16. struct VSParticleDrawOut
  17. {
  18. float3 pos : POSITION;
  19. float4 color : COLOR;
  20. };
  21. struct GSParticleDrawOut
  22. {
  23. float2 tex : TEXCOORD0;
  24. float4 color : COLOR;
  25. float4 pos : SV_POSITION;
  26. };
  27. struct PSParticleDrawIn
  28. {
  29. float2 tex : TEXCOORD0;
  30. float4 color : COLOR;
  31. };
  32. struct PosVelo
  33. {
  34. float4 pos;
  35. float4 velo;
  36. };
  37. Texture2D g_txDiffuse;
  38. StructuredBuffer<PosVelo> g_bufPosVelo;
  39. SamplerState g_samLinear
  40. {
  41. Filter = MIN_MAG_MIP_LINEAR;
  42. AddressU = Clamp;
  43. AddressV = Clamp;
  44. };
  45. cbuffer cb0
  46. {
  47. row_major float4x4 g_mWorldViewProj;
  48. row_major float4x4 g_mInvView;
  49. };
  50. cbuffer cb1
  51. {
  52. static float g_fParticleRad = 10.0f;
  53. };
  54. cbuffer cbImmutable
  55. {
  56. static float3 g_positions[4] =
  57. {
  58. float3( -1, 1, 0 ),
  59. float3( 1, 1, 0 ),
  60. float3( -1, -1, 0 ),
  61. float3( 1, -1, 0 ),
  62. };
  63. static float2 g_texcoords[4] =
  64. {
  65. float2(0,0),
  66. float2(1,0),
  67. float2(0,1),
  68. float2(1,1),
  69. };
  70. };
  71. //
  72. // Vertex shader for drawing the point-sprite particles
  73. //
  74. VSParticleDrawOut main(VSParticleIn input)
  75. {
  76. VSParticleDrawOut output;
  77. output.pos = g_bufPosVelo[input.id].pos;
  78. float mag = g_bufPosVelo[input.id].velo.w/9;
  79. output.color = lerp( float4(1,0.1,0.1,1), input.color, mag );
  80. return output;
  81. }