Fix lighting issues in both client-only and single player world

This commit is contained in:
TomTheFurry
2023-06-15 16:41:17 +08:00
parent 2ab16b1fe5
commit 419af81523
4 changed files with 14 additions and 3 deletions
@@ -26,11 +26,18 @@ public class LodDataBuilder {
int mappedId = chunkData.getMapping().addIfNotPresentAndGetId(biome, blockState);
// FIXME: The +1 offset to reproduce the old behavior. Remove this when we get per-face lighting
byte light = (byte) ((chunkWrapper.getBlockLight(x,lastY+1,z) << 4) + chunkWrapper.getSkyLight(x,lastY+1,z));
int y=chunkWrapper.getLightBlockingHeightMapValue(x, z);
int top = y;
for (; y>=chunkWrapper.getMinBuildHeight(); y--) {
IBiomeWrapper newBiome = chunkWrapper.getBiome(x, y, z);
IBlockStateWrapper newBlockState = chunkWrapper.getBlockState(x, y, z);
if (top == 30 && y == 29 && chunkWrapper.getSkyLight(x,y+1,z) == 0)
{
int a = 0;
}
byte newLight = (byte) ((chunkWrapper.getBlockLight(x,y+1,z) << 4) + chunkWrapper.getSkyLight(x,y+1,z));
if (!newBiome.equals(biome) || !newBlockState.equals(blockState)) {
@@ -52,6 +59,7 @@ public class LodDataBuilder {
chunkData.setSingleColumn(longs.toArray(new long[0]), x, z);
}
}
if (!canGenerateLodFromChunk(chunkWrapper)) return null;
LodUtil.assertTrue(chunkData.emptyCount() == 0);
return chunkData;
}
@@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.logging.ConfigBasedLogger;
import com.seibel.lod.core.logging.DhLoggerBuilder;
import com.seibel.lod.core.util.LodUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.glfw.GLFW;
@@ -457,7 +458,7 @@ public class GLProxy
"Vertex Attribute Buffer Binding: " + (c.glVertexAttribBinding != 0) + " <- optional improvement\n" +
"Buffer Storage: " + (c.glBufferStorage != 0) + " <- optional improvement\n";
}
private static void logMessage(GLMessage msg)
{
GLMessage.ESeverity s = msg.severity;
@@ -465,6 +466,7 @@ public class GLProxy
msg.type == GLMessage.EType.UNDEFINED_BEHAVIOR)
{
GL_LOGGER.error("GL ERROR {} from {}: {}", msg.id, msg.source, msg.message);
LodUtil.assertNotReach();
throw new RuntimeException("GL ERROR: " + msg.toString());
}
@@ -83,6 +83,7 @@ public class LodRenderer
shaderProgram.bindVertexBuffer(vbo.getId());
GL32.glDrawElements(GL32.GL_TRIANGLES, (vbo.getVertexCount()/4)*6,
quadIBO.getType(), 0);
vbo.unbind();
}
public Vec3f getLookVector() {
return MC_RENDER.getLookAtVector();
@@ -266,8 +266,8 @@ public class LodUtil
debugBreak();
}
}
private static void debugBreak() {
public static void debugBreak() {
int a = 0; // Set breakpoint here for auto pause on assert failure
}