diff --git a/buildscript/src/main/java/Buildscript.java b/buildscript/src/main/java/Buildscript.java index 1e183a1fb5..0f1f481fff 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.22")); + 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.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); diff --git a/src/main/java/net/coderbot/iris/Iris.java b/src/main/java/net/coderbot/iris/Iris.java index c6d6e3e5a8..e008548b8d 100644 --- a/src/main/java/net/coderbot/iris/Iris.java +++ b/src/main/java/net/coderbot/iris/Iris.java @@ -79,9 +79,6 @@ public class Iris { private static ShaderPack currentPack; private static String currentPackName; private static Optional storedError = Optional.empty(); - private static boolean sodiumInvalid; - private static boolean hasNEC; - private static boolean sodiumInstalled; private static boolean initialized; private static PipelineManager pipelineManager; @@ -114,12 +111,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 - ); - - hasNEC = FabricLoader.getInstance().isModLoaded("notenoughcrashes"); - ModContainer iris = FabricLoader.getInstance().getModContainer(MODID) .orElseThrow(() -> new IllegalStateException("Couldn't find the mod container for Iris")); @@ -753,18 +744,6 @@ public static String getBackupVersionNumber() { return backupVersionNumber; } - 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/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..9880c13d52 --- /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(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) { + if (Iris.getPipelineManager().getPipelineNullable() instanceof NewWorldRenderingPipeline pipeline) { + return pipeline.getDHCompat().getFramebuffer(); + } else { + return instance.getTargetFrameBuffer(); + } + } +} diff --git a/src/main/java/net/coderbot/iris/mixin/MixinDebugScreenOverlay.java b/src/main/java/net/coderbot/iris/mixin/MixinDebugScreenOverlay.java index 10c7aedf9d..2ac73fd49e 100644 --- a/src/main/java/net/coderbot/iris/mixin/MixinDebugScreenOverlay.java +++ b/src/main/java/net/coderbot/iris/mixin/MixinDebugScreenOverlay.java @@ -59,19 +59,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/MixinGameRenderer.java b/src/main/java/net/coderbot/iris/mixin/MixinGameRenderer.java index bb5bd0504e..6900d50697 100644 --- a/src/main/java/net/coderbot/iris/mixin/MixinGameRenderer.java +++ b/src/main/java/net/coderbot/iris/mixin/MixinGameRenderer.java @@ -56,6 +56,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/mixin/MixinLevelRenderer.java b/src/main/java/net/coderbot/iris/mixin/MixinLevelRenderer.java index b4e117b242..a257d4f1e0 100644 --- a/src/main/java/net/coderbot/iris/mixin/MixinLevelRenderer.java +++ b/src/main/java/net/coderbot/iris/mixin/MixinLevelRenderer.java @@ -77,11 +77,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() && !FabricLoader.getInstance().isDevelopmentEnvironment()) { - 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/MixinTitleScreen.java b/src/main/java/net/coderbot/iris/mixin/MixinTitleScreen.java index 1dad30b435..0b98da271f 100644 --- a/src/main/java/net/coderbot/iris/mixin/MixinTitleScreen.java +++ b/src/main/java/net/coderbot/iris/mixin/MixinTitleScreen.java @@ -1,28 +1,14 @@ package net.coderbot.iris.mixin; -import com.google.common.collect.ImmutableList; import net.coderbot.iris.Iris; -import net.coderbot.iris.gui.debug.DebugLoadFailedGridScreen; -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 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; @@ -32,65 +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(); - } - }, - Component.translatable("iris.nec.failure.title", Iris.MODNAME).withStyle(ChatFormatting.BOLD, ChatFormatting.RED), - Component.translatable("iris.nec.failure.description"), - Component.translatable("options.graphics.warning.accept").withStyle(ChatFormatting.RED), - Component.translatable("menu.quit").withStyle(ChatFormatting.BOLD))); - return; - } else { - if (!iris$hasFirstInit) { - Iris.onLoadingComplete(); - } - - iris$hasFirstInit = true; - - return; + 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 { - if (FabricLoader.getInstance().isDevelopmentEnvironment()) { - Minecraft.getInstance().setScreen(this); - } else { - Minecraft.getInstance().stop(); - } - } - }, - Component.translatable("iris.sodium.failure.title").withStyle(ChatFormatting.RED), - Component.translatable(reason), - Component.translatable("iris.sodium.failure.download"), - FabricLoader.getInstance().isDevelopmentEnvironment() ? Component.literal("Continue (Development)") : Component.translatable("menu.quit")));*/ } } 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 e4c625ad34..caadf5e9dd 100644 --- a/src/main/java/net/coderbot/iris/mixin/gui/MixinGui.java +++ b/src/main/java/net/coderbot/iris/mixin/gui/MixinGui.java @@ -35,32 +35,6 @@ public class MixinGui { } } - @Inject(method = "render", at = @At("RETURN")) - public void iris$displayBigSodiumWarning(GuiGraphics guiGraphics, float pFloat1, 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; - - guiGraphics.fill(1, y - 1, 2 + lineWidth + 1, y + lineHeight - 1, 0x9050504E); - guiGraphics.drawString(font, string, 2, y, 0xFFFF55); - } - } - @Inject(method = "renderVignette", at = @At("HEAD"), cancellable = true) private void iris$disableVignetteRendering(GuiGraphics pGui0, Entity pEntity1, CallbackInfo ci) { WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable(); diff --git a/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java index a6690999b7..20564a9ab9 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.GameRenderer; import net.minecraft.client.renderer.texture.AbstractTexture; 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; @@ -1281,6 +1285,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 aaf57760aa..e4346a5ce4 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; @@ -139,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 @@ -221,4 +227,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..3bec5584b0 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; @@ -44,6 +45,7 @@ public interface WorldRenderingPipeline { void beginTranslucents(); void finalizeLevelRendering(); + void finalizeGameRendering(); void destroy(); SodiumTerrainPipeline getSodiumTerrainPipeline(); @@ -64,4 +66,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 f0779857fd..8f1a9e8b2a 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; @@ -188,6 +187,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(); @@ -206,6 +206,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(); @@ -485,6 +486,9 @@ 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, shadowRenderTargets == null ? null : createShadowTerrainSamplers, createTerrainImages, createShadowTerrainImages, renderTargets, flippedAfterPrepare, flippedAfterTranslucent, shadowRenderTargets != null ? shadowRenderTargets.createShadowFramebuffer(ImmutableSet.of(), programSet.getShadow().filter(source -> !source.getDirectives().hasUnknownDrawBuffers()).map(source -> source.getDirectives().getDrawBuffers()).orElse(new int[]{0, 1})) : null, customUniforms); @@ -1097,6 +1101,10 @@ public void finalizeLevelRendering() { isRenderingWorld = false; compositeRenderer.renderAll(); finalPassRenderer.renderFinalPass(); + } + + @Override + public void finalizeGameRendering() { colorSpaceConverter.process(Minecraft.getInstance().getMainRenderTarget().getColorTextureId()); } @@ -1178,7 +1186,6 @@ private void destroyShaders() { public void destroy() { destroyed = true; - destroyShaders(); // Unbind all textures @@ -1257,6 +1264,11 @@ public float getSunPathRotation() { return sunPathRotation; } + @Override + public DHCompat getDHCompat() { + return dhCompat; + } + protected AbstractTexture getWhitePixel() { return whitePixel; } 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); diff --git a/src/main/java/net/coderbot/iris/shaderpack/ShaderPack.java b/src/main/java/net/coderbot/iris/shaderpack/ShaderPack.java index 6d733e3213..4660fcc4cf 100644 --- a/src/main/java/net/coderbot/iris/shaderpack/ShaderPack.java +++ b/src/main/java/net/coderbot/iris/shaderpack/ShaderPack.java @@ -45,7 +45,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; @@ -73,7 +83,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); } @@ -87,11 +97,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; @@ -151,10 +163,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<>(); @@ -199,7 +210,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, ""))); } @@ -239,8 +250,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 32bb6eddf8..6276c953e3 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; @@ -111,13 +113,18 @@ 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()); - } - + 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 { @@ -524,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 }); @@ -537,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); 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..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,19 +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) - .map(line -> { - if (line.startsWith("#")) { + 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; - } 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"; + 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"); 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); } } 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 } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 43bf110ca8..37238b3e53 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", @@ -34,6 +34,7 @@ "mixins.iris.vertexformat.json", "mixins.iris.bettermipmaps.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 + } +} 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 73ea6c2005..87a8ae4bbb 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(Component.translatable("options.iris.shadowDistance")) .setTooltip(Component.translatable("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 : (Component.translatable(key, v)).getString(); + }; + } + public static OptionImpl createLimitedVideoSettingsButton(MinecraftOptionsStorage vanillaOpts) { return OptionImpl.createBuilder(SupportedGraphicsMode.class, vanillaOpts) .setName(Component.translatable("options.graphics")) // TODO: State that Fabulous Graphics is incompatible with Shader Packs in the tooltip .setTooltip(Component.translatable("sodium.options.graphics_quality.tooltip")) .setControl(option -> new CyclingControl<>(option, SupportedGraphicsMode.class, - new Component[] { Component.literal("Fast"), Component.literal("Fancy") })) + new Component[] { Component.translatable("options.graphics.fast"), Component.translatable("options.graphics.fancy") })) .setBinding( (opts, value) -> opts.graphicsMode().set(value.toVanilla()), opts -> SupportedGraphicsMode.fromVanilla(opts.graphicsMode().get()))