voksel/res/shaders/chunk.vs.glsl

21 lines
723 B
Text
Raw Normal View History

2021-08-26 16:26:45 +03:00
#version 330 core
layout (location = 0) in vec3 pos;
layout (location = 1) in vec2 texCoord;
2021-09-12 19:59:23 +03:00
layout (location = 2) in uint light; // first 16 bits are RGBA (4 bits each) light, last 2 bits are the vertex AO
2021-08-26 16:26:45 +03:00
out vec2 passTexCoord;
2021-09-12 19:59:23 +03:00
out vec3 passLight;
out float passAO;
2021-08-26 16:26:45 +03:00
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main() {
gl_Position = projection * view * model * vec4(pos, 1.0f);
2021-09-12 19:59:23 +03:00
passTexCoord = vec2(texCoord.x, 1.0f - texCoord.y);
float intensity = (light & 0xFu) / 15.0f;
passLight = vec3(((light >> 12u) & 0xFu) / 15.0f * intensity, ((light >> 8u) & 0xFu) / 15.0f * intensity, ((light >> 4u) & 0xFu) / 15.0f * intensity);
passAO = 1.0f - (((light >> 30u) & 3u) / 3.0f);
}