Tweeks and fixes

This commit is contained in:
mcrcortex
2024-01-30 11:13:48 +10:00
parent 23c8c9a072
commit 10bb73adf6
6 changed files with 29 additions and 9 deletions

View File

@@ -28,7 +28,7 @@ public class DistanceTracker {
this.minYSection = MinecraftClient.getInstance().world.getBottomSectionCoord()/2;
this.maxYSection = MinecraftClient.getInstance().world.getTopSectionCoord()/2;
if (false) {
if (true) {
this.rings[0] = new TransitionRing2D(5, MinecraftClient.getInstance().options.getViewDistance().getValue() / 2, (x, z) -> {
for (int y = this.minYSection; y <= this.maxYSection; y++) {
this.tracker.remLvl0(x, y, z);

View File

@@ -439,12 +439,32 @@ public class ModelManager {
return res;
}
//TODO:FIXME: if the model is not already in the cache for some reason it renders black, need to figure out why
public long getModelMetadata(int blockId) {
int map = this.idMappings[blockId];
int map = 0;
while ((map = this.idMappings[blockId]) == -1) {
Thread.onSpinWait();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
if (map == -1) {
throw new IllegalArgumentException("Id hasnt been computed yet: " + blockId);
}
return this.metadataCache[map];
long meta = 0;
while ((meta = this.metadataCache[map]) == 0) {
Thread.onSpinWait();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
return meta;
}
public int getModelId(int blockId) {

View File

@@ -115,7 +115,6 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
RenderLayer.getCutoutMipped().startDrawing();
int oldActiveTexture = glGetInteger(GL_ACTIVE_TEXTURE);
int oldBoundTexture = glGetInteger(GL_TEXTURE_BINDING_2D);
//RenderSystem.enableBlend();
//RenderSystem.defaultBlendFunc();
@@ -127,8 +126,9 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
//Bind the texture atlas
glBindSampler(0, this.models.getSamplerId());
glActiveTexture(GL_TEXTURE0);
int oldBoundTexture = glGetInteger(GL_TEXTURE_BINDING_2D);
glBindSampler(0, this.models.getSamplerId());
glBindTexture(GL_TEXTURE_2D, this.models.getTextureId());
glClearNamedBufferData(this.glCommandCountBuffer.id, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, new int[1]);
@@ -174,10 +174,10 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
int oldActiveTexture = glGetInteger(GL_ACTIVE_TEXTURE);
int oldBoundTexture = glGetInteger(GL_TEXTURE_BINDING_2D);
glBindSampler(0, this.models.getSamplerId());
glActiveTexture(GL_TEXTURE0);
int oldBoundTexture = glGetInteger(GL_TEXTURE_BINDING_2D);
glBindTexture(GL_TEXTURE_2D, this.models.getTextureId());
this.lodShader.bind();

View File

@@ -216,7 +216,7 @@ public class WorldImporter {
biomes,
(bx, by, bz, state) -> {
int block = 0;
int sky = 15;//since sky is inverted
int sky = 0;
if (blockLight != null) {
block = blockLight.get(bx, by, bz);
}

View File

@@ -14,6 +14,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class MixinSodiumWorldRender {
@Inject(method = "drawChunkLayer", at = @At("HEAD"), cancellable = true)
private void cancelRender(RenderLayer renderLayer, MatrixStack matrixStack, double x, double y, double z, CallbackInfo ci) {
ci.cancel();
//ci.cancel();
}
}

View File

@@ -21,7 +21,7 @@ void main() {
ivec3 pos = (((ipos<<detail)-baseSectionPos)<<5);
pos += aabbOffset;
pos -= (1<<detail);
pos += (ivec3(gl_VertexID&1, (gl_VertexID>>2)&1, (gl_VertexID>>1)&1)*(size+1))*(1<<detail);
pos += (ivec3(gl_VertexID&1, (gl_VertexID>>2)&1, (gl_VertexID>>1)&1)*(size+2))*(1<<detail);
gl_Position = MVP * vec4(vec3(pos),1);