From 9436414c5002e86e64f90be3f10933fdba63943e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 1 Oct 2022 19:35:43 +0200 Subject: a --- shaders/tile-shader.frag | 10 ++++++---- shaders/tile-shader.vert | 15 ++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'shaders') 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; -- cgit v1.2.3