summaryrefslogtreecommitdiff
path: root/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2020-04-01 23:24:52 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-04-02 11:25:21 -0300
commit87c658b3041b86557d0131ffb3e187a60c3e9af0 (patch)
treee124f61b12422bc1001f6b556b8f717c2d780a1a /servers/rendering/rasterizer_rd/shaders/specular_merge.glsl
parentff14d071ccfdf25b899ab49312ef639da7c71fd6 (diff)
Re-Added screen space reflection.
Diffstat (limited to 'servers/rendering/rasterizer_rd/shaders/specular_merge.glsl')
-rw-r--r--servers/rendering/rasterizer_rd/shaders/specular_merge.glsl59
1 files changed, 59 insertions, 0 deletions
diff --git a/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl b/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl
new file mode 100644
index 0000000000..b28250318e
--- /dev/null
+++ b/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl
@@ -0,0 +1,59 @@
+/* clang-format off */
+[vertex]
+
+#version 450
+
+VERSION_DEFINES
+
+layout(location = 0) out vec2 uv_interp;
+/* clang-format on */
+
+void main() {
+
+ vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0));
+ uv_interp = base_arr[gl_VertexIndex];
+
+ gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0);
+}
+
+/* clang-format off */
+[fragment]
+
+#version 450
+
+VERSION_DEFINES
+
+layout(location = 0) in vec2 uv_interp;
+/* clang-format on */
+
+layout(set = 0, binding = 0) uniform sampler2D specular;
+
+#ifdef MODE_SSR
+
+layout(set = 1, binding = 0) uniform sampler2D ssr;
+
+#endif
+
+#ifdef MODE_MERGE
+
+layout(set = 2, binding = 0) uniform sampler2D diffuse;
+
+#endif
+
+layout(location = 0) out vec4 frag_color;
+
+void main() {
+
+ frag_color.rgb = texture(specular, uv_interp).rgb;
+ frag_color.a = 0.0;
+#ifdef MODE_SSR
+
+ vec4 ssr = texture(ssr, uv_interp);
+ frag_color.rgb = mix(frag_color.rgb, ssr.rgb, ssr.a);
+#endif
+
+#ifdef MODE_MERGE
+ frag_color += texture(diffuse, uv_interp);
+#endif
+ //added using additive blend
+}