diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-01 19:35:43 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-01 19:35:43 +0200 |
commit | 9436414c5002e86e64f90be3f10933fdba63943e (patch) | |
tree | 96dde7340044d2088d6948dada1b0da0f34d4c43 /shaders | |
parent | 85a8bd54726fe4edc70676b797ed90f519dbbf7d (diff) |
a
Diffstat (limited to 'shaders')
-rw-r--r-- | shaders/tile-shader.frag | 10 | ||||
-rw-r--r-- | shaders/tile-shader.vert | 15 |
2 files changed, 16 insertions, 9 deletions
diff --git a/shaders/tile-shader.frag b/shaders/tile-shader.frag index f75a0478..8a31a1e1 100644 --- a/shaders/tile-shader.frag +++ b/shaders/tile-shader.frag @@ -1,12 +1,14 @@ +#version 450 precision highp float; -layout(location = 2) uniform sampler2D textureData; - -in vec2 interpolatedTextureCoordinates; +const int MAX_SAMPLERS = 16; +layout (location = 0) uniform sampler2D samplers[MAX_SAMPLERS]; +layout (location = 0) in vec2 texcoord; +layout (location = 1) flat in uint sampler_id; out vec4 fragmentColor; void main() { - fragmentColor.rgb = texture(textureData, interpolatedTextureCoordinates).rgb; + fragmentColor.rgb = texture(samplers[sampler_id], texcoord).rgb; fragmentColor.a = 1; } diff --git a/shaders/tile-shader.vert b/shaders/tile-shader.vert index 239f4b07..6c12f1e2 100644 --- a/shaders/tile-shader.vert +++ b/shaders/tile-shader.vert @@ -1,14 +1,19 @@ +#version 450 precision highp float; +layout (location = 0) uniform vec2 scale; +layout (location = 1) uniform vec2 offset; + layout(location = 0) in vec4 position; -layout(location = 1) in vec2 textureCoordinates; -layout(location = 0) uniform vec2 scale; -layout(location = 3) uniform vec2 offset; +layout(location = 1) in vec2 texcoord; +layout(location = 2) flat in uint sampler_id; -out vec2 interpolatedTextureCoordinates; +layout (location = 0) out vec2 out_texcoord; +layout (location = 1) flat out uint out_sampler_id; void main() { - interpolatedTextureCoordinates = textureCoordinates; + interpolatedTextureCoordinates = texcoord; + out_sampler_id = sampler_id; float cx = 2/scale.x, cy = 2/scale.y; float x = position.y, y = position.x, z = position.z; |