diff --git a/common/src/main/java/net/irisshaders/iris/pathways/LightningHandler.java b/common/src/main/java/net/irisshaders/iris/pathways/LightningHandler.java index d3d1b4987f..3787892511 100644 --- a/common/src/main/java/net/irisshaders/iris/pathways/LightningHandler.java +++ b/common/src/main/java/net/irisshaders/iris/pathways/LightningHandler.java @@ -46,6 +46,14 @@ public class LightningHandler extends RenderType { .createCompositeState(true) ); + public static final Function SPS = Util.memoize(r -> new InnerWrappedRenderType("iris_sps", create("sps", DefaultVertexFormat.POSITION_TEX_COLOR, VertexFormat.Mode.QUADS, 1_536, true, false, + RenderType.CompositeState.builder() + .setShaderState(new ShaderStateShard(ShaderAccess::getSPSShader)) + .setTextureState(new RenderStateShard.TextureStateShard(r, false, false)) + .setTransparencyState(RenderStateShard.LIGHTNING_TRANSPARENCY) + .createCompositeState(true) + ), new LightningRenderStateShard())); + public LightningHandler(String pRenderType0, VertexFormat pVertexFormat1, VertexFormat.Mode pVertexFormat$Mode2, int pInt3, boolean pBoolean4, boolean pBoolean5, Runnable pRunnable6, Runnable pRunnable7) { super(pRenderType0, pVertexFormat1, pVertexFormat$Mode2, pInt3, pBoolean4, pBoolean5, pRunnable6, pRunnable7); } diff --git a/common/src/main/java/net/irisshaders/iris/pipeline/programs/ShaderAccess.java b/common/src/main/java/net/irisshaders/iris/pipeline/programs/ShaderAccess.java index 571dc8f3fe..c2f1ca0f45 100644 --- a/common/src/main/java/net/irisshaders/iris/pipeline/programs/ShaderAccess.java +++ b/common/src/main/java/net/irisshaders/iris/pipeline/programs/ShaderAccess.java @@ -63,4 +63,14 @@ public static ShaderInstance getMekasuitShader() { return GameRenderer.getRendertypeEntityCutoutShader(); } + + public static ShaderInstance getSPSShader() { + WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable(); + + if (pipeline instanceof ShaderRenderingPipeline) { + return ((ShaderRenderingPipeline) pipeline).getShaderMap().getShader(ShadowRenderingState.areShadowsCurrentlyBeingRendered() ? ShaderKey.SHADOW_LIGHTNING : ShaderKey.SPS); + } + + return GameRenderer.getRendertypeEntityCutoutShader(); + } } diff --git a/common/src/main/java/net/irisshaders/iris/pipeline/programs/ShaderKey.java b/common/src/main/java/net/irisshaders/iris/pipeline/programs/ShaderKey.java index 5c480c6ec8..be7c285c67 100644 --- a/common/src/main/java/net/irisshaders/iris/pipeline/programs/ShaderKey.java +++ b/common/src/main/java/net/irisshaders/iris/pipeline/programs/ShaderKey.java @@ -20,6 +20,7 @@ public enum ShaderKey { BASIC_COLOR(ProgramId.Basic, AlphaTests.NON_ZERO_ALPHA, DefaultVertexFormat.POSITION_COLOR, FogMode.OFF, LightingModel.LIGHTMAP), TEXTURED(ProgramId.Textured, AlphaTests.NON_ZERO_ALPHA, DefaultVertexFormat.POSITION_TEX, FogMode.OFF, LightingModel.LIGHTMAP), TEXTURED_COLOR(ProgramId.Textured, AlphaTests.ONE_TENTH_ALPHA, DefaultVertexFormat.POSITION_TEX_COLOR, FogMode.OFF, LightingModel.LIGHTMAP), + SPS(ProgramId.Lightning, AlphaTests.ONE_TENTH_ALPHA, DefaultVertexFormat.POSITION_TEX_COLOR, FogMode.PER_FRAGMENT, LightingModel.FULLBRIGHT), SKY_BASIC(ProgramId.SkyBasic, AlphaTests.OFF, DefaultVertexFormat.POSITION, FogMode.PER_VERTEX, LightingModel.LIGHTMAP), SKY_BASIC_COLOR(ProgramId.SkyBasic, AlphaTests.NON_ZERO_ALPHA, DefaultVertexFormat.POSITION_COLOR, FogMode.OFF, LightingModel.LIGHTMAP), SKY_TEXTURED(ProgramId.SkyTextured, AlphaTests.OFF, DefaultVertexFormat.POSITION_TEX, FogMode.OFF, LightingModel.LIGHTMAP), diff --git a/neoforge/src/main/java/net/irisshaders/iris/mixin/forge/MixinRenderSPS.java b/neoforge/src/main/java/net/irisshaders/iris/mixin/forge/MixinRenderSPS.java new file mode 100644 index 0000000000..583a010652 --- /dev/null +++ b/neoforge/src/main/java/net/irisshaders/iris/mixin/forge/MixinRenderSPS.java @@ -0,0 +1,29 @@ +package net.irisshaders.iris.mixin.forge; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import net.irisshaders.iris.Iris; +import net.irisshaders.iris.pathways.LightningHandler; +import net.irisshaders.iris.vertices.ImmediateState; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.resources.ResourceLocation; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.function.Function; + +@Pseudo +@Mixin(targets = "mekanism.client.render.lib.effect.BillboardingEffectRenderer", remap = false) +public class MixinRenderSPS { + @WrapOperation(method = "render(Lnet/minecraft/resources/ResourceLocation;Ljava/lang/String;Ljava/util/function/Supplier;)V", at = @At( + value = "FIELD", + target = "Lmekanism/client/render/MekanismRenderType;SPS:Ljava/util/function/Function;")) + private static Function doNotSwitchShaders(Operation> original) { + if (Iris.isPackInUseQuick() && ImmediateState.isRenderingLevel) { + return LightningHandler.SPS; + } else { + return original.call(); + } + } +} diff --git a/neoforge/src/main/resources/mixins.iris.forge.json b/neoforge/src/main/resources/mixins.iris.forge.json index 0ffb4fbcb3..536ab558a7 100644 --- a/neoforge/src/main/resources/mixins.iris.forge.json +++ b/neoforge/src/main/resources/mixins.iris.forge.json @@ -9,6 +9,7 @@ "MixinShaderInstance", "MixinRenderFlame", "MixinRenderMekasuit", + "MixinRenderSPS", "MixinShadowRenderer", "MixinVBOIE" ],