voksel/content/base/shaders/chunk.vs.glsl

26 lines
637 B
GLSL

#version 330 core
layout (location = 0) in vec3 pos;
layout (location = 1) in uint tex;
layout (location = 2) in vec4 light;
layout (location = 3) in float sunlight;
out vec3 passTexCoords;
out vec3 passLight;
uniform mat4 mvpMatrix;
uniform float globalSunlight;
const vec2 texCoords[4] = vec2[4](
vec2(0.0f, 0.0f),
vec2(0.0f, 1.0f),
vec2(1.0f, 0.0f),
vec2(1.0f, 1.0f)
);
void main() {
gl_Position = mvpMatrix * vec4(pos, 1.0f);
uint index = tex >> 30;
uint layer = tex & 0x3FFFFFFFu;
passTexCoords = vec3(texCoords[index].x, 1.0f - texCoords[index].y, layer);
passLight = light.rgb * light.a;
}