Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Feb 1, 2024
1 parent 61c792a commit afddcee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/main/java/net/coderbot/iris/compat/dh/DHCompatInternal.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
Expand Down Expand Up @@ -108,6 +112,8 @@ public void createDepthTex(int width, int height) {
depthTexNoTranslucent = null;
}

translucentDepthDirty = true;

depthTexNoTranslucent = new DepthTexture(width, height, DepthBufferFormat.DEPTH32F);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public void beforeRender(DhApiEventParam<DhApiRenderParam> 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);
Expand Down

0 comments on commit afddcee

Please sign in to comment.