From a76a240527e93780bbcba57c09bef377419d47a7 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Fri, 17 Nov 2023 06:29:27 -1000 Subject: [PATCH 01/16] Preliminary support for Distant Horizons 2.0 --- buildscript/src/main/java/Buildscript.java | 3 +- .../net/coderbot/iris/compat/dh/DHCompat.java | 15 ++++++ .../dh/mixin/IrisDHCompatMixinPlugin.java | 50 +++++++++++++++++++ .../compat/dh/mixin/MixinDHApplyShader.java | 24 +++++++++ .../DeferredWorldRenderingPipeline.java | 8 ++- .../FixedFunctionWorldRenderingPipeline.java | 6 +++ .../iris/pipeline/WorldRenderingPipeline.java | 2 + .../newshader/NewWorldRenderingPipeline.java | 12 +++-- src/main/resources/fabric.mod.json | 1 + src/main/resources/mixins.iris.compat.dh.json | 13 +++++ 10 files changed, 128 insertions(+), 6 deletions(-) create mode 100644 src/main/java/net/coderbot/iris/compat/dh/DHCompat.java create mode 100644 src/main/java/net/coderbot/iris/compat/dh/mixin/IrisDHCompatMixinPlugin.java create mode 100644 src/main/java/net/coderbot/iris/compat/dh/mixin/MixinDHApplyShader.java create mode 100644 src/main/resources/mixins.iris.compat.dh.json diff --git a/buildscript/src/main/java/Buildscript.java b/buildscript/src/main/java/Buildscript.java index ddd6d9e1a2..0633380263 100644 --- a/buildscript/src/main/java/Buildscript.java +++ b/buildscript/src/main/java/Buildscript.java @@ -71,7 +71,7 @@ public MappingTree createMappings() { @Override public FabricLoader getLoader() { - return new FabricLoader(FabricMaven.URL, FabricMaven.loader("0.14.10")); + return new FabricLoader(FabricMaven.URL, FabricMaven.loader("0.14.24")); } @Override @@ -101,6 +101,7 @@ public void getModDependencies(ModDependencyCollector d) { jij(d.addMaven(Maven.MAVEN_CENTRAL, new MavenId("io.github.douira:glsl-transformer:2.0.0-pre13"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME)); jij(d.addMaven(Maven.MAVEN_CENTRAL, new MavenId("org.antlr:antlr4-runtime:4.11.1"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME)); + d.addMaven("https://api.modrinth.com/maven", new MavenId("maven.modrinth", "distanthorizons", "2.0.0-a-1.18.2"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME); if (SODIUM) { d.addMaven(FabricMaven.URL, new MavenId(FabricMaven.GROUP_ID + ".fabric-api", "fabric-api-base", "0.4.3+d7c144a8d2"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME); diff --git a/src/main/java/net/coderbot/iris/compat/dh/DHCompat.java b/src/main/java/net/coderbot/iris/compat/dh/DHCompat.java new file mode 100644 index 0000000000..e30dfec871 --- /dev/null +++ b/src/main/java/net/coderbot/iris/compat/dh/DHCompat.java @@ -0,0 +1,15 @@ +package net.coderbot.iris.compat.dh; + +import net.coderbot.iris.gl.framebuffer.GlFramebuffer; + +public class DHCompat { + private GlFramebuffer fb; + + public int getFramebuffer() { + return fb.getId(); + } + + public void setFramebuffer(GlFramebuffer fb) { + this.fb = fb; + } +} diff --git a/src/main/java/net/coderbot/iris/compat/dh/mixin/IrisDHCompatMixinPlugin.java b/src/main/java/net/coderbot/iris/compat/dh/mixin/IrisDHCompatMixinPlugin.java new file mode 100644 index 0000000000..6d7cc93e14 --- /dev/null +++ b/src/main/java/net/coderbot/iris/compat/dh/mixin/IrisDHCompatMixinPlugin.java @@ -0,0 +1,50 @@ +package net.coderbot.iris.compat.dh.mixin; + +import net.fabricmc.loader.api.FabricLoader; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +/** + * Non-critical mixin config plugin, just disables mixins if Distant Horizons isn't present, + * since otherwise the log gets spammed with warnings. + */ +public class IrisDHCompatMixinPlugin implements IMixinConfigPlugin { + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + return FabricLoader.getInstance().isModLoaded("distanthorizons"); + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} diff --git a/src/main/java/net/coderbot/iris/compat/dh/mixin/MixinDHApplyShader.java b/src/main/java/net/coderbot/iris/compat/dh/mixin/MixinDHApplyShader.java new file mode 100644 index 0000000000..8a386d5828 --- /dev/null +++ b/src/main/java/net/coderbot/iris/compat/dh/mixin/MixinDHApplyShader.java @@ -0,0 +1,24 @@ +package net.coderbot.iris.compat.dh.mixin; + +import com.seibel.distanthorizons.core.render.renderer.shaders.DhApplyShader; +import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; +import net.coderbot.iris.Iris; +import net.coderbot.iris.compat.dh.DHCompat; +import net.coderbot.iris.pipeline.WorldRenderingPipeline; +import net.coderbot.iris.pipeline.newshader.NewWorldRenderingPipeline; +import net.irisshaders.iris.api.v0.IrisApi; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(DhApplyShader.class) +public class MixinDHApplyShader { + @Redirect(method = "onRender", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftRenderWrapper;getTargetFrameBuffer()I")) + private int changeFB(IMinecraftRenderWrapper instance) { + if (Iris.getPipelineManager().getPipelineNullable() instanceof NewWorldRenderingPipeline pipeline) { + return pipeline.getDHCompat().getFramebuffer(); + } else { + return instance.getTargetFrameBuffer(); + } + } +} diff --git a/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java index d363beea52..e177d6b902 100644 --- a/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java @@ -11,6 +11,7 @@ import net.coderbot.iris.Iris; import net.coderbot.iris.block_rendering.BlockMaterialMapping; import net.coderbot.iris.block_rendering.BlockRenderingSettings; +import net.coderbot.iris.compat.dh.DHCompat; import net.coderbot.iris.features.FeatureFlags; import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability; import net.coderbot.iris.gbuffer_overrides.matching.ProgramTable; @@ -82,8 +83,6 @@ import net.minecraft.client.renderer.texture.AbstractTexture; import net.minecraft.network.chat.TranslatableComponent; import org.jetbrains.annotations.Nullable; -import org.lwjgl.opengl.GL; -import org.lwjgl.opengl.GL11C; import org.lwjgl.opengl.GL15C; import org.lwjgl.opengl.GL20C; import org.lwjgl.opengl.GL21C; @@ -573,6 +572,11 @@ public float getSunPathRotation() { return sunPathRotation; } + @Override + public DHCompat getDHCompat() { + return null; + } + private RenderCondition getCondition(WorldRenderingPhase phase) { if (isRenderingShadow) { return RenderCondition.SHADOW; diff --git a/src/main/java/net/coderbot/iris/pipeline/FixedFunctionWorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/FixedFunctionWorldRenderingPipeline.java index aaf57760aa..95a038543f 100644 --- a/src/main/java/net/coderbot/iris/pipeline/FixedFunctionWorldRenderingPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/FixedFunctionWorldRenderingPipeline.java @@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; import net.coderbot.iris.block_rendering.BlockRenderingSettings; +import net.coderbot.iris.compat.dh.DHCompat; import net.coderbot.iris.features.FeatureFlags; import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability; import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition; @@ -221,4 +222,9 @@ public float getSunPathRotation() { // No sun tilt return 0; } + + @Override + public DHCompat getDHCompat() { + return null; + } } diff --git a/src/main/java/net/coderbot/iris/pipeline/WorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/WorldRenderingPipeline.java index 73ea1dc6b7..5e4ba7b0fc 100644 --- a/src/main/java/net/coderbot/iris/pipeline/WorldRenderingPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/WorldRenderingPipeline.java @@ -1,6 +1,7 @@ package net.coderbot.iris.pipeline; import it.unimi.dsi.fastutil.objects.Object2ObjectMap; +import net.coderbot.iris.compat.dh.DHCompat; import net.coderbot.iris.features.FeatureFlags; import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition; import net.coderbot.iris.gbuffer_overrides.state.RenderTargetStateListener; @@ -64,4 +65,5 @@ public interface WorldRenderingPipeline { float getSunPathRotation(); + DHCompat getDHCompat(); } diff --git a/src/main/java/net/coderbot/iris/pipeline/newshader/NewWorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/newshader/NewWorldRenderingPipeline.java index 40cd61647e..664faa2bff 100644 --- a/src/main/java/net/coderbot/iris/pipeline/newshader/NewWorldRenderingPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/newshader/NewWorldRenderingPipeline.java @@ -8,13 +8,12 @@ import com.mojang.blaze3d.vertex.VertexFormat; import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; -import net.coderbot.iris.Iris; import net.coderbot.iris.block_rendering.BlockMaterialMapping; import net.coderbot.iris.block_rendering.BlockRenderingSettings; import net.coderbot.iris.colorspace.ColorSpace; -import net.coderbot.iris.colorspace.ColorSpaceComputeConverter; import net.coderbot.iris.colorspace.ColorSpaceConverter; import net.coderbot.iris.colorspace.ColorSpaceFragmentConverter; +import net.coderbot.iris.compat.dh.DHCompat; import net.coderbot.iris.features.FeatureFlags; import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability; import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition; @@ -186,6 +185,7 @@ public class NewWorldRenderingPipeline implements WorldRenderingPipeline, CoreWo private final ShaderPack pack; private PackShadowDirectives shadowDirectives; private ColorSpace currentColorSpace; + private DHCompat dhCompat; public NewWorldRenderingPipeline(ProgramSet programSet) throws IOException { ShaderPrinter.resetPrintState(); @@ -204,6 +204,7 @@ public NewWorldRenderingPipeline(ProgramSet programSet) throws IOException { this.shouldRenderMoon = programSet.getPackDirectives().shouldRenderMoon(); this.allowConcurrentCompute = programSet.getPackDirectives().getConcurrentCompute(); this.frustumCulling = programSet.getPackDirectives().shouldUseFrustumCulling(); + this.dhCompat = new DHCompat(); this.resolver = new ProgramFallbackResolver(programSet); this.pack = programSet.getPack(); @@ -480,6 +481,7 @@ public NewWorldRenderingPipeline(ProgramSet programSet) throws IOException { this.shadowRenderer = null; } + dhCompat.setFramebuffer(renderTargets.createGbufferFramebuffer(ImmutableSet.of(), new int[] { 0 })); // TODO: Create fallback Sodium shaders if the pack doesn't provide terrain shaders // Currently we use Sodium's shaders but they don't support EXP2 fog underwater. this.sodiumTerrainPipeline = new SodiumTerrainPipeline(this, programSet, createTerrainSamplers, @@ -1173,7 +1175,6 @@ private void destroyShaders() { public void destroy() { destroyed = true; - destroyShaders(); // Unbind all textures @@ -1252,6 +1253,11 @@ public float getSunPathRotation() { return sunPathRotation; } + @Override + public DHCompat getDHCompat() { + return dhCompat; + } + protected AbstractTexture getWhitePixel() { return whitePixel; } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index b2c6d4dcf6..bab1de2c02 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -35,6 +35,7 @@ "mixins.iris.bettermipmaps.json", "mixins.iris.optimized-stitching.json", "mixins.iris.compat.indigo.json", + "mixins.iris.compat.dh.json", "mixins.iris.compat.sodium.json", "mixins.iris.compat.indium.json", "mixins.iris.fixes.maxfpscrash.json" diff --git a/src/main/resources/mixins.iris.compat.dh.json b/src/main/resources/mixins.iris.compat.dh.json new file mode 100644 index 0000000000..b9ab960fd0 --- /dev/null +++ b/src/main/resources/mixins.iris.compat.dh.json @@ -0,0 +1,13 @@ +{ + "required": true, + "minVersion": "0.8", + "plugin": "net.coderbot.iris.compat.dh.mixin.IrisDHCompatMixinPlugin", + "package": "net.coderbot.iris.compat.dh.mixin", + "compatibilityLevel": "JAVA_8", + "client": [ + "MixinDHApplyShader" + ], + "injectors": { + "defaultRequire": 1 + } +} From ed51b1a04d35463c3b33488e56053c0ed821153c Mon Sep 17 00:00:00 2001 From: IMS212 Date: Fri, 17 Nov 2023 07:55:42 -1000 Subject: [PATCH 02/16] a --- buildscript/src/main/java/Buildscript.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildscript/src/main/java/Buildscript.java b/buildscript/src/main/java/Buildscript.java index e935903805..5f59ceee4c 100644 --- a/buildscript/src/main/java/Buildscript.java +++ b/buildscript/src/main/java/Buildscript.java @@ -101,7 +101,7 @@ public void getModDependencies(ModDependencyCollector d) { jij(d.addMaven(Maven.MAVEN_CENTRAL, new MavenId("io.github.douira:glsl-transformer:2.0.0-pre13"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME)); jij(d.addMaven(Maven.MAVEN_CENTRAL, new MavenId("org.antlr:antlr4-runtime:4.11.1"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME)); - d.addMaven("https://api.modrinth.com/maven", new MavenId("maven.modrinth", "distanthorizons", "2.0.0-a-1.18.2"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME); + d.addMaven("https://api.modrinth.com/maven", new MavenId("maven.modrinth", "distanthorizons", "2.0.0-a-1.19.2"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME); if (SODIUM) { d.addMaven(FabricMaven.URL, new MavenId(FabricMaven.GROUP_ID + ".fabric-api", "fabric-api-base", "0.4.3+d7c144a8d2"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME); From 99bdabaf6b57120424f0d326e6ba389fa6644a18 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Fri, 17 Nov 2023 08:00:31 -1000 Subject: [PATCH 03/16] Fix build --- .../net/coderbot/iris/compat/dh/mixin/MixinDHApplyShader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/coderbot/iris/compat/dh/mixin/MixinDHApplyShader.java b/src/main/java/net/coderbot/iris/compat/dh/mixin/MixinDHApplyShader.java index 8a386d5828..9880c13d52 100644 --- a/src/main/java/net/coderbot/iris/compat/dh/mixin/MixinDHApplyShader.java +++ b/src/main/java/net/coderbot/iris/compat/dh/mixin/MixinDHApplyShader.java @@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -@Mixin(DhApplyShader.class) +@Mixin(value = DhApplyShader.class, remap = false) public class MixinDHApplyShader { @Redirect(method = "onRender", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftRenderWrapper;getTargetFrameBuffer()I")) private int changeFB(IMinecraftRenderWrapper instance) { From 106ae58d2b363471ff33c5f7868b78ca2bb34cfd Mon Sep 17 00:00:00 2001 From: IMS212 Date: Sat, 18 Nov 2023 10:36:00 -1000 Subject: [PATCH 04/16] Fix option translations --- .../compat/sodium/impl/options/IrisSodiumOptions.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sodiumCompatibility/java/net/coderbot/iris/compat/sodium/impl/options/IrisSodiumOptions.java b/src/sodiumCompatibility/java/net/coderbot/iris/compat/sodium/impl/options/IrisSodiumOptions.java index 300f8635b4..0946846038 100644 --- a/src/sodiumCompatibility/java/net/coderbot/iris/compat/sodium/impl/options/IrisSodiumOptions.java +++ b/src/sodiumCompatibility/java/net/coderbot/iris/compat/sodium/impl/options/IrisSodiumOptions.java @@ -22,7 +22,7 @@ public static OptionImpl createMaxShadowDistanceSlider(Minecra OptionImpl maxShadowDistanceSlider = OptionImpl.createBuilder(int.class, vanillaOpts) .setName(new TranslatableComponent("options.iris.shadowDistance")) .setTooltip(new TranslatableComponent("options.iris.shadowDistance.sodium_tooltip")) - .setControl(option -> new SliderControl(option, 0, 32, 1, ControlValueFormatter.quantityOrDisabled("Chunks", "Disabled"))) + .setControl(option -> new SliderControl(option, 0, 32, 1, translateVariableOrDisabled("options.chunks", "Disabled"))) .setBinding((options, value) -> { IrisVideoSettings.shadowDistance = value; try { @@ -64,13 +64,19 @@ public static OptionImpl createColorSpaceButton(MinecraftOp return colorSpace; } + static ControlValueFormatter translateVariableOrDisabled(String key, String disabled) { + return (v) -> { + return v == 0 ? disabled : (new TranslatableComponent(key, v)).getString(); + }; + } + public static OptionImpl createLimitedVideoSettingsButton(MinecraftOptionsStorage vanillaOpts) { return OptionImpl.createBuilder(SupportedGraphicsMode.class, vanillaOpts) .setName(new TranslatableComponent("options.graphics")) // TODO: State that Fabulous Graphics is incompatible with Shader Packs in the tooltip .setTooltip(new TranslatableComponent("sodium.options.graphics_quality.tooltip")) .setControl(option -> new CyclingControl<>(option, SupportedGraphicsMode.class, - new Component[] { new TextComponent("Fast"), new TextComponent("Fancy") })) + new Component[] { new TranslatableComponent("options.graphics.fast"), new TranslatableComponent("options.graphics.fancy") })) .setBinding( (opts, value) -> opts.graphicsMode = value.toVanilla(), opts -> SupportedGraphicsMode.fromVanilla(opts.graphicsMode)) From b7482042b50b738cae787663a3a3779758bd6e81 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Sun, 19 Nov 2023 09:14:01 -1000 Subject: [PATCH 05/16] Minor fix for biome uniforms --- .../java/net/coderbot/iris/shaderpack/ShaderProperties.java | 2 +- .../java/net/coderbot/iris/uniforms/custom/CustomUniforms.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java b/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java index 32bb6eddf8..2d7f220599 100644 --- a/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java +++ b/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java @@ -113,7 +113,7 @@ private ShaderProperties() { // TODO: Is there a better solution than having ShaderPack pass a root path to ShaderProperties to be able to read textures? public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, Iterable environmentDefines, Iterable replacements) { for (StringPair pair : replacements) { - contents = contents.replace(pair.getKey(), pair.getValue()); + contents = contents.replaceAll("\\b" + pair.getKey() + "\\b", pair.getValue()); } String preprocessedContents = PropertiesPreprocessor.preprocessSource(contents, shaderPackOptions, environmentDefines); diff --git a/src/main/java/net/coderbot/iris/uniforms/custom/CustomUniforms.java b/src/main/java/net/coderbot/iris/uniforms/custom/CustomUniforms.java index f0feb91279..c898f352a5 100644 --- a/src/main/java/net/coderbot/iris/uniforms/custom/CustomUniforms.java +++ b/src/main/java/net/coderbot/iris/uniforms/custom/CustomUniforms.java @@ -306,7 +306,7 @@ public void addVariable(String type, String name, String expression, boolean isU ExpressionElement ast = Parser.parse(expression, IrisOptions.options); variables.put(name, new Variable(parsedType, name, ast, isUniform)); } catch (Exception e) { - Iris.logger.warn("Failed to parse custom variable/uniform", e); + Iris.logger.warn("Failed to parse custom variable/uniform " + name + " with expression " + expression, e); } } From a4a85e524d0e993eb93ab5b9fb2fc96a24747f45 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Tue, 21 Nov 2023 18:37:20 -1000 Subject: [PATCH 06/16] Fix entityId in core shaders --- .../transform/transformer/VanillaCoreTransformer.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/coderbot/iris/pipeline/transform/transformer/VanillaCoreTransformer.java b/src/main/java/net/coderbot/iris/pipeline/transform/transformer/VanillaCoreTransformer.java index c03af75be8..4b838304bf 100644 --- a/src/main/java/net/coderbot/iris/pipeline/transform/transformer/VanillaCoreTransformer.java +++ b/src/main/java/net/coderbot/iris/pipeline/transform/transformer/VanillaCoreTransformer.java @@ -18,7 +18,10 @@ public static void transform( VanillaParameters parameters) { if (parameters.inputs.hasOverlay()) { - AttributeTransformer.patchOverlayColor(t, tree, root, parameters); + if (!parameters.inputs.isText()) { + AttributeTransformer.patchOverlayColor(t, tree, root, parameters); + } + AttributeTransformer.patchEntityId(t, tree, root, parameters); } CommonTransformer.transform(t, tree, root, parameters, true); From 04c2e0c65f5490c3d4d7258426a74a7ca3e66dd9 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Tue, 21 Nov 2023 21:01:11 -0800 Subject: [PATCH 07/16] Remove old Sodium/NEC code --- src/main/java/net/coderbot/iris/Iris.java | 30 ------- .../coderbot/iris/mixin/MixinTitleScreen.java | 79 +------------------ 2 files changed, 3 insertions(+), 106 deletions(-) diff --git a/src/main/java/net/coderbot/iris/Iris.java b/src/main/java/net/coderbot/iris/Iris.java index 460bd9739d..c543735a80 100644 --- a/src/main/java/net/coderbot/iris/Iris.java +++ b/src/main/java/net/coderbot/iris/Iris.java @@ -71,9 +71,6 @@ public class Iris { private static ShaderPack currentPack; private static String currentPackName; - private static boolean sodiumInvalid; - private static boolean hasNEC; - private static boolean sodiumInstalled; private static boolean initialized; private static PipelineManager pipelineManager; @@ -103,21 +100,6 @@ public class Iris { *

This is called right before options are loaded, so we can add key bindings here.

*/ public void onEarlyInitialize() { - FabricLoader.getInstance().getModContainer("sodium").ifPresent( - modContainer -> { - sodiumInstalled = true; - String versionString = modContainer.getMetadata().getVersion().getFriendlyString(); - - // This makes it so that if we don't have the right version of Sodium, it will show the user a - // nice warning, and prevent them from playing the game with a wrong version of Sodium. - if (!SodiumVersionCheck.isAllowedVersion(versionString)) { - sodiumInvalid = true; - } - } - ); - - hasNEC = FabricLoader.getInstance().isModLoaded("notenoughcrashes"); - ModContainer iris = FabricLoader.getInstance().getModContainer(MODID) .orElseThrow(() -> new IllegalStateException("Couldn't find the mod container for Iris")); @@ -723,18 +705,6 @@ public static String getFormattedVersion() { return color + version; } - public static boolean isSodiumInvalid() { - return sodiumInvalid; - } - - public static boolean isSodiumInstalled() { - return sodiumInstalled; - } - - public static boolean hasNotEnoughCrashes() { - return hasNEC; - } - public static Path getShaderpacksDirectory() { if (shaderpacksDirectory == null) { shaderpacksDirectory = FabricLoader.getInstance().getGameDir().resolve("shaderpacks"); diff --git a/src/main/java/net/coderbot/iris/mixin/MixinTitleScreen.java b/src/main/java/net/coderbot/iris/mixin/MixinTitleScreen.java index 980aa4e29d..0b98da271f 100644 --- a/src/main/java/net/coderbot/iris/mixin/MixinTitleScreen.java +++ b/src/main/java/net/coderbot/iris/mixin/MixinTitleScreen.java @@ -1,29 +1,14 @@ package net.coderbot.iris.mixin; -import com.google.common.collect.ImmutableList; import net.coderbot.iris.Iris; -import net.coderbot.iris.compat.sodium.SodiumVersionCheck; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.ChatFormatting; -import net.minecraft.Util; -import net.minecraft.client.GraphicsStatus; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.AlertScreen; -import net.minecraft.client.gui.screens.ConfirmScreen; -import net.minecraft.client.gui.screens.PopupScreen; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.TitleScreen; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.network.chat.TranslatableComponent; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.net.URI; -import java.net.URISyntaxException; - @Mixin(TitleScreen.class) public class MixinTitleScreen extends Screen { private static boolean iris$hasFirstInit; @@ -33,70 +18,12 @@ protected MixinTitleScreen(Component arg) { } @Inject(method = "init", at = @At("RETURN")) - public void iris$showSodiumIncompatScreen(CallbackInfo ci) { - if (iris$hasFirstInit) return; - - String reason; - - if (!Iris.isSodiumInstalled() && !FabricLoader.getInstance().isDevelopmentEnvironment()) { - reason = "iris.sodium.failure.reason.notFound"; - } else if (Iris.isSodiumInvalid()) { - reason = "iris.sodium.failure.reason.incompatible"; - } else if (Iris.hasNotEnoughCrashes()) { - Minecraft.getInstance().setScreen(new ConfirmScreen( - bool -> { - if (bool) { - if (!iris$hasFirstInit) { - Iris.onLoadingComplete(); - } - - iris$hasFirstInit = true; - - Minecraft.getInstance().setScreen(this); - } else { - Minecraft.getInstance().stop(); - } - }, - new TranslatableComponent("iris.nec.failure.title", Iris.MODNAME).withStyle(ChatFormatting.BOLD, ChatFormatting.RED), - new TranslatableComponent("iris.nec.failure.description"), - new TranslatableComponent("options.graphics.warning.accept").withStyle(ChatFormatting.RED), - new TranslatableComponent("menu.quit").withStyle(ChatFormatting.BOLD))); - return; - } else { - if (!iris$hasFirstInit) { - Iris.onLoadingComplete(); - } - - iris$hasFirstInit = true; - - return; - } - - if (Iris.isSodiumInvalid()) { - Minecraft.getInstance().setScreen(new AlertScreen( - Minecraft.getInstance()::stop, - new TranslatableComponent("iris.sodium.failure.title").withStyle(ChatFormatting.RED), - new TranslatableComponent("iris.sodium.failure.reason"), - new TranslatableComponent("menu.quit"))); + public void iris$firstInit(CallbackInfo ci) { + if (!iris$hasFirstInit) { + Iris.onLoadingComplete(); } iris$hasFirstInit = true; - Minecraft.getInstance().setScreen(new ConfirmScreen( - (boolean accepted) -> { - if (accepted) { - try { - Util.getPlatform().openUri(new URI(SodiumVersionCheck.getDownloadLink())); - } catch (URISyntaxException e) { - throw new IllegalStateException(e); - } - } else { - Minecraft.getInstance().stop(); - } - }, - new TranslatableComponent("iris.sodium.failure.title").withStyle(ChatFormatting.RED), - new TranslatableComponent(reason), - new TranslatableComponent("iris.sodium.failure.download"), - new TranslatableComponent("menu.quit"))); } } From 0d33d99f10b32079ae35f2fda36b011fb2cab977 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Tue, 21 Nov 2023 21:02:40 -0800 Subject: [PATCH 08/16] I need to learn to try my code --- .../iris/mixin/MixinDebugScreenOverlay.java | 14 +++++----- .../iris/mixin/MixinLevelRenderer.java | 5 ---- .../iris/mixin/MixinSystemReport.java | 8 ------ .../net/coderbot/iris/mixin/gui/MixinGui.java | 27 ------------------- 4 files changed, 7 insertions(+), 47 deletions(-) diff --git a/src/main/java/net/coderbot/iris/mixin/MixinDebugScreenOverlay.java b/src/main/java/net/coderbot/iris/mixin/MixinDebugScreenOverlay.java index 208c44f26d..15c411263c 100644 --- a/src/main/java/net/coderbot/iris/mixin/MixinDebugScreenOverlay.java +++ b/src/main/java/net/coderbot/iris/mixin/MixinDebugScreenOverlay.java @@ -58,19 +58,19 @@ public abstract class MixinDebugScreenOverlay { messages.add(3, "Direct Buffers: +" + iris$humanReadableByteCountBin(iris$directPool.getMemoryUsed())); - if (!Iris.isSodiumInstalled()) { - messages.add(3, "Native Memory: +" + iris$humanReadableByteCountBin(iris$getNativeMemoryUsage())); - } + //if (!Iris.isSodiumInstalled()) { + // messages.add(3, "Native Memory: +" + iris$humanReadableByteCountBin(iris$getNativeMemoryUsage())); + //} } @Inject(method = "getGameInformation", at = @At("RETURN")) private void iris$appendShadowDebugText(CallbackInfoReturnable> cir) { List messages = cir.getReturnValue(); - if (!Iris.isSodiumInstalled() && Iris.getCurrentPack().isPresent()) { - messages.add(1, ChatFormatting.YELLOW + "[" + Iris.MODNAME + "] Sodium isn't installed; you will have poor performance."); - messages.add(2, ChatFormatting.YELLOW + "[" + Iris.MODNAME + "] Install Sodium if you want to run benchmarks or get higher FPS!"); - } + //if (!Iris.isSodiumInstalled() && Iris.getCurrentPack().isPresent()) { + // messages.add(1, ChatFormatting.YELLOW + "[" + Iris.MODNAME + "] Sodium isn't installed; you will have poor performance."); + // messages.add(2, ChatFormatting.YELLOW + "[" + Iris.MODNAME + "] Install Sodium if you want to run benchmarks or get higher FPS!"); + //} Iris.getPipelineManager().getPipeline().ifPresent(pipeline -> pipeline.addDebugText(messages)); } diff --git a/src/main/java/net/coderbot/iris/mixin/MixinLevelRenderer.java b/src/main/java/net/coderbot/iris/mixin/MixinLevelRenderer.java index a998bd66cc..5355426038 100644 --- a/src/main/java/net/coderbot/iris/mixin/MixinLevelRenderer.java +++ b/src/main/java/net/coderbot/iris/mixin/MixinLevelRenderer.java @@ -69,11 +69,6 @@ public class MixinLevelRenderer { private void iris$setupPipeline(PoseStack poseStack, float tickDelta, long startTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projection, CallbackInfo callback) { - if (Iris.isSodiumInvalid()) { - throw new IllegalStateException("An invalid version of Sodium is installed, and the warning screen somehow" + - " didn't work. This is a bug! Please report it to the Iris developers."); - } - IrisTimeUniforms.updateTime(); CapturedRenderingState.INSTANCE.setGbufferModelView(poseStack.last().pose()); CapturedRenderingState.INSTANCE.setGbufferProjection(projection); diff --git a/src/main/java/net/coderbot/iris/mixin/MixinSystemReport.java b/src/main/java/net/coderbot/iris/mixin/MixinSystemReport.java index 8eec02d752..cc28904bf4 100644 --- a/src/main/java/net/coderbot/iris/mixin/MixinSystemReport.java +++ b/src/main/java/net/coderbot/iris/mixin/MixinSystemReport.java @@ -32,13 +32,5 @@ private void fillSystemDetails(CallbackInfo ci) { }); return sb.toString(); }); - - this.setDetail("NEC status", () -> { - if (Iris.hasNotEnoughCrashes()) { - return "Has NEC: INVALID"; - } else { - return "No NEC detected"; - } - }); } } diff --git a/src/main/java/net/coderbot/iris/mixin/gui/MixinGui.java b/src/main/java/net/coderbot/iris/mixin/gui/MixinGui.java index 98bc987633..ee3068156b 100644 --- a/src/main/java/net/coderbot/iris/mixin/gui/MixinGui.java +++ b/src/main/java/net/coderbot/iris/mixin/gui/MixinGui.java @@ -35,33 +35,6 @@ public class MixinGui { } } - // TODO: Move this to a more appropriate mixin - @Inject(method = "render", at = @At("RETURN")) - public void iris$displayBigSodiumWarning(PoseStack poseStack, float tickDelta, CallbackInfo ci) { - if (Iris.isSodiumInstalled() - || Minecraft.getInstance().options.renderDebug - || !Iris.getCurrentPack().isPresent()) { - return; - } - - Font font = Minecraft.getInstance().font; - - List warningLines = new ArrayList<>(); - warningLines.add("[" + Iris.MODNAME + "] Sodium isn't installed; you will have poor performance."); - warningLines.add("[" + Iris.MODNAME + "] Install Sodium if you want to run benchmarks or get higher FPS!"); - - for (int i = 0; i < warningLines.size(); ++i) { - String string = warningLines.get(i); - - final int lineHeight = 9; - final int lineWidth = font.width(string); - final int y = 2 + lineHeight * i; - - GuiComponent.fill(poseStack, 1, y - 1, 2 + lineWidth + 1, y + lineHeight - 1, 0x9050504E); - font.draw(poseStack, string, 2.0F, y, 0xFFFF55); - } - } - @Inject(method = "renderVignette", at = @At("HEAD"), cancellable = true) private void iris$disableVignetteRendering(Entity entity, CallbackInfo ci) { WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable(); From 9ebd2b9be5328d0c2c2d0a0a747563d86d78033c Mon Sep 17 00:00:00 2001 From: IMS212 Date: Tue, 21 Nov 2023 21:03:12 -0800 Subject: [PATCH 09/16] get outta my dev env DH --- buildscript/src/main/java/Buildscript.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildscript/src/main/java/Buildscript.java b/buildscript/src/main/java/Buildscript.java index 0633380263..3a13588024 100644 --- a/buildscript/src/main/java/Buildscript.java +++ b/buildscript/src/main/java/Buildscript.java @@ -101,7 +101,7 @@ public void getModDependencies(ModDependencyCollector d) { jij(d.addMaven(Maven.MAVEN_CENTRAL, new MavenId("io.github.douira:glsl-transformer:2.0.0-pre13"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME)); jij(d.addMaven(Maven.MAVEN_CENTRAL, new MavenId("org.antlr:antlr4-runtime:4.11.1"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME)); - d.addMaven("https://api.modrinth.com/maven", new MavenId("maven.modrinth", "distanthorizons", "2.0.0-a-1.18.2"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME); + d.addMaven("https://api.modrinth.com/maven", new MavenId("maven.modrinth", "distanthorizons", "2.0.0-a-1.18.2"), ModDependencyFlag.COMPILE); if (SODIUM) { d.addMaven(FabricMaven.URL, new MavenId(FabricMaven.GROUP_ID + ".fabric-api", "fabric-api-base", "0.4.3+d7c144a8d2"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME); From a972c9191b105ddf47424044eddd68258a69fa4f Mon Sep 17 00:00:00 2001 From: IMS212 Date: Wed, 22 Nov 2023 15:53:48 -0800 Subject: [PATCH 10/16] Change version to 1.6.11 --- src/main/resources/fabric.mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index bab1de2c02..1d7ada1835 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "iris", - "version": "1.6.10-development-environment", + "version": "1.6.11-development-environment", "name": "Iris", "description": "A modern shaders mod for Minecraft intended to be compatible with existing OptiFine shader packs", From 635b8b02d1d65bf2fe57ebd8b16dc6cb4242f758 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Thu, 23 Nov 2023 10:21:49 -0800 Subject: [PATCH 11/16] Fix --- buildscript/src/main/java/Buildscript.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildscript/src/main/java/Buildscript.java b/buildscript/src/main/java/Buildscript.java index 53daa1b53f..51d3d65493 100644 --- a/buildscript/src/main/java/Buildscript.java +++ b/buildscript/src/main/java/Buildscript.java @@ -101,7 +101,7 @@ public void getModDependencies(ModDependencyCollector d) { jij(d.addMaven(Maven.MAVEN_CENTRAL, new MavenId("io.github.douira:glsl-transformer:2.0.0-pre13"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME)); jij(d.addMaven(Maven.MAVEN_CENTRAL, new MavenId("org.antlr:antlr4-runtime:4.11.1"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME)); - d.addMaven("https://api.modrinth.com/maven", new MavenId("maven.modrinth", "distanthorizons", "2.0.0-a-1.19.2"), ModDependencyFlag.COMPILE); + d.addMaven("https://api.modrinth.com/maven", new MavenId("maven.modrinth", "distanthorizons", "2.0.0-a-1.19.4"), ModDependencyFlag.COMPILE); if (SODIUM) { d.addMaven(FabricMaven.URL, new MavenId(FabricMaven.GROUP_ID + ".fabric-api", "fabric-api-base", "0.4.17+93d8cb8253"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME); From a51c9d2e8d067c06ce3f44ebef9df6a57f902671 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Sun, 26 Nov 2023 16:37:27 -0800 Subject: [PATCH 12/16] With this one weird trick, you too can lose 100 uniforms --- .../coderbot/iris/shaderpack/ShaderPack.java | 28 +++++++++++++------ .../iris/shaderpack/ShaderProperties.java | 6 +--- .../preprocessor/PropertiesPreprocessor.java | 14 +--------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/main/java/net/coderbot/iris/shaderpack/ShaderPack.java b/src/main/java/net/coderbot/iris/shaderpack/ShaderPack.java index 7f829c3cf1..790d557de4 100644 --- a/src/main/java/net/coderbot/iris/shaderpack/ShaderPack.java +++ b/src/main/java/net/coderbot/iris/shaderpack/ShaderPack.java @@ -47,7 +47,17 @@ import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Properties; +import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -75,7 +85,7 @@ public class ShaderPack { private List dimensionIds; private Map dimensionMap; - public ShaderPack(Path root, Iterable environmentDefines) throws IOException, IllegalStateException { + public ShaderPack(Path root, ImmutableList environmentDefines) throws IOException, IllegalStateException { this(root, Collections.emptyMap(), environmentDefines); } @@ -89,11 +99,13 @@ public ShaderPack(Path root, Iterable environmentDefines) throws IOE * have completed, and there is no need to hold on to the path for that reason. * @throws IOException if there are any IO errors during shader pack loading. */ - public ShaderPack(Path root, Map changedConfigs, Iterable environmentDefines) throws IOException, IllegalStateException { + public ShaderPack(Path root, Map changedConfigs, ImmutableList environmentDefines) throws IOException, IllegalStateException { // A null path is not allowed. Objects.requireNonNull(root); - + ArrayList envDefines1 = new ArrayList<>(environmentDefines); + envDefines1.addAll(IrisDefines.createIrisReplacements()); + environmentDefines = ImmutableList.copyOf(envDefines1); ImmutableList.Builder starts = ImmutableList.builder(); ImmutableList potentialFileNames = ShaderPackSourceNames.POTENTIAL_STARTS; @@ -153,10 +165,9 @@ public ShaderPack(Path root, Map changedConfigs, Iterable replacements = IrisDefines.createIrisReplacements(); Iterable finalEnvironmentDefines = environmentDefines; this.shaderProperties = loadProperties(root, "shaders.properties") - .map(source -> new ShaderProperties(source, shaderPackOptions, finalEnvironmentDefines, replacements)) + .map(source -> new ShaderProperties(source, shaderPackOptions, finalEnvironmentDefines)) .orElseGet(ShaderProperties::empty); activeFeatures = new HashSet<>(); @@ -201,7 +212,7 @@ public ShaderPack(Path root, Map changedConfigs, Iterable optionalFeatureFlags = shaderProperties.getOptionalFeatureFlags().stream().filter(flag -> !FeatureFlags.isInvalid(flag)).collect(Collectors.toList()); if (!optionalFeatureFlags.isEmpty()) { - + optionalFeatureFlags.forEach(flag -> Iris.logger.warn("Found flag " + flag)); optionalFeatureFlags.forEach(flag -> newEnvDefines.add(new StringPair("IRIS_FEATURE_" + flag, ""))); } @@ -241,8 +252,7 @@ public ShaderPack(Path root, Map changedConfigs, Iterable finalEnvironmentDefines1 = new ArrayList<>((Collection) finalEnvironmentDefines); - finalEnvironmentDefines1.addAll(IrisDefines.createIrisReplacements()); + Iterable finalEnvironmentDefines1 = environmentDefines; this.sourceProvider = (path) -> { String pathString = path.getPathString(); // Removes the first "/" in the path if present, and the file diff --git a/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java b/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java index 2d7f220599..31e12f2657 100644 --- a/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java +++ b/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java @@ -111,11 +111,7 @@ private ShaderProperties() { } // TODO: Is there a better solution than having ShaderPack pass a root path to ShaderProperties to be able to read textures? - public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, Iterable environmentDefines, Iterable replacements) { - for (StringPair pair : replacements) { - contents = contents.replaceAll("\\b" + pair.getKey() + "\\b", pair.getValue()); - } - + public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, Iterable environmentDefines) { String preprocessedContents = PropertiesPreprocessor.preprocessSource(contents, shaderPackOptions, environmentDefines); Properties preprocessed = new OrderBackedProperties(); diff --git a/src/main/java/net/coderbot/iris/shaderpack/preprocessor/PropertiesPreprocessor.java b/src/main/java/net/coderbot/iris/shaderpack/preprocessor/PropertiesPreprocessor.java index 7bb2bd9846..74da7f19ab 100644 --- a/src/main/java/net/coderbot/iris/shaderpack/preprocessor/PropertiesPreprocessor.java +++ b/src/main/java/net/coderbot/iris/shaderpack/preprocessor/PropertiesPreprocessor.java @@ -78,19 +78,7 @@ private static String process(Preprocessor preprocessor, String source) { // Not super efficient, but this removes trailing whitespace on lines, fixing an issue with whitespace after // line continuations (see PreprocessorTest#testWeirdPropertiesLineContinuation) // Required for Voyager Shader - source = Arrays.stream(source.split("\\R")).map(String::trim) - .map(line -> { - if (line.startsWith("#")) { - // In PropertyCollectingListener we suppress "unknown preprocessor directive errors" and - // assume the line to be a comment, since in .properties files `#` also functions as a comment - // marker. - return line; - } else { - // This is a hack to ensure that non-macro lines don't have any preprocessing applied... - // In properties files, we don't substitute #define values except on macro lines. - return "#warning IRIS_PASSTHROUGH " + line; - } - }).collect(Collectors.joining("\n")) + "\n"; + source = Arrays.stream(source.split("\\R")).map(String::trim).collect(Collectors.joining("\n")) + "\n"; // TODO: This is a horrible fix to trick the preprocessor into not seeing the backslashes during processing. We need a better way to do this. source = source.replace("\\", "IRIS_PASSTHROUGHBACKSLASH"); From f2998a1001656bfa0dd9c9a36e654fa25a90e060 Mon Sep 17 00:00:00 2001 From: IMS Date: Mon, 27 Nov 2023 14:51:24 -0800 Subject: [PATCH 13/16] I swear I did this --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6558bedcfe..70e63fdd26 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## Links -* **Visit [our website](https://irisshaders.net) for downloads and pretty screenshots!** +* **Visit [our website](https://irisshaders.dev) for downloads and pretty screenshots!** * * **Visit [Modrinth](https://modrinth.com/shaders) to find shader packs!** * Visit [our Discord server](https://discord.gg/jQJnav2jPu) to chat about the mod and get support! It's also a great place to get development updates right as they're happening. * Visit [the developer documentation](https://github.com/IrisShaders/Iris/tree/trunk/docs/development) for information on developing, building, and contributing to Iris! From 8b55c8b7ec708662245342a048c30cd84f13c022 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Sat, 2 Dec 2023 08:47:05 -0800 Subject: [PATCH 14/16] Fix some issues with color space conversion --- .../net/coderbot/iris/mixin/MixinGameRenderer.java | 5 +++++ .../pipeline/DeferredWorldRenderingPipeline.java | 5 +++++ .../FixedFunctionWorldRenderingPipeline.java | 5 +++++ .../iris/pipeline/WorldRenderingPipeline.java | 1 + .../newshader/NewWorldRenderingPipeline.java | 4 ++++ .../coderbot/iris/shaderpack/ShaderProperties.java | 11 +++++++++++ src/main/resources/colorSpace.csh | 14 +++++++------- 7 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/coderbot/iris/mixin/MixinGameRenderer.java b/src/main/java/net/coderbot/iris/mixin/MixinGameRenderer.java index aabf4052ed..cea7e40e54 100644 --- a/src/main/java/net/coderbot/iris/mixin/MixinGameRenderer.java +++ b/src/main/java/net/coderbot/iris/mixin/MixinGameRenderer.java @@ -57,6 +57,11 @@ public class MixinGameRenderer { itemInHandRenderer.renderHandsWithItems(tickDelta, poseStack, bufferSource, localPlayer, light); } + @Inject(method = "renderLevel", at = @At("TAIL")) + private void iris$runColorSpace(float pGameRenderer0, long pLong1, PoseStack pPoseStack2, CallbackInfo ci) { + Iris.getPipelineManager().getPipeline().ifPresent(WorldRenderingPipeline::finalizeGameRendering); + } + @Redirect(method = "reloadShaders", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/Lists;newArrayList()Ljava/util/ArrayList;")) private ArrayList iris$reloadGeometryShaders() { ArrayList programs = Lists.newArrayList(); diff --git a/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java index e177d6b902..858528c985 100644 --- a/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java @@ -1290,6 +1290,11 @@ public void finalizeLevelRendering() { isRenderingFullScreenPass = false; } + @Override + public void finalizeGameRendering() { + + } + @Override public SodiumTerrainPipeline getSodiumTerrainPipeline() { return sodiumTerrainPipeline; diff --git a/src/main/java/net/coderbot/iris/pipeline/FixedFunctionWorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/FixedFunctionWorldRenderingPipeline.java index 95a038543f..e4346a5ce4 100644 --- a/src/main/java/net/coderbot/iris/pipeline/FixedFunctionWorldRenderingPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/FixedFunctionWorldRenderingPipeline.java @@ -140,6 +140,11 @@ public void finalizeLevelRendering() { // stub: nothing to do here } + @Override + public void finalizeGameRendering() { + // stub: nothing to do here + } + @Override public void destroy() { // stub: nothing to do here diff --git a/src/main/java/net/coderbot/iris/pipeline/WorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/WorldRenderingPipeline.java index 5e4ba7b0fc..3bec5584b0 100644 --- a/src/main/java/net/coderbot/iris/pipeline/WorldRenderingPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/WorldRenderingPipeline.java @@ -45,6 +45,7 @@ public interface WorldRenderingPipeline { void beginTranslucents(); void finalizeLevelRendering(); + void finalizeGameRendering(); void destroy(); SodiumTerrainPipeline getSodiumTerrainPipeline(); diff --git a/src/main/java/net/coderbot/iris/pipeline/newshader/NewWorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/newshader/NewWorldRenderingPipeline.java index 664faa2bff..670cf06f20 100644 --- a/src/main/java/net/coderbot/iris/pipeline/newshader/NewWorldRenderingPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/newshader/NewWorldRenderingPipeline.java @@ -1094,6 +1094,10 @@ public void finalizeLevelRendering() { isRenderingWorld = false; compositeRenderer.renderAll(); finalPassRenderer.renderFinalPass(); + } + + @Override + public void finalizeGameRendering() { colorSpaceConverter.process(Minecraft.getInstance().getMainRenderTarget().getColorTextureId()); } diff --git a/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java b/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java index 31e12f2657..5adba0c55a 100644 --- a/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java +++ b/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java @@ -29,9 +29,11 @@ import net.coderbot.iris.shaderpack.preprocessor.PropertiesPreprocessor; import net.coderbot.iris.shaderpack.texture.TextureStage; import net.coderbot.iris.uniforms.custom.CustomUniforms; +import net.fabricmc.loader.api.FabricLoader; import java.io.IOException; import java.io.StringReader; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.EnumMap; @@ -114,6 +116,15 @@ private ShaderProperties() { public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, Iterable environmentDefines) { String preprocessedContents = PropertiesPreprocessor.preprocessSource(contents, shaderPackOptions, environmentDefines); + if (Iris.getIrisConfig().areDebugOptionsEnabled()) { + try { + Files.writeString(FabricLoader.getInstance().getGameDir().resolve("preprocessed.properties"), preprocessedContents); + Files.writeString(FabricLoader.getInstance().getGameDir().resolve("original.properties"), contents); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + Properties preprocessed = new OrderBackedProperties(); Properties original = new OrderBackedProperties(); try { diff --git a/src/main/resources/colorSpace.csh b/src/main/resources/colorSpace.csh index baee69b49b..016417bb04 100644 --- a/src/main/resources/colorSpace.csh +++ b/src/main/resources/colorSpace.csh @@ -10,7 +10,7 @@ layout(rgba8) uniform image2D readImage; #else uniform sampler2D readImage; in vec2 uv; -out vec3 outColor; +out vec4 outColor; #endif // https://en.wikipedia.org/wiki/Rec._709#Transfer_characteristics @@ -107,13 +107,13 @@ void main() { #if CURRENT_COLOR_SPACE != SRGB #ifdef COMPUTE ivec2 PixelIndex = ivec2(gl_GlobalInvocationID.xy); - vec3 SourceColor = imageLoad(readImage, PixelIndex).rgb; + vec4 SourceColor = imageLoad(readImage, PixelIndex); #else - vec3 SourceColor = texture(readImage, uv).rgb; + vec4 SourceColor = texture(readImage, uv); #endif - SourceColor = InverseEOTF_IEC61966(SourceColor); + SourceColor.rgb = InverseEOTF_IEC61966(SourceColor.rgb); - vec3 TargetColor = SourceColor; + vec3 TargetColor = SourceColor.rgb; #if CURRENT_COLOR_SPACE == DCI_P3 // https://en.wikipedia.org/wiki/DCI-P3 @@ -137,9 +137,9 @@ void main() { #endif #ifdef COMPUTE - imageStore(readImage, PixelIndex, vec4(TargetColor, 1.0)); + imageStore(readImage, PixelIndex, vec4(TargetColor, SourceColor.a)); #else - outColor = TargetColor; + outColor = vec4(TargetColor, SourceColor.a); #endif #endif } From e8a625222920f9b9e8249b7adb285a83abf9bbda Mon Sep 17 00:00:00 2001 From: IMS212 Date: Sun, 3 Dec 2023 09:24:02 -0800 Subject: [PATCH 15/16] Extremely dumb code --- .../preprocessor/PropertiesPreprocessor.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/coderbot/iris/shaderpack/preprocessor/PropertiesPreprocessor.java b/src/main/java/net/coderbot/iris/shaderpack/preprocessor/PropertiesPreprocessor.java index 74da7f19ab..414e877203 100644 --- a/src/main/java/net/coderbot/iris/shaderpack/preprocessor/PropertiesPreprocessor.java +++ b/src/main/java/net/coderbot/iris/shaderpack/preprocessor/PropertiesPreprocessor.java @@ -6,6 +6,7 @@ import org.anarres.cpp.Feature; import org.anarres.cpp.LexerException; import org.anarres.cpp.Preprocessor; +import org.anarres.cpp.PreprocessorCommand; import org.anarres.cpp.StringLexerSource; import org.anarres.cpp.Token; @@ -14,6 +15,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.stream.Collectors; @@ -78,7 +80,21 @@ private static String process(Preprocessor preprocessor, String source) { // Not super efficient, but this removes trailing whitespace on lines, fixing an issue with whitespace after // line continuations (see PreprocessorTest#testWeirdPropertiesLineContinuation) // Required for Voyager Shader - source = Arrays.stream(source.split("\\R")).map(String::trim).collect(Collectors.joining("\n")) + "\n"; + source = Arrays.stream(source.split("\\R")).map(String::trim) + .map(line -> { + if (line.startsWith("#")) { + for (PreprocessorCommand command : PreprocessorCommand.values()) { + if (line.startsWith("#" + (command.name().replace("PP_", "").toLowerCase(Locale.ROOT)))) { + return line; + } + } + return ""; + } + // In PropertyCollectingListener we suppress "unknown preprocessor directive errors" and + // assume the line to be a comment, since in .properties files `#` also functions as a comment + // marker. + return line.replace("#", ""); + }).collect(Collectors.joining("\n")) + "\n"; // TODO: This is a horrible fix to trick the preprocessor into not seeing the backslashes during processing. We need a better way to do this. source = source.replace("\\", "IRIS_PASSTHROUGHBACKSLASH"); From 8a6cdbbd7d3cc8ad46aea7307a170aaae78c36bc Mon Sep 17 00:00:00 2001 From: IMS212 Date: Tue, 5 Dec 2023 15:23:11 -0800 Subject: [PATCH 16/16] Fix SSBO's... again --- .../net/coderbot/iris/shaderpack/ShaderProperties.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java b/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java index 5adba0c55a..6276c953e3 100644 --- a/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java +++ b/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java @@ -531,10 +531,6 @@ public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, It customUniforms.addVariable(parts[0], parts[1], value, true); }); - - handleWhitespacedListDirective(key, value, "iris.features.required", options -> requiredFeatureFlags = options); - handleWhitespacedListDirective(key, value, "iris.features.optional", options -> optionalFeatureFlags = options); - // TODO: Buffer size directives // TODO: Conditional program enabling directives }); @@ -544,6 +540,9 @@ public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, It String key = (String) keyObject; String value = (String) valueObject; + handleWhitespacedListDirective(key, value, "iris.features.required", options -> requiredFeatureFlags = options); + handleWhitespacedListDirective(key, value, "iris.features.optional", options -> optionalFeatureFlags = options); + // Defining "sliders" multiple times in the properties file will only result in // the last definition being used, should be tested if behavior matches OptiFine handleWhitespacedListDirective(key, value, "sliders", sliders -> sliderOptions = sliders);