Fully works

This commit is contained in:
mcrcortex
2024-01-29 21:31:24 +10:00
parent e33b8deb32
commit 23c8c9a072
8 changed files with 35 additions and 7 deletions

View File

@@ -10,4 +10,8 @@ vec4 extractFaceSizes(uint faceData) {
uint faceHasAlphaCuttout(uint faceData) {
return (faceData>>22)&1;
}
uint faceHasAlphaCuttoutOverride(uint faceData) {
return (faceData>>23)&1;
}

View File

@@ -20,7 +20,8 @@ void main() {
//Transform ipos with respect to the vertex corner
ivec3 pos = (((ipos<<detail)-baseSectionPos)<<5);
pos += aabbOffset;
pos += (ivec3(gl_VertexID&1, (gl_VertexID>>2)&1, (gl_VertexID>>1)&1)*size)*(1<<detail);
pos -= (1<<detail);
pos += (ivec3(gl_VertexID&1, (gl_VertexID>>2)&1, (gl_VertexID>>1)&1)*(size+1))*(1<<detail);
gl_Position = MVP * vec4(vec3(pos),1);

View File

@@ -1,6 +1,9 @@
#version 460 core
layout(binding = 0) uniform sampler2D blockModelAtlas;
//TODO: need to fix when merged quads have discardAlpha set to false but they span multiple tiles
// however they are not a full block
layout(location = 0) in vec2 uv;
layout(location = 1) in flat vec2 baseUV;
layout(location = 2) in flat vec4 colourTinting;

View File

@@ -60,8 +60,9 @@ void main() {
vec3 corner = innerPos * (1<<lodLevel) + lodCorner;
vec2 faceOffset = getFaceSizeOffset(faceData, cornerIdx);
vec2 quadSize = vec2(extractSize(quad) * ivec2((cornerIdx>>1)&1, cornerIdx&1));
vec2 size = (quadSize + faceOffset) * (1<<lodLevel);
ivec2 quadSize = extractSize(quad);
vec2 respectiveQuadSize = vec2(quadSize * ivec2((cornerIdx>>1)&1, cornerIdx&1));
vec2 size = (respectiveQuadSize + faceOffset) * (1<<lodLevel);
vec3 offset = vec3(size, (float(face&1) + getDepthOffset(faceData, face)) * (1<<lodLevel));
@@ -84,10 +85,13 @@ void main() {
//TODO: make the face orientated by 2x3 so that division is not a integer div and modulo isnt needed
// as these are very slow ops
baseUV = modelUV + (vec2(face%3, face/3) * (1f/(vec2(3,2)*256f)));
uv = quadSize + faceOffset;//Add in the face offset for 0,0 uv
uv = respectiveQuadSize + faceOffset;//Add in the face offset for 0,0 uv
discardAlpha = faceHasAlphaCuttout(faceData);
//We need to have a conditional override based on if the model size is < a full face + quadSize > 1
discardAlpha |= uint(any(greaterThan(quadSize, ivec2(1)))) & faceHasAlphaCuttoutOverride(faceData);
//Compute lighting
colourTinting = getLighting(extractLightId(quad));