specular_merge.glsl 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #[vertex]
  2. #version 450
  3. #VERSION_DEFINES
  4. #if defined(USE_MULTIVIEW) && defined(has_VK_KHR_multiview)
  5. #extension GL_EXT_multiview : enable
  6. #endif
  7. #ifdef USE_MULTIVIEW
  8. #ifdef has_VK_KHR_multiview
  9. #define ViewIndex gl_ViewIndex
  10. #else // has_VK_KHR_multiview
  11. // !BAS! This needs to become an input once we implement our fallback!
  12. #define ViewIndex 0
  13. #endif // has_VK_KHR_multiview
  14. #else // USE_MULTIVIEW
  15. // Set to zero, not supported in non stereo
  16. #define ViewIndex 0
  17. #endif //USE_MULTIVIEW
  18. #ifdef USE_MULTIVIEW
  19. layout(location = 0) out vec3 uv_interp;
  20. #else // USE_MULTIVIEW
  21. layout(location = 0) out vec2 uv_interp;
  22. #endif //USE_MULTIVIEW
  23. void main() {
  24. vec2 base_arr[3] = vec2[](vec2(-1.0, -1.0), vec2(-1.0, 3.0), vec2(3.0, -1.0));
  25. gl_Position = vec4(base_arr[gl_VertexIndex], 0.0, 1.0);
  26. uv_interp.xy = clamp(gl_Position.xy, vec2(0.0, 0.0), vec2(1.0, 1.0)) * 2.0; // saturate(x) * 2.0
  27. #ifdef USE_MULTIVIEW
  28. uv_interp.z = ViewIndex;
  29. #endif
  30. }
  31. #[fragment]
  32. #version 450
  33. #VERSION_DEFINES
  34. #if defined(USE_MULTIVIEW) && defined(has_VK_KHR_multiview)
  35. #extension GL_EXT_multiview : enable
  36. #endif
  37. #ifdef USE_MULTIVIEW
  38. #ifdef has_VK_KHR_multiview
  39. #define ViewIndex gl_ViewIndex
  40. #else // has_VK_KHR_multiview
  41. // !BAS! This needs to become an input once we implement our fallback!
  42. #define ViewIndex 0
  43. #endif // has_VK_KHR_multiview
  44. #else // USE_MULTIVIEW
  45. // Set to zero, not supported in non stereo
  46. #define ViewIndex 0
  47. #endif //USE_MULTIVIEW
  48. #ifdef USE_MULTIVIEW
  49. layout(location = 0) in vec3 uv_interp;
  50. #else // USE_MULTIVIEW
  51. layout(location = 0) in vec2 uv_interp;
  52. #endif //USE_MULTIVIEW
  53. #ifdef USE_MULTIVIEW
  54. layout(set = 0, binding = 0) uniform sampler2DArray specular;
  55. #else // USE_MULTIVIEW
  56. layout(set = 0, binding = 0) uniform sampler2D specular;
  57. #endif //USE_MULTIVIEW
  58. #ifdef MODE_SSR
  59. #ifdef USE_MULTIVIEW
  60. layout(set = 1, binding = 0) uniform sampler2DArray ssr;
  61. #else // USE_MULTIVIEW
  62. layout(set = 1, binding = 0) uniform sampler2D ssr;
  63. #endif //USE_MULTIVIEW
  64. #endif
  65. #ifdef MODE_MERGE
  66. #ifdef USE_MULTIVIEW
  67. layout(set = 2, binding = 0) uniform sampler2DArray diffuse;
  68. #else // USE_MULTIVIEW
  69. layout(set = 2, binding = 0) uniform sampler2D diffuse;
  70. #endif //USE_MULTIVIEW
  71. #endif
  72. layout(location = 0) out vec4 frag_color;
  73. void main() {
  74. frag_color.rgb = texture(specular, uv_interp).rgb;
  75. frag_color.a = 0.0;
  76. #ifdef MODE_SSR
  77. vec4 ssr_color = texture(ssr, uv_interp);
  78. frag_color.rgb = mix(frag_color.rgb, ssr_color.rgb, ssr_color.a);
  79. #endif
  80. #ifdef MODE_MERGE
  81. frag_color += texture(diffuse, uv_interp);
  82. #endif
  83. //added using additive blend
  84. }