Fix flickering lightmap by redo lightmap system
This commit is contained in:
@@ -25,12 +25,14 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import com.seibel.lod.core.logging.ConfigBasedLogger;
|
||||
import com.seibel.lod.core.logging.ConfigBasedSpamLogger;
|
||||
import com.seibel.lod.core.logging.SpamReducedLogger;
|
||||
import com.seibel.lod.core.objects.BoolType;
|
||||
import com.seibel.lod.core.objects.Pos2D;
|
||||
import com.seibel.lod.core.render.objects.GLState;
|
||||
import com.seibel.lod.core.util.*;
|
||||
import com.seibel.lod.core.util.gridList.*;
|
||||
import com.seibel.lod.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
|
||||
@@ -65,6 +67,8 @@ public class LodRenderer
|
||||
public static final ConfigBasedLogger EVENT_LOGGER = new ConfigBasedLogger(LogManager.getLogger(LodRenderer.class),
|
||||
() -> CONFIG.client().advanced().debugging().debugSwitch().getLogRendererBufferEvent());
|
||||
|
||||
public static ConfigBasedSpamLogger tickLogger = new ConfigBasedSpamLogger(LogManager.getLogger(LodRenderer.class),
|
||||
() -> CONFIG.client().advanced().debugging().debugSwitch().getLogRendererBufferEvent(),1);
|
||||
public static final boolean ENABLE_DRAW_LAG_SPIKE_LOGGING = false;
|
||||
public static final boolean ENABLE_DUMP_GL_STATE = true;
|
||||
public static final long DRAW_LAG_SPIKE_THRESHOLD_NS = TimeUnit.NANOSECONDS.convert(20, TimeUnit.MILLISECONDS);
|
||||
@@ -136,7 +140,6 @@ public class LodRenderer
|
||||
{
|
||||
lodBufferBuilderFactory = newLodNodeBufferBuilder;
|
||||
}
|
||||
public static SpamReducedLogger tickLogger = new SpamReducedLogger(1);
|
||||
|
||||
/**
|
||||
* Besides drawing the LODs this method also starts
|
||||
@@ -285,7 +288,7 @@ public class LodRenderer
|
||||
GL32.glActiveTexture(GL32.GL_TEXTURE0);
|
||||
drawSetActiveTexture.end("drawSetActiveTexture");
|
||||
LagSpikeCatcher drawCalculateParams = new LagSpikeCatcher();
|
||||
LightmapTexture lightmapTexture = new LightmapTexture();
|
||||
//LightmapTexture lightmapTexture = new LightmapTexture();
|
||||
|
||||
/*---------Get required data--------*/
|
||||
// Get the matrixs for rendering
|
||||
@@ -311,7 +314,9 @@ public class LodRenderer
|
||||
|
||||
// Note: Since lightmapTexture is changing every frame, it's faster to recreate it than to reuse the old one.
|
||||
LagSpikeCatcher drawFillLightmap = new LagSpikeCatcher();
|
||||
lightmapTexture.fillData(MC_RENDER.getLightmapTextureWidth(), MC_RENDER.getLightmapTextureHeight(), MC_RENDER.getLightmapPixels());
|
||||
ILightMapWrapper lightmap = MC_RENDER.getLightmapWrapper();
|
||||
lightmap.bind();
|
||||
//lightmapTexture.fillData(MC_RENDER.getLightmapTextureWidth(), MC_RENDER.getLightmapTextureHeight(), MC_RENDER.getLightmapPixels());
|
||||
drawFillLightmap.end("drawFillLightmap");
|
||||
drawFillData.end("DrawFillData");
|
||||
//===========//
|
||||
@@ -364,11 +369,12 @@ public class LodRenderer
|
||||
draw.end("LodDraw");
|
||||
profiler.popPush("LOD cleanup");
|
||||
LagSpikeCatcher drawCleanup = new LagSpikeCatcher();
|
||||
lightmap.unbind();
|
||||
|
||||
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, 0);
|
||||
|
||||
shaderProgram.unbind();
|
||||
lightmapTexture.free();
|
||||
//lightmapTexture.free();
|
||||
GL32.glClear(GL32.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
currentState.restore();
|
||||
|
||||
+3
@@ -32,6 +32,7 @@ import com.seibel.lod.core.wrapperInterfaces.IVersionConstants;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
|
||||
|
||||
@@ -133,6 +134,8 @@ public interface IMinecraftRenderWrapper extends IBindable
|
||||
/** @returns null if there was a issue getting the lightmap */
|
||||
int[] getLightmapPixels();
|
||||
|
||||
ILightMapWrapper getLightmapWrapper();
|
||||
|
||||
/** @returns -1 if there was an issue getting the lightmap */
|
||||
int getLightmapTextureHeight();
|
||||
/** @returns -1 if there was an issue getting the lightmap */
|
||||
|
||||
@@ -28,4 +28,8 @@ import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
|
||||
public interface ILightMapWrapper extends IBindable
|
||||
{
|
||||
int getLightValue(int skyLight, int blockLight);
|
||||
|
||||
// Returns the binded texture position
|
||||
int bind();
|
||||
void unbind();
|
||||
}
|
||||
|
||||
@@ -29,8 +29,12 @@ void main()
|
||||
vertexWorldPos = vPosition.xyz + modelOffset;
|
||||
vertexYPos = vPosition.y + worldYOffset;
|
||||
|
||||
float light = (vPosition.a+0.5) / 256.0;
|
||||
vertexColor = color * texture(lightMap, vec2(light,0.5));
|
||||
float delta = 0.5/16.0;
|
||||
|
||||
float light = (vPosition.a) / 16.0;
|
||||
float partLight = modf(light, light);
|
||||
light = light / 16.0;
|
||||
vertexColor = color * texture(lightMap, vec2(light+delta, partLight+delta));
|
||||
|
||||
gl_Position = combinedMatrix * vec4(vertexWorldPos, 1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user