VolumeRenderBase.bslinc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. Technique : base("VolumeRenderBase") =
  2. {
  3. Language = "HLSL11";
  4. Pass =
  5. {
  6. DepthWrite = false;
  7. DepthRead = false;
  8. Common =
  9. {
  10. struct VStoGS
  11. {
  12. float4 position : SV_POSITION;
  13. float2 uv0 : TEXCOORD0;
  14. uint layerIdx : TEXCOORD1;
  15. };
  16. struct GStoFS
  17. {
  18. float4 position : SV_POSITION;
  19. float2 uv0 : TEXCOORD0;
  20. uint layerIdx : SV_RenderTargetArrayIndex;
  21. };
  22. };
  23. Vertex =
  24. {
  25. struct VertexInput
  26. {
  27. float2 screenPos : POSITION;
  28. float2 uv0 : TEXCOORD0;
  29. uint layerIdx : SV_InstanceID;
  30. };
  31. VStoGS main(VertexInput input)
  32. {
  33. VStoGS output;
  34. output.position = float4(input.screenPos, 0, 1);
  35. output.uv0 = input.uv0;
  36. output.layerIdx = input.layerIdx;
  37. return output;
  38. }
  39. };
  40. Geometry =
  41. {
  42. [maxvertexcount(3)]
  43. void main(triangle VStoGS input[3], inout TriangleStream<GStoFS> outStream)
  44. {
  45. GStoFS vert0;
  46. vert0.position = input[0].position;
  47. vert0.uv0 = input[0].uv0;
  48. vert0.layerIdx = input[0].layerIdx;
  49. GStoFS vert1;
  50. vert1.position = input[1].position;
  51. vert1.uv0 = input[1].uv0;
  52. vert1.layerIdx = input[1].layerIdx;
  53. GStoFS vert2;
  54. vert2.position = input[2].position;
  55. vert2.uv0 = input[2].uv0;
  56. vert2.layerIdx = input[2].layerIdx;
  57. outStream.Append(vert0);
  58. outStream.Append(vert1);
  59. outStream.Append(vert2);
  60. }
  61. };
  62. };
  63. };
  64. Technique : base("VolumeRenderBase") =
  65. {
  66. Language = "GLSL";
  67. Pass =
  68. {
  69. DepthWrite = false;
  70. DepthRead = false;
  71. Vertex =
  72. {
  73. in vec2 bs_position;
  74. in vec2 bs_texcoord0;
  75. out VStoGS
  76. {
  77. vec2 uv0;
  78. flat int layerIdx;
  79. } VSOutput;
  80. out gl_PerVertex
  81. {
  82. vec4 gl_Position;
  83. };
  84. void main()
  85. {
  86. gl_Position = vec4(bs_position, 0, 1);
  87. VSOutput.uv0 = bs_texcoord0;
  88. VSOutput.layerIdx = int(gl_InstanceID);
  89. }
  90. };
  91. Geometry =
  92. {
  93. layout (triangles) in;
  94. layout (triangle_strip, max_vertices=3) out;
  95. in VStoGS
  96. {
  97. vec2 uv0;
  98. flat int layerIdx;
  99. } GSInput[3];
  100. out GStoFS
  101. {
  102. vec2 uv0;
  103. } GSOutput;
  104. in gl_PerVertex
  105. {
  106. vec4 gl_Position;
  107. } gl_in[];
  108. out gl_PerVertex
  109. {
  110. vec4 gl_Position;
  111. };
  112. out int gl_Layer;
  113. void main()
  114. {
  115. gl_Layer = GSInput[0].layerIdx;
  116. gl_Position = gl_in[0].gl_Position;
  117. GSOutput.uv0 = GSInput[0].uv0;
  118. EmitVertex();
  119. gl_Position = gl_in[1].gl_Position;
  120. GSOutput.uv0 = GSInput[1].uv0;
  121. EmitVertex();
  122. gl_Position = gl_in[2].gl_Position;
  123. GSOutput.uv0 = GSInput[2].uv0;
  124. EmitVertex();
  125. }
  126. };
  127. };
  128. };