diff --git a/src/main/java/me/cortex/voxy/client/core/model/TextureUtils.java b/src/main/java/me/cortex/voxy/client/core/model/TextureUtils.java index b3bd36fb..62294d74 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/TextureUtils.java +++ b/src/main/java/me/cortex/voxy/client/core/model/TextureUtils.java @@ -32,7 +32,8 @@ public class TextureUtils { } else if (mode == WRITE_CHECK_DEPTH) { return (data.depth()[index]>>>8)!=((1<<24)-1); } else if (mode == WRITE_CHECK_ALPHA) { - return ((data.colour()[index]>>>24)&0xff)!=0; + //TODO:FIXME: for some reason it has an alpha of 1 even if its ment to be 0 + return ((data.colour()[index]>>>24)&0xff)>1; } throw new IllegalArgumentException(); } diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/Gl46FarWorldRenderer.java b/src/main/java/me/cortex/voxy/client/core/rendering/Gl46FarWorldRenderer.java index 27de4adc..818e2d0a 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/Gl46FarWorldRenderer.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/Gl46FarWorldRenderer.java @@ -137,6 +137,7 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer { this.lodShader.bind(); glDisable(GL_CULL_FACE); + glPointSize(10); glMultiDrawElementsIndirectCountARB(GL_TRIANGLES, GL_UNSIGNED_SHORT, 0, 0, (int) (this.geometry.getSectionCount()*4.4), 0); glEnable(GL_CULL_FACE); diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinGameRenderer.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinGameRenderer.java index 94f15a37..e740a20b 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinGameRenderer.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinGameRenderer.java @@ -18,6 +18,7 @@ public class MixinGameRenderer { @ModifyConstant(method = "getBasicProjectionMatrix", constant = @Constant(floatValue = 0.05F)) public float modifyNearplane(float constant) { - return 10; + //return 10; + return constant; } } \ No newline at end of file diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinMinecraftClient.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinMinecraftClient.java index 8c3f0159..7d611b1f 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinMinecraftClient.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinMinecraftClient.java @@ -11,6 +11,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class MixinMinecraftClient { @Inject(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resource/PeriodicNotificationManager;(Lnet/minecraft/util/Identifier;Lit/unimi/dsi/fastutil/objects/Object2BooleanFunction;)V", shift = At.Shift.AFTER)) private void injectRenderDoc(RunArgs args, CallbackInfo ci) { - //System.load("C:\\Program Files\\RenderDoc\\renderdoc.dll"); + System.load("C:\\Program Files\\RenderDoc\\renderdoc.dll"); } } diff --git a/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinSodiumWorldRender.java b/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinSodiumWorldRender.java index 7bf9baee..aff75e39 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinSodiumWorldRender.java +++ b/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinSodiumWorldRender.java @@ -12,6 +12,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class MixinSodiumWorldRender { @Inject(method = "drawChunkLayer", at = @At("HEAD"), cancellable = true, require = 0) private void cancelRender(RenderLayer renderLayer, MatrixStack matrixStack, double x, double y, double z, CallbackInfo ci) { - //ci.cancel(); + ci.cancel(); } } diff --git a/src/main/java/me/cortex/voxy/common/world/ActiveSectionTracker.java b/src/main/java/me/cortex/voxy/common/world/ActiveSectionTracker.java index 7d190962..41b517f0 100644 --- a/src/main/java/me/cortex/voxy/common/world/ActiveSectionTracker.java +++ b/src/main/java/me/cortex/voxy/common/world/ActiveSectionTracker.java @@ -11,11 +11,12 @@ public class ActiveSectionTracker { private final Long2ObjectOpenHashMap>[] loadedSectionCache; private final SectionLoader loader; + //private final SectionDataCache dataCache; @SuppressWarnings("unchecked") - public ActiveSectionTracker(int cacheSizeBits, SectionLoader loader) { + public ActiveSectionTracker(int numSlicesBits, SectionLoader loader) { this.loader = loader; - this.loadedSectionCache = new Long2ObjectOpenHashMap[1<(1024); } @@ -42,7 +43,11 @@ public class ActiveSectionTracker { //If this thread was the one to create the reference then its the thread to load the section if (isLoader) { var section = new WorldSection(lvl, x, y, z, this); - int status = this.loader.load(section); + int status = -1;//this.dataCache.load(section); + if (status == -1) {//Cache miss + status = this.loader.load(section); + } + if (status < 0) { //TODO: Instead if throwing an exception do something better throw new IllegalStateException("Unable to load section"); diff --git a/src/main/java/me/cortex/voxy/common/world/SectionDataCache.java b/src/main/java/me/cortex/voxy/common/world/SectionDataCache.java new file mode 100644 index 00000000..7610efce --- /dev/null +++ b/src/main/java/me/cortex/voxy/common/world/SectionDataCache.java @@ -0,0 +1,48 @@ +package me.cortex.voxy.common.world; + + +import it.unimi.dsi.fastutil.longs.Long2ObjectMap; +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap; + +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; + +public class SectionDataCache { + private record MapPair(Reference2LongOpenHashMap> ref2pos, Long2ObjectMap> pos2ref) { + public MapPair() { + this(new Reference2LongOpenHashMap<>(), new Long2ObjectOpenHashMap<>()); + } + } + private final MapPair[] maps; + private final ReferenceQueue cleanupQueue; + public SectionDataCache(int sliceBits) { + this.cleanupQueue = new ReferenceQueue<>(); + this.maps = new MapPair[1<(section.data)); + return -1; + } + //var data = entry.data.get(); + //if (data == null) { + // map.remove(section.key); + // return -1; + //} + //System.arraycopy(data, 0, section.data, 0, data.length); + return 0; + } + } +} diff --git a/src/main/resources/assets/voxy/shaders/lod/gl46/quads.vert b/src/main/resources/assets/voxy/shaders/lod/gl46/quads.vert index 885d9562..25a8988a 100644 --- a/src/main/resources/assets/voxy/shaders/lod/gl46/quads.vert +++ b/src/main/resources/assets/voxy/shaders/lod/gl46/quads.vert @@ -78,14 +78,14 @@ void main() { offset = offset.zxy; } - gl_Position = MVP * vec4(corner + offset, 1); + gl_Position = MVP * vec4(corner + offset, 1f); //Compute the uv coordinates vec2 modelUV = vec2(modelId&0xFF, (modelId>>8)&0xFF)*(1f/(256f)); //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))); + baseUV = modelUV + (vec2(face%3, face/3) * (1f/(vec2(3f, 2f)*256f))); uv = respectiveQuadSize + faceOffset;//Add in the face offset for 0,0 uv discardAlpha = faceHasAlphaCuttout(faceData); diff --git a/src/main/resources/assets/voxy/shaders/post/ssao.comp b/src/main/resources/assets/voxy/shaders/post/ssao.comp index cd841c2c..7b110298 100644 --- a/src/main/resources/assets/voxy/shaders/post/ssao.comp +++ b/src/main/resources/assets/voxy/shaders/post/ssao.comp @@ -47,7 +47,7 @@ void main() { float d = computeAOAngle(pos, 0.75*(1<