diff --git a/src/main/java/net/coderbot/iris/compat/dh/DHCompatInternal.java b/src/main/java/net/coderbot/iris/compat/dh/DHCompatInternal.java index b9e5a78646..82c011a24c 100644 --- a/src/main/java/net/coderbot/iris/compat/dh/DHCompatInternal.java +++ b/src/main/java/net/coderbot/iris/compat/dh/DHCompatInternal.java @@ -6,15 +6,18 @@ import com.seibel.distanthorizons.coreapi.DependencyInjection.OverrideInjector; import com.seibel.distanthorizons.coreapi.util.math.Vec3f; import net.coderbot.iris.Iris; +import net.coderbot.iris.gl.IrisRenderSystem; import net.coderbot.iris.gl.buffer.ShaderStorageBuffer; import net.coderbot.iris.gl.framebuffer.GlFramebuffer; import net.coderbot.iris.gl.texture.DepthBufferFormat; +import net.coderbot.iris.gl.texture.DepthCopyStrategy; import net.coderbot.iris.pipeline.ShadowRenderer; import net.coderbot.iris.pipeline.newshader.NewWorldRenderingPipeline; import net.coderbot.iris.rendertarget.DepthTexture; import net.coderbot.iris.shaderpack.ProgramSource; import net.coderbot.iris.uniforms.CapturedRenderingState; import net.minecraft.client.Minecraft; +import org.lwjgl.opengl.GL20C; public class DHCompatInternal { @@ -30,6 +33,7 @@ public class DHCompatInternal private GlFramebuffer dhShadowFramebuffer; private DhFrameBufferWrapper dhShadowFramebufferWrapper; private DepthTexture depthTexNoTranslucent; + private boolean translucentDepthDirty; private int storedDepthTex; public boolean shouldOverride; @@ -108,6 +112,8 @@ public void createDepthTex(int width, int height) { depthTexNoTranslucent = null; } + translucentDepthDirty = true; + depthTexNoTranslucent = new DepthTexture(width, height, DepthBufferFormat.DEPTH32F); } @@ -146,6 +152,7 @@ public void clear() { dhWaterFramebuffer = null; dhShadowFramebuffer = null; storedDepthTex = -1; + translucentDepthDirty = true; OverrideInjector.INSTANCE.unbind(IDhApiFramebuffer.class, dhTerrainFramebufferWrapper); OverrideInjector.INSTANCE.unbind(IDhApiFramebuffer.class, dhShadowFramebufferWrapper); @@ -207,6 +214,17 @@ public static int getDhBlockRenderDistance() { return DhApi.Delayed.configs.graphics().chunkRenderDistance().getValue() * 16; } + public void copyTranslucents(int width, int height) { + if (translucentDepthDirty) { + translucentDepthDirty = false; + RenderSystem.bindTexture(depthTexNoTranslucent.getTextureId()); + dhTerrainFramebuffer.bindAsReadBuffer(); + IrisRenderSystem.copyTexImage2D(GL20C.GL_TEXTURE_2D, 0, DepthBufferFormat.DEPTH32F.getGlInternalFormat(), 0, 0, width, height, 0); + } else { + DepthCopyStrategy.fastest(false).copy(dhTerrainFramebuffer, storedDepthTex, null, depthTexNoTranslucent.getTextureId(), width, height); + } + } + public float getFarPlane() { return (float)((double)(getDhBlockRenderDistance() + 512) * Math.sqrt(2.0)); } diff --git a/src/main/java/net/coderbot/iris/compat/dh/LodRendererEvents.java b/src/main/java/net/coderbot/iris/compat/dh/LodRendererEvents.java index cf9e8ce65e..c319527a93 100644 --- a/src/main/java/net/coderbot/iris/compat/dh/LodRendererEvents.java +++ b/src/main/java/net/coderbot/iris/compat/dh/LodRendererEvents.java @@ -342,7 +342,7 @@ public void beforeRender(DhApiEventParam event) if (DHCompatInternal.INSTANCE.shouldOverride && DHCompatInternal.INSTANCE.getTranslucentFB() != null) { - DepthCopyStrategy.fastest(false).copy(DHCompatInternal.INSTANCE.getSolidFB(), depthTextureId, null, DHCompatInternal.INSTANCE.getDepthTexNoTranslucent(), textureWidth, textureHeight); + DHCompatInternal.INSTANCE.copyTranslucents(textureWidth, textureHeight); DHCompatInternal.INSTANCE.getTranslucentShader().bind(); Matrix4f projection = CapturedRenderingState.INSTANCE.getGbufferProjection(); //float nearClip = DhApi.Delayed.renderProxy.getNearClipPlaneDistanceInBlocks(partialTicks);