voxel-test/resources/shaders/tiling.vs

39 lines
1.1 KiB
GLSL

#version 330
in vec3 vertexPosition;
in vec2 vertexTexCoord;
in vec3 vertexNormal;
in vec2 vertexTileTexCoord;
in uvec4 vertexMetadata1;
in uvec4 vertexOcclusionSides;
out vec2 fragTexCoord;
out vec3 fragNormal;
out vec2 fragTileTexCoord;
flat out uvec4 occlusionSides;
flat out int topLeftObscured;
flat out int topRightObscured;
flat out int bottomLeftObscured;
flat out int bottomRightObscured;
flat out int quadHeight;
flat out int quadWidth;
uniform mat4 mvp;
void main() {
fragTexCoord = vertexTexCoord;
fragTileTexCoord = vertexTileTexCoord;
fragNormal = vertexNormal;
occlusionSides = vertexOcclusionSides;
gl_Position = mvp*vec4(vertexPosition, 1.0);
// metadata 1 parsing
int metadata1W = int(vertexMetadata1.w);
topLeftObscured = (metadata1W & 0x1); // Take 0th bit.
topRightObscured = (metadata1W & 0x2) >> 1; // Take 1st bits.
bottomLeftObscured = (metadata1W & 0x4) >> 2; // Take 2nd bits.
bottomRightObscured = (metadata1W & 0x8) >> 3; // Take 3rd bits.
quadHeight = (metadata1W & 0x3f0) >> 4; // Take 4rd-9th bits.
quadWidth = (metadata1W & 0xfc00) >> 10; // Take 10th-16th bits.
}