From b41f5d5d9e863df15da3787a18a6822974e8793c Mon Sep 17 00:00:00 2001 From: Imbris Date: Sun, 6 Dec 2020 16:42:01 -0500 Subject: [PATCH] Fix flipping in post-processing stages and precompute the uv in those in the vert shader --- assets/voxygen/shaders/clouds-frag.glsl | 5 +---- assets/voxygen/shaders/clouds-vert.glsl | 4 ++-- assets/voxygen/shaders/postprocess-frag.glsl | 5 +---- assets/voxygen/shaders/postprocess-vert.glsl | 4 ++-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/assets/voxygen/shaders/clouds-frag.glsl b/assets/voxygen/shaders/clouds-frag.glsl index 8cb717be95..7f70b99c6b 100644 --- a/assets/voxygen/shaders/clouds-frag.glsl +++ b/assets/voxygen/shaders/clouds-frag.glsl @@ -32,7 +32,7 @@ uniform texture2D t_src_depth; layout(set = 1, binding = 3) uniform sampler s_src_depth; -layout(location = 0) in vec2 f_pos; +layout(location = 0) in vec2 uv; layout (std140, set = 1, binding = 4) uniform u_locals { @@ -58,9 +58,6 @@ vec3 wpos_at(vec2 uv) { } void main() { - // TODO: precompute in the vertex shader? - vec2 uv = (f_pos + 1.0) * 0.5; - vec4 color = texture(sampler2D(t_src_color, s_src_color), uv); // Apply clouds diff --git a/assets/voxygen/shaders/clouds-vert.glsl b/assets/voxygen/shaders/clouds-vert.glsl index 6a4b469af1..c6b977a409 100644 --- a/assets/voxygen/shaders/clouds-vert.glsl +++ b/assets/voxygen/shaders/clouds-vert.glsl @@ -18,7 +18,7 @@ #include -layout(location = 0) out vec2 f_pos; +layout(location = 0) out vec2 uv; void main() { // Generate fullscreen triangle @@ -27,7 +27,7 @@ void main() { float(gl_VertexIndex % 2) * 4.0 - 1.0 ); - f_pos = v_pos; + uv = (v_pos * vec2(1.0, -1.0) + 1.0) * 0.5; gl_Position = vec4(v_pos, 0.0, 1.0); } diff --git a/assets/voxygen/shaders/postprocess-frag.glsl b/assets/voxygen/shaders/postprocess-frag.glsl index 2f05428ab7..7fd489cedb 100644 --- a/assets/voxygen/shaders/postprocess-frag.glsl +++ b/assets/voxygen/shaders/postprocess-frag.glsl @@ -28,7 +28,7 @@ layout(set = 1, binding = 1) uniform sampler s_src_color; -layout(location = 0) in vec2 f_pos; +layout(location = 0) in vec2 uv; layout (std140, set = 1, binding = 2) uniform u_locals { @@ -150,9 +150,6 @@ vec3 _illuminate(float max_light, vec3 view_dir, /*vec3 max_light, */vec3 emitte } void main() { - // TODO: precompute in the vertex shader? - vec2 uv = (f_pos + 1.0) * 0.5; - /* if (medium.x == 1u) { uv = clamp(uv + vec2(sin(uv.y * 16.0 + tick.x), sin(uv.x * 24.0 + tick.x)) * 0.005, 0, 1); } */ diff --git a/assets/voxygen/shaders/postprocess-vert.glsl b/assets/voxygen/shaders/postprocess-vert.glsl index 6a4b469af1..c6b977a409 100644 --- a/assets/voxygen/shaders/postprocess-vert.glsl +++ b/assets/voxygen/shaders/postprocess-vert.glsl @@ -18,7 +18,7 @@ #include -layout(location = 0) out vec2 f_pos; +layout(location = 0) out vec2 uv; void main() { // Generate fullscreen triangle @@ -27,7 +27,7 @@ void main() { float(gl_VertexIndex % 2) * 4.0 - 1.0 ); - f_pos = v_pos; + uv = (v_pos * vec2(1.0, -1.0) + 1.0) * 0.5; gl_Position = vec4(v_pos, 0.0, 1.0); }