Debian Codegraph @

servers/rendering/renderer_rd/shaders/effects/specular_merge.glsl

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