diff --git a/src/main/java/me/cortex/voxy/client/core/model/ModelFactory.java b/src/main/java/me/cortex/voxy/client/core/model/ModelFactory.java index 1f34ffd1..059f05df 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/ModelFactory.java +++ b/src/main/java/me/cortex/voxy/client/core/model/ModelFactory.java @@ -345,6 +345,8 @@ public class ModelFactory { boolean fullyOpaque = true; + //TODO: FIXME faces that have the same "alignment depth" e.g. (sizes[0]+sizes[1])~=1 can be merged into a double faced single quad + //TODO: add a bunch of control config options for overriding/setting options of metadata for each face of each type for (int face = 5; face != -1; face--) {//In reverse order to make indexing into the metadata long easier long faceUploadPtr = uploadPtr + 4L * face;//Each face gets 4 bytes worth of data @@ -394,14 +396,19 @@ public class ModelFactory { - //Scale face size from 0->this.modelTextureSize-1 to 0->15 - for (int i = 0; i < 4; i++) { - faceSize[i] = Math.round((((float)faceSize[i])/(MODEL_TEXTURE_SIZE-1))*15); + if (MODEL_TEXTURE_SIZE-1 != 15) { + //Scale face size from 0->this.modelTextureSize-1 to 0->15 + for (int i = 0; i < 4; i++) { + faceSize[i] = Math.round((((float) faceSize[i]) / (MODEL_TEXTURE_SIZE - 1)) * 15); + } } int faceModelData = 0; faceModelData |= faceSize[0] | (faceSize[1]<<4) | (faceSize[2]<<8) | (faceSize[3]<<12); - faceModelData |= Math.round(offset*63)<<16;//Change the scale from 0->1 (ends inclusive) float to 0->63 (6 bits) NOTE! that 63 == 1.0f meaning its shifted all the way to the other side of the model + //Change the scale from 0->1 (ends inclusive) + // this is cursed also warning stuff at 63 (i.e half a pixel from the end will be clamped to the end) + int enc = Math.round(offset*64); + faceModelData |= Math.min(enc,63)<<16; //Still have 11 bits free //Stuff like fences are solid, however they have extra side piece that mean it needs to have discard on diff --git a/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java b/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java index d11bd1f6..eb3c74f6 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java +++ b/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java @@ -67,8 +67,8 @@ public class ModelTextureBakery { int meta = getMetaFromLayer(layer); - for (Direction direction : new Direction[]{Direction.DOWN, Direction.UP, Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST, null}) { - for (var part : model.getParts(new LocalRandom(42L))) { + for (var part : model.getParts(new LocalRandom(42L))) { + for (Direction direction : new Direction[]{Direction.DOWN, Direction.UP, Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST, null}) { var quads = part.getQuads(direction); for (var quad : quads) { this.vc.quad(quad, meta|(quad.hasTint()?4:0)); diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/section/geometry/BasicSectionGeometryData.java b/src/main/java/me/cortex/voxy/client/core/rendering/section/geometry/BasicSectionGeometryData.java index d427d7b5..902398b8 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/section/geometry/BasicSectionGeometryData.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/section/geometry/BasicSectionGeometryData.java @@ -111,6 +111,12 @@ public class BasicSectionGeometryData implements IGeometryData { glFinish(); gpuMemory = Capabilities.INSTANCE.getFreeDedicatedGpuMemory(); } + if (this.geometryBuffer.isSparse()) { + glBindBuffer(GL_ARRAY_BUFFER, this.geometryBuffer.id); + glBufferPageCommitmentARB(GL_ARRAY_BUFFER, 0, this.sparseCommitment, false); + glBindBuffer(GL_ARRAY_BUFFER, 0); + } + glFinish(); this.geometryBuffer.free(); glFinish(); diff --git a/src/main/resources/assets/voxy/shaders/lod/block_model.glsl b/src/main/resources/assets/voxy/shaders/lod/block_model.glsl index cf928a43..5c859252 100644 --- a/src/main/resources/assets/voxy/shaders/lod/block_model.glsl +++ b/src/main/resources/assets/voxy/shaders/lod/block_model.glsl @@ -9,7 +9,9 @@ struct BlockModel { //TODO: FIXME: this isnt actually correct cause depending on the face (i think) it could be 1/64 th of a position off // but im going to assume that since we are dealing with huge render distances, this shouldent matter that much float extractFaceIndentation(uint faceData) { - return float((faceData>>16)&63u)/63.0; + uint enc = (faceData>>16)&63u; + enc += uint(enc==63u);//convert 63 to 64 cause of pain reasons + return float(enc)/64.0; } vec4 extractFaceSizes(uint faceData) {