Remaining things for outline culling

This commit is contained in:
mcrcortex
2025-05-02 23:45:18 +10:00
parent fce99fbde3
commit 79cd18d310
3 changed files with 46 additions and 16 deletions

View File

@@ -10,16 +10,20 @@ layout(binding = 1, std430) restrict readonly buffer ChunkPosBuffer {
ivec2[] chunkPos;
};
ivec3 unpackPos(ivec2 pos) {
return ivec3(pos.y>>10, (pos.x<<12)>>12, ((pos.y<<22)|int(uint(pos.x)>>10))>>10);
}
void main() {
uint id = (gl_InstanceID<<5)+gl_BaseInstance+(gl_VertexID>>3);
ivec3 origin = ivec3(chunkPos[id], 0).xzy;
ivec3 origin = unpackPos(chunkPos[id]);
origin -= section.xyz;
ivec3 cubeCornerI = ivec3(gl_VertexID&1, (gl_VertexID>>2)&1, (gl_VertexID>>1)&1);
//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.y = cubeCornerI.y*1024-512;
gl_Position = MVP * vec4(vec3(cubeCornerI+origin)*16, 1);
gl_Position.z -= 0.0001f;
gl_Position.z -= 0.0005f;
}