diff --git a/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinBlockRenderer.java b/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinBlockRenderer.java index 4909ff8fdb..9b871ddea2 100644 --- a/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinBlockRenderer.java +++ b/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinBlockRenderer.java @@ -33,10 +33,10 @@ public class MixinBlockRenderer { hasOverride = false; } - @WrapOperation(method = "bufferQuad", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer;attemptPassDowngrade(Lnet/caffeinemc/mods/sodium/client/render/frapi/mesh/MutableQuadViewImpl;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/TerrainRenderPass;)Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/TerrainRenderPass;")) - private TerrainRenderPass iris$skipPassDowngrade(BlockRenderer instance, MutableQuadViewImpl mutableQuadView, TextureAtlasSprite quad, TerrainRenderPass sprite, Operation original) { + @WrapOperation(method = "bufferQuad", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer;attemptPassDowngrade(Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/TerrainRenderPass;)Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/TerrainRenderPass;")) + private TerrainRenderPass iris$skipPassDowngrade(BlockRenderer instance, TextureAtlasSprite textureAtlasSprite, TerrainRenderPass sprite, Operation original) { if (hasOverride) return null; - return original.call(instance, mutableQuadView, quad, sprite); + return original.call(instance, textureAtlasSprite, sprite); } } diff --git a/common/src/main/java/net/irisshaders/iris/mixin/MixinGameRenderer.java b/common/src/main/java/net/irisshaders/iris/mixin/MixinGameRenderer.java index bccacc56b6..e43f150ee3 100644 --- a/common/src/main/java/net/irisshaders/iris/mixin/MixinGameRenderer.java +++ b/common/src/main/java/net/irisshaders/iris/mixin/MixinGameRenderer.java @@ -142,7 +142,7 @@ public class MixinGameRenderer { }, at = @At("HEAD"), cancellable = true) private static void iris$overrideTranslucentShader(CallbackInfoReturnable cir) { if (ShadowRenderer.ACTIVE) { - override(ShaderKey.SHADOW_TERRAIN_CUTOUT, cir); + override(ShaderKey.SHADOW_TRANSLUCENT, cir); } else if (isBlockEntities() || isEntities()) { override(ShaderKey.MOVING_BLOCK, cir); } else if (shouldOverrideShaders()) { @@ -162,6 +162,10 @@ public class MixinGameRenderer { }, at = @At("HEAD"), cancellable = true) private static void iris$overrideEntityCutoutShader(CallbackInfoReturnable cir) { if (ShadowRenderer.ACTIVE) { + if (isBlockEntities()) { + override(ShaderKey.SHADOW_BLOCK, cir); + return; + } override(ShaderKey.SHADOW_ENTITIES_CUTOUT, cir); } else if (HandRenderer.INSTANCE.isActive()) { override(HandRenderer.INSTANCE.isRenderingSolid() ? ShaderKey.HAND_CUTOUT_DIFFUSE : ShaderKey.HAND_WATER_DIFFUSE, cir); @@ -183,6 +187,10 @@ public class MixinGameRenderer { }, at = @At("HEAD"), cancellable = true) private static void iris$overrideEntityTranslucentShader(CallbackInfoReturnable cir) { if (ShadowRenderer.ACTIVE) { + if (isBlockEntities()) { + override(ShaderKey.SHADOW_BLOCK, cir); + return; + } override(ShaderKey.SHADOW_ENTITIES_CUTOUT, cir); } else if (HandRenderer.INSTANCE.isActive()) { override(HandRenderer.INSTANCE.isRenderingSolid() ? ShaderKey.HAND_CUTOUT_DIFFUSE : ShaderKey.HAND_WATER_DIFFUSE, cir); @@ -229,6 +237,10 @@ public class MixinGameRenderer { }, at = @At("HEAD"), cancellable = true) private static void iris$overrideEntitySolidDiffuseShader(CallbackInfoReturnable cir) { if (ShadowRenderer.ACTIVE) { + if (isBlockEntities()) { + override(ShaderKey.SHADOW_BLOCK, cir); + return; + } override(ShaderKey.SHADOW_ENTITIES_CUTOUT, cir); } else if (HandRenderer.INSTANCE.isActive()) { override(HandRenderer.INSTANCE.isRenderingSolid() ? ShaderKey.HAND_CUTOUT_DIFFUSE : ShaderKey.HAND_WATER_DIFFUSE, cir); @@ -288,7 +300,10 @@ public class MixinGameRenderer { }, at = @At("HEAD"), cancellable = true) private static void iris$overrideEntityTranslucentEmissiveShader(CallbackInfoReturnable cir) { if (ShadowRenderer.ACTIVE) { - // TODO: Wrong program + if (isBlockEntities()) { + override(ShaderKey.SHADOW_BLOCK, cir); + return; + } override(ShaderKey.SHADOW_ENTITIES_CUTOUT, cir); } else if (isBlockEntities()) { override(ShaderKey.BLOCK_ENTITY, cir); 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 9f5d649491..06390f5420 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 @@ -12,6 +12,7 @@ public enum ShaderKey { // if you auto-format this and destroy all the manual indentation, I'll steal your kneecaps + // update: sorry - ims BASIC(ProgramId.Basic, AlphaTests.OFF, DefaultVertexFormat.POSITION, FogMode.PER_VERTEX, LightingModel.LIGHTMAP), BASIC_COLOR(ProgramId.Basic, AlphaTests.NON_ZERO_ALPHA, DefaultVertexFormat.POSITION_COLOR, FogMode.OFF, LightingModel.LIGHTMAP), @@ -66,9 +67,11 @@ public enum ShaderKey { MEKANISM_FLAME(ProgramId.SpiderEyes, AlphaTests.ONE_TENTH_ALPHA, DefaultVertexFormat.POSITION_TEX_COLOR, FogMode.PER_VERTEX, LightingModel.LIGHTMAP), // Note: These must be at the very end (NewWorldRenderingPipeline implementation details) - SHADOW_TERRAIN_CUTOUT(ProgramId.Shadow, AlphaTests.ONE_TENTH_ALPHA, IrisVertexFormats.TERRAIN, FogMode.OFF, LightingModel.LIGHTMAP), - SHADOW_ENTITIES_CUTOUT(ProgramId.Shadow, AlphaTests.ONE_TENTH_ALPHA, IrisVertexFormats.ENTITY, FogMode.OFF, LightingModel.LIGHTMAP), - SHADOW_BEACON_BEAM(ProgramId.Shadow, AlphaTests.OFF, DefaultVertexFormat.BLOCK, FogMode.OFF, LightingModel.FULLBRIGHT), + SHADOW_TERRAIN_CUTOUT(ProgramId.ShadowCutout, AlphaTests.ONE_TENTH_ALPHA, IrisVertexFormats.TERRAIN, FogMode.OFF, LightingModel.LIGHTMAP), + SHADOW_TRANSLUCENT(ProgramId.ShadowWater, AlphaTests.ONE_TENTH_ALPHA, IrisVertexFormats.TERRAIN, FogMode.OFF, LightingModel.LIGHTMAP), + SHADOW_ENTITIES_CUTOUT(ProgramId.ShadowEntities, AlphaTests.ONE_TENTH_ALPHA, IrisVertexFormats.ENTITY, FogMode.OFF, LightingModel.LIGHTMAP), + SHADOW_BLOCK(ProgramId.ShadowBlock, AlphaTests.ONE_TENTH_ALPHA, IrisVertexFormats.ENTITY, FogMode.OFF, LightingModel.LIGHTMAP), + SHADOW_BEACON_BEAM(ProgramId.ShadowEntities, AlphaTests.OFF, DefaultVertexFormat.BLOCK, FogMode.OFF, LightingModel.FULLBRIGHT), SHADOW_BASIC(ProgramId.Shadow, AlphaTests.OFF, DefaultVertexFormat.POSITION, FogMode.OFF, LightingModel.LIGHTMAP), SHADOW_BASIC_COLOR(ProgramId.Shadow, AlphaTests.NON_ZERO_ALPHA, DefaultVertexFormat.POSITION_COLOR, FogMode.OFF, LightingModel.LIGHTMAP), SHADOW_TEX(ProgramId.Shadow, AlphaTests.NON_ZERO_ALPHA, DefaultVertexFormat.POSITION_TEX, FogMode.OFF, LightingModel.LIGHTMAP), @@ -76,13 +79,13 @@ public enum ShaderKey { SHADOW_CLOUDS(ProgramId.Shadow, AlphaTests.ONE_TENTH_ALPHA, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL, FogMode.OFF, LightingModel.LIGHTMAP), SHADOW_LINES(ProgramId.Shadow, AlphaTests.OFF, DefaultVertexFormat.POSITION_COLOR_NORMAL, FogMode.OFF, LightingModel.LIGHTMAP), SHADOW_LEASH(ProgramId.Shadow, AlphaTests.OFF, DefaultVertexFormat.POSITION_COLOR_LIGHTMAP, FogMode.OFF, LightingModel.LIGHTMAP), - SHADOW_LIGHTNING(ProgramId.Shadow, AlphaTests.OFF, DefaultVertexFormat.POSITION_COLOR, FogMode.OFF, LightingModel.FULLBRIGHT), + SHADOW_LIGHTNING(ProgramId.ShadowLightning, AlphaTests.OFF, DefaultVertexFormat.POSITION_COLOR, FogMode.OFF, LightingModel.FULLBRIGHT), SHADOW_PARTICLES(ProgramId.Shadow, AlphaTests.ONE_TENTH_ALPHA, DefaultVertexFormat.PARTICLE, FogMode.OFF, LightingModel.LIGHTMAP), - SHADOW_TEXT(ProgramId.Shadow, AlphaTests.NON_ZERO_ALPHA, IrisVertexFormats.GLYPH, FogMode.OFF, LightingModel.LIGHTMAP), - SHADOW_TEXT_BG(ProgramId.Shadow, AlphaTests.NON_ZERO_ALPHA, DefaultVertexFormat.POSITION_COLOR_LIGHTMAP, FogMode.OFF, LightingModel.LIGHTMAP), - SHADOW_TEXT_INTENSITY(ProgramId.Shadow, AlphaTests.NON_ZERO_ALPHA, IrisVertexFormats.GLYPH, FogMode.OFF, LightingModel.LIGHTMAP), - IE_COMPAT_SHADOW(ProgramId.Shadow, AlphaTests.ONE_TENTH_ALPHA, ShaderAccess.IE_FORMAT, FogMode.OFF, LightingModel.LIGHTMAP), - MEKANISM_FLAME_SHADOW(ProgramId.Shadow, AlphaTests.ONE_TENTH_ALPHA, DefaultVertexFormat.POSITION_TEX_COLOR, FogMode.OFF, LightingModel.LIGHTMAP); + SHADOW_TEXT(ProgramId.ShadowEntities, AlphaTests.NON_ZERO_ALPHA, IrisVertexFormats.GLYPH, FogMode.OFF, LightingModel.LIGHTMAP), + SHADOW_TEXT_BG(ProgramId.ShadowEntities, AlphaTests.NON_ZERO_ALPHA, DefaultVertexFormat.POSITION_COLOR_LIGHTMAP, FogMode.OFF, LightingModel.LIGHTMAP), + SHADOW_TEXT_INTENSITY(ProgramId.ShadowEntities, AlphaTests.NON_ZERO_ALPHA, IrisVertexFormats.GLYPH, FogMode.OFF, LightingModel.LIGHTMAP), + IE_COMPAT_SHADOW(ProgramId.ShadowEntities, AlphaTests.ONE_TENTH_ALPHA, ShaderAccess.IE_FORMAT, FogMode.OFF, LightingModel.LIGHTMAP), + MEKANISM_FLAME_SHADOW(ProgramId.ShadowEntities, AlphaTests.ONE_TENTH_ALPHA, DefaultVertexFormat.POSITION_TEX_COLOR, FogMode.OFF, LightingModel.LIGHTMAP); private final ProgramId program; private final AlphaTest alphaTest; @@ -123,7 +126,7 @@ public String getName() { } public boolean isShadow() { - return this.getProgram() == ProgramId.Shadow; + return this.getProgram() == ProgramId.Shadow || this.getProgram() == ProgramId.ShadowCutout || this.getProgram() == ProgramId.ShadowWater || this.getProgram() == ProgramId.ShadowSolid || this.getProgram() == ProgramId.ShadowEntities || this.getProgram() == ProgramId.ShadowBlock; } public boolean hasDiffuseLighting() { diff --git a/common/src/main/java/net/irisshaders/iris/pipeline/programs/SodiumPrograms.java b/common/src/main/java/net/irisshaders/iris/pipeline/programs/SodiumPrograms.java index e7eb3ad605..135c9f7550 100644 --- a/common/src/main/java/net/irisshaders/iris/pipeline/programs/SodiumPrograms.java +++ b/common/src/main/java/net/irisshaders/iris/pipeline/programs/SodiumPrograms.java @@ -123,7 +123,7 @@ private GlFramebuffer createFramebuffer(Pass pass, ProgramSource source, Supplier shadowRenderTargets, RenderTargets renderTargets, Supplier> flipState) { - if (pass == Pass.SHADOW || pass == Pass.SHADOW_CUTOUT) { + if (pass == Pass.SHADOW || pass == Pass.SHADOW_CUTOUT || pass == Pass.SHADOW_TRANS) { return shadowRenderTargets.get().createShadowFramebuffer(ImmutableSet.of(), source == null ? new int[]{0, 1} : (source.getDirectives().hasUnknownDrawBuffers() ? new int[]{0, 1} : source.getDirectives().getDrawBuffers())); } else { @@ -182,7 +182,7 @@ private Pass mapTerrainRenderPass(TerrainRenderPass pass) { } else if (pass == DefaultTerrainRenderPasses.CUTOUT) { return ShadowRenderingState.areShadowsCurrentlyBeingRendered() ? Pass.SHADOW_CUTOUT : Pass.TERRAIN_CUTOUT; } else if (pass == DefaultTerrainRenderPasses.TRANSLUCENT) { - return ShadowRenderingState.areShadowsCurrentlyBeingRendered() ? Pass.SHADOW : Pass.TRANSLUCENT; + return ShadowRenderingState.areShadowsCurrentlyBeingRendered() ? Pass.SHADOW_TRANS : Pass.TRANSLUCENT; } else { throw new IllegalArgumentException("Unknown pass: " + pass); } @@ -191,6 +191,7 @@ private Pass mapTerrainRenderPass(TerrainRenderPass pass) { public enum Pass { SHADOW(ProgramId.ShadowSolid), SHADOW_CUTOUT(ProgramId.ShadowCutout), + SHADOW_TRANS(ProgramId.ShadowWater), TERRAIN(ProgramId.TerrainSolid), TERRAIN_CUTOUT(ProgramId.TerrainCutout), TRANSLUCENT(ProgramId.Water); diff --git a/common/src/main/java/net/irisshaders/iris/shaderpack/loading/ProgramId.java b/common/src/main/java/net/irisshaders/iris/shaderpack/loading/ProgramId.java index 584a02c96c..a1815f825a 100644 --- a/common/src/main/java/net/irisshaders/iris/shaderpack/loading/ProgramId.java +++ b/common/src/main/java/net/irisshaders/iris/shaderpack/loading/ProgramId.java @@ -11,6 +11,10 @@ public enum ProgramId { Shadow(ProgramGroup.Shadow, "", BlendModeOverride.OFF), ShadowSolid(ProgramGroup.Shadow, "solid", Shadow, BlendModeOverride.OFF), ShadowCutout(ProgramGroup.Shadow, "cutout", Shadow, BlendModeOverride.OFF), + ShadowWater(ProgramGroup.Shadow, "water", Shadow, BlendModeOverride.OFF), + ShadowEntities(ProgramGroup.Shadow, "entities", Shadow, BlendModeOverride.OFF), + ShadowLightning(ProgramGroup.Shadow, "lightning", ShadowEntities, BlendModeOverride.OFF), + ShadowBlock(ProgramGroup.Shadow, "block", Shadow, BlendModeOverride.OFF), Basic(ProgramGroup.Gbuffers, "basic"), Line(ProgramGroup.Gbuffers, "line", Basic),