SceneDebug.ankiprog 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <!--
  2. Copyright (C) 2009-2018, Panagiotis Christopoulos Charitos and contributors.
  3. All rights reserved.
  4. Code licensed under the BSD License.
  5. http://www.anki3d.org/LICENSE
  6. -->
  7. <shaderProgram>
  8. <mutators>
  9. <mutator name="COLOR_TEXTURE" values="0 1"/>
  10. <mutator name="DITHERED_DEPTH_TEST" values="0 1"/>
  11. </mutators>
  12. <inputs>
  13. <input name="INSTANCE_COUNT" type="uint" const="1"/>
  14. </inputs>
  15. <shaders>
  16. <shader type="vert">
  17. <source><![CDATA[
  18. #include "shaders/Common.glsl"
  19. layout(location = 0) in vec3 in_position;
  20. #if COLOR_TEXTURE == 1
  21. layout(location = 1) in vec2 in_uv;
  22. layout(location = 0) out vec2 out_uv;
  23. #endif
  24. layout(ANKI_UBO_BINDING(1, 0), row_major) uniform u0_
  25. {
  26. mat4 u_mvp[INSTANCE_COUNT];
  27. vec4 u_color;
  28. };
  29. out gl_PerVertex
  30. {
  31. vec4 gl_Position;
  32. };
  33. void main()
  34. {
  35. #if COLOR_TEXTURE == 1
  36. out_uv = in_uv;
  37. #endif
  38. gl_Position = u_mvp[gl_InstanceID] * vec4(in_position, 1.0);
  39. }
  40. ]]></source>
  41. </shader>
  42. <shader type="frag">
  43. <source><![CDATA[
  44. #include "shaders/Common.glsl"
  45. #if COLOR_TEXTURE == 1
  46. layout(location = 0) in vec2 in_uv;
  47. layout(ANKI_TEX_BINDING(1, 0)) uniform sampler2D u_tex;
  48. #endif
  49. layout(ANKI_UBO_BINDING(1, 0), row_major) uniform u0_
  50. {
  51. mat4 u_mvp[INSTANCE_COUNT];
  52. vec4 u_color;
  53. };
  54. // NOTE: Don't eliminate the binding because it confuses the descriptor set creation
  55. #if DITHERED_DEPTH_TEST == 1 || 1
  56. layout(ANKI_TEX_BINDING(0, 0)) uniform sampler2D u_depthRt;
  57. #endif
  58. layout(location = 0) out vec4 out_color;
  59. void main()
  60. {
  61. // Check if we should skip the frag
  62. #if DITHERED_DEPTH_TEST == 1
  63. vec2 uv = gl_FragCoord.xy / vec2(textureSize(u_depthRt, 0));
  64. float depthRef = textureLod(u_depthRt, uv, 0.0).r;
  65. bool depthTestFailed = gl_FragCoord.z >= depthRef;
  66. ivec2 fragCoordi = ivec2(gl_FragCoord.xy);
  67. if(depthTestFailed && ((fragCoordi.x + fragCoordi.y) % 8) != 0)
  68. {
  69. discard;
  70. }
  71. #endif
  72. // Write the color
  73. #if COLOR_TEXTURE == 1
  74. out_color = texture(u_tex, in_uv) * u_color;
  75. #else
  76. out_color = u_color;
  77. #endif
  78. }
  79. ]]></source>
  80. </shader>
  81. </shaders>
  82. </shaderProgram>