fixed side lighting

This commit is contained in:
cola98765
2021-10-15 23:20:54 +02:00
parent 4ab4dc59e7
commit 30e796f5bf
7 changed files with 41 additions and 52 deletions
@@ -89,6 +89,8 @@ public class LodBufferBuilder
/** This boolean indicates that ever buffer need to be regenerated */
public volatile boolean fullRegeneration = false;
public static int skyLightPlayer = 15;
/**
* How many buffers there are for the given region. <Br>
* This is done because some regions may require more memory than
@@ -237,7 +239,7 @@ public class LodBufferBuilder
//================================//
ClientWorld world = mc.getClientWorld();
int skyLightPlayer = world.getBrightness(LightType.SKY, playerBlockPos);
skyLightPlayer = world.getBrightness(LightType.SKY, playerBlockPos);
for (int xRegion = 0; xRegion < lodDim.getWidth(); xRegion++)
{
@@ -392,7 +394,7 @@ public class LodBufferBuilder
break;
LodConfig.CLIENT.graphics.lodTemplate.get().template.addLodToBuffer(currentBuffers[bufferIndex], playerBlockPosRounded, data, adjData,
detailLevel, posX, posZ, box, renderer.previousDebugMode, renderer.lightMap, adjShadeDisabled, (DataPointUtil.getFlag(data) && skyLightPlayer == 0));
detailLevel, posX, posZ, box, renderer.previousDebugMode, renderer.lightMap, adjShadeDisabled);
}
@@ -38,7 +38,7 @@ public abstract class AbstractLodTemplate
/** Uploads the given LOD to the buffer. */
public abstract void addLodToBuffer(BufferBuilder buffer, BlockPos bufferCenterBlockPos, long data, Map<Direction, long[]> adjData,
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, NativeImage lightMap, boolean[] adjShadeDisabled, boolean caveLight);
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, NativeImage lightMap, boolean[] adjShadeDisabled);
/** add the given position and color to the buffer */
protected void addPosAndColor(BufferBuilder buffer,
@@ -319,16 +319,13 @@ public class Box
//Down direction case
singleAdjDataPoint = adjData.get(Direction.DOWN)[0];
if(DataPointUtil.doesItExist(singleAdjDataPoint))
{
skyLights.get(Direction.DOWN)[0] = (byte) DataPointUtil.getLightSky(singleAdjDataPoint);
}else
{
skyLights.get(Direction.DOWN)[0] = (byte) DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
else
skyLights.get(Direction.DOWN)[0] = skyLights.get(Direction.UP)[0];
}
//other sided
//TODO clean some similar cases
for (Direction direction : ADJ_DIRECTIONS)
{
singleAdjDataPoint = 0;
if (isCulled(direction))
continue;
@@ -339,6 +336,7 @@ public class Box
adjDepth.get(direction)[0] = minY;
adjHeight.get(direction)[1] = VOID_FACE;
adjDepth.get(direction)[1] = VOID_FACE;
skyLights.get(direction)[0] = 15; //in void set full sky light
continue;
}
@@ -374,7 +372,7 @@ public class Box
else
{
adjDepth.get(direction)[faceToDraw] = getMinY();
skyLights.get(direction)[faceToDraw] = (byte) 0;
skyLights.get(direction)[faceToDraw] = (byte) DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
}
faceToDraw++;
toFinish = false;
@@ -404,7 +402,7 @@ public class Box
else
{
adjDepth.get(direction)[faceToDraw] = height;
skyLights.get(direction)[faceToDraw] = (byte) DataPointUtil.getLightSky(singleAdjDataPoint);
skyLights.get(direction)[faceToDraw] = (byte) DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
}
toFinish = false;
faceToDraw++;
@@ -415,7 +413,7 @@ public class Box
// the adj data intersects the higher part of the current data
// we start the creation of a new face
adjHeight.get(direction)[faceToDraw] = depth;
//skyLights.get(direction)[faceToDraw] = (byte) DataPointUtil.getLightSky(singleAdjDataPoint);
//skyLights.get(direction)[faceToDraw] = (byte) DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
firstFace = false;
toFinish = true;
toFinishIndex = i + 1;
@@ -431,7 +429,7 @@ public class Box
}
adjDepth.get(direction)[faceToDraw] = height;
skyLights.get(direction)[faceToDraw] = (byte) DataPointUtil.getLightSky(singleAdjDataPoint);
skyLights.get(direction)[faceToDraw] = (byte) DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
faceToDraw++;
adjHeight.get(direction)[faceToDraw] = depth;
firstFace = false;
@@ -455,13 +453,9 @@ public class Box
{
singleAdjDataPoint = dataPoint[toFinishIndex];
if (DataPointUtil.doesItExist(singleAdjDataPoint))
{
skyLights.get(direction)[faceToDraw] = (byte) DataPointUtil.getLightSky(singleAdjDataPoint);
}
skyLights.get(direction)[faceToDraw] = (byte) DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
else
{
skyLights.get(direction)[faceToDraw] = skyLights.get(Direction.UP)[0];
}
}
faceToDraw++;
}
@@ -47,7 +47,7 @@ public class CubicLodTemplate extends AbstractLodTemplate
@Override
public void addLodToBuffer(BufferBuilder buffer, BlockPos bufferCenterBlockPos, long data, Map<Direction, long[]> adjData,
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, NativeImage lightMap, boolean[] adjShadeDisabled, boolean caveLight)
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, NativeImage lightMap, boolean[] adjShadeDisabled)
{
if (box == null)
return;
@@ -61,36 +61,19 @@ public class CubicLodTemplate extends AbstractLodTemplate
else
color = DataPointUtil.getColor(data);
if (caveLight)
{
generateBoundingBox(
box,
DataPointUtil.getHeight(data),
DataPointUtil.getDepth(data),
blockWidth,
posX * blockWidth, 0, posZ * blockWidth, // x, y, z offset
bufferCenterBlockPos,
adjData,
color,
0,
DataPointUtil.getLightBlock(data),
adjShadeDisabled);
}
else
{
generateBoundingBox(
box,
DataPointUtil.getHeight(data),
DataPointUtil.getDepth(data),
blockWidth,
posX * blockWidth, 0, posZ * blockWidth, // x, y, z offset
bufferCenterBlockPos,
adjData,
color,
DataPointUtil.getLightSky(data),
DataPointUtil.getLightBlock(data),
adjShadeDisabled);
}
generateBoundingBox(
box,
DataPointUtil.getHeight(data),
DataPointUtil.getDepth(data),
blockWidth,
posX * blockWidth, 0, posZ * blockWidth, // x, y, z offset
bufferCenterBlockPos,
adjData,
color,
DataPointUtil.getLightSkyAlt(data),
DataPointUtil.getLightBlock(data),
adjShadeDisabled);
addBoundingBoxToBuffer(buffer, box);
}
@@ -39,7 +39,7 @@ public class DynamicLodTemplate extends AbstractLodTemplate
{
@Override
public void addLodToBuffer(BufferBuilder buffer, BlockPos bufferCenterBlockPos, long data, Map<Direction, long[]> adjData,
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, NativeImage lightMap, boolean[] adjShadeDisabled, boolean caveLight)
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, NativeImage lightMap, boolean[] adjShadeDisabled)
{
ClientProxy.LOGGER.error(DynamicLodTemplate.class.getSimpleName() + " is not implemented!");
}
@@ -37,7 +37,7 @@ public class TriangularLodTemplate extends AbstractLodTemplate
{
@Override
public void addLodToBuffer(BufferBuilder buffer, BlockPos bufferCenterBlockPos, long data, Map<Direction, long[]> adjData,
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, NativeImage lightMap, boolean[] adjShadeDisabled, boolean caveLight)
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, NativeImage lightMap, boolean[] adjShadeDisabled)
{
ClientProxy.LOGGER.error(DynamicLodTemplate.class.getSimpleName() + " is not implemented!");
}
@@ -3,6 +3,8 @@ package com.seibel.lod.util;
import com.seibel.lod.enums.DistanceGenerationMode;
import net.minecraft.client.renderer.texture.NativeImage;
import static com.seibel.lod.builders.bufferBuilding.LodBufferBuilder.skyLightPlayer;
public class DataPointUtil
{
/*
@@ -149,6 +151,14 @@ public class DataPointUtil
return (int) ((dataPoint >>> SKY_LIGHT_SHIFT) & SKY_LIGHT_MASK);
}
public static int getLightSkyAlt(long dataPoint)
{
if (skyLightPlayer == 0 && ((dataPoint >>> FLAG_SHIFT) & FLAG_MASK) == 1)
return 0;
else
return (int) ((dataPoint >>> SKY_LIGHT_SHIFT) & SKY_LIGHT_MASK);
}
public static int getLightBlock(long dataPoint)
{
return (int) ((dataPoint >>> BLOCK_LIGHT_SHIFT) & BLOCK_LIGHT_MASK);