diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-02-23 13:25:39 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-02-23 13:25:39 +0100 |
commit | eeedd2061bee36f49ea20e898e8edf3676bd15b5 (patch) | |
tree | 4e22a3d50d6f97992aa3b46d00b276ddac928e6a /shaders | |
parent | 920aa82a3a05402cc0489a8d9e0b9b2f4a4e3117 (diff) |
flush
Diffstat (limited to 'shaders')
-rw-r--r-- | shaders/tile-shader.frag | 5 | ||||
-rw-r--r-- | shaders/tile-shader.vert | 7 |
2 files changed, 9 insertions, 3 deletions
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; } |