Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ed50e5134 | |||
| b5e3e6867c | |||
| 3e04342148 | |||
| 6699b568df | |||
| 53bee4ad42 | |||
| 5d5e462221 | |||
| d9b924cfed | |||
| 8bd70d593c | |||
| 5597044604 | |||
| 5d7c043d06 | |||
| 4aac61b37f | |||
| 22460fa1f5 | |||
| 2d127c7d98 | |||
| 91e17c420a | |||
| 93f5a85cb5 | |||
| b275971486 | |||
| 1234ff4d28 |
@@ -38,7 +38,7 @@ public final class ModInfo
|
||||
public static final String NAME = "DistantHorizons";
|
||||
/** Human-readable version of NAME */
|
||||
public static final String READABLE_NAME = "Distant Horizons";
|
||||
public static final String VERSION = "2.3.1-b";
|
||||
public static final String VERSION = "2.3.2-b";
|
||||
/** Returns true if the current build is an unstable developer build, false otherwise. */
|
||||
public static final boolean IS_DEV_BUILD = VERSION.toLowerCase().contains("dev");
|
||||
|
||||
|
||||
@@ -99,6 +99,11 @@ public class SharedApi
|
||||
|
||||
public static void setDhWorld(AbstractDhWorld newWorld)
|
||||
{
|
||||
AbstractDhWorld oldWorld = currentWorld;
|
||||
if (oldWorld != null)
|
||||
{
|
||||
oldWorld.close();
|
||||
}
|
||||
currentWorld = newWorld;
|
||||
|
||||
// starting and stopping the DataRenderTransformer is necessary to prevent attempting to
|
||||
|
||||
@@ -328,7 +328,8 @@ public class DhLightingEngine
|
||||
continue;
|
||||
}
|
||||
|
||||
if (relNeighbourBlockPos.getY() < neighbourChunk.getMinNonEmptyHeight() || relNeighbourBlockPos.getY() > neighbourChunk.getExclusiveMaxBuildHeight())
|
||||
if (relNeighbourBlockPos.getY() < neighbourChunk.getMinNonEmptyHeight()
|
||||
|| relNeighbourBlockPos.getY() >= neighbourChunk.getExclusiveMaxBuildHeight())
|
||||
{
|
||||
// the light pos is outside the chunk's min/max height,
|
||||
// this can happen if given a chunk that hasn't finished generating
|
||||
|
||||
@@ -290,7 +290,7 @@ public class WorldGenModule implements Closeable
|
||||
remainingChunkCount += this.worldGenerationQueue.getQueuedChunkCount();
|
||||
String remainingChunkCountStr = F3Screen.NUMBER_FORMAT.format(remainingChunkCount);
|
||||
|
||||
String message = "DH Gen/Import: " + remainingChunkCountStr + " chunks left.";
|
||||
String message = "DH is loading chunks. " + remainingChunkCountStr + " left.";
|
||||
|
||||
// show a message about how to disable progress logging if requested
|
||||
int msToShowDisableInstructions = Config.Common.WorldGenerator.generationProgressDisableMessageDisplayTimeInSeconds.get() * 1_000;
|
||||
|
||||
@@ -510,10 +510,13 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
|
||||
{
|
||||
// TODO memoization is needed for multiplayer, otherwise
|
||||
// new retrieval requests won't be submitted.
|
||||
// TODO why is that the case? Shouldn't the missing positions be un-changing?
|
||||
// TODO why is that the case? Shouldn't the missing positions be un-changing?
|
||||
// TODO setting this value to low can cause world gen to slow down significantly
|
||||
// due to a race condition where the world gen thinks it is finished, but the results
|
||||
// haven't been saved to file yet, causing the gen to fire again
|
||||
this.missingGenerationPosFunc = Suppliers.memoizeWithExpiration(
|
||||
() -> this.fullDataSourceProvider.getPositionsToRetrieve(this.pos),
|
||||
15, TimeUnit.SECONDS);
|
||||
10, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
LongArrayList missingGenerationPos = this.getMissingGenerationPos();
|
||||
|
||||
@@ -359,6 +359,7 @@ public class RenderBufferHandler implements AutoCloseable
|
||||
// debug wireframe setup //
|
||||
//=======================//
|
||||
|
||||
// TODO move this logic into LodRenderer so all the GL states can be handled there
|
||||
boolean renderWireframe = Config.Client.Advanced.Debugging.renderWireframe.get();
|
||||
if (renderWireframe)
|
||||
{
|
||||
|
||||
@@ -57,10 +57,10 @@ public class GLState
|
||||
public boolean depth;
|
||||
public boolean writeToDepthBuffer;
|
||||
public int depthFunc;
|
||||
//public boolean stencil;
|
||||
//public int stencilFunc;
|
||||
//public int stencilRef;
|
||||
//public int stencilMask;
|
||||
public boolean stencil;
|
||||
public int stencilFunc;
|
||||
public int stencilRef;
|
||||
public int stencilMask;
|
||||
public int[] view;
|
||||
public boolean cull;
|
||||
public int cullMode;
|
||||
@@ -121,10 +121,10 @@ public class GLState
|
||||
this.depth = GL32.glIsEnabled(GL32.GL_DEPTH_TEST);
|
||||
this.writeToDepthBuffer = GL32.glGetInteger(GL32.GL_DEPTH_WRITEMASK) == GL32.GL_TRUE;
|
||||
this.depthFunc = GL32.glGetInteger(GL32.GL_DEPTH_FUNC);
|
||||
//this.stencil = GL32.glIsEnabled(GL32.GL_STENCIL_TEST);
|
||||
//this.stencilFunc = GL32.glGetInteger(GL32.GL_STENCIL_FUNC);
|
||||
//this.stencilRef = GL32.glGetInteger(GL32.GL_STENCIL_REF);
|
||||
//this.stencilMask = GL32.glGetInteger(GL32.GL_STENCIL_VALUE_MASK);
|
||||
this.stencil = GL32.glIsEnabled(GL32.GL_STENCIL_TEST);
|
||||
this.stencilFunc = GL32.glGetInteger(GL32.GL_STENCIL_FUNC);
|
||||
this.stencilRef = GL32.glGetInteger(GL32.GL_STENCIL_REF);
|
||||
this.stencilMask = GL32.glGetInteger(GL32.GL_STENCIL_VALUE_MASK);
|
||||
this.view = new int[4];
|
||||
GL32.glGetIntegerv(GL32.GL_VIEWPORT, this.view);
|
||||
this.cull = GL32.glIsEnabled(GL32.GL_CULL_FACE);
|
||||
@@ -143,11 +143,11 @@ public class GLState
|
||||
", FB depth=" + this.frameBufferDepthTexture +
|
||||
", blend=" + this.blend + ", scissor=" + this.scissor + ", blendMode=" + GLEnums.getString(this.blendSrcColor) + "," + GLEnums.getString(this.blendDstColor) +
|
||||
", depth=" + this.depth +
|
||||
//", depthFunc=" + GLEnums.getString(this.depthFunc) + ", stencil=" + this.stencil + ", stencilFunc=" +
|
||||
//GLEnums.getString(this.stencilFunc) + ", stencilRef=" + this.stencilRef + ", stencilMask=" + this.stencilMask +
|
||||
", depthFunc=" + GLEnums.getString(this.depthFunc) + ", stencil=" + this.stencil +
|
||||
", stencilFunc=" + GLEnums.getString(this.stencilFunc) + ", stencilRef=" + this.stencilRef + ", stencilMask=" + this.stencilMask +
|
||||
", view={x:" + this.view[0] + ", y:" + this.view[1] +
|
||||
", w:" + this.view[2] + ", h:" + this.view[3] + "}" + ", cull=" + this.cull + ", cullMode="
|
||||
+ GLEnums.getString(this.cullMode) + ", polyMode=" + GLEnums.getString(this.polyMode) +
|
||||
", w:" + this.view[2] + ", h:" + this.view[3] + "}" + ", cull=" + this.cull +
|
||||
", cullMode=" + GLEnums.getString(this.cullMode) + ", polyMode=" + GLEnums.getString(this.polyMode) +
|
||||
'}';
|
||||
}
|
||||
|
||||
@@ -233,15 +233,15 @@ public class GLState
|
||||
}
|
||||
GLMC.glDepthFunc(this.depthFunc);
|
||||
|
||||
//if (this.stencil)
|
||||
//{
|
||||
// GL32.glEnable(GL32.GL_STENCIL_TEST);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// GL32.glDisable(GL32.GL_STENCIL_TEST);
|
||||
//}
|
||||
//GL32.glStencilFunc(this.stencilFunc, this.stencilRef, this.stencilMask);
|
||||
if (this.stencil)
|
||||
{
|
||||
GL32.glEnable(GL32.GL_STENCIL_TEST);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL32.glDisable(GL32.GL_STENCIL_TEST);
|
||||
}
|
||||
GL32.glStencilFunc(this.stencilFunc, this.stencilRef, this.stencilMask);
|
||||
|
||||
GL32.glViewport(this.view[0], this.view[1], this.view[2], this.view[3]);
|
||||
if (this.cull)
|
||||
|
||||
+28
-14
@@ -86,22 +86,31 @@ public class FadeRenderer
|
||||
this.fadeFramebuffer = -1;
|
||||
}
|
||||
|
||||
if (this.fadeTexture != -1)
|
||||
{
|
||||
GLMC.glDeleteTextures(this.fadeTexture);
|
||||
this.fadeTexture = -1;
|
||||
}
|
||||
|
||||
this.fadeFramebuffer = GL32.glGenFramebuffers();
|
||||
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, this.fadeFramebuffer);
|
||||
|
||||
this.fadeTexture = GL32.glGenTextures();
|
||||
GLMC.glBindTexture(this.fadeTexture);
|
||||
GL32.glTexImage2D(GL32.GL_TEXTURE_2D, 0, GL32.GL_RGBA16, width, height, 0, GL32.GL_RGBA, GL32.GL_UNSIGNED_SHORT_4_4_4_4, (ByteBuffer) null);
|
||||
GL32.glTexParameteri(GL32.GL_TEXTURE_2D, GL32.GL_TEXTURE_MIN_FILTER, GL32.GL_LINEAR);
|
||||
GL32.glTexParameteri(GL32.GL_TEXTURE_2D, GL32.GL_TEXTURE_MAG_FILTER, GL32.GL_LINEAR);
|
||||
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D, this.fadeTexture, 0);
|
||||
|
||||
// Applying the fade texture is only needed if MC is drawing to their own frame buffer,
|
||||
// otherwise we can directly render to their texture
|
||||
if (MC_RENDER.mcRendersToFrameBuffer())
|
||||
{
|
||||
if (this.fadeTexture != -1)
|
||||
{
|
||||
GLMC.glDeleteTextures(this.fadeTexture);
|
||||
this.fadeTexture = -1;
|
||||
}
|
||||
|
||||
this.fadeTexture = GL32.glGenTextures();
|
||||
GLMC.glBindTexture(this.fadeTexture);
|
||||
GL32.glTexImage2D(GL32.GL_TEXTURE_2D, 0, GL32.GL_RGBA16, width, height, 0, GL32.GL_RGBA, GL32.GL_UNSIGNED_SHORT_4_4_4_4, (ByteBuffer) null);
|
||||
GL32.glTexParameteri(GL32.GL_TEXTURE_2D, GL32.GL_TEXTURE_MIN_FILTER, GL32.GL_LINEAR);
|
||||
GL32.glTexParameteri(GL32.GL_TEXTURE_2D, GL32.GL_TEXTURE_MAG_FILTER, GL32.GL_LINEAR);
|
||||
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D, this.fadeTexture, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D, MC_RENDER.getColorTextureId(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -146,8 +155,13 @@ public class FadeRenderer
|
||||
|
||||
profiler.popPush("Fade Apply");
|
||||
|
||||
FadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
|
||||
FadeApplyShader.INSTANCE.render(partialTicks);
|
||||
// Applying the fade texture is only needed if MC is drawing to their own frame buffer,
|
||||
// otherwise we can directly render to their texture
|
||||
if (MC_RENDER.mcRendersToFrameBuffer())
|
||||
{
|
||||
FadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
|
||||
FadeApplyShader.INSTANCE.render(partialTicks);
|
||||
}
|
||||
|
||||
profiler.pop();
|
||||
}
|
||||
|
||||
+41
-40
@@ -557,34 +557,24 @@ public class LodRenderer
|
||||
activeFrameBuffer.bind();
|
||||
|
||||
|
||||
boolean clearTextures = !ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeTextureClearEvent.class, renderEventParam);
|
||||
if (clearTextures)
|
||||
{
|
||||
if (this.usingMcFrameBuffer && framebufferOverride == null)
|
||||
{
|
||||
// Due to using MC/Optifine's framebuffer we need to re-bind the depth texture,
|
||||
// otherwise we'll be writing to MC/Optifine's depth texture which causes rendering issues
|
||||
activeFrameBuffer.addDepthAttachment(this.depthTexture.getTextureId(), EDhDepthBufferFormat.DEPTH32F.isCombinedStencil());
|
||||
|
||||
|
||||
// don't clear the color texture, that removes the sky
|
||||
GL32.glClear(GL32.GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
else if (firstPass)
|
||||
{
|
||||
GL32.glClear(GL32.GL_COLOR_BUFFER_BIT | GL32.GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
// by default draw everything as triangles
|
||||
GL32.glPolygonMode(GL32.GL_FRONT_AND_BACK, GL32.GL_FILL);
|
||||
GLMC.enableFaceCulling();
|
||||
|
||||
GLMC.glBlendFunc(GL32.GL_SRC_ALPHA, GL32.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GLMC.glBlendFuncSeparate(GL32.GL_SRC_ALPHA, GL32.GL_ONE_MINUS_SRC_ALPHA, GL32.GL_ONE, GL32.GL_ZERO);
|
||||
|
||||
GL32.glDisable(GL32.GL_SCISSOR_TEST);
|
||||
|
||||
// Enable depth test and depth mask
|
||||
GLMC.enableDepthTest();
|
||||
GLMC.glDepthFunc(GL32.GL_LESS);
|
||||
GLMC.enableDepthMask();
|
||||
|
||||
// This is required for MC versions 1.21.5+
|
||||
// due to MC updating the lightmap by changing the viewport size
|
||||
GL32.glViewport(0, 0, this.cachedWidth, this.cachedHeight);
|
||||
|
||||
/*---------Bind required objects--------*/
|
||||
// Setup LodRenderProgram and the LightmapTexture if it has not yet been done
|
||||
// also binds LightmapTexture, VAO, and ShaderProgram
|
||||
@@ -605,6 +595,33 @@ public class LodRenderer
|
||||
}
|
||||
|
||||
this.lodRenderProgram.fillUniformData(renderEventParam);
|
||||
|
||||
|
||||
// needs to be fired after all the textures have been created/bound
|
||||
boolean clearTextures = !ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeTextureClearEvent.class, renderEventParam);
|
||||
if (clearTextures)
|
||||
{
|
||||
GL32.glClearDepth(1.0);
|
||||
|
||||
float[] clearColorValues = new float[4];
|
||||
GL32.glGetFloatv(GL32.GL_COLOR_CLEAR_VALUE, clearColorValues);
|
||||
GL32.glClearColor(clearColorValues[0], clearColorValues[1], clearColorValues[2], 1.0f);
|
||||
|
||||
if (this.usingMcFrameBuffer && framebufferOverride == null)
|
||||
{
|
||||
// Due to using MC/Optifine's framebuffer we need to re-bind the depth texture,
|
||||
// otherwise we'll be writing to MC/Optifine's depth texture which causes rendering issues
|
||||
activeFrameBuffer.addDepthAttachment(this.depthTexture.getTextureId(), EDhDepthBufferFormat.DEPTH32F.isCombinedStencil());
|
||||
|
||||
|
||||
// don't clear the color texture, that removes the sky
|
||||
GL32.glClear(GL32.GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
else if (firstPass)
|
||||
{
|
||||
GL32.glClear(GL32.GL_COLOR_BUFFER_BIT | GL32.GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Setup all render objects - MUST be called on the render thread */
|
||||
@@ -656,7 +673,7 @@ public class LodRenderer
|
||||
if(this.framebuffer.getStatus() != GL32.GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
// This generally means something wasn't bound, IE missing either the color or depth texture
|
||||
SPAM_LOGGER.warn("FrameBuffer ["+this.framebuffer.getId()+"] isn't complete.");
|
||||
EVENT_LOGGER.warn("FrameBuffer ["+this.framebuffer.getId()+"] isn't complete.");
|
||||
}
|
||||
|
||||
|
||||
@@ -716,25 +733,6 @@ public class LodRenderer
|
||||
|
||||
|
||||
|
||||
private Color getFogColor(float partialTicks)
|
||||
{
|
||||
Color fogColor;
|
||||
|
||||
if (Config.Client.Advanced.Graphics.Fog.colorMode.get() == EDhApiFogColorMode.USE_SKY_COLOR)
|
||||
{
|
||||
fogColor = MC_RENDER.getSkyColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
fogColor = MC_RENDER.getFogColor(partialTicks);
|
||||
}
|
||||
|
||||
return fogColor;
|
||||
}
|
||||
private Color getSpecialFogColor(float partialTicks) { return MC_RENDER.getSpecialFogColor(partialTicks); }
|
||||
|
||||
|
||||
|
||||
//===============//
|
||||
// API functions //
|
||||
//===============//
|
||||
@@ -748,7 +746,10 @@ public class LodRenderer
|
||||
public static int getActiveColorTextureId() { return activeColorTextureId; }
|
||||
|
||||
private void setActiveDepthTextureId(int depthTextureId) { activeDepthTextureId = depthTextureId; }
|
||||
/** Returns -1 if no texture has been bound yet */
|
||||
/**
|
||||
* FIXME it's possible for this to return an invalid texture ID if the renderer is being re-built at the same time
|
||||
* Returns -1 if no texture has been bound yet
|
||||
*/
|
||||
public static int getActiveDepthTextureId() { return activeDepthTextureId; }
|
||||
|
||||
|
||||
|
||||
+82
-3
@@ -75,6 +75,18 @@ public class DhApplyShader extends AbstractShaderRenderer
|
||||
|
||||
@Override
|
||||
protected void onRender()
|
||||
{
|
||||
if (MC_RENDER.mcRendersToFrameBuffer())
|
||||
{
|
||||
this.renderToFrameBuffer();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.renderToMcTexture();
|
||||
}
|
||||
}
|
||||
// TODO merge duplicate code between these to render methods
|
||||
private void renderToFrameBuffer()
|
||||
{
|
||||
int targetFrameBuffer = MC_RENDER.getTargetFrameBuffer();
|
||||
if (targetFrameBuffer == -1)
|
||||
@@ -87,9 +99,15 @@ public class DhApplyShader extends AbstractShaderRenderer
|
||||
|
||||
GLMC.disableDepthTest();
|
||||
|
||||
GLMC.enableBlend();
|
||||
GL32.glBlendEquation(GL32.GL_FUNC_ADD);
|
||||
GLMC.glBlendFunc(GL32.GL_ONE, GL32.GL_ONE_MINUS_SRC_ALPHA);
|
||||
// blending isn't needed, we're manually merging the MC and DH textures
|
||||
// Note: this prevents the sun/moon and stars from rendering through transparent LODs,
|
||||
// however this also fixes transparent LODs from glowing when rendered against the sky during the day
|
||||
GLMC.disableBlend();
|
||||
|
||||
// old blending logic in case it's ever needed:
|
||||
//GLMC.enableBlend();
|
||||
//GL32.glBlendEquation(GL32.GL_FUNC_ADD);
|
||||
//GLMC.glBlendFunc(GL32.GL_ONE, GL32.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GLMC.glActiveTexture(GL32.GL_TEXTURE0);
|
||||
GLMC.glBindTexture(LodRenderer.getActiveColorTextureId());
|
||||
@@ -110,5 +128,66 @@ public class DhApplyShader extends AbstractShaderRenderer
|
||||
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, targetFrameBuffer);
|
||||
|
||||
}
|
||||
private void renderToMcTexture()
|
||||
{
|
||||
int targetColorTextureId = MC_RENDER.getColorTextureId();
|
||||
if (targetColorTextureId == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int dhFrameBufferId = LodRenderer.getActiveFramebufferId();
|
||||
if (dhFrameBufferId == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int mcFrameBufferId = MC_RENDER.getTargetFrameBuffer();
|
||||
if (mcFrameBufferId == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GLState state = new GLState();
|
||||
|
||||
GLMC.disableDepthTest();
|
||||
|
||||
// blending isn't needed, we're just directly merging the MC and DH textures
|
||||
// Note: this prevents the sun/moon and stars from rendering through transparent LODs,
|
||||
// however this also fixes
|
||||
GLMC.disableBlend();
|
||||
|
||||
// old blending logic in case it's ever needed:
|
||||
//GLMC.enableBlend();
|
||||
//GL32.glBlendEquation(GL32.GL_FUNC_ADD);
|
||||
//GLMC.glBlendFunc(GL32.GL_ONE, GL32.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GLMC.glActiveTexture(GL32.GL_TEXTURE0);
|
||||
GLMC.glBindTexture(LodRenderer.getActiveColorTextureId());
|
||||
GL32.glUniform1i(this.gDhColorTextureUniform, 0);
|
||||
|
||||
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
|
||||
GLMC.glBindTexture(LodRenderer.getActiveDepthTextureId());
|
||||
GL32.glUniform1i(this.gDepthMapUniform, 1);
|
||||
|
||||
|
||||
|
||||
GL32.glFramebufferTexture(GL32.GL_DRAW_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, targetColorTextureId, 0);
|
||||
|
||||
// Copy to MC's texture via MC's framebuffer
|
||||
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, dhFrameBufferId);
|
||||
|
||||
ScreenQuad.INSTANCE.render();
|
||||
|
||||
|
||||
// restore everything, except at this point the MC framebuffer should now be used instead
|
||||
state.restore();
|
||||
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, mcFrameBufferId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+10
@@ -20,6 +20,7 @@
|
||||
package com.seibel.distanthorizons.core.render.renderer.shaders;
|
||||
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.render.glObject.GLState;
|
||||
import com.seibel.distanthorizons.core.render.glObject.shader.ShaderProgram;
|
||||
import com.seibel.distanthorizons.core.render.renderer.FadeRenderer;
|
||||
import com.seibel.distanthorizons.core.render.renderer.LodRenderer;
|
||||
@@ -104,6 +105,12 @@ public class FadeApplyShader extends AbstractShaderRenderer
|
||||
@Override
|
||||
protected void onRender()
|
||||
{
|
||||
if (!MC_RENDER.mcRendersToFrameBuffer())
|
||||
{
|
||||
throw new IllegalStateException("If Minecraft is directly rendering to a texture the apply shader isn't needed, just draw the fade directly to the MC color texture.");
|
||||
}
|
||||
|
||||
|
||||
GLMC.disableBlend();
|
||||
|
||||
// Depth testing must be disabled otherwise this application shader won't apply anything.
|
||||
@@ -119,6 +126,9 @@ public class FadeApplyShader extends AbstractShaderRenderer
|
||||
ScreenQuad.INSTANCE.render();
|
||||
|
||||
GLMC.enableDepthTest();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -165,6 +165,7 @@ public class FadeShader extends AbstractShaderRenderer
|
||||
GL32.glUniform1i(this.uMcDepthTexture, 0);
|
||||
|
||||
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
|
||||
// FIXME it's possible for this to return an invalid texture ID if the renderer is being re-built at the same time
|
||||
GLMC.glBindTexture(LodRenderer.getActiveDepthTextureId());
|
||||
GL32.glUniform1i(this.uDhDepthTexture, 1);
|
||||
|
||||
|
||||
+1
@@ -84,6 +84,7 @@ public class FogApplyShader extends AbstractShaderRenderer
|
||||
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
|
||||
GLMC.glBindTexture(LodRenderer.getActiveDepthTextureId());
|
||||
GL32.glUniform1i(this.depthTextureUniform, 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+15
-2
@@ -28,9 +28,11 @@ import com.seibel.distanthorizons.core.render.glObject.shader.ShaderProgram;
|
||||
import com.seibel.distanthorizons.core.render.renderer.LodRenderer;
|
||||
import com.seibel.distanthorizons.core.render.renderer.ScreenQuad;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftGLWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -41,11 +43,14 @@ public class FogShader extends AbstractShaderRenderer
|
||||
|
||||
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
||||
private static final IMinecraftGLWrapper GLMC = SingletonInjector.INSTANCE.get(IMinecraftGLWrapper.class);
|
||||
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||
|
||||
|
||||
|
||||
public int frameBuffer;
|
||||
|
||||
private Mat4f inverseMvmProjMatrix;
|
||||
private Mat4f inverseMvmProjMatrix;
|
||||
|
||||
|
||||
|
||||
//==========//
|
||||
@@ -253,7 +258,15 @@ public class FogShader extends AbstractShaderRenderer
|
||||
|
||||
// this is necessary for MC 1.16 (IE Legacy OpenGL)
|
||||
// otherwise the framebuffer isn't cleared correctly and the fog smears across the screen
|
||||
GL32.glClear(GL32.GL_COLOR_BUFFER_BIT | GL32.GL_DEPTH_BUFFER_BIT);
|
||||
if (MC_RENDER.runningLegacyOpenGL())
|
||||
{
|
||||
// in another part of the DH code we set the fog color to opaque, here it needs to be transparent
|
||||
float[] clearColorValues = new float[4];
|
||||
GL32.glGetFloatv(GL32.GL_COLOR_CLEAR_VALUE, clearColorValues);
|
||||
GL32.glClearColor(clearColorValues[0], clearColorValues[1], clearColorValues[2], 0.0f);
|
||||
|
||||
GL32.glClear(GL32.GL_COLOR_BUFFER_BIT | GL32.GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
|
||||
ScreenQuad.INSTANCE.render();
|
||||
|
||||
-3
@@ -134,9 +134,6 @@ public class SSAOApplyShader extends AbstractShaderRenderer
|
||||
// it should be automatically restored after rendering is complete.
|
||||
GLMC.disableDepthTest();
|
||||
|
||||
GLMC.glActiveTexture(GL32.GL_TEXTURE0);
|
||||
GLMC.glBindTexture(0);
|
||||
|
||||
// apply the rendered SSAO to the LODs
|
||||
GLMC.glBindFramebuffer(GL32.GL_READ_FRAMEBUFFER, SSAOShader.INSTANCE.frameBuffer);
|
||||
GLMC.glBindFramebuffer(GL32.GL_DRAW_FRAMEBUFFER, LodRenderer.getActiveFramebufferId());
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.seibel.distanthorizons.core.sql.DbConnectionClosedException;
|
||||
import com.seibel.distanthorizons.core.sql.dto.IBaseDTO;
|
||||
import com.seibel.distanthorizons.core.sql.repo.phantoms.AutoClosableTrackingWrapper;
|
||||
import com.seibel.distanthorizons.core.util.KeyedLockContainer;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -501,7 +502,12 @@ public abstract class AbstractDhRepo<TKey, TDTO extends IBaseDTO<TKey>> implemen
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.warn("Attempting to close already closed database connection: [" + connectionString + "]");
|
||||
// these warnings can be ignored in release builds, as long as the connection is closed it doesn't really matter
|
||||
// TODO fix duplicate closes
|
||||
if (ModInfo.IS_DEV_BUILD)
|
||||
{
|
||||
LOGGER.warn("Attempting to close already closed database connection: [" + connectionString + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -562,7 +568,12 @@ public abstract class AbstractDhRepo<TKey, TDTO extends IBaseDTO<TKey>> implemen
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.warn("Attempting to close already closed database connection: [" + this.connectionString + "]");
|
||||
// these warnings can be ignored in release builds, as long as the connection is closed it doesn't really matter
|
||||
// TODO fix duplicate closes
|
||||
if (ModInfo.IS_DEV_BUILD)
|
||||
{
|
||||
LOGGER.warn("Attempting to close already closed database connection: [" + this.connectionString + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
ACTIVE_CONNECTION_STRINGS_BY_REPO.remove(this);
|
||||
|
||||
+4
-2
@@ -78,9 +78,11 @@ public class RateLimitedThreadPoolExecutor extends ThreadPoolExecutor
|
||||
long runTime = System.nanoTime() - this.runStartTime.get();
|
||||
Thread.sleep(TimeUnit.NANOSECONDS.toMillis((long) (runTime / this.runTimeRatioConfig.get() - runTime)));
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
catch (InterruptedException ignore)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
// if this thread is interrupted that means the
|
||||
// thread pool is being shut down,
|
||||
// we don't need to log that.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-2
@@ -89,7 +89,14 @@ public class ThreadPoolUtil
|
||||
|
||||
public static void setupThreadPools()
|
||||
{
|
||||
// thread pools
|
||||
//==================//
|
||||
// main thread pool //
|
||||
//==================//
|
||||
|
||||
if (taskPicker != null)
|
||||
{
|
||||
taskPicker.shutdown();
|
||||
}
|
||||
taskPicker = new PriorityTaskPicker();
|
||||
|
||||
networkCompressionThreadPool = taskPicker.createExecutor();
|
||||
@@ -98,8 +105,22 @@ public class ThreadPoolUtil
|
||||
updatePropagatorThreadPool = taskPicker.createExecutor();
|
||||
worldGenThreadPool = taskPicker.createExecutor();
|
||||
|
||||
// single thread pools
|
||||
|
||||
|
||||
//=========================//
|
||||
// standalone thread pools //
|
||||
//=========================//
|
||||
|
||||
if (beaconCullingThreadPool != null)
|
||||
{
|
||||
beaconCullingThreadPool.shutdown();
|
||||
}
|
||||
beaconCullingThreadPool = ThreadUtil.makeSingleThreadPool(BEACON_CULLING_THREAD_NAME);
|
||||
|
||||
if (fullDataMigrationThreadPool != null)
|
||||
{
|
||||
fullDataMigrationThreadPool.shutdown();
|
||||
}
|
||||
fullDataMigrationThreadPool = ThreadUtil.makeSingleThreadPool(FULL_DATA_MIGRATION_THREAD_NAME);
|
||||
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ public class DhClientWorld extends AbstractDhWorld implements IDhClientWorld
|
||||
public final ClientOnlySaveStructure saveStructure;
|
||||
public final ClientNetworkState networkState = new ClientNetworkState();
|
||||
|
||||
public ExecutorService dhTickerThread = ThreadUtil.makeSingleThreadPool("Client World Ticker Thread");
|
||||
public EventLoop eventLoop = new EventLoop(this.dhTickerThread, this::_clientTick);
|
||||
public final ExecutorService dhTickerThread = ThreadUtil.makeSingleThreadPool("Client World Ticker Thread");
|
||||
public final EventLoop eventLoop = new EventLoop(this.dhTickerThread, this::_clientTick);
|
||||
|
||||
|
||||
|
||||
@@ -128,6 +128,8 @@ public class DhClientWorld extends AbstractDhWorld implements IDhClientWorld
|
||||
{
|
||||
this.networkState.close();
|
||||
|
||||
this.dhTickerThread.shutdownNow();
|
||||
|
||||
|
||||
for (DhClientLevel dhClientLevel : this.levels.values())
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@ public class DhServerWorld extends AbstractDhServerWorld<DhServerLevel>
|
||||
}
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// level handling //
|
||||
//================//
|
||||
|
||||
@@ -23,9 +23,11 @@ import com.seibel.distanthorizons.core.level.IDhLevel;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface IDhWorld
|
||||
// TODO why is this exist alongside AbstractDhWorld?
|
||||
public interface IDhWorld extends Closeable
|
||||
{
|
||||
|
||||
IDhLevel getOrLoadLevel(@NotNull ILevelWrapper levelWrapper);
|
||||
|
||||
+5
@@ -49,6 +49,11 @@ public interface IBlockStateWrapper extends IDhApiBlockStateWrapper
|
||||
boolean isBeaconBlock();
|
||||
/** IE a glass block that can affect the beacon beam color */
|
||||
boolean isBeaconTintBlock();
|
||||
/**
|
||||
* Returns true for any blocks that allow beacon beams to go through.
|
||||
* IE: glass, stairs, bedrock, chests, end portal frames, carpet, cake
|
||||
*/
|
||||
boolean allowsBeaconBeamPassage();
|
||||
/**
|
||||
* The blocks used by a beacon's base
|
||||
* IE Iron, diamond, gold, etc.
|
||||
|
||||
+2
-1
@@ -381,8 +381,9 @@ public interface IChunkWrapper extends IBindable
|
||||
for (int y = beaconRelPos.getY() +1; y <= maxY; y++)
|
||||
{
|
||||
IBlockStateWrapper block = centerChunk.getBlockState(beaconRelPos.getX(), y, beaconRelPos.getZ());
|
||||
if (!block.isAir() && block.getOpacity() == LodUtil.BLOCK_FULLY_OPAQUE)
|
||||
if (!block.allowsBeaconBeamPassage())
|
||||
{
|
||||
// beam is blocked by this block
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -60,6 +60,9 @@ public interface IMinecraftRenderWrapper extends IBindable
|
||||
int getScreenWidth();
|
||||
int getScreenHeight();
|
||||
|
||||
boolean mcRendersToFrameBuffer();
|
||||
boolean runningLegacyOpenGL();
|
||||
|
||||
/** @return -1 if no valid framebuffer is available yet */
|
||||
int getTargetFrameBuffer(); // Note: Iris is now hooking onto this for DH + Iris compat, try not to change (unless we wanna deal with some annoyances)
|
||||
// Iris commit: https://github.com/IrisShaders/Iris/commit/a76a240527e93780bbcba57c09bef377419d47a7#diff-7b9ded0c79bbcdb130010373387756a28ee8d3640d522c0a5b7acd0abbfc20aeR16
|
||||
|
||||
@@ -8,17 +8,26 @@ uniform sampler2D gDhColorTexture;
|
||||
uniform sampler2D gDhDepthTexture;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* LOD application shader
|
||||
*
|
||||
* This merges the rendered LODs into Minecraft's texture/FBO
|
||||
*/
|
||||
void main()
|
||||
{
|
||||
fragColor = vec4(0.0);
|
||||
|
||||
float fragmentDepth = texture(gDhDepthTexture, TexCoord).r;
|
||||
|
||||
// a fragment depth of "1" means the fragment wasn't drawn to,
|
||||
// only update fragments that were drawn to
|
||||
if (fragmentDepth != 1)
|
||||
float fragmentDepth = texture(gDhDepthTexture, TexCoord).r;
|
||||
if (fragmentDepth != 1)
|
||||
{
|
||||
fragColor = texture(gDhColorTexture, TexCoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
// use the original MC texture if no LODs were drawn to this fragment
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,16 +8,19 @@ uniform sampler2D uColorTexture;
|
||||
uniform sampler2D uDepthTexture;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fog application shader
|
||||
*
|
||||
* This merges the rendered fog onto DH's rendered LODs
|
||||
*/
|
||||
void main()
|
||||
{
|
||||
fragColor = vec4(1.0);
|
||||
|
||||
float fragmentDepth = textureLod(uDepthTexture, TexCoord, 0).r;
|
||||
fragColor = vec4(0.0);
|
||||
|
||||
// a fragment depth of "1" means the fragment wasn't drawn to,
|
||||
// only update fragments that were drawn to
|
||||
if (fragmentDepth != 1)
|
||||
float fragmentDepth = textureLod(uDepthTexture, TexCoord, 0).r;
|
||||
if (fragmentDepth != 1)
|
||||
{
|
||||
fragColor = texture(uColorTexture, TexCoord);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user