From eeedd2061bee36f49ea20e898e8edf3676bd15b5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Feb 2022 13:25:39 +0100 Subject: flush --- shaders/tile-shader.frag | 5 ++++- shaders/tile-shader.vert | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'shaders') diff --git a/shaders/tile-shader.frag b/shaders/tile-shader.frag index 624fc8c5..2d3de0b2 100644 --- a/shaders/tile-shader.frag +++ b/shaders/tile-shader.frag @@ -1,11 +1,14 @@ uniform vec3 color = vec3(1.0, 1.0, 1.0); -uniform sampler2D textureData; +layout(location = 2) uniform sampler2D textureData; +layout(location = 1) uniform float y_scale; in vec2 interpolatedTextureCoordinates; +in float interpolated_frag_depth; out vec4 fragmentColor; void main() { fragmentColor.rgb = color*texture(textureData, interpolatedTextureCoordinates).rgb; fragmentColor.a = 1.0; + gl_FragDepth = -interpolated_frag_depth * y_scale; } diff --git a/shaders/tile-shader.vert b/shaders/tile-shader.vert index 7a5bd1c3..cc90bae5 100644 --- a/shaders/tile-shader.vert +++ b/shaders/tile-shader.vert @@ -2,12 +2,15 @@ precision highp float; layout(location = 0) in vec4 position; layout(location = 1) in vec2 textureCoordinates; -uniform mat4 projection; +layout(location = 0) uniform mat4 projection; +layout(location = 1) uniform float y_scale; out vec2 interpolatedTextureCoordinates; +out float interpolated_frag_depth; void main() { interpolatedTextureCoordinates = textureCoordinates; - gl_Position = projection * position; + gl_Position = projection * vec4(position.xy, 0, position.w) + vec4(0, position.z * y_scale, 0, 0); + interpolated_frag_depth = position.z; } -- cgit v1.2.3