Added min chunk bounds + fix other bugs in model baking and other places

This commit is contained in:
mcrcortex
2025-05-01 23:24:41 +10:00
parent fbcef60f67
commit 0b88a6f824
16 changed files with 189 additions and 125 deletions

View File

@@ -11,11 +11,13 @@ layout(binding = 1, std430) restrict readonly buffer ChunkPosBuffer {
};
void main() {
ivec3 origin = ivec3(chunkPos[gl_InstanceID], 0).xzy;
origin -= section.xyz;
ivec3 cubeCornerI = ivec3(gl_VertexID&1, (gl_VertexID>>2)&1, (gl_VertexID>>1)&1);
cubeCornerI.xz += chunkPos[gl_InstanceID];
//Expand the y height to be big (will be +- 8192)
//TODO: make it W.R.T world height and offsets
cubeCornerI.y = cubeCornerI.y*1024-512;
cubeCornerI -= section.xyz;
gl_Position = MVP * vec4(vec3(cubeCornerI*16), 1);
cubeCornerI.y = cubeCornerI.y*32-16;
gl_Position = MVP * vec4(vec3(cubeCornerI+origin)*16, 1);
gl_Position.z -= 0.0001f;
}

View File

@@ -1,5 +1,6 @@
#version 460 core
layout(binding = 0) uniform sampler2D blockModelAtlas;
layout(binding = 2) uniform sampler2D depthTex;
//#define DEBUG_RENDER
@@ -19,6 +20,10 @@ layout(location = 6) in flat uint quadDebug;
#endif
layout(location = 0) out vec4 outColour;
void main() {
//Check the minimum bounding texture and ensure we are greater than it
if (gl_FragCoord.z < texelFetch(depthTex, ivec2(gl_FragCoord.xy), 0).r) {
discard;
}
vec2 uv = mod(uv, vec2(1.0))*(1.0/(vec2(3.0,2.0)*256.0));
//vec4 colour = solidColour;
vec4 colour = texture(blockModelAtlas, uv + baseUV, ((flags>>1)&1u)*-4.0);