Skip to content

Commit

Permalink
fix sodium and iris integration for sky and emancipation
Browse files Browse the repository at this point in the history
  • Loading branch information
gliscowo committed Dec 9, 2024
1 parent b83b08e commit 1884dcb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<SodiumPrograms.Pass> cir) {
if (pass != SKY_PASS) return;
cir.setReturnValue(ShadowRenderingState.areShadowsCurrentlyBeingRendered() ? SodiumPrograms.Pass.SHADOW : SodiumPrograms.Pass.TERRAIN);
}

}
4 changes: 3 additions & 1 deletion src/main/resources/affinity.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1884dcb

Please sign in to comment.