Common and version specific shader packages #10

Merged
embeddedt merged 24 commits from mitchej123/celeritas:common-shaders-and-enhancements into stonecutter 2025-03-31 19:52:28 -04:00
73 changed files with 171 additions and 135 deletions
Showing only changes of commit 45fb5cf465 - Show all commits

No files matched your search

+4
View File
@@ -20,6 +20,8 @@ repositories {
} }
dependencies { dependencies {
implementation(project(":common"))
def lwjglVersion = "3.3.1" def lwjglVersion = "3.3.1"
compileOnly "org.lwjgl:lwjgl:${lwjglVersion}" compileOnly "org.lwjgl:lwjgl:${lwjglVersion}"
compileOnly "org.lwjgl:lwjgl-opengl:${lwjglVersion}" compileOnly "org.lwjgl:lwjgl-opengl:${lwjglVersion}"
@@ -32,6 +34,8 @@ dependencies {
compileOnly("com.google.guava:guava:31.1-jre") compileOnly("com.google.guava:guava:31.1-jre")
compileOnly("org.ow2.asm:asm:9.6") compileOnly("org.ow2.asm:asm:9.6")
compileOnly("org.ow2.asm:asm-tree:9.6") compileOnly("org.ow2.asm:asm-tree:9.6")
implementation("org.apache.commons:commons-compress:1.26.0")
def glslTransformLib = "org.taumc:glsl-transformation-lib:${glsl_transformation_lib_version}:fat" def glslTransformLib = "org.taumc:glsl-transformation-lib:${glsl_transformation_lib_version}:fat"
def jcpp = "org.anarres:jcpp:1.4.14" def jcpp = "org.anarres:jcpp:1.4.14"
def shaderDeps = [glslTransformLib, jcpp] def shaderDeps = [glslTransformLib, jcpp]
@@ -0,0 +1,17 @@
package net.irisshaders.iris;
import java.nio.file.Path;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
public class IrisCommon {
private static Path shaderpacksDirectory;
public static Path getShaderpacksDirectory() {
if (shaderpacksDirectory == null) {
shaderpacksDirectory = PLATFORM_UTIL.getGameDir().resolve("shaderpacks");
}
return shaderpacksDirectory;
}
}
@@ -8,4 +8,11 @@ public class IrisConstants {
* separately in mixin plugin classes & the language files. * separately in mixin plugin classes & the language files.
*/ */
public static final String MODNAME = "Celeritas"; public static final String MODNAME = "Celeritas";
public static final float DEPTH = 0.125F;
// Bump this up if you want more shadow color buffers!
// This is currently set at 2 for ShadersMod / OptiFine parity but can theoretically be bumped up to 8.
// TODO: Make this configurable?
public static final int MAX_SHADOW_COLOR_BUFFERS_IRIS = 8;
public static final int MAX_SHADOW_COLOR_BUFFERS_OF = 2;
} }
@@ -5,7 +5,7 @@ import java.nio.FloatBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER; import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
import static com.mitchej123.glsm.MinecraftVersionShimService.MINECRAFT_SHIM; import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM; import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER; import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
@@ -2,7 +2,6 @@ package net.irisshaders.iris.shaderpack.include;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.shaderpack.error.RusticError; import net.irisshaders.iris.shaderpack.error.RusticError;
import net.irisshaders.iris.shaderpack.transform.line.LineTransform; import net.irisshaders.iris.shaderpack.transform.line.LineTransform;
@@ -19,6 +18,8 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
/** /**
* A directed graph data structure that holds the loaded source of all shader programs * A directed graph data structure that holds the loaded source of all shader programs
* and the files included by each source file. Each node / vertex in the graph * and the files included by each source file. Each node / vertex in the graph
@@ -196,7 +197,7 @@ public class IncludeGraph {
"""); """);
// TODO: Expose this to the caller (more semantic error handling) // TODO: Expose this to the caller (more semantic error handling)
Iris.logger.error(error.toString()); IRIS_LOGGER.error(error.toString());
throw new IllegalStateException("Cycle detected in #include graph, see previous messages for details"); throw new IllegalStateException("Cycle detected in #include graph, see previous messages for details");
} }
@@ -5,11 +5,11 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
import net.irisshaders.iris.IrisConstants;
import net.irisshaders.iris.helpers.OptionalBoolean; import net.irisshaders.iris.helpers.OptionalBoolean;
import net.irisshaders.iris.shaderpack.include.AbsolutePackPath; import net.irisshaders.iris.shaderpack.include.AbsolutePackPath;
import net.irisshaders.iris.shaderpack.option.values.OptionValues; import net.irisshaders.iris.shaderpack.option.values.OptionValues;
import net.irisshaders.iris.shaderpack.parsing.ParsedString; import net.irisshaders.iris.shaderpack.parsing.ParsedString;
import net.irisshaders.iris.shaderpack.properties.PackShadowDirectives;
import net.irisshaders.iris.shaderpack.transform.line.LineTransform; import net.irisshaders.iris.shaderpack.transform.line.LineTransform;
import java.util.HashMap; import java.util.HashMap;
@@ -83,7 +83,7 @@ public final class OptionAnnotatedSource {
"noiseTextureResolution" "noiseTextureResolution"
); );
for (int i = 0; i < PackShadowDirectives.MAX_SHADOW_COLOR_BUFFERS_IRIS; i++) { for (int i = 0; i < IrisConstants.MAX_SHADOW_COLOR_BUFFERS_IRIS; i++) {
values.add("shadowcolor" + i + "Mipmap"); values.add("shadowcolor" + i + "Mipmap");
values.add("shadowColor" + i + "Mipmap"); values.add("shadowColor" + i + "Mipmap");
values.add("shadowcolor" + i + "Nearest"); values.add("shadowcolor" + i + "Nearest");
@@ -1,11 +1,12 @@
package net.irisshaders.iris.shaderpack.option; package net.irisshaders.iris.shaderpack.option;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import net.irisshaders.iris.Iris;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class OptionSet { public class OptionSet {
private final ImmutableMap<String, MergedBooleanOption> booleanOptions; private final ImmutableMap<String, MergedBooleanOption> booleanOptions;
private final ImmutableMap<String, MergedStringOption> stringOptions; private final ImmutableMap<String, MergedStringOption> stringOptions;
@@ -69,7 +70,7 @@ public class OptionSet {
if (merged == null) { if (merged == null) {
// TODO: Warn about ambiguous options better // TODO: Warn about ambiguous options better
Iris.logger.warn("Ignoring ambiguous boolean option " + option.getName()); IRIS_LOGGER.warn("Ignoring ambiguous boolean option " + option.getName());
booleanOptions.remove(option.getName()); booleanOptions.remove(option.getName());
return; return;
} }
@@ -95,7 +96,7 @@ public class OptionSet {
if (merged == null) { if (merged == null) {
// TODO: Warn about ambiguous options better // TODO: Warn about ambiguous options better
Iris.logger.warn("Ignoring ambiguous string option " + option.getName()); IRIS_LOGGER.warn("Ignoring ambiguous string option " + option.getName());
stringOptions.remove(option.getName()); stringOptions.remove(option.getName());
return; return;
} }
@@ -1,6 +1,5 @@
package net.irisshaders.iris.shaderpack.option; package net.irisshaders.iris.shaderpack.option;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.IrisLogging; import net.irisshaders.iris.IrisLogging;
import net.irisshaders.iris.shaderpack.option.values.OptionValues; import net.irisshaders.iris.shaderpack.option.values.OptionValues;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -13,6 +12,8 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class ProfileSet { public class ProfileSet {
private final LinkedHashMap<String, Profile> orderedProfiles; // The order that profiles should cycle through private final LinkedHashMap<String, Profile> orderedProfiles; // The order that profiles should cycle through
private final List<Profile> sortedProfiles; // The order that profiles should be scanned through private final List<Profile> sortedProfiles; // The order that profiles should be scanned through
@@ -78,7 +79,7 @@ public class ProfileSet {
} else if (optionSet.isBooleanOption(option)) { } else if (optionSet.isBooleanOption(option)) {
builder.option(option, "true"); builder.option(option, "true");
} else { } else {
Iris.logger.warn("Invalid pack option: " + option); IRIS_LOGGER.warn("Invalid pack option: " + option);
} }
} }
@@ -1,11 +1,12 @@
package net.irisshaders.iris.shaderpack.option.values; package net.irisshaders.iris.shaderpack.option.values;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.helpers.OptionalBoolean; import net.irisshaders.iris.helpers.OptionalBoolean;
import net.irisshaders.iris.shaderpack.option.OptionSet; import net.irisshaders.iris.shaderpack.option.OptionSet;
import java.util.Optional; import java.util.Optional;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public interface OptionValues { public interface OptionValues {
OptionalBoolean getBooleanValue(String name); OptionalBoolean getBooleanValue(String name);
@@ -14,7 +15,7 @@ public interface OptionValues {
default boolean getBooleanValueOrDefault(String name) { default boolean getBooleanValueOrDefault(String name) {
return getBooleanValue(name).orElseGet(() -> { return getBooleanValue(name).orElseGet(() -> {
if (!getOptionSet().getBooleanOptions().containsKey(name)) { if (!getOptionSet().getBooleanOptions().containsKey(name)) {
Iris.logger.warn("Tried to get boolean value for unknown option: " + name + ", defaulting to true!"); IRIS_LOGGER.warn("Tried to get boolean value for unknown option: " + name + ", defaulting to true!");
return true; return true;
} }
return getOptionSet().getBooleanOptions().get(name).getOption().getDefaultValue(); return getOptionSet().getBooleanOptions().get(name).getOption().getDefaultValue();
@@ -1,9 +1,9 @@
package net.irisshaders.iris.shaderpack.properties; package net.irisshaders.iris.shaderpack.properties;
import net.irisshaders.iris.Iris;
import java.util.Optional; import java.util.Optional;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public enum ParticleRenderingSettings { public enum ParticleRenderingSettings {
BEFORE, BEFORE,
MIXED, MIXED,
@@ -13,7 +13,7 @@ public enum ParticleRenderingSettings {
try { try {
return Optional.of(ParticleRenderingSettings.valueOf(name)); return Optional.of(ParticleRenderingSettings.valueOf(name));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Iris.logger.warn("Invalid particle rendering settings! " + name); IRIS_LOGGER.warn("Invalid particle rendering settings! " + name);
return Optional.empty(); return Optional.empty();
} }
} }
@@ -1,7 +1,10 @@
package com.mitchej123.glsm; package org.embeddedt.embeddium.compat.mc;
import java.util.ServiceLoader; import java.util.ServiceLoader;
/**
* Service for providing version-specific Minecraft functionality.
*/
public interface MinecraftVersionShimService { public interface MinecraftVersionShimService {
MinecraftVersionShimService MINECRAFT_SHIM = ServiceLoader.load(MinecraftVersionShimService.class).findFirst().orElseThrow(); MinecraftVersionShimService MINECRAFT_SHIM = ServiceLoader.load(MinecraftVersionShimService.class).findFirst().orElseThrow();
@@ -0,0 +1,23 @@
package org.embeddedt.embeddium.compat.mc;
import java.nio.file.Path;
import java.util.ServiceLoader;
/**
* Service for providing platform-specific utilities.
*/
public interface PlatformUtilService {
PlatformUtilService PLATFORM_UTIL = ServiceLoader.load(PlatformUtilService.class).findFirst().orElseThrow();
boolean isLoadValid();
boolean modPresent(String modid);
String getModName(String modId);
boolean isDevelopmentEnvironment();
Path getConfigDir();
Path getGameDir();
}
@@ -2,12 +2,13 @@ package org.embeddedt.embeddium.impl.config;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.embeddedt.embeddium.impl.util.PlatformUtil;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
public class ConfigMigrator { public class ConfigMigrator {
public static Logger LOGGER = LogManager.getLogger("Embeddium"); public static Logger LOGGER = LogManager.getLogger("Embeddium");
@@ -15,11 +16,11 @@ public class ConfigMigrator {
* Tries to migrate the equivalent config file from Rubidium to the Embeddium name if possible. * Tries to migrate the equivalent config file from Rubidium to the Embeddium name if possible.
*/ */
public static Path handleConfigMigration(String fileName) { public static Path handleConfigMigration(String fileName) {
Path mainPath = PlatformUtil.getConfigDir().resolve(fileName); Path mainPath = PLATFORM_UTIL.getConfigDir().resolve(fileName);
try { try {
if(Files.notExists(mainPath)) { if(Files.notExists(mainPath)) {
String legacyName = fileName.replace("embeddium", "rubidium"); String legacyName = fileName.replace("embeddium", "rubidium");
Path legacyPath = PlatformUtil.getConfigDir().resolve(legacyName); Path legacyPath = PLATFORM_UTIL.getConfigDir().resolve(legacyName);
if(Files.exists(legacyPath)) { if(Files.exists(legacyPath)) {
Files.move(legacyPath, mainPath); Files.move(legacyPath, mainPath);
LOGGER.warn("Migrated {} config file to {}", legacyName, fileName); LOGGER.warn("Migrated {} config file to {}", legacyName, fileName);
@@ -2,7 +2,6 @@ package org.embeddedt.embeddium.impl.gui;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
//? if >=1.15 //? if >=1.15
import com.mojang.blaze3d.vertex.PoseStack;
import org.embeddedt.embeddium.api.EmbeddiumConstants; import org.embeddedt.embeddium.api.EmbeddiumConstants;
import org.embeddedt.embeddium.api.OptionGUIConstructionEvent; import org.embeddedt.embeddium.api.OptionGUIConstructionEvent;
import org.embeddedt.embeddium.impl.gui.console.Console; import org.embeddedt.embeddium.impl.gui.console.Console;
@@ -34,7 +33,6 @@ import org.embeddedt.embeddium.impl.gui.frame.components.SearchTextFieldModel;
import org.embeddedt.embeddium.impl.gui.frame.tab.Tab; import org.embeddedt.embeddium.impl.gui.frame.tab.Tab;
import org.embeddedt.embeddium.impl.gui.frame.tab.TabFrame; import org.embeddedt.embeddium.impl.gui.frame.tab.TabFrame;
import org.embeddedt.embeddium.impl.render.ShaderModBridge; import org.embeddedt.embeddium.impl.render.ShaderModBridge;
import org.embeddedt.embeddium.impl.util.PlatformUtil;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import java.util.ArrayList; import java.util.ArrayList;
@@ -17,20 +17,18 @@ import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.ComponentPath; import net.minecraft.client.gui.ComponentPath;
import net.minecraft.client.gui.navigation.FocusNavigationEvent; import net.minecraft.client.gui.navigation.FocusNavigationEvent;
//?} //?}
import net.minecraft.locale.Language;
import net.minecraft.network.chat.Component;
//? if >=1.16.2 //? if >=1.16.2
import net.minecraft.util.FormattedCharSequence;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.embeddedt.embeddium.api.options.OptionIdentifier; import org.embeddedt.embeddium.api.options.OptionIdentifier;
import org.embeddedt.embeddium.impl.gui.theme.DefaultColors; import org.embeddedt.embeddium.impl.gui.theme.DefaultColors;
import org.embeddedt.embeddium.impl.util.PlatformUtil;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
import java.util.function.Predicate; import java.util.function.Predicate;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
public class OptionPageFrame extends AbstractFrame { public class OptionPageFrame extends AbstractFrame {
protected final OptionPage page; protected final OptionPage page;
private long lastTime = 0; private long lastTime = 0;
@@ -165,7 +163,7 @@ public class OptionPageFrame extends AbstractFrame {
var id = option.getId(); var id = option.getId();
if (OptionIdentifier.isPresent(page.getId()) && OptionIdentifier.isPresent(id) && !Objects.equals(normalizeModForTooltip(page.getId().getModId()), normalizeModForTooltip(id.getModId()))) { if (OptionIdentifier.isPresent(page.getId()) && OptionIdentifier.isPresent(id) && !Objects.equals(normalizeModForTooltip(page.getId().getModId()), normalizeModForTooltip(id.getModId()))) {
var addedByModString = ComponentUtil.translatable("embeddium.options.added_by_mod_string", ComponentUtil.literal(PlatformUtil.getModName(id.getModId())).withStyle(ChatFormatting.WHITE)).withStyle(ChatFormatting.GRAY); var addedByModString = ComponentUtil.translatable("embeddium.options.added_by_mod_string", ComponentUtil.literal(PLATFORM_UTIL.getModName(id.getModId())).withStyle(ChatFormatting.WHITE)).withStyle(ChatFormatting.GRAY);
tooltip.add(addedByModString.getString()); tooltip.add(addedByModString.getString());
} }
@@ -9,17 +9,19 @@ import org.embeddedt.embeddium.api.options.OptionIdentifier;
import org.embeddedt.embeddium.impl.gui.frame.AbstractFrame; import org.embeddedt.embeddium.impl.gui.frame.AbstractFrame;
import org.embeddedt.embeddium.impl.gui.frame.OptionPageFrame; import org.embeddedt.embeddium.impl.gui.frame.OptionPageFrame;
import org.embeddedt.embeddium.impl.gui.frame.ScrollableFrame; import org.embeddedt.embeddium.impl.gui.frame.ScrollableFrame;
import org.embeddedt.embeddium.impl.util.PlatformUtil;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.function.Supplier; import java.util.function.Supplier;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
public record Tab<T extends AbstractFrame>(OptionIdentifier<Void> id, Component title, Supplier<Boolean> onSelectFunction, Function<Dim2i, T> frameFunction) { public record Tab<T extends AbstractFrame>(OptionIdentifier<Void> id, Component title, Supplier<Boolean> onSelectFunction, Function<Dim2i, T> frameFunction) {
static Component idComponent(String namespace) { static Component idComponent(String namespace) {
return ComponentUtil.literal(PlatformUtil.getModName(namespace)) return ComponentUtil.literal(PLATFORM_UTIL.getModName(namespace))
//? if <1.16 { //? if <1.16 {
/*.withStyle(s -> s.setBold(true)) /*.withStyle(s -> s.setBold(true))
*///?} else *///?} else
@@ -2,17 +2,18 @@ package org.embeddedt.embeddium.impl.mixin.core;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import org.embeddedt.embeddium.impl.gl.debug.GLDebug; import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
import org.embeddedt.embeddium.impl.util.PlatformUtil;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
@Mixin(RenderSystem.class) @Mixin(RenderSystem.class)
public class RenderSystemMixin { public class RenderSystemMixin {
@Inject(method = "initRenderer", at = @At("RETURN")) @Inject(method = "initRenderer", at = @At("RETURN"))
private static void resetDebug(CallbackInfo ci) { private static void resetDebug(CallbackInfo ci) {
if (PlatformUtil.isDevelopmentEnvironment()) { if (PLATFORM_UTIL.isDevelopmentEnvironment()) {
System.setProperty("celeritas.enableGLDebug", "true"); System.setProperty("celeritas.enableGLDebug", "true");
} }
GLDebug.reloadDebugState(); GLDebug.reloadDebugState();
@@ -56,17 +56,18 @@ import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Vector3d;
import java.util.*; import java.util.*;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
/** /**
* Provides an extension to vanilla's {@link LevelRenderer}. * Provides an extension to vanilla's {@link LevelRenderer}.
*/ */
public class CeleritasWorldRenderer { public class CeleritasWorldRenderer {
private static final boolean ENABLE_BLOCKENTITY_CULLING = PlatformUtil.modPresent("valkyrienskies"); private static final boolean ENABLE_BLOCKENTITY_CULLING = PLATFORM_UTIL.modPresent("valkyrienskies");
private final Minecraft client; private final Minecraft client;
@@ -1,63 +1,61 @@
package org.embeddedt.embeddium.impl.util; package org.embeddedt.embeddium.impl.util;
import net.fabricmc.loader.api.FabricLoader;
import org.embeddedt.embeddium.impl.loader.common.EarlyLoaderServices;
import java.nio.file.Path; import java.nio.file.Path;
//? if forge { //? if forge {
import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.loading.FMLLoader; import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.fml.loading.FMLPaths;
import org.embeddedt.embeddium.compat.mc.PlatformUtilService;
public class PlatformUtil { public class PlatformUtilImpl implements PlatformUtilService {
public static boolean isLoadValid() { public boolean isLoadValid() {
return FMLLoader.getLoadingModList().getErrors().isEmpty(); return FMLLoader.getLoadingModList().getErrors().isEmpty();
} }
public static boolean modPresent(String modid) { public boolean modPresent(String modid) {
return FMLLoader.getLoadingModList().getModFileById(modid) != null; return FMLLoader.getLoadingModList().getModFileById(modid) != null;
} }
public static String getModName(String modId) { public String getModName(String modId) {
return ModList.get().getModContainerById(modId).map(container -> container.getModInfo().getDisplayName()).orElse(modId); return ModList.get().getModContainerById(modId).map(container -> container.getModInfo().getDisplayName()).orElse(modId);
} }
public static boolean isDevelopmentEnvironment() { public boolean isDevelopmentEnvironment() {
return !FMLLoader.isProduction(); return !FMLLoader.isProduction();
} }
public static Path getConfigDir() { public Path getConfigDir() {
return FMLPaths.CONFIGDIR.get(); return FMLPaths.CONFIGDIR.get();
} }
public static Path getGameDir() { public Path getGameDir() {
return FMLPaths.GAMEDIR.get(); return FMLPaths.GAMEDIR.get();
} }
} }
//?} else if fabric { //?} else if fabric {
/*public class PlatformUtil { /*public class PlatformUtilImpl implements PlatformUtilService {
public static boolean isLoadValid() { public boolean isLoadValid() {
return true; return true;
} }
public static boolean modPresent(String modid) { public boolean modPresent(String modid) {
return EarlyLoaderServices.INSTANCE.isModLoaded(modid); return EarlyLoaderServices.INSTANCE.isModLoaded(modid);
} }
public static String getModName(String modId) { public String getModName(String modId) {
return FabricLoader.getInstance().getModContainer(modId).map(c -> c.getMetadata().getName()).orElse(modId); return FabricLoader.getInstance().getModContainer(modId).map(c -> c.getMetadata().getName()).orElse(modId);
} }
public static boolean isDevelopmentEnvironment() { public boolean isDevelopmentEnvironment() {
return FabricLoader.getInstance().isDevelopmentEnvironment(); return FabricLoader.getInstance().isDevelopmentEnvironment();
} }
public static Path getConfigDir() { public Path getConfigDir() {
return FabricLoader.getInstance().getConfigDir(); return FabricLoader.getInstance().getConfigDir();
} }
public static Path getGameDir() { public Path getGameDir() {
return FabricLoader.getInstance().getGameDir(); return FabricLoader.getInstance().getGameDir();
} }
} }
@@ -66,31 +64,31 @@ public class PlatformUtil {
import net.neoforged.fml.loading.FMLLoader; import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.fml.loading.FMLPaths; import net.neoforged.fml.loading.FMLPaths;
public class PlatformUtil { public class PlatformUtilImpl implements PlatformUtilService {
public static boolean isLoadValid() { public boolean isLoadValid() {
//? if >=1.20.6 { //? if >=1.20.6 {
/^return !FMLLoader.getLoadingModList().hasErrors(); /^return !FMLLoader.getLoadingModList().hasErrors();
^///?} else ^///?} else
return FMLLoader.getLoadingModList().getErrors().isEmpty(); return FMLLoader.getLoadingModList().getErrors().isEmpty();
} }
public static boolean modPresent(String modid) { public boolean modPresent(String modid) {
return FMLLoader.getLoadingModList().getModFileById(modid) != null; return FMLLoader.getLoadingModList().getModFileById(modid) != null;
} }
public static String getModName(String modId) { public String getModName(String modId) {
return ModList.get().getModContainerById(modId).map(container -> container.getModInfo().getDisplayName()).orElse(modId); return ModList.get().getModContainerById(modId).map(container -> container.getModInfo().getDisplayName()).orElse(modId);
} }
public static boolean isDevelopmentEnvironment() { public boolean isDevelopmentEnvironment() {
return !FMLLoader.isProduction(); return !FMLLoader.isProduction();
} }
public static Path getConfigDir() { public Path getConfigDir() {
return FMLPaths.CONFIGDIR.get(); return FMLPaths.CONFIGDIR.get();
} }
public static Path getGameDir() { public Path getGameDir() {
return FMLPaths.GAMEDIR.get(); return FMLPaths.GAMEDIR.get();
} }
} }
@@ -0,0 +1 @@
org.embeddedt.embeddium.impl.util.PlatformUtilImpl
@@ -37,7 +37,6 @@ import net.minecraft.network.chat.Component;
import org.embeddedt.embeddium.impl.Celeritas; import org.embeddedt.embeddium.impl.Celeritas;
import org.embeddedt.embeddium.impl.gl.debug.GLDebug; import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
import org.embeddedt.embeddium.impl.loader.common.EarlyLoaderServices; import org.embeddedt.embeddium.impl.loader.common.EarlyLoaderServices;
import org.embeddedt.embeddium.impl.util.PlatformUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
@@ -59,6 +58,8 @@ import java.util.stream.Stream;
import java.util.zip.ZipError; import java.util.zip.ZipError;
import java.util.zip.ZipException; import java.util.zip.ZipException;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
public class Iris { public class Iris {
public static final IrisLogging logger = IrisLogging.IRIS_LOGGER; public static final IrisLogging logger = IrisLogging.IRIS_LOGGER;
@@ -67,8 +68,7 @@ public class Iris {
private static final String backupVersionNumber = "1.20.3"; private static final String backupVersionNumber = "1.20.3";
public static NamespacedId lastDimension = null; public static NamespacedId lastDimension = null;
public static boolean testing = false; public static boolean testing = false;
private static Path shaderpacksDirectory; private static ShaderpackDirectoryManager shaderpacksDirectoryManager;
private static ShaderpackDirectoryManager shaderpacksDirectoryManager;
private static ShaderPack currentPack; private static ShaderPack currentPack;
private static String currentPackName; private static String currentPackName;
private static Optional<Exception> storedError = Optional.empty(); private static Optional<Exception> storedError = Optional.empty();
@@ -235,8 +235,8 @@ public class Iris {
Path shaderPackConfigTxt; Path shaderPackConfigTxt;
try { try {
shaderPackRoot = getShaderpacksDirectory().resolve(name); shaderPackRoot = IrisCommon.getShaderpacksDirectory().resolve(name);
shaderPackConfigTxt = getShaderpacksDirectory().resolve(name + ".txt"); shaderPackConfigTxt = IrisCommon.getShaderpacksDirectory().resolve(name + ".txt");
} catch (InvalidPathException e) { } catch (InvalidPathException e) {
logger.error("Failed to load the shaderpack \"{}\" because it contains invalid characters in its path", name); logger.error("Failed to load the shaderpack \"{}\" because it contains invalid characters in its path", name);
@@ -436,7 +436,7 @@ public class Iris {
// identified as a shader pack due to it containing // identified as a shader pack due to it containing
// folders which contain "shaders" folders, this is // folders which contain "shaders" folders, this is
// necessary to check against that // necessary to check against that
if (pack.equals(getShaderpacksDirectory())) { if (pack.equals(IrisCommon.getShaderpacksDirectory())) {
return false; return false;
} }
try (Stream<Path> stream = Files.walk(pack)) { try (Stream<Path> stream = Files.walk(pack)) {
@@ -653,7 +653,7 @@ public class Iris {
ChatFormatting color; ChatFormatting color;
String version = getVersion(); String version = getVersion();
if (PlatformUtil.isDevelopmentEnvironment()) { if (PLATFORM_UTIL.isDevelopmentEnvironment()) {
color = ChatFormatting.GOLD; color = ChatFormatting.GOLD;
version = version + " (Development Environment)"; version = version + " (Development Environment)";
} else if (version.endsWith("-dirty") || version.contains("unknown") || version.endsWith("-nogit")) { } else if (version.endsWith("-dirty") || version.contains("unknown") || version.endsWith("-nogit")) {
@@ -682,17 +682,9 @@ public class Iris {
return backupVersionNumber; return backupVersionNumber;
} }
public static Path getShaderpacksDirectory() { public static ShaderpackDirectoryManager getShaderpacksDirectoryManager() {
if (shaderpacksDirectory == null) {
shaderpacksDirectory = PlatformUtil.getGameDir().resolve("shaderpacks");
}
return shaderpacksDirectory;
}
public static ShaderpackDirectoryManager getShaderpacksDirectoryManager() {
if (shaderpacksDirectoryManager == null) { if (shaderpacksDirectoryManager == null) {
shaderpacksDirectoryManager = new ShaderpackDirectoryManager(getShaderpacksDirectory()); shaderpacksDirectoryManager = new ShaderpackDirectoryManager(IrisCommon.getShaderpacksDirectory());
} }
return shaderpacksDirectoryManager; return shaderpacksDirectoryManager;
@@ -727,15 +719,15 @@ public class Iris {
DHCompat.run(); DHCompat.run();
try { try {
if (!Files.exists(getShaderpacksDirectory())) { if (!Files.exists(IrisCommon.getShaderpacksDirectory())) {
Files.createDirectories(getShaderpacksDirectory()); Files.createDirectories(IrisCommon.getShaderpacksDirectory());
} }
} catch (IOException e) { } catch (IOException e) {
logger.warn("Failed to create the shaderpacks directory!"); logger.warn("Failed to create the shaderpacks directory!");
logger.warn("", e); logger.warn("", e);
} }
irisConfig = new IrisConfig(PlatformUtil.getConfigDir().resolve(IrisConstants.MODID + "-shaders.properties")); irisConfig = new IrisConfig(PLATFORM_UTIL.getConfigDir().resolve(IrisConstants.MODID + "-shaders.properties"));
try { try {
irisConfig.initialize(); irisConfig.initialize();
@@ -4,7 +4,7 @@ import java.nio.IntBuffer;
import java.util.*; import java.util.*;
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER; import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
import static com.mitchej123.glsm.MinecraftVersionShimService.MINECRAFT_SHIM; import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import net.irisshaders.iris.Iris; import net.irisshaders.iris.Iris;
@@ -6,14 +6,14 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER; import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
import static com.mitchej123.glsm.MinecraftVersionShimService.MINECRAFT_SHIM; import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
import static org.embeddedt.embeddium.compat.dh.DHCompatService.DH_COMPAT; import static org.embeddedt.embeddium.compat.dh.DHCompatService.DH_COMPAT;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.platform.GlUtil; import com.mojang.blaze3d.platform.GlUtil;
import net.irisshaders.iris.Iris; import net.irisshaders.iris.Iris;
import net.irisshaders.iris.IrisConstants;
import net.irisshaders.iris.helpers.StringPair; import net.irisshaders.iris.helpers.StringPair;
import net.irisshaders.iris.pathways.HandRenderer;
import net.irisshaders.iris.pipeline.WorldRenderingPhase; import net.irisshaders.iris.pipeline.WorldRenderingPhase;
import net.irisshaders.iris.texture.format.TextureFormat; import net.irisshaders.iris.texture.format.TextureFormat;
import net.irisshaders.iris.texture.format.TextureFormatLoader; import net.irisshaders.iris.texture.format.TextureFormatLoader;
@@ -77,7 +77,7 @@ public class StandardMacros {
define(standardDefines, "MC_SPECULAR_MAP"); define(standardDefines, "MC_SPECULAR_MAP");
define(standardDefines, "MC_RENDER_QUALITY", "1.0"); define(standardDefines, "MC_RENDER_QUALITY", "1.0");
define(standardDefines, "MC_SHADOW_QUALITY", "1.0"); define(standardDefines, "MC_SHADOW_QUALITY", "1.0");
define(standardDefines, "MC_HAND_DEPTH", Float.toString(HandRenderer.DEPTH)); define(standardDefines, "MC_HAND_DEPTH", Float.toString(IrisConstants.DEPTH));
TextureFormat textureFormat = TextureFormatLoader.getFormat(); TextureFormat textureFormat = TextureFormatLoader.getFormat();
if (textureFormat != null) { if (textureFormat != null) {
@@ -3,6 +3,7 @@ package net.irisshaders.iris.gui.element;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import net.irisshaders.iris.Iris; import net.irisshaders.iris.Iris;
import net.irisshaders.iris.IrisCommon;
import net.irisshaders.iris.gui.FileDialogUtil; import net.irisshaders.iris.gui.FileDialogUtil;
import net.irisshaders.iris.gui.GuiUtil; import net.irisshaders.iris.gui.GuiUtil;
import net.irisshaders.iris.gui.NavigationController; import net.irisshaders.iris.gui.NavigationController;
@@ -279,7 +280,7 @@ public class ShaderPackOptionList extends IrisContainerObjectSelectionList<Shade
FileDialogUtil.fileSelectDialog( FileDialogUtil.fileSelectDialog(
FileDialogUtil.DialogType.OPEN, "Import Shader Settings from File", FileDialogUtil.DialogType.OPEN, "Import Shader Settings from File",
Iris.getShaderpacksDirectory().resolve(Iris.getCurrentPackName() + ".txt"), IrisCommon.getShaderpacksDirectory().resolve(Iris.getCurrentPackName() + ".txt"),
"Shader Pack Settings (.txt)", "*.txt") "Shader Pack Settings (.txt)", "*.txt")
.whenComplete((path, err) -> { .whenComplete((path, err) -> {
if (err != null) { if (err != null) {
@@ -315,7 +316,7 @@ public class ShaderPackOptionList extends IrisContainerObjectSelectionList<Shade
FileDialogUtil.fileSelectDialog( FileDialogUtil.fileSelectDialog(
FileDialogUtil.DialogType.SAVE, "Export Shader Settings to File", FileDialogUtil.DialogType.SAVE, "Export Shader Settings to File",
Iris.getShaderpacksDirectory().resolve(Iris.getCurrentPackName() + ".txt"), IrisCommon.getShaderpacksDirectory().resolve(Iris.getCurrentPackName() + ".txt"),
"Shader Pack Settings (.txt)", "*.txt") "Shader Pack Settings (.txt)", "*.txt")
.whenComplete((path, err) -> { .whenComplete((path, err) -> {
if (err != null) { if (err != null) {
@@ -329,7 +330,7 @@ public class ShaderPackOptionList extends IrisContainerObjectSelectionList<Shade
// Dirty way of getting the currently applied settings as a Properties, directly // Dirty way of getting the currently applied settings as a Properties, directly
// opens and copies out of the saved settings file if it is present // opens and copies out of the saved settings file if it is present
Path sourceTxtPath = Iris.getShaderpacksDirectory().resolve(Iris.getCurrentPackName() + ".txt"); Path sourceTxtPath = IrisCommon.getShaderpacksDirectory().resolve(Iris.getCurrentPackName() + ".txt");
if (Files.exists(sourceTxtPath)) { if (Files.exists(sourceTxtPath)) {
try (InputStream in = Files.newInputStream(sourceTxtPath)) { try (InputStream in = Files.newInputStream(sourceTxtPath)) {
toSave.load(in); toSave.load(in);
@@ -1,6 +1,7 @@
package net.irisshaders.iris.gui.element; package net.irisshaders.iris.gui.element;
import net.irisshaders.iris.Iris; import net.irisshaders.iris.Iris;
import net.irisshaders.iris.IrisCommon;
import net.irisshaders.iris.gui.GuiUtil; import net.irisshaders.iris.gui.GuiUtil;
import net.irisshaders.iris.gui.screen.ShaderPackScreen; import net.irisshaders.iris.gui.screen.ShaderPackScreen;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
@@ -48,7 +49,7 @@ public class ShaderPackSelectionList extends IrisObjectSelectionList<ShaderPackS
this.topButtonRow = new TopButtonRowEntry(this, Iris.getIrisConfig().areShadersEnabled()); this.topButtonRow = new TopButtonRowEntry(this, Iris.getIrisConfig().areShadersEnabled());
try { try {
watcher1 = FileSystems.getDefault().newWatchService(); watcher1 = FileSystems.getDefault().newWatchService();
key1 = Iris.getShaderpacksDirectory().register(watcher1, key1 = IrisCommon.getShaderpacksDirectory().register(watcher1,
StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_CREATE,
StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_MODIFY,
StandardWatchEventKinds.ENTRY_DELETE); StandardWatchEventKinds.ENTRY_DELETE);
@@ -2,12 +2,7 @@ package net.irisshaders.iris.gui.option;
import net.irisshaders.iris.Iris; import net.irisshaders.iris.Iris;
import net.irisshaders.iris.pathways.colorspace.ColorSpace; import net.irisshaders.iris.pathways.colorspace.ColorSpace;
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
import net.minecraft.client.OptionInstance;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.network.chat.Component;
import java.io.IOException;
public class IrisVideoSettings { public class IrisVideoSettings {
public static int shadowDistance = 32; public static int shadowDistance = 32;
@@ -24,7 +24,6 @@ import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.util.FormattedCharSequence; import net.minecraft.util.FormattedCharSequence;
import org.embeddedt.embeddium.impl.util.PlatformUtil;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
@@ -42,6 +41,9 @@ import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
public class ShaderPackScreen extends Screen implements HudHideable { public class ShaderPackScreen extends Screen implements HudHideable {
/** /**
* Queue rendering to happen on top of all elements. Useful for tooltips or dialogs. * Queue rendering to happen on top of all elements. Useful for tooltips or dialogs.
@@ -80,7 +82,7 @@ public class ShaderPackScreen extends Screen implements HudHideable {
String irisName = IrisConstants.MODNAME + " " + Iris.getVersion(); String irisName = IrisConstants.MODNAME + " " + Iris.getVersion();
if (PlatformUtil.isDevelopmentEnvironment()) { if (PLATFORM_UTIL.isDevelopmentEnvironment()) {
this.developmentComponent = Component.literal("Development Environment").withStyle(ChatFormatting.GOLD); this.developmentComponent = Component.literal("Development Environment").withStyle(ChatFormatting.GOLD);
} }
@@ -1,9 +1,8 @@
package net.irisshaders.iris.pathways; package net.irisshaders.iris.pathways;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import net.irisshaders.iris.IrisConstants;
import net.irisshaders.iris.versionutils.ModelTranslucencyHelper; import net.irisshaders.iris.versionutils.ModelTranslucencyHelper;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import net.irisshaders.batchedentityrendering.impl.FullyBufferedMultiBufferSource; import net.irisshaders.batchedentityrendering.impl.FullyBufferedMultiBufferSource;
@@ -15,8 +14,6 @@ import net.irisshaders.iris.uniforms.CapturedRenderingState;
import net.minecraft.client.Camera; import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
@@ -24,14 +21,10 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.level.GameType; import net.minecraft.world.level.GameType;
import org.joml.Matrix4f;
import java.util.function.BooleanSupplier;
public class HandRenderer { public class HandRenderer {
public static final HandRenderer INSTANCE = new HandRenderer(); public static final HandRenderer INSTANCE = new HandRenderer();
public static final float DEPTH = 0.125F; private final FullyBufferedMultiBufferSource bufferSource = new FullyBufferedMultiBufferSource();
private final FullyBufferedMultiBufferSource bufferSource = new FullyBufferedMultiBufferSource();
private boolean ACTIVE; private boolean ACTIVE;
private boolean renderingSolid; private boolean renderingSolid;
@@ -39,7 +32,7 @@ public class HandRenderer {
final PoseStack.Pose pose = poseStack.last(); final PoseStack.Pose pose = poseStack.last();
// We need to scale the matrix by 0.125 so the hand doesn't clip through blocks. // We need to scale the matrix by 0.125 so the hand doesn't clip through blocks.
Matrix4f scaleMatrix = new Matrix4f().scale(1F, 1F, DEPTH); Matrix4f scaleMatrix = new Matrix4f().scale(1F, 1F, IrisConstants.DEPTH);
scaleMatrix.mul(gameRenderer.getProjectionMatrix(((GameRendererAccessor) gameRenderer).invokeGetFov(camera, tickDelta, false))); scaleMatrix.mul(gameRenderer.getProjectionMatrix(((GameRendererAccessor) gameRenderer).invokeGetFov(camera, tickDelta, false)));
gameRenderer.resetProjectionMatrix(scaleMatrix); gameRenderer.resetProjectionMatrix(scaleMatrix);
@@ -2,10 +2,7 @@ package net.irisshaders.iris.pipeline;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration; import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexType;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.gl.blending.AlphaTest; import net.irisshaders.iris.gl.blending.AlphaTest;
import net.irisshaders.iris.gl.blending.AlphaTests; import net.irisshaders.iris.gl.blending.AlphaTests;
import net.irisshaders.iris.gl.blending.BlendModeOverride; import net.irisshaders.iris.gl.blending.BlendModeOverride;
@@ -16,15 +13,12 @@ import net.irisshaders.iris.gl.program.ProgramSamplers;
import net.irisshaders.iris.gl.program.ProgramUniforms; import net.irisshaders.iris.gl.program.ProgramUniforms;
import net.irisshaders.iris.gl.state.FogMode; import net.irisshaders.iris.gl.state.FogMode;
import net.irisshaders.iris.gl.state.ShaderAttributeInputs; import net.irisshaders.iris.gl.state.ShaderAttributeInputs;
import net.irisshaders.iris.gl.texture.TextureType;
import net.irisshaders.iris.helpers.Tri;
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge; import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
import net.irisshaders.iris.pipeline.transform.PatchShaderType; import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.ShaderPrinter; import net.irisshaders.iris.pipeline.transform.ShaderPrinter;
import net.irisshaders.iris.shaderpack.loading.ProgramId; import net.irisshaders.iris.shaderpack.loading.ProgramId;
import net.irisshaders.iris.shaderpack.programs.ProgramSet; import net.irisshaders.iris.shaderpack.programs.ProgramSet;
import net.irisshaders.iris.shaderpack.programs.ProgramSource; import net.irisshaders.iris.shaderpack.programs.ProgramSource;
import net.irisshaders.iris.shaderpack.texture.TextureStage;
import net.irisshaders.iris.targets.RenderTargets; import net.irisshaders.iris.targets.RenderTargets;
import net.irisshaders.iris.uniforms.CommonUniforms; import net.irisshaders.iris.uniforms.CommonUniforms;
import net.irisshaders.iris.uniforms.builtin.BuiltinReplacementUniforms; import net.irisshaders.iris.uniforms.builtin.BuiltinReplacementUniforms;
@@ -5,7 +5,6 @@ import com.google.gson.Gson;
import net.irisshaders.iris.Iris; import net.irisshaders.iris.Iris;
import net.irisshaders.iris.pipeline.transform.PatchShaderType; import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.binary.Hex;
import org.embeddedt.embeddium.impl.util.PlatformUtil;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
@@ -26,13 +25,15 @@ import java.util.function.Supplier;
import java.util.zip.DeflaterOutputStream; import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream; import java.util.zip.InflaterInputStream;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
public class ShaderTransformationDiskCache { public class ShaderTransformationDiskCache {
/** /**
* This value must be incremented whenever a new version of Cornea is published with updated transformers. * This value must be incremented whenever a new version of Cornea is published with updated transformers.
*/ */
private static final int TRANSFORMER_VERSION = 1; private static final int TRANSFORMER_VERSION = 1;
private static final Path SHADER_CACHE_PATH = PlatformUtil.getGameDir().resolve("cornea_transform_cache"); private static final Path SHADER_CACHE_PATH = PLATFORM_UTIL.getGameDir().resolve("cornea_transform_cache");
private static final MessageDigest DIGEST; private static final MessageDigest DIGEST;
@@ -24,8 +24,6 @@ import net.irisshaders.iris.uniforms.VanillaUniforms;
import net.irisshaders.iris.uniforms.builtin.BuiltinReplacementUniforms; import net.irisshaders.iris.uniforms.builtin.BuiltinReplacementUniforms;
import net.irisshaders.iris.uniforms.custom.CustomUniforms; import net.irisshaders.iris.uniforms.custom.CustomUniforms;
import net.minecraft.Util; import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackResources; import net.minecraft.server.packs.PackResources;
import net.minecraft.server.packs.PathPackResources; import net.minecraft.server.packs.PathPackResources;
@@ -37,7 +35,6 @@ import net.minecraft.server.packs.repository.PackSource;
import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceProvider; import net.minecraft.server.packs.resources.ResourceProvider;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.embeddedt.embeddium.impl.util.PlatformUtil;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
@@ -45,13 +42,14 @@ import java.io.InputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException; import java.util.concurrent.CompletionException;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.function.Supplier; import java.util.function.Supplier;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
public class ShaderCreator { public class ShaderCreator {
public static CompletableFuture<ExtendedShader> create(WorldRenderingPipeline pipeline, Executor syncExecutor, String name, ProgramSource source, ProgramId programId, GlFramebuffer writingToBeforeTranslucent, public static CompletableFuture<ExtendedShader> create(WorldRenderingPipeline pipeline, Executor syncExecutor, String name, ProgramSource source, ProgramId programId, GlFramebuffer writingToBeforeTranslucent,
GlFramebuffer writingToAfterTranslucent, AlphaTest fallbackAlpha, GlFramebuffer writingToAfterTranslucent, AlphaTest fallbackAlpha,
@@ -240,7 +238,7 @@ public class ShaderCreator {
//? if >=1.20.6 { //? if >=1.20.6 {
/*return new PathPackResources(new PackLocationInfo("<iris shaderpack shaders>", Component.literal("iris"), PackSource.BUILT_IN, Optional.of(new KnownPack("iris", "shader", "1.0"))), PlatformUtil.getConfigDir()); /*return new PathPackResources(new PackLocationInfo("<iris shaderpack shaders>", Component.literal("iris"), PackSource.BUILT_IN, Optional.of(new KnownPack("iris", "shader", "1.0"))), PlatformUtil.getConfigDir());
*///?} else *///?} else
return new PathPackResources("<iris shaderpack shaders>", PlatformUtil.getConfigDir(), true); return new PathPackResources("<iris shaderpack shaders>", PLATFORM_UTIL.getConfigDir(), true);
} }
private StringResource(ResourceLocation id, String content) { private StringResource(ResourceLocation id, String content) {
@@ -2,7 +2,6 @@ package net.irisshaders.iris.pipeline.transform;
import net.irisshaders.iris.Iris; import net.irisshaders.iris.Iris;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.embeddedt.embeddium.impl.util.PlatformUtil;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@@ -12,11 +11,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Stream; import java.util.stream.Stream;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
/** /**
* Static class that deals with printing the patched_shader folder. * Static class that deals with printing the patched_shader folder.
*/ */
public class ShaderPrinter { public class ShaderPrinter {
private static final Path debugOutDir = PlatformUtil.getGameDir().resolve("patched_shaders"); private static final Path debugOutDir = PLATFORM_UTIL.getGameDir().resolve("patched_shaders");
private static boolean outputLocationCleared = false; private static boolean outputLocationCleared = false;
private static int programCounter = 0; private static int programCounter = 0;
@@ -3,6 +3,7 @@ package net.irisshaders.iris.samplers;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import net.irisshaders.iris.IrisConstants;
import net.irisshaders.iris.gl.image.GlImage; import net.irisshaders.iris.gl.image.GlImage;
import net.irisshaders.iris.gl.sampler.GlSampler; import net.irisshaders.iris.gl.sampler.GlSampler;
import net.irisshaders.iris.gl.sampler.SamplerHolder; import net.irisshaders.iris.gl.sampler.SamplerHolder;
@@ -11,7 +12,6 @@ import net.irisshaders.iris.gl.texture.TextureAccess;
import net.irisshaders.iris.gl.texture.TextureType; import net.irisshaders.iris.gl.texture.TextureType;
import net.irisshaders.iris.pipeline.WorldRenderingPipeline; import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
import net.irisshaders.iris.shaderpack.properties.PackRenderTargetDirectives; import net.irisshaders.iris.shaderpack.properties.PackRenderTargetDirectives;
import net.irisshaders.iris.shaderpack.properties.PackShadowDirectives;
import net.irisshaders.iris.shadows.ShadowRenderTargets; import net.irisshaders.iris.shadows.ShadowRenderTargets;
import net.irisshaders.iris.targets.RenderTarget; import net.irisshaders.iris.targets.RenderTarget;
import net.irisshaders.iris.targets.RenderTargets; import net.irisshaders.iris.targets.RenderTargets;
@@ -109,7 +109,7 @@ public class IrisSamplers {
ImmutableList.Builder<String> shadowSamplers = ImmutableList.<String>builder().add("shadowtex0", "shadowtex0DH", "shadowtex0HW", "shadowtex1", "shadowtex1HW", "shadowtex1DH", "shadow", "watershadow", ImmutableList.Builder<String> shadowSamplers = ImmutableList.<String>builder().add("shadowtex0", "shadowtex0DH", "shadowtex0HW", "shadowtex1", "shadowtex1HW", "shadowtex1DH", "shadow", "watershadow",
"shadowcolor"); "shadowcolor");
for (int i = 0; i < PackShadowDirectives.MAX_SHADOW_COLOR_BUFFERS_IRIS; i++) { for (int i = 0; i < IrisConstants.MAX_SHADOW_COLOR_BUFFERS_IRIS; i++) {
shadowSamplers.add("shadowcolor" + i); shadowSamplers.add("shadowcolor" + i);
shadowSamplers.add("shadowcolorimg" + i); shadowSamplers.add("shadowcolorimg" + i);
} }
@@ -18,7 +18,6 @@ import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
import net.irisshaders.iris.shaderpack.option.OrderBackedProperties; import net.irisshaders.iris.shaderpack.option.OrderBackedProperties;
import net.irisshaders.iris.shaderpack.option.ShaderPackOptions; import net.irisshaders.iris.shaderpack.option.ShaderPackOptions;
import net.irisshaders.iris.shaderpack.preprocessor.PropertiesPreprocessor; import net.irisshaders.iris.shaderpack.preprocessor.PropertiesPreprocessor;
import org.embeddedt.embeddium.impl.util.PlatformUtil;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@@ -30,6 +29,8 @@ import java.nio.file.NoSuchFileException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.*; import java.util.*;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
/** /**
* A utility class for parsing entries in item.properties, block.properties, and entities.properties files in shaderpacks * A utility class for parsing entries in item.properties, block.properties, and entities.properties files in shaderpacks
*/ */
@@ -108,7 +109,7 @@ public class IdMap {
if (Iris.getIrisConfig().areDebugOptionsEnabled()) { if (Iris.getIrisConfig().areDebugOptionsEnabled()) {
ShaderPrinter.deleteIfClearing(); ShaderPrinter.deleteIfClearing();
try (OutputStream os = Files.newOutputStream(PlatformUtil.getGameDir().resolve("patched_shaders").resolve(name))) { try (OutputStream os = Files.newOutputStream(PLATFORM_UTIL.getGameDir().resolve("patched_shaders").resolve(name))) {
properties.store(new OutputStreamWriter(os, StandardCharsets.UTF_8), "Patched version of properties"); properties.store(new OutputStreamWriter(os, StandardCharsets.UTF_8), "Patched version of properties");
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@@ -1,6 +1,7 @@
package net.irisshaders.iris.shaderpack.discovery; package net.irisshaders.iris.shaderpack.discovery;
import net.irisshaders.iris.Iris; import net.irisshaders.iris.Iris;
import net.irisshaders.iris.IrisCommon;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
@@ -39,7 +40,7 @@ public class ShaderpackDirectoryManager {
} }
public void copyPackIntoDirectory(String name, Path source) throws IOException { public void copyPackIntoDirectory(String name, Path source) throws IOException {
Path target = Iris.getShaderpacksDirectory().resolve(name); Path target = IrisCommon.getShaderpacksDirectory().resolve(name);
// Copy the pack file into the shaderpacks folder. // Copy the pack file into the shaderpacks folder.
Files.copy(source, target); Files.copy(source, target);
@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.irisshaders.iris.Iris; import net.irisshaders.iris.Iris;
import net.irisshaders.iris.IrisConstants;
import net.irisshaders.iris.gl.texture.InternalTextureFormat; import net.irisshaders.iris.gl.texture.InternalTextureFormat;
import net.irisshaders.iris.helpers.OptionalBoolean; import net.irisshaders.iris.helpers.OptionalBoolean;
import net.irisshaders.iris.shaderpack.parsing.DirectiveHolder; import net.irisshaders.iris.shaderpack.parsing.DirectiveHolder;
@@ -12,13 +13,8 @@ import org.joml.Vector4f;
import java.util.Optional; import java.util.Optional;
public class PackShadowDirectives { public class PackShadowDirectives {
// Bump this up if you want more shadow color buffers!
// This is currently set at 2 for ShadersMod / OptiFine parity but can theoretically be bumped up to 8.
// TODO: Make this configurable?
public static final int MAX_SHADOW_COLOR_BUFFERS_IRIS = 8;
public static final int MAX_SHADOW_COLOR_BUFFERS_OF = 2;
private final OptionalBoolean shadowEnabled; private final OptionalBoolean shadowEnabled;
private final OptionalBoolean dhShadowEnabled; private final OptionalBoolean dhShadowEnabled;
private final boolean shouldRenderTerrain; private final boolean shouldRenderTerrain;
private final boolean shouldRenderTranslucent; private final boolean shouldRenderTranslucent;
@@ -330,7 +326,7 @@ public class PackShadowDirectives {
} }
private void acceptBufferDirectives(DirectiveHolder directives, Int2ObjectMap<SamplingSettings> settings) { private void acceptBufferDirectives(DirectiveHolder directives, Int2ObjectMap<SamplingSettings> settings) {
for (int i = 0; i < PackShadowDirectives.MAX_SHADOW_COLOR_BUFFERS_IRIS; i++) { for (int i = 0; i < IrisConstants.MAX_SHADOW_COLOR_BUFFERS_IRIS; i++) {
String bufferName = "shadowcolor" + i; String bufferName = "shadowcolor" + i;
int finalI = i; int finalI = i;
directives.acceptConstStringDirective(bufferName + "Format", format -> { directives.acceptConstStringDirective(bufferName + "Format", format -> {
@@ -31,7 +31,6 @@ import net.irisshaders.iris.shaderpack.option.ShaderPackOptions;
import net.irisshaders.iris.shaderpack.preprocessor.PropertiesPreprocessor; import net.irisshaders.iris.shaderpack.preprocessor.PropertiesPreprocessor;
import net.irisshaders.iris.shaderpack.texture.TextureStage; import net.irisshaders.iris.shaderpack.texture.TextureStage;
import net.irisshaders.iris.uniforms.custom.CustomUniforms; import net.irisshaders.iris.uniforms.custom.CustomUniforms;
import org.embeddedt.embeddium.impl.util.PlatformUtil;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
@@ -49,6 +48,8 @@ import java.util.Properties;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
/** /**
* The parsed representation of the shaders.properties file. This class is not meant to be stored permanently, rather * The parsed representation of the shaders.properties file. This class is not meant to be stored permanently, rather
* it merely exists as an intermediate step until we build up PackDirectives and ProgramDirectives objects from the * it merely exists as an intermediate step until we build up PackDirectives and ProgramDirectives objects from the
@@ -126,8 +127,8 @@ public class ShaderProperties {
if (Iris.getIrisConfig().areDebugOptionsEnabled()) { if (Iris.getIrisConfig().areDebugOptionsEnabled()) {
try { try {
Files.writeString(PlatformUtil.getGameDir().resolve("preprocessed.properties"), preprocessedContents); Files.writeString(PLATFORM_UTIL.getGameDir().resolve("preprocessed.properties"), preprocessedContents);
Files.writeString(PlatformUtil.getGameDir().resolve("original.properties"), contents); Files.writeString(PLATFORM_UTIL.getGameDir().resolve("original.properties"), contents);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@@ -3,6 +3,7 @@ package net.irisshaders.iris.shadows;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
import net.irisshaders.iris.IrisConstants;
import net.irisshaders.iris.features.FeatureFlags; import net.irisshaders.iris.features.FeatureFlags;
import net.irisshaders.iris.gl.IrisRenderSystem; import net.irisshaders.iris.gl.IrisRenderSystem;
import net.irisshaders.iris.gl.framebuffer.GlFramebuffer; import net.irisshaders.iris.gl.framebuffer.GlFramebuffer;
@@ -42,7 +43,7 @@ public class ShadowRenderTargets {
public ShadowRenderTargets(WorldRenderingPipeline pipeline, int resolution, PackShadowDirectives shadowDirectives) { public ShadowRenderTargets(WorldRenderingPipeline pipeline, int resolution, PackShadowDirectives shadowDirectives) {
this.pipeline = pipeline; this.pipeline = pipeline;
this.shadowDirectives = shadowDirectives; this.shadowDirectives = shadowDirectives;
this.size = pipeline.hasFeature(FeatureFlags.HIGHER_SHADOWCOLOR) ? PackShadowDirectives.MAX_SHADOW_COLOR_BUFFERS_IRIS : PackShadowDirectives.MAX_SHADOW_COLOR_BUFFERS_OF; this.size = pipeline.hasFeature(FeatureFlags.HIGHER_SHADOWCOLOR) ? IrisConstants.MAX_SHADOW_COLOR_BUFFERS_IRIS : IrisConstants.MAX_SHADOW_COLOR_BUFFERS_OF;
targets = new RenderTarget[size]; targets = new RenderTarget[size];
formats = new InternalTextureFormat[size]; formats = new InternalTextureFormat[size];
flipped = new boolean[size]; flipped = new boolean[size];
@@ -1,10 +1,10 @@
package org.embeddedt.embeddium.impl; package org.embeddedt.embeddium.impl;
import com.mitchej123.glsm.MinecraftVersionShimService; import org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import org.embeddedt.embeddium.impl.loader.common.EarlyLoaderServices; import org.embeddedt.embeddium.impl.loader.common.EarlyLoaderServices;
public class MinecraftModernVersionShim implements MinecraftVersionShimService { public class MinecraftModernVersionShimImpl implements MinecraftVersionShimService {
@Override @Override
public boolean getSmartCull() { public boolean getSmartCull() {
return Minecraft.getInstance().smartCull; return Minecraft.getInstance().smartCull;
@@ -1 +0,0 @@
org.embeddedt.embeddium.impl.MinecraftModernVersionShim
@@ -0,0 +1 @@
org.embeddedt.embeddium.impl.MinecraftModernVersionShimImpl