Skip to content

Commit

Permalink
Upgrade to latest DH
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Jan 22, 2024
1 parent 3ff530e commit b8b531c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void renderShadowSolid() {
}

public void renderShadowTranslucent() {
ClientApi.INSTANCE.renderTranslucentLods(ClientLevelWrapper.getWrapper(Minecraft.getInstance().level),
ClientApi.INSTANCE.renderDeferredLods(ClientLevelWrapper.getWrapper(Minecraft.getInstance().level),
McObjectConverter.Convert(ShadowRenderer.MODELVIEW),
McObjectConverter.Convert(ShadowRenderer.PROJECTION),
CapturedRenderingState.INSTANCE.getTickDelta());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,26 @@ public class MixinLodRenderer {
@Shadow
@Final
private static IMinecraftClientWrapper MC;

@Shadow
private boolean deferWaterRendering;
@Shadow
private DHDepthTexture depthTexture;
@Shadow
private int cachedWidth;
@Shadow
private int cachedHeight;
@Shadow
private boolean deferTransparentRendering;
@Unique
private boolean atTranslucent;

@Unique
private int frame;

@Inject(method = "drawLODs", at = @At("TAIL"))
@Inject(method = "drawLods", at = @At("HEAD"))
private void setDeferred(IClientLevelWrapper clientLevelWrapper, Mat4f baseModelViewMatrix, Mat4f baseProjectionMatrix, float partialTicks, IProfilerWrapper profiler, CallbackInfo ci) {
this.deferWaterRendering = IrisApi.getInstance().isShaderPackInUse();
this.deferTransparentRendering = IrisApi.getInstance().isShaderPackInUse();
}

@Redirect(method = "drawLODs", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/render/RenderBufferHandler;buildRenderListAndUpdateSections(Lcom/seibel/distanthorizons/coreapi/util/math/Vec3f;)V"))
@Redirect(method = "renderLodPass", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/render/RenderBufferHandler;buildRenderListAndUpdateSections(Lcom/seibel/distanthorizons/coreapi/util/math/Vec3f;)V"))
private void dontBuildTwice(RenderBufferHandler instance, Vec3f e) {
if (frame != SystemTimeUniforms.COUNTER.getAsInt()) {
frame = SystemTimeUniforms.COUNTER.getAsInt();
Expand All @@ -87,16 +86,16 @@ private void createDepthTex(int width, int height, CallbackInfo ci) {
}

@Inject(method = {
"drawLODs",
"drawTranslucentLODs"
"drawLods",
"drawDeferredLods"
}, at = @At("HEAD"), cancellable = true)
private void cancelIfShadowDoesNotExist(IClientLevelWrapper clientLevelWrapper, Mat4f baseModelViewMatrix, Mat4f baseProjectionMatrix, float partialTicks, IProfilerWrapper profiler, CallbackInfo ci) {
if (ShadowRenderingState.areShadowsCurrentlyBeingRendered() && !DHCompatInternal.INSTANCE.shouldOverrideShadow) {
ci.cancel();
}
}

@Inject(method = "renderWaterOnly", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/render/RenderBufferHandler;renderTransparent(Lcom/seibel/distanthorizons/core/render/renderer/LodRenderer;)V"))
@Inject(method = "renderTransparentBuffers", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/render/RenderBufferHandler;renderTransparent(Lcom/seibel/distanthorizons/core/render/renderer/LodRenderer;)V"))
private void onTransparent(IProfilerWrapper profiler, float partialTicks, CallbackInfo ci) {
if (DHCompatInternal.INSTANCE.shouldOverrideShadow && ShadowRenderingState.areShadowsCurrentlyBeingRendered()) {
DHCompatInternal.INSTANCE.getShadowShader().bind();
Expand All @@ -121,15 +120,15 @@ private void onTransparent(IProfilerWrapper profiler, float partialTicks, Callba
atTranslucent = true;
}

@Redirect(method = "drawLODs", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/render/glObject/GLProxy;runRenderThreadTasks()V"))
@Redirect(method = "renderLodPass", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/render/glObject/GLProxy;runRenderThreadTasks()V"))
private void runOnlyOnMain(GLProxy instance) {
if (!ShadowRenderingState.areShadowsCurrentlyBeingRendered()) {
instance.runRenderThreadTasks();
}
}

@Redirect(method = {
"setupGLState",
"setupGLStateAndRenderObjects",
}, at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL32;glClear(I)V"))
private void properClear(int i) {
if (ShadowRenderingState.areShadowsCurrentlyBeingRendered()) return;
Expand All @@ -141,7 +140,7 @@ private void properClear(int i) {
}
}

@Redirect(method = "setupGLState", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/render/renderer/LodRenderProgram;bind()V"))
@Redirect(method = "setupGLStateAndRenderObjects", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/render/renderer/LodRenderProgram;bind()V"))
private void bindSolid(LodRenderProgram instance) {
if (DHCompatInternal.INSTANCE.shouldOverride) {
instance.bind();
Expand All @@ -157,8 +156,7 @@ private void bindSolid(LodRenderProgram instance) {
}

@Redirect(method = {
"drawLODs",
"drawTranslucentLODs"
"renderLodPass"
}, at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/render/renderer/LodRenderProgram;unbind()V"))
private void unbindSolid(LodRenderProgram instance) {
if (DHCompatInternal.INSTANCE.shouldOverride) {
Expand All @@ -173,7 +171,7 @@ private void unbindSolid(LodRenderProgram instance) {
}
}

@Redirect(method = "setupGLState", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/render/glObject/texture/DhFramebuffer;bind()V"))
@Redirect(method = "setupGLStateAndRenderObjects", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/render/glObject/texture/DhFramebuffer;bind()V"))
private void changeFramebuffer(DhFramebuffer instance) {
if (DHCompatInternal.INSTANCE.shouldOverride) {
if (ShadowRenderingState.areShadowsCurrentlyBeingRendered()) {
Expand All @@ -186,7 +184,7 @@ private void changeFramebuffer(DhFramebuffer instance) {
}
}

@Redirect(method = "setupGLState", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/render/glObject/texture/DhFramebuffer;getId()I"))
@Redirect(method = "setupGLStateAndRenderObjects", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/render/glObject/texture/DhFramebuffer;getId()I"))
private int changeFramebuffer2(DhFramebuffer instance) {
if (DHCompatInternal.INSTANCE.shouldOverride) {
if (ShadowRenderingState.areShadowsCurrentlyBeingRendered()) {
Expand All @@ -199,8 +197,8 @@ private int changeFramebuffer2(DhFramebuffer instance) {
}
}

@Inject(method = "drawLODs", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/wrapperInterfaces/misc/ILightMapWrapper;bind()V", remap = true))
private void fillUniformDataSolid(IClientLevelWrapper clientLevelWrapper, Mat4f baseModelViewMatrix, Mat4f baseProjectionMatrix, float partialTicks, IProfilerWrapper profiler, CallbackInfo ci) {
@Inject(method = "renderLodPass", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/render/RenderBufferHandler;renderOpaque(Lcom/seibel/distanthorizons/core/render/renderer/LodRenderer;)V", remap = true))
private void fillUniformDataSolid(IClientLevelWrapper clientLevelWrapper, Mat4f baseModelViewMatrix, Mat4f baseProjectionMatrix, float partialTicks, IProfilerWrapper profiler, boolean runningDeferredPass, CallbackInfo ci) {
if (DHCompatInternal.INSTANCE.shouldOverride) {
if (ShadowRenderingState.areShadowsCurrentlyBeingRendered()) {
DHCompatInternal.INSTANCE.getShadowShader().fillUniformData(ShadowRenderer.PROJECTION, ShadowRenderer.MODELVIEW, MC.getWrappedClientLevel().getMinHeight(), partialTicks);
Expand Down
26 changes: 0 additions & 26 deletions src/main/java/net/coderbot/iris/compat/dh/mixin/MixinLodUtil.java

This file was deleted.

16 changes: 16 additions & 0 deletions src/main/java/net/coderbot/iris/gl/shader/StandardMacros.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ public static ImmutableList<StringPair> createStandardEnvironmentDefines() {
define(standardDefines, "DISTANT_HORIZONS");
}

define(standardDefines, "DH_BLOCK_UNKNOWN", String.valueOf(0));
define(standardDefines, "DH_BLOCK_LEAVES", String.valueOf(1));
define(standardDefines, "DH_BLOCK_STONE", String.valueOf(2));
define(standardDefines, "DH_BLOCK_WOOD", String.valueOf(3));
define(standardDefines, "DH_BLOCK_METAL", String.valueOf(4));
define(standardDefines, "DH_BLOCK_DIRT", String.valueOf(5));
define(standardDefines, "DH_BLOCK_LAVA", String.valueOf(6));
define(standardDefines, "DH_BLOCK_DEEPSLATE", String.valueOf(7));
define(standardDefines, "DH_BLOCK_SNOW", String.valueOf(8));
define(standardDefines, "DH_BLOCK_SAND", String.valueOf(9));
define(standardDefines, "DH_BLOCK_TERRACOTTA", String.valueOf(10));
define(standardDefines, "DH_BLOCK_NETHER_STONE", String.valueOf(11));
define(standardDefines, "DH_BLOCK_WATER", String.valueOf(12));
define(standardDefines, "DH_BLOCK_AIR", String.valueOf(14));
define(standardDefines, "DH_BLOCK_ILLUMINATED", String.valueOf(15));

for (String glExtension : getGlExtensions()) {
define(standardDefines, glExtension);
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/mixins.iris.compat.dh.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"compatibilityLevel": "JAVA_8",
"client": [
"MixinDHApplyShader",
"MixinLodRenderer",
"MixinLodUtil"
"MixinLodRenderer"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit b8b531c

Please sign in to comment.