From 1884dcb79fe9705c7e0bb64a931b135aaa9bcb9c Mon Sep 17 00:00:00 2001 From: glisco Date: Mon, 9 Dec 2024 22:28:28 +0100 Subject: [PATCH] fix sodium and iris integration for sky and emancipation --- .../EmancipationVertexConsumerProvider.java | 2 +- .../client/iris/SodiumProgramsMixin.java | 33 +++++++++++++++++++ src/main/resources/affinity.mixins.json | 4 ++- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/main/java/io/wispforest/affinity/mixin/client/iris/SodiumProgramsMixin.java diff --git a/src/main/java/io/wispforest/affinity/client/render/EmancipationVertexConsumerProvider.java b/src/main/java/io/wispforest/affinity/client/render/EmancipationVertexConsumerProvider.java index 9d39e405..e30a9c21 100644 --- a/src/main/java/io/wispforest/affinity/client/render/EmancipationVertexConsumerProvider.java +++ b/src/main/java/io/wispforest/affinity/client/render/EmancipationVertexConsumerProvider.java @@ -120,7 +120,7 @@ public VertexConsumer overlay(int u, int v) { @Override public VertexConsumer light(int u, int v) { - this.delegate.light(u | v << 16); + this.light = u | v << 16; return this; } diff --git a/src/main/java/io/wispforest/affinity/mixin/client/iris/SodiumProgramsMixin.java b/src/main/java/io/wispforest/affinity/mixin/client/iris/SodiumProgramsMixin.java new file mode 100644 index 00000000..05e335b8 --- /dev/null +++ b/src/main/java/io/wispforest/affinity/mixin/client/iris/SodiumProgramsMixin.java @@ -0,0 +1,33 @@ +package io.wispforest.affinity.mixin.client.iris; + +import io.wispforest.affinity.client.render.SkyCaptureBuffer; +import io.wispforest.affinity.misc.CompatMixin; +import io.wispforest.affinity.mixin.client.sodium.TerrainRenderPassAccessor; +import net.caffeinemc.mods.sodium.client.render.chunk.terrain.DefaultTerrainRenderPasses; +import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; +import net.irisshaders.iris.pipeline.programs.SodiumPrograms; +import net.irisshaders.iris.shadows.ShadowRenderingState; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Arrays; + +@Pseudo +@CompatMixin("iris") +@Mixin(SodiumPrograms.class) +public class SodiumProgramsMixin { + + @Unique + private static final TerrainRenderPass SKY_PASS = Arrays.stream(DefaultTerrainRenderPasses.ALL).filter(pass -> ((TerrainRenderPassAccessor) pass).affinity$getLayer() == SkyCaptureBuffer.SKY_STENCIL_LAYER).findFirst().get(); + + @Inject(method = "mapTerrainRenderPass", at = @At("HEAD"), cancellable = true) + private void fixSky(TerrainRenderPass pass, CallbackInfoReturnable cir) { + if (pass != SKY_PASS) return; + cir.setReturnValue(ShadowRenderingState.areShadowsCurrentlyBeingRendered() ? SodiumPrograms.Pass.SHADOW : SodiumPrograms.Pass.TERRAIN); + } + +} diff --git a/src/main/resources/affinity.mixins.json b/src/main/resources/affinity.mixins.json index 219223dd..044bd587 100644 --- a/src/main/resources/affinity.mixins.json +++ b/src/main/resources/affinity.mixins.json @@ -132,11 +132,13 @@ "client.WorldRendererAccessor", "client.WorldRendererMixin", "client.iris.HorizonRendererMixin", + "client.iris.SodiumProgramsMixin", "client.iris.WorldRenderingPhaseMixin", "client.sodium.DefaultMaterialsMixin", "client.sodium.DefaultTerrainRenderPassesMixin", "client.sodium.SodiumWorldRendererMixin", - "client.sodium.TerrainRenderPassAccessor" + "client.sodium.TerrainRenderPassAccessor", + "client.sodium.AlphaMaskConsumerMixin" ], "injectors": { "defaultRequire": 1