more-shader-refactors #11
No files matched your search
@@ -1,12 +1,145 @@
|
||||
package net.irisshaders.iris;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import com.google.common.base.Throwables;
|
||||
import lombok.Getter;
|
||||
import net.irisshaders.iris.config.IrisConfig;
|
||||
import net.irisshaders.iris.gl.shader.StandardMacros;
|
||||
import net.irisshaders.iris.helpers.OptionalBoolean;
|
||||
import net.irisshaders.iris.pipeline.PipelineManager;
|
||||
import net.irisshaders.iris.shaderpack.DimensionId;
|
||||
import net.irisshaders.iris.shaderpack.ShaderPack;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.irisshaders.iris.shaderpack.option.OptionSet;
|
||||
import net.irisshaders.iris.shaderpack.option.Profile;
|
||||
import net.irisshaders.iris.shaderpack.option.values.MutableOptionValues;
|
||||
import net.irisshaders.iris.shaderpack.option.values.OptionValues;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.taumc.celeritas.api.v0.CeleritasShadersApi;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipError;
|
||||
import java.util.zip.ZipException;
|
||||
|
||||
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
||||
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
|
||||
|
||||
public class IrisCommon {
|
||||
|
||||
public static final float DEGREES_TO_RADIANS = (float)Math.PI / 180.0F;
|
||||
private static Path shaderpacksDirectory;
|
||||
private static final Map<String, String> shaderPackOptionQueue = new HashMap<>();
|
||||
@Getter private static IrisConfig irisConfig;
|
||||
private static ShaderPack currentPack;
|
||||
private static boolean initialized;
|
||||
private static boolean renderSystemInit = false;
|
||||
public static NamespacedId lastDimension = null;
|
||||
private static PipelineManager pipelineManager;
|
||||
private static Optional<Exception> storedError = Optional.empty();
|
||||
|
||||
|
||||
private static boolean loadPackWhenPossible = false;
|
||||
|
||||
public static void loadShaderpackWhenPossible() {
|
||||
loadPackWhenPossible = true;
|
||||
}
|
||||
|
||||
|
||||
public static Optional<Exception> getStoredError() {
|
||||
return storedError;
|
||||
}
|
||||
|
||||
public static void setStoredError(Optional<Exception> error) {
|
||||
storedError = error;
|
||||
}
|
||||
|
||||
public static boolean isFallback() {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
public static void setFallback(boolean fallback) {
|
||||
IrisCommon.fallback = fallback;
|
||||
}
|
||||
|
||||
// Flag variable used when reloading
|
||||
// Used in favor of queueDefaultShaderPackOptionValues() for resetting as the
|
||||
// behavior is more concrete and therefore is more likely to repair a user's issues
|
||||
private static boolean resetShaderPackOptions = false;
|
||||
static FileSystem zipFileSystem;
|
||||
static boolean fallback;
|
||||
static String currentPackName;
|
||||
|
||||
/**
|
||||
* Called once RenderSystem#initRenderer has completed. This means that we can safely access OpenGL.
|
||||
*/
|
||||
public static void onRenderSystemInit() {
|
||||
if (!initialized) {
|
||||
IRIS_LOGGER.warn("Iris::onRenderSystemInit was called, but Iris::onEarlyInitialize was not called." +
|
||||
" Trying to avoid a crash but this is an odd state.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
renderSystemInit = true;
|
||||
|
||||
|
||||
CeleritasShadersApi.getInstance().onRenderSystemInit();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called very early on in Minecraft initialization. At this point we *cannot* safely access OpenGL, but we can do
|
||||
* some very basic setup, config loading, and environment checks.
|
||||
*
|
||||
* <p>This is roughly equivalent to Fabric Loader's ClientModInitializer#onInitializeClient entrypoint, except
|
||||
* it's entirely cross platform & we get to decide its exact semantics.</p>
|
||||
*
|
||||
* <p>This is called right before options are loaded, so we can add key bindings here.</p>
|
||||
*/
|
||||
public static void onEarlyInitialize() {
|
||||
|
||||
try {
|
||||
if (!Files.exists(IrisCommon.getShaderpacksDirectory())) {
|
||||
Files.createDirectories(IrisCommon.getShaderpacksDirectory());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
IRIS_LOGGER.warn("Failed to create the shaderpacks directory!");
|
||||
IRIS_LOGGER.warn("", e);
|
||||
}
|
||||
|
||||
irisConfig = new IrisConfig(PLATFORM_UTIL.getConfigDir().resolve(IrisConstants.MODID + "-shaders.properties"));
|
||||
|
||||
try {
|
||||
IrisCommon.getIrisConfig().initialize();
|
||||
} catch (IOException e) {
|
||||
IRIS_LOGGER.error("Failed to initialize Iris configuration, default values will be used instead");
|
||||
IRIS_LOGGER.error("", e);
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
CeleritasShadersApi.getInstance().onEarlyInitialize();
|
||||
}
|
||||
public static void onLoadingComplete() {
|
||||
if (!initialized) {
|
||||
IRIS_LOGGER.warn("Iris::onLoadingComplete was called, but Iris::onEarlyInitialize was not called." +
|
||||
" Trying to avoid a crash but this is an odd state.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize the pipeline now so that we don't increase world loading time. Just going to guess that
|
||||
// the player is in the overworld.
|
||||
// See: https://github.com/IrisShaders/Iris/issues/323
|
||||
lastDimension = DimensionId.OVERWORLD;
|
||||
|
||||
CeleritasShadersApi.getInstance().onLoadingComplete();
|
||||
}
|
||||
|
||||
public static Path getShaderpacksDirectory() {
|
||||
if (shaderpacksDirectory == null) {
|
||||
@@ -15,4 +148,351 @@ public class IrisCommon {
|
||||
|
||||
return shaderpacksDirectory;
|
||||
}
|
||||
|
||||
public static boolean isValidShaderpack(Path pack) {
|
||||
if (Files.isDirectory(pack)) {
|
||||
// Sometimes the shaderpack directory itself can be
|
||||
// identified as a shader pack due to it containing
|
||||
// folders which contain "shaders" folders, this is
|
||||
// necessary to check against that
|
||||
if (pack.equals(getShaderpacksDirectory())) {
|
||||
return false;
|
||||
}
|
||||
try (Stream<Path> stream = Files.walk(pack)) {
|
||||
return stream
|
||||
.filter(Files::isDirectory)
|
||||
// Prevent a pack simply named "shaders" from being
|
||||
// identified as a valid pack
|
||||
.filter(path -> !path.equals(pack))
|
||||
.anyMatch(path -> path.endsWith("shaders"));
|
||||
} catch (IOException ignored) {
|
||||
// ignored, not a valid shader pack.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (pack.toString().endsWith(".zip")) {
|
||||
try (FileSystem zipSystem = FileSystems.newFileSystem(pack, IrisCommon.class.getClassLoader())) {
|
||||
Path root = zipSystem.getRootDirectories().iterator().next();
|
||||
try (Stream<Path> stream = Files.walk(root)) {
|
||||
return stream
|
||||
.filter(Files::isDirectory)
|
||||
.anyMatch(path -> path.endsWith("shaders"));
|
||||
}
|
||||
} catch (ZipError zipError) {
|
||||
// Java 8 seems to throw a ZipError instead of a subclass of IOException
|
||||
IRIS_LOGGER.warn("The ZIP at " + pack + " is corrupt");
|
||||
} catch (IOException ignored) {
|
||||
// ignored, not a valid shader pack.
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Map<String, String> getShaderPackOptionQueue() {
|
||||
return shaderPackOptionQueue;
|
||||
}
|
||||
|
||||
public static void queueShaderPackOptionsFromProfile(Profile profile) {
|
||||
getShaderPackOptionQueue().putAll(profile.optionValues);
|
||||
}
|
||||
|
||||
public static void queueShaderPackOptionsFromProperties(Properties properties) {
|
||||
queueDefaultShaderPackOptionValues();
|
||||
|
||||
properties.stringPropertyNames().forEach(key ->
|
||||
getShaderPackOptionQueue().put(key, properties.getProperty(key)));
|
||||
}
|
||||
|
||||
// Used in favor of resetShaderPackOptions as the aforementioned requires the pack to be reloaded
|
||||
public static void queueDefaultShaderPackOptionValues() {
|
||||
clearShaderPackOptionQueue();
|
||||
|
||||
getCurrentPack().ifPresent(pack -> {
|
||||
OptionSet options = pack.getShaderPackOptions().getOptionSet();
|
||||
OptionValues values = pack.getShaderPackOptions().getOptionValues();
|
||||
|
||||
options.getStringOptions().forEach((key, mOpt) -> {
|
||||
if (values.getStringValue(key).isPresent()) {
|
||||
getShaderPackOptionQueue().put(key, mOpt.getOption().getDefaultValue());
|
||||
}
|
||||
});
|
||||
options.getBooleanOptions().forEach((key, mOpt) -> {
|
||||
if (values.getBooleanValue(key) != OptionalBoolean.DEFAULT) {
|
||||
getShaderPackOptionQueue().put(key, Boolean.toString(mOpt.getOption().getDefaultValue()));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static void clearShaderPackOptionQueue() {
|
||||
getShaderPackOptionQueue().clear();
|
||||
}
|
||||
|
||||
public static void resetShaderPackOptionsOnNextReload() {
|
||||
resetShaderPackOptions = true;
|
||||
}
|
||||
|
||||
public static void clearResetShaderPackOptions() {
|
||||
resetShaderPackOptions = false;
|
||||
}
|
||||
|
||||
public static boolean shouldResetShaderPackOptionsOnNextReload() {
|
||||
return resetShaderPackOptions;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Optional<ShaderPack> getCurrentPack() {
|
||||
return Optional.ofNullable(currentPack);
|
||||
}
|
||||
|
||||
static Optional<Path> loadExternalZipShaderpack(Path shaderpackPath) throws IOException {
|
||||
FileSystem zipSystem = FileSystems.newFileSystem(shaderpackPath, IrisCommon.class.getClassLoader());
|
||||
IrisCommon.zipFileSystem = zipSystem;
|
||||
|
||||
// Should only be one root directory for a zip shaderpack
|
||||
Path root = zipSystem.getRootDirectories().iterator().next();
|
||||
|
||||
Path potentialShaderDir = zipSystem.getPath("shaders");
|
||||
|
||||
// If the shaders dir was immediately found return it
|
||||
// Otherwise, manually search through each directory path until it ends with "shaders"
|
||||
if (Files.exists(potentialShaderDir)) {
|
||||
return Optional.of(potentialShaderDir);
|
||||
}
|
||||
|
||||
// Sometimes shaderpacks have their shaders directory within another folder in the shaderpack
|
||||
// For example Sildurs-Vibrant-Shaders.zip/shaders
|
||||
// While other packs have Trippy-Shaderpack-master.zip/Trippy-Shaderpack-master/shaders
|
||||
// This makes it hard to determine what is the actual shaders dir
|
||||
try (Stream<Path> stream = Files.walk(root)) {
|
||||
return stream
|
||||
.filter(Files::isDirectory)
|
||||
.filter(path -> path.endsWith("shaders"))
|
||||
.findFirst();
|
||||
}
|
||||
}
|
||||
|
||||
static Optional<Properties> tryReadConfigProperties(Path path) {
|
||||
Properties properties = new Properties();
|
||||
|
||||
if (Files.exists(path)) {
|
||||
try (InputStream is = Files.newInputStream(path)) {
|
||||
// NB: config properties are specified to be encoded with ISO-8859-1 by OptiFine,
|
||||
// so we don't need to do the UTF-8 workaround here.
|
||||
properties.load(is);
|
||||
} catch (IOException e) {
|
||||
// TODO: Better error handling
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.of(properties);
|
||||
}
|
||||
|
||||
static void tryUpdateConfigPropertiesFile(Path path, Properties properties) {
|
||||
try {
|
||||
if (properties.isEmpty()) {
|
||||
// Delete the file or don't create it if there are no changed configs
|
||||
if (Files.exists(path)) {
|
||||
Files.delete(path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try (OutputStream out = Files.newOutputStream(path)) {
|
||||
properties.store(out, null);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO: Better error handling
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadShaderpack() {
|
||||
if (getIrisConfig() == null) {
|
||||
if (!initialized) {
|
||||
throw new IllegalStateException("Iris::loadShaderpack was called, but Iris::onInitializeClient wasn't" +
|
||||
" called yet. How did this happen?");
|
||||
} else {
|
||||
throw new NullPointerException("Iris.irisConfig was null unexpectedly");
|
||||
}
|
||||
}
|
||||
|
||||
if (!getIrisConfig().areShadersEnabled()) {
|
||||
IRIS_LOGGER.info("Shaders are disabled because enableShaders is set to false in iris.properties");
|
||||
|
||||
setShadersDisabled();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Attempt to load an external shaderpack if it is available
|
||||
Optional<String> externalName = getIrisConfig().getShaderPackName();
|
||||
|
||||
if (externalName.isEmpty()) {
|
||||
IRIS_LOGGER.info("Shaders are disabled because no valid shaderpack is selected");
|
||||
|
||||
setShadersDisabled();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!loadExternalShaderpack(externalName.get())) {
|
||||
IRIS_LOGGER.warn("Falling back to normal rendering without shaders because the shaderpack could not be loaded");
|
||||
setShadersDisabled();
|
||||
fallback = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void setShadersDisabled() {
|
||||
currentPack = null;
|
||||
fallback = false;
|
||||
currentPackName = "(off)";
|
||||
|
||||
IRIS_LOGGER.info("Shaders are disabled");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static boolean loadExternalShaderpack(String name) {
|
||||
Path shaderPackRoot;
|
||||
Path shaderPackConfigTxt;
|
||||
|
||||
try {
|
||||
shaderPackRoot = getShaderpacksDirectory().resolve(name);
|
||||
shaderPackConfigTxt = getShaderpacksDirectory().resolve(name + ".txt");
|
||||
} catch (InvalidPathException e) {
|
||||
IRIS_LOGGER.error("Failed to load the shaderpack \"{}\" because it contains invalid characters in its path", name);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isValidShaderpack(shaderPackRoot)) {
|
||||
IRIS_LOGGER.error("Pack \"{}\" is not valid! Can't load it.", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
Path shaderPackPath;
|
||||
|
||||
if (!Files.isDirectory(shaderPackRoot) && shaderPackRoot.toString().endsWith(".zip")) {
|
||||
Optional<Path> optionalPath;
|
||||
|
||||
try {
|
||||
optionalPath = loadExternalZipShaderpack(shaderPackRoot);
|
||||
} catch (FileSystemNotFoundException | NoSuchFileException e) {
|
||||
IRIS_LOGGER.error("Failed to load the shaderpack \"{}\" because it does not exist in your shaderpacks folder!", name);
|
||||
|
||||
return false;
|
||||
} catch (ZipException e) {
|
||||
IRIS_LOGGER.error("The shaderpack \"{}\" appears to be corrupted, please try downloading it again!", name);
|
||||
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
IRIS_LOGGER.error("Failed to load the shaderpack \"{}\"!", name);
|
||||
IRIS_LOGGER.error("", e);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (optionalPath.isPresent()) {
|
||||
shaderPackPath = optionalPath.get();
|
||||
} else {
|
||||
IRIS_LOGGER.error("Could not load the shaderpack \"{}\" because it appears to lack a \"shaders\" directory", name);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!Files.exists(shaderPackRoot)) {
|
||||
IRIS_LOGGER.error("Failed to load the shaderpack \"{}\" because it does not exist!", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
// If it's a folder-based shaderpack, just use the shaders subdirectory
|
||||
shaderPackPath = shaderPackRoot.resolve("shaders");
|
||||
}
|
||||
|
||||
if (!Files.exists(shaderPackPath)) {
|
||||
IRIS_LOGGER.error("Could not load the shaderpack \"{}\" because it appears to lack a \"shaders\" directory", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
Map<String, String> changedConfigs = tryReadConfigProperties(shaderPackConfigTxt)
|
||||
.map(properties -> (Map<String, String>) (Object) properties)
|
||||
.orElse(new HashMap<>());
|
||||
|
||||
changedConfigs.putAll(getShaderPackOptionQueue());
|
||||
clearShaderPackOptionQueue();
|
||||
|
||||
if (shouldResetShaderPackOptionsOnNextReload()) {
|
||||
changedConfigs.clear();
|
||||
}
|
||||
clearResetShaderPackOptions();
|
||||
|
||||
try {
|
||||
currentPack = new ShaderPack(shaderPackPath, changedConfigs, StandardMacros.createStandardEnvironmentDefines());
|
||||
|
||||
MutableOptionValues changedConfigsValues = currentPack.getShaderPackOptions().getOptionValues().mutableCopy();
|
||||
|
||||
// Store changed values from those currently in use by the shader pack
|
||||
Properties configsToSave = new Properties();
|
||||
changedConfigsValues.getBooleanValues().forEach((k, v) -> configsToSave.setProperty(k, Boolean.toString(v)));
|
||||
changedConfigsValues.getStringValues().forEach(configsToSave::setProperty);
|
||||
|
||||
tryUpdateConfigPropertiesFile(shaderPackConfigTxt, configsToSave);
|
||||
} catch (Exception e) {
|
||||
IRIS_LOGGER.error("Failed to load the shaderpack \"{}\"!", name);
|
||||
IRIS_LOGGER.error("", e);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
fallback = false;
|
||||
currentPackName = name;
|
||||
|
||||
IRIS_LOGGER.info("Using shaderpack: " + name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys and deallocates all created OpenGL resources. Useful as part of a reload.
|
||||
*/
|
||||
static void destroyEverything() {
|
||||
currentPack = null;
|
||||
|
||||
CeleritasShadersApi.getInstance().destroyEverything();
|
||||
|
||||
// Close the zip filesystem that the shaderpack was loaded from
|
||||
//
|
||||
// This prevents a FileSystemAlreadyExistsException when reloading shaderpacks.
|
||||
if (zipFileSystem != null) {
|
||||
try {
|
||||
zipFileSystem.close();
|
||||
} catch (NoSuchFileException e) {
|
||||
IRIS_LOGGER.warn("Failed to close the shaderpack zip when reloading because it was deleted, proceeding anyways.");
|
||||
} catch (IOException e) {
|
||||
IRIS_LOGGER.error("Failed to close zip file system?", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static PipelineManager getPipelineManager() {
|
||||
if (pipelineManager == null) {
|
||||
pipelineManager = new PipelineManager(CeleritasShadersApi.getInstance()::createPipeline);
|
||||
}
|
||||
|
||||
if (loadPackWhenPossible && renderSystemInit) {
|
||||
loadPackWhenPossible = false;
|
||||
CeleritasShadersApi.getInstance().reload();
|
||||
|
||||
}
|
||||
|
||||
return pipelineManager;
|
||||
}
|
||||
|
||||
public static NamespacedId getLastDimension() {
|
||||
return lastDimension;
|
||||
}
|
||||
}
|
||||
+6
-7
@@ -1,12 +1,10 @@
|
||||
package net.irisshaders.iris.compat.dh;
|
||||
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.gl.shader.ShaderCompileException;
|
||||
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
|
||||
import net.irisshaders.iris.uniforms.CapturedRenderingState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.embeddedt.embeddium.impl.loader.common.EarlyLoaderServices;
|
||||
import org.joml.Matrix4f;
|
||||
import org.taumc.celeritas.api.v0.CeleritasShadersApi;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
@@ -14,6 +12,7 @@ import java.lang.invoke.MethodType;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
||||
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||
|
||||
public class DHCompat {
|
||||
private static boolean dhPresent = true;
|
||||
@@ -31,7 +30,7 @@ public class DHCompat {
|
||||
public DHCompat(IrisRenderingPipeline pipeline, boolean renderDHShadow) {
|
||||
try {
|
||||
if (dhPresent) {
|
||||
compatInternalInstance = Class.forName("net.irisshaders.iris.compat.dh.DHCompatInternal").getDeclaredConstructor(pipeline.getClass(), boolean.class).newInstance(pipeline, renderDHShadow);
|
||||
compatInternalInstance = CeleritasShadersApi.getInstance().getDHCompatInstance(pipeline, renderDHShadow);
|
||||
lastIncompatible = (boolean) incompatible.invoke(compatInternalInstance);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
@@ -58,7 +57,7 @@ public class DHCompat {
|
||||
|
||||
public static void run() {
|
||||
try {
|
||||
if (EarlyLoaderServices.INSTANCE.isModLoaded("distanthorizons")) {
|
||||
if (MINECRAFT_SHIM.isDHPresent()) {
|
||||
deletePipeline = MethodHandles.lookup().findVirtual(Class.forName("net.irisshaders.iris.compat.dh.DHCompatInternal"), "clear", MethodType.methodType(void.class));
|
||||
MethodHandle setupEventHandlers = MethodHandles.lookup().findStatic(Class.forName("net.irisshaders.iris.compat.dh.LodRendererEvents"), "setupEventHandlers", MethodType.methodType(void.class));
|
||||
getDepthTex = MethodHandles.lookup().findVirtual(Class.forName("net.irisshaders.iris.compat.dh.DHCompatInternal"), "getStoredDepthTex", MethodType.methodType(int.class));
|
||||
@@ -76,7 +75,7 @@ public class DHCompat {
|
||||
} catch (Throwable e) {
|
||||
dhPresent = false;
|
||||
|
||||
if (EarlyLoaderServices.INSTANCE.isModLoaded("distanthorizons")) {
|
||||
if (MINECRAFT_SHIM.isDHPresent()) {
|
||||
if (e instanceof ExceptionInInitializerError eiie) {
|
||||
throw new RuntimeException("Failure loading DH compat.", eiie.getCause());
|
||||
} else {
|
||||
@@ -113,7 +112,7 @@ public class DHCompat {
|
||||
}
|
||||
|
||||
public static int getRenderDistance() {
|
||||
if (!dhPresent) return Minecraft.getInstance().options.getEffectiveRenderDistance();
|
||||
if (!dhPresent) return MINECRAFT_SHIM.getEffectiveRenderDistance();
|
||||
|
||||
try {
|
||||
return (int) getRenderDistance.invoke();
|
||||
@@ -10,6 +10,7 @@ import org.joml.Vector2f;
|
||||
import org.joml.Vector3i;
|
||||
import org.lwjgl.opengl.GL43C;
|
||||
import org.lwjgl.opengl.GL46C;
|
||||
import org.taumc.celeritas.api.v0.CeleritasShadersApi;
|
||||
|
||||
public final class ComputeProgram extends GlResource {
|
||||
private final ProgramUniforms uniforms;
|
||||
@@ -72,7 +73,7 @@ public final class ComputeProgram extends GlResource {
|
||||
}
|
||||
|
||||
public void dispatch(float width, float height) {
|
||||
if (!MINECRAFT_SHIM.irisAllowConcurrentUpdate()) {
|
||||
if (!CeleritasShadersApi.getInstance().irisAllowConcurrentUpdate()) {
|
||||
IrisRenderSystem.memoryBarrier(GL43C.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL43C.GL_TEXTURE_FETCH_BARRIER_BIT | GL43C.GL_SHADER_STORAGE_BARRIER_BIT);
|
||||
}
|
||||
|
||||
|
||||
+5
-14
@@ -11,14 +11,11 @@ import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINE
|
||||
import static org.embeddedt.embeddium.compat.dh.DHCompatService.DH_COMPAT;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.blaze3d.platform.GlUtil;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisConstants;
|
||||
import net.irisshaders.iris.helpers.StringPair;
|
||||
import net.irisshaders.iris.pipeline.WorldRenderingPhase;
|
||||
import net.irisshaders.iris.texture.format.TextureFormat;
|
||||
import net.irisshaders.iris.texture.format.TextureFormatLoader;
|
||||
import net.minecraft.Util;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL20C;
|
||||
import org.lwjgl.opengl.GL30C;
|
||||
@@ -103,7 +100,7 @@ public class StandardMacros {
|
||||
* @see <a href="https://github.com/sp614x/optifine/blob/9c6a5b5326558ccc57c6490b66b3be3b2dc8cbef/OptiFineDoc/doc/shaders.txt#L696-L699">Optifine Doc</a>
|
||||
*/
|
||||
public static String getMcVersion() {
|
||||
String version = Iris.getReleaseTarget();
|
||||
String version = MINECRAFT_SHIM.getMcVersion();
|
||||
|
||||
if (version == null) {
|
||||
throw new IllegalStateException("Could not get the current minecraft version!");
|
||||
@@ -113,7 +110,7 @@ public class StandardMacros {
|
||||
|
||||
if (splitVersion.length < 2) {
|
||||
IRIS_LOGGER.error("Could not parse game version \"" + version + "\"");
|
||||
splitVersion = Iris.getBackupVersionNumber().split("\\.");
|
||||
splitVersion = MINECRAFT_SHIM.getBackupVersionNumber().split("\\.");
|
||||
}
|
||||
|
||||
String major = splitVersion[0];
|
||||
@@ -192,13 +189,7 @@ public class StandardMacros {
|
||||
* @see <a href="https://github.com/sp614x/optifine/blob/9c6a5b5326558ccc57c6490b66b3be3b2dc8cbef/OptiFineDoc/doc/shaders.txt#L709-L714">Optifine Doc</a>
|
||||
*/
|
||||
public static String getOsString() {
|
||||
return switch (Util.getPlatform()) {
|
||||
case OSX -> "MC_OS_MAC";
|
||||
case LINUX -> "MC_OS_LINUX";
|
||||
case WINDOWS ->
|
||||
"MC_OS_WINDOWS"; // Note: Optifine doesn't have a macro for Solaris. https://github.com/sp614x/optifine/blob/9c6a5b5326558ccc57c6490b66b3be3b2dc8cbef/OptiFineDoc/doc/shaders.txt#L709-L714
|
||||
default -> "MC_OS_UNKNOWN";
|
||||
};
|
||||
return MINECRAFT_SHIM.getOsString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,7 +199,7 @@ public class StandardMacros {
|
||||
* @see <a href="https://github.com/sp614x/optifine/blob/9c6a5b5326558ccc57c6490b66b3be3b2dc8cbef/OptiFineDoc/doc/shaders.txt#L716-L723">Optifine Doc</a>
|
||||
*/
|
||||
public static String getVendor() {
|
||||
String vendor = Objects.requireNonNull(GlUtil.getVendor()).toLowerCase(Locale.ROOT);
|
||||
String vendor = Objects.requireNonNull(GL_STATE_MANAGER.glGetString(GL11.GL_VENDOR).toLowerCase(Locale.ROOT));
|
||||
if (vendor.startsWith("ati")) {
|
||||
return "MC_GL_VENDOR_ATI";
|
||||
} else if (vendor.startsWith("intel")) {
|
||||
@@ -230,7 +221,7 @@ public class StandardMacros {
|
||||
* @see <a href="https://github.com/sp614x/optifine/blob/9c6a5b5326558ccc57c6490b66b3be3b2dc8cbef/OptiFineDoc/doc/shaders.txt#L725-L733">Optifine Doc</a>
|
||||
*/
|
||||
public static String getRenderer() {
|
||||
String renderer = Objects.requireNonNull(GlUtil.getRenderer()).toLowerCase(Locale.ROOT);
|
||||
String renderer = Objects.requireNonNull(GL_STATE_MANAGER.glGetString(GL11.GL_RENDERER)).toLowerCase(Locale.ROOT);
|
||||
if (renderer.startsWith("amd")) {
|
||||
return "MC_GL_RENDERER_RADEON";
|
||||
} else if (renderer.startsWith("ati")) {
|
||||
+14
-34
@@ -1,8 +1,5 @@
|
||||
package net.irisshaders.iris.gl.state;
|
||||
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
|
||||
public class ShaderAttributeInputs {
|
||||
private boolean color;
|
||||
private boolean tex;
|
||||
@@ -14,45 +11,28 @@ public class ShaderAttributeInputs {
|
||||
private boolean text;
|
||||
// WARNING: adding new fields requires updating hashCode and equals methods!
|
||||
|
||||
public ShaderAttributeInputs(VertexFormat format, boolean isFullbright, boolean isLines, boolean glint, boolean text) {
|
||||
if (format == DefaultVertexFormat.POSITION_COLOR_NORMAL && !isLines) {
|
||||
newLines = true;
|
||||
}
|
||||
|
||||
this.text = text;
|
||||
this.glint = glint;
|
||||
|
||||
format.getElementAttributeNames().forEach(name -> {
|
||||
if ("Color".equals(name)) {
|
||||
color = true;
|
||||
}
|
||||
|
||||
if ("UV0".equals(name)) {
|
||||
tex = true;
|
||||
}
|
||||
|
||||
if ("UV1".equals(name)) {
|
||||
overlay = true;
|
||||
}
|
||||
|
||||
if ("UV2".equals(name) && !isFullbright) {
|
||||
light = true;
|
||||
}
|
||||
|
||||
if ("Normal".equals(name)) {
|
||||
normal = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ShaderAttributeInputs(boolean color, boolean tex, boolean overlay, boolean light, boolean normal) {
|
||||
this.color = color;
|
||||
this.tex = tex;
|
||||
this.overlay = overlay;
|
||||
this.light = light;
|
||||
this.normal = normal;
|
||||
|
||||
this.newLines = false;
|
||||
this.glint = false;
|
||||
this.text = false;
|
||||
}
|
||||
|
||||
public ShaderAttributeInputs(boolean color, boolean tex, boolean overlay, boolean light, boolean normal, boolean newLines, boolean glint, boolean text) {
|
||||
this.color = color;
|
||||
this.tex = tex;
|
||||
this.overlay = overlay;
|
||||
this.light = light;
|
||||
this.normal = normal;
|
||||
this.newLines = newLines;
|
||||
this.glint = glint;
|
||||
this.text = text;
|
||||
}
|
||||
public boolean hasColor() {
|
||||
return color;
|
||||
}
|
||||
+2
-2
@@ -8,17 +8,17 @@ import java.util.function.Function;
|
||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
||||
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
|
||||
import net.irisshaders.iris.uniforms.SystemTimeUniforms;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.opengl.GL20C;
|
||||
import org.taumc.celeritas.api.v0.CeleritasShadersApi;
|
||||
|
||||
public class PipelineManager {
|
||||
private final Function<NamespacedId, WorldRenderingPipeline> pipelineFactory;
|
||||
private final Map<NamespacedId, WorldRenderingPipeline> pipelinesPerDimension = new HashMap<>();
|
||||
private WorldRenderingPipeline pipeline = new VanillaRenderingPipeline();
|
||||
private WorldRenderingPipeline pipeline = CeleritasShadersApi.getInstance().createVanillaRenderingPipeline();
|
||||
private int versionCounterForSodiumShaderReload = 0;
|
||||
|
||||
public PipelineManager(Function<NamespacedId, WorldRenderingPipeline> pipelineFactory) {
|
||||
+8
-14
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
|
||||
@@ -11,17 +12,16 @@ import net.irisshaders.iris.compat.dh.DHCompat;
|
||||
import net.irisshaders.iris.features.FeatureFlags;
|
||||
import net.irisshaders.iris.gl.texture.TextureType;
|
||||
import net.irisshaders.iris.helpers.Tri;
|
||||
import net.irisshaders.iris.mixin.LevelRendererAccessor;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
|
||||
import net.irisshaders.iris.shaderpack.properties.CloudSetting;
|
||||
import net.irisshaders.iris.shaderpack.properties.ParticleRenderingSettings;
|
||||
import net.irisshaders.iris.shaderpack.texture.TextureStage;
|
||||
import net.irisshaders.iris.targets.RenderTargetStateListener;
|
||||
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class VanillaRenderingPipeline implements WorldRenderingPipeline {
|
||||
import org.embeddedt.embeddium.compat.mc.ICamera;
|
||||
import org.embeddedt.embeddium.compat.mc.ILevelRenderer;
|
||||
|
||||
public abstract class VanillaRenderingPipeline implements WorldRenderingPipeline {
|
||||
public VanillaRenderingPipeline() {
|
||||
WorldRenderingSettings.INSTANCE.setDisableDirectionalShading(shouldDisableDirectionalShading());
|
||||
WorldRenderingSettings.INSTANCE.setUseSeparateAo(false);
|
||||
@@ -29,19 +29,18 @@ public class VanillaRenderingPipeline implements WorldRenderingPipeline {
|
||||
WorldRenderingSettings.INSTANCE.setAmbientOcclusionLevel(1.0f);
|
||||
WorldRenderingSettings.INSTANCE.setUseExtendedVertexFormat(false);
|
||||
WorldRenderingSettings.INSTANCE.setVoxelizeLightBlocks(false);
|
||||
WorldRenderingSettings.INSTANCE.setBlockTypeIds(null);
|
||||
WorldRenderingSettings.INSTANCE.setFallbackTextureMaterialMapping(null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginLevelRendering() {
|
||||
// Use the default Minecraft framebuffer and ensure that no programs are in use
|
||||
Minecraft.getInstance().getMainRenderTarget().bindWrite(true);
|
||||
MINECRAFT_SHIM.bindFramebuffer();
|
||||
GL_STATE_MANAGER.glUseProgram(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderShadows(LevelRendererAccessor worldRenderer, Camera camera) {
|
||||
public void renderShadows(ILevelRenderer worldRenderer, ICamera camera) {
|
||||
// stub: nothing to do here
|
||||
}
|
||||
|
||||
@@ -182,11 +181,6 @@ public class VanillaRenderingPipeline implements WorldRenderingPipeline {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleRenderingSettings getParticleRenderingSettings() {
|
||||
return Minecraft.useShaderTransparency() ? ParticleRenderingSettings.AFTER : ParticleRenderingSettings.MIXED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowConcurrentCompute() {
|
||||
return false;
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.irisshaders.iris.pipeline;
|
||||
|
||||
public enum WorldRenderingPhase {
|
||||
NONE,
|
||||
SKY,
|
||||
SUNSET,
|
||||
CUSTOM_SKY,
|
||||
SUN,
|
||||
MOON,
|
||||
STARS,
|
||||
VOID,
|
||||
TERRAIN_SOLID,
|
||||
TERRAIN_CUTOUT_MIPPED,
|
||||
TERRAIN_CUTOUT,
|
||||
ENTITIES,
|
||||
BLOCK_ENTITIES,
|
||||
DESTROY,
|
||||
OUTLINE,
|
||||
DEBUG,
|
||||
HAND_SOLID,
|
||||
TERRAIN_TRANSLUCENT,
|
||||
TRIPWIRE,
|
||||
PARTICLES,
|
||||
CLOUDS,
|
||||
RAIN_SNOW,
|
||||
WORLD_BORDER,
|
||||
HAND_TRANSLUCENT;
|
||||
|
||||
}
|
||||
+2
-2
@@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import net.irisshaders.iris.gl.shader.StandardMacros;
|
||||
import net.irisshaders.iris.helpers.StringPair;
|
||||
import net.irisshaders.iris.parsing.BiomeCategories;
|
||||
import net.irisshaders.iris.uniforms.BiomeUniforms;
|
||||
import org.taumc.celeritas.api.v0.CeleritasShadersApi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -25,7 +25,7 @@ public class IrisDefines {
|
||||
public static ImmutableList<StringPair> createIrisReplacements() {
|
||||
ArrayList<StringPair> s = new ArrayList<>(StandardMacros.createStandardEnvironmentDefines());
|
||||
|
||||
BiomeUniforms.getBiomeMap().forEach((biome, id) -> define(s, "BIOME_" + biome.location().getPath().toUpperCase(Locale.ROOT), String.valueOf(id)));
|
||||
CeleritasShadersApi.getInstance().processBiomeMap((key, value) -> define(s, key, value));
|
||||
|
||||
BiomeCategories[] categories = BiomeCategories.values();
|
||||
for (int i = 0; i < categories.length; i++) {
|
||||
+4
-17
@@ -8,11 +8,8 @@ import com.google.gson.stream.JsonReader;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.irisshaders.iris.features.FeatureFlags;
|
||||
import net.irisshaders.iris.gl.texture.TextureDefinition;
|
||||
import net.irisshaders.iris.gui.FeatureMissingErrorScreen;
|
||||
import net.irisshaders.iris.gui.screen.ShaderPackScreen;
|
||||
import net.irisshaders.iris.helpers.StringPair;
|
||||
import net.irisshaders.iris.pathways.colorspace.ColorSpace;
|
||||
import net.irisshaders.iris.shaderpack.include.AbsolutePackPath;
|
||||
@@ -20,10 +17,10 @@ import net.irisshaders.iris.shaderpack.include.IncludeGraph;
|
||||
import net.irisshaders.iris.shaderpack.include.IncludeProcessor;
|
||||
import net.irisshaders.iris.shaderpack.include.ShaderPackSourceNames;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.irisshaders.iris.shaderpack.option.menu.OptionMenuContainer;
|
||||
import net.irisshaders.iris.shaderpack.option.OrderBackedProperties;
|
||||
import net.irisshaders.iris.shaderpack.option.ProfileSet;
|
||||
import net.irisshaders.iris.shaderpack.option.ShaderPackOptions;
|
||||
import net.irisshaders.iris.shaderpack.option.menu.OptionMenuContainer;
|
||||
import net.irisshaders.iris.shaderpack.option.values.MutableOptionValues;
|
||||
import net.irisshaders.iris.shaderpack.option.values.OptionValues;
|
||||
import net.irisshaders.iris.shaderpack.preprocessor.JcppProcessor;
|
||||
@@ -35,11 +32,8 @@ import net.irisshaders.iris.shaderpack.texture.CustomTextureData;
|
||||
import net.irisshaders.iris.shaderpack.texture.TextureFilteringData;
|
||||
import net.irisshaders.iris.shaderpack.texture.TextureStage;
|
||||
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.taumc.celeritas.api.v0.CeleritasShadersApi;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@@ -197,15 +191,8 @@ public class ShaderPack {
|
||||
List<String> invalidFeatureFlags = invalidFlagList.stream().map(FeatureFlags::getHumanReadableName).toList();
|
||||
|
||||
if (!invalidFeatureFlags.isEmpty()) {
|
||||
if (Minecraft.getInstance().screen instanceof ShaderPackScreen) {
|
||||
MutableComponent component = Component.translatable("iris.unsupported.pack.description", FeatureFlags.getInvalidStatus(invalidFlagList), invalidFeatureFlags.stream()
|
||||
.collect(Collectors.joining(", ", ": ", ".")));
|
||||
if (SystemUtils.IS_OS_MAC) {
|
||||
component = component.append(Component.translatable("iris.unsupported.pack.macos"));
|
||||
}
|
||||
Minecraft.getInstance().setScreen(new FeatureMissingErrorScreen(Minecraft.getInstance().screen, Component.translatable("iris.unsupported.pack"), component));
|
||||
}
|
||||
IrisApi.getInstance().getConfig().setShadersEnabledAndApply(false);
|
||||
CeleritasShadersApi.getInstance().handleUnsupportedFeatureFlags(invalidFlagList, invalidFeatureFlags);
|
||||
CeleritasShadersApi.getInstance().getConfig().setShadersEnabledAndApply(false);
|
||||
}
|
||||
List<StringPair> newEnvDefines = new ArrayList<>(environmentDefines);
|
||||
|
||||
+7
-58
@@ -1,23 +1,15 @@
|
||||
package net.irisshaders.iris.shaderpack.materialmap;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntFunction;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||
|
||||
public class WorldRenderingSettings {
|
||||
public static final WorldRenderingSettings INSTANCE = new WorldRenderingSettings();
|
||||
|
||||
private boolean reloadRequired;
|
||||
private Object2IntMap<BlockState> blockStateIds;
|
||||
private FallbackTextureMaterials fallbackTextureMaterialMapping;
|
||||
private Map<Block, RenderType> blockTypeIds;
|
||||
|
||||
private Object2IntFunction<NamespacedId> entityIds;
|
||||
private Object2IntFunction<NamespacedId> itemIds;
|
||||
private float ambientOcclusionLevel;
|
||||
@@ -30,8 +22,6 @@ public class WorldRenderingSettings {
|
||||
|
||||
public WorldRenderingSettings() {
|
||||
reloadRequired = false;
|
||||
blockStateIds = null;
|
||||
blockTypeIds = null;
|
||||
ambientOcclusionLevel = 1.0F;
|
||||
disableDirectionalShading = false;
|
||||
useSeparateAo = false;
|
||||
@@ -51,56 +41,11 @@ public class WorldRenderingSettings {
|
||||
|
||||
public void reloadRendererIfRequired() {
|
||||
if (isReloadRequired()) {
|
||||
if (Minecraft.getInstance().levelRenderer != null) {
|
||||
Minecraft.getInstance().levelRenderer.allChanged();
|
||||
}
|
||||
|
||||
MINECRAFT_SHIM.markRendererReloadRequired();
|
||||
clearReloadRequired();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object2IntMap<BlockState> getBlockStateIds() {
|
||||
return blockStateIds;
|
||||
}
|
||||
|
||||
public void setBlockStateIds(Object2IntMap<BlockState> blockStateIds) {
|
||||
if (Objects.equals(this.blockStateIds, blockStateIds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.reloadRequired = true;
|
||||
this.blockStateIds = blockStateIds;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FallbackTextureMaterials getFallbackTextureMaterialMapping() {
|
||||
return fallbackTextureMaterialMapping;
|
||||
}
|
||||
|
||||
public void setFallbackTextureMaterialMapping(FallbackTextureMaterials fallbackTextureMaterialMapping) {
|
||||
if (Objects.equals(this.fallbackTextureMaterialMapping, fallbackTextureMaterialMapping)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.reloadRequired = true;
|
||||
this.fallbackTextureMaterialMapping = fallbackTextureMaterialMapping;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public Map<Block, RenderType> getBlockTypeIds() {
|
||||
return blockTypeIds;
|
||||
}
|
||||
|
||||
public void setBlockTypeIds(Map<Block, RenderType> blockTypeIds) {
|
||||
if (Objects.equals(this.blockTypeIds, blockTypeIds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.reloadRequired = true;
|
||||
this.blockTypeIds = blockTypeIds;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object2IntFunction<NamespacedId> getEntityIds() {
|
||||
@@ -199,4 +144,8 @@ public class WorldRenderingSettings {
|
||||
public boolean hasVillagerConversionId() {
|
||||
return hasVillagerConversionId;
|
||||
}
|
||||
|
||||
public void setReloadRequired() {
|
||||
reloadRequired = true;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -4,6 +4,7 @@ import org.embeddedt.embeddium.compat.mc.IResource;
|
||||
import org.embeddedt.embeddium.compat.mc.IResourceLocation;
|
||||
import org.embeddedt.embeddium.compat.mc.IResourceProvider;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.taumc.celeritas.api.v0.CeleritasShadersApi;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
@@ -71,7 +72,7 @@ public class TextureFormatLoader {
|
||||
|
||||
private static void onFormatChange() {
|
||||
try {
|
||||
MINECRAFT_SHIM.reloadIris();
|
||||
CeleritasShadersApi.getInstance().reloadIris();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.irisshaders.iris.uniforms;
|
||||
|
||||
import net.irisshaders.iris.gl.uniform.UniformHolder;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
public interface BiomeUniforms {
|
||||
BiomeUniforms BIOME_UNIFORMS = ServiceLoader.load(BiomeUniforms.class).findFirst().orElseThrow();
|
||||
|
||||
void addBiomeUniforms(UniformHolder uniforms);
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package net.irisshaders.iris.uniforms;
|
||||
|
||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||
import static net.irisshaders.iris.gl.uniform.UniformUpdateFrequency.*;
|
||||
import static net.irisshaders.iris.uniforms.IdMapUniforms.ID_MAP_UNIFORMS;
|
||||
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||
|
||||
import net.irisshaders.iris.compat.dh.DHCompat;
|
||||
import net.irisshaders.iris.gl.blending.BlendMode;
|
||||
import net.irisshaders.iris.gl.state.FogMode;
|
||||
import net.irisshaders.iris.gl.state.StateUpdateNotifiers;
|
||||
import net.irisshaders.iris.gl.uniform.DynamicUniformHolder;
|
||||
import net.irisshaders.iris.gl.uniform.UniformHolder;
|
||||
import net.irisshaders.iris.layer.GbufferPrograms;
|
||||
import net.irisshaders.iris.shaderpack.IdMap;
|
||||
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
||||
import net.irisshaders.iris.uniforms.transforms.SmoothedFloat;
|
||||
import net.irisshaders.iris.uniforms.transforms.SmoothedVec2f;
|
||||
import org.joml.*;
|
||||
import org.joml.Math;
|
||||
|
||||
public final class CommonUniforms {
|
||||
private static final Vector4i ZERO_VECTOR_4i = new Vector4i(0, 0, 0, 0);
|
||||
|
||||
static {
|
||||
GbufferPrograms.init();
|
||||
}
|
||||
|
||||
private CommonUniforms() {
|
||||
// no construction allowed
|
||||
}
|
||||
|
||||
// Needs to use a LocationalUniformHolder as we need it for the common uniforms
|
||||
public static void addDynamicUniforms(DynamicUniformHolder uniforms, FogMode fogMode) {
|
||||
ExternallyManagedUniforms.addExternallyManagedUniforms117(uniforms);
|
||||
FogUniforms.addFogUniforms(uniforms, fogMode);
|
||||
IrisInternalUniforms.addFogUniforms(uniforms, fogMode);
|
||||
|
||||
// This is a fallback for when entityId via attributes cannot be used. (lightning)
|
||||
uniforms.uniform1i( "entityId", CapturedRenderingState.INSTANCE::getCurrentRenderedEntity, StateUpdateNotifiers.fallbackEntityNotifier);
|
||||
|
||||
// TODO: OptiFine doesn't think that atlasSize is a "dynamic" uniform,
|
||||
// but we do. How will custom uniforms depending on atlasSize work?
|
||||
//
|
||||
// Note: on 1.17+ we don't need to reset this when textures are bound, since
|
||||
// the shader will always be setup (and therefore uniforms will be re-uploaded)
|
||||
// after the texture is changed and before rendering starts.
|
||||
uniforms.uniform2i("atlasSize", MINECRAFT_SHIM::getAtlasSize, listener -> {});
|
||||
|
||||
uniforms.uniform2i("gtextureSize", MINECRAFT_SHIM::getTextureSize, StateUpdateNotifiers.bindTextureNotifier);
|
||||
|
||||
uniforms.uniform4i("blendFunc", () -> {
|
||||
if (GL_STATE_MANAGER.isBlendEnabled()) {
|
||||
final BlendMode blend = GL_STATE_MANAGER.getBlendMode();
|
||||
return new Vector4i(blend.srcRgb(), blend.dstRgb(), blend.srcAlpha(), blend.dstAlpha());
|
||||
} else {
|
||||
return ZERO_VECTOR_4i;
|
||||
}
|
||||
}, StateUpdateNotifiers.blendFuncNotifier);
|
||||
|
||||
uniforms.uniform1i("renderStage", () -> GbufferPrograms.getCurrentPhase().ordinal(), StateUpdateNotifiers.phaseChangeNotifier);
|
||||
}
|
||||
|
||||
public static void addCommonUniforms(DynamicUniformHolder uniforms, IdMap idMap, PackDirectives directives, FrameUpdateNotifier updateNotifier, FogMode fogMode) {
|
||||
CommonUniforms.addNonDynamicUniforms(uniforms, idMap, directives, updateNotifier);
|
||||
CommonUniforms.addDynamicUniforms(uniforms, fogMode);
|
||||
}
|
||||
|
||||
public static void addNonDynamicUniforms(UniformHolder uniforms, IdMap idMap, PackDirectives directives, FrameUpdateNotifier updateNotifier) {
|
||||
CameraUniforms.addCameraUniforms(uniforms, updateNotifier);
|
||||
ViewportUniforms.addViewportUniforms(uniforms);
|
||||
WorldTimeUniforms.addWorldTimeUniforms(uniforms);
|
||||
SystemTimeUniforms.addSystemTimeUniforms(uniforms);
|
||||
BiomeUniforms.BIOME_UNIFORMS.addBiomeUniforms(uniforms);
|
||||
new CelestialUniforms(directives.getSunPathRotation()).addCelestialUniforms(uniforms);
|
||||
IrisExclusiveUniforms.addIrisExclusiveUniforms(uniforms);
|
||||
IrisTimeUniforms.addTimeUniforms(uniforms);
|
||||
MatrixUniforms.addMatrixUniforms(uniforms, directives);
|
||||
ID_MAP_UNIFORMS.addIdMapUniforms(updateNotifier, uniforms, idMap, directives.isOldHandLight());
|
||||
CommonUniforms.generalCommonUniforms(uniforms, updateNotifier, directives);
|
||||
}
|
||||
|
||||
public static void generalCommonUniforms(UniformHolder uniforms, FrameUpdateNotifier updateNotifier, PackDirectives directives) {
|
||||
ExternallyManagedUniforms.addExternallyManagedUniforms117(uniforms);
|
||||
|
||||
SmoothedVec2f eyeBrightnessSmooth = new SmoothedVec2f(directives.getEyeBrightnessHalfLife(), directives.getEyeBrightnessHalfLife(), MINECRAFT_SHIM::getEyeBrightness, updateNotifier);
|
||||
|
||||
uniforms
|
||||
.uniform1b(PER_FRAME, "hideGUI", MINECRAFT_SHIM::hideGui)
|
||||
.uniform1b(PER_FRAME, "isRightHanded", MINECRAFT_SHIM::isRightHanded)
|
||||
.uniform1i(PER_FRAME, "isEyeInWater", MINECRAFT_SHIM::isEyeInWater)
|
||||
.uniform1f(PER_FRAME, "blindness", MINECRAFT_SHIM::getBlindness)
|
||||
.uniform1f(PER_FRAME, "darknessFactor", MINECRAFT_SHIM::getDarknessFactor)
|
||||
.uniform1f(PER_FRAME, "darknessLightFactor", CapturedRenderingState.INSTANCE::getDarknessLightFactor)
|
||||
.uniform1f(PER_FRAME, "nightVision", MINECRAFT_SHIM::getNightVision)
|
||||
.uniform1b(PER_FRAME, "is_sneaking", MINECRAFT_SHIM::isSneaking)
|
||||
.uniform1b(PER_FRAME, "is_sprinting", MINECRAFT_SHIM::isSprinting)
|
||||
.uniform1b(PER_FRAME, "is_hurt", MINECRAFT_SHIM::isHurt)
|
||||
.uniform1b(PER_FRAME, "is_invisible", MINECRAFT_SHIM::isInvisible)
|
||||
.uniform1b(PER_FRAME, "is_burning", MINECRAFT_SHIM::isBurning)
|
||||
.uniform1b(PER_FRAME, "is_on_ground", MINECRAFT_SHIM::isOnGround)
|
||||
// TODO: Do we need to clamp this to avoid fullbright breaking shaders? Or should shaders be able to detect
|
||||
// that the player is trying to turn on fullbright?
|
||||
.uniform1f(PER_FRAME, "screenBrightness", MINECRAFT_SHIM::getScreenBrightness)
|
||||
// just a dummy value for shaders where entityColor isn't supplied through a vertex attribute (and thus is
|
||||
// not available) - suppresses warnings. See AttributeShaderTransformer for the actual entityColor code.
|
||||
.uniform4f(ONCE, "entityColor", () -> new Vector4f(0, 0, 0, 0))
|
||||
.uniform1i(ONCE, "blockEntityId", () -> -1)
|
||||
.uniform1i(ONCE, "currentRenderedItemId", () -> -1)
|
||||
.uniform1f(ONCE, "pi", () -> Math.PI)
|
||||
.uniform1f(PER_TICK, "playerMood", MINECRAFT_SHIM::getPlayerMood)
|
||||
.uniform2i(PER_FRAME, "eyeBrightness", MINECRAFT_SHIM::getEyeBrightness)
|
||||
.uniform2i(PER_FRAME, "eyeBrightnessSmooth", () -> {
|
||||
Vector2f smoothed = eyeBrightnessSmooth.get();
|
||||
return new Vector2i((int) smoothed.x(), (int) smoothed.y());
|
||||
})
|
||||
.uniform1f(PER_TICK, "rainStrength", MINECRAFT_SHIM::getRainStrength)
|
||||
.uniform1f(PER_TICK, "wetness", new SmoothedFloat(directives.getWetnessHalfLife(), directives.getDrynessHalfLife(), MINECRAFT_SHIM::getRainStrength, updateNotifier))
|
||||
.uniform3d(PER_FRAME, "skyColor", MINECRAFT_SHIM::getSkyColor)
|
||||
.uniform1f(PER_FRAME, "dhFarPlane", DHCompat::getFarPlane)
|
||||
.uniform1f(PER_FRAME, "dhNearPlane", DHCompat::getNearPlane)
|
||||
.uniform1i(PER_FRAME, "dhRenderDistance", DHCompat::getRenderDistance);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.irisshaders.iris.uniforms;
|
||||
|
||||
import net.irisshaders.iris.gl.uniform.UniformHolder;
|
||||
import net.irisshaders.iris.shaderpack.IdMap;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
public interface IdMapUniforms {
|
||||
IdMapUniforms ID_MAP_UNIFORMS = ServiceLoader.load(IdMapUniforms.class).findFirst().orElseThrow();
|
||||
|
||||
void addIdMapUniforms(FrameUpdateNotifier notifier, UniformHolder uniforms, IdMap idMap, boolean isOldHandLight);
|
||||
}
|
||||
+3
-5
@@ -3,13 +3,12 @@ package net.irisshaders.iris.uniforms;
|
||||
import net.irisshaders.iris.compat.dh.DHCompat;
|
||||
import net.irisshaders.iris.gl.uniform.UniformHolder;
|
||||
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
||||
import net.irisshaders.iris.shadows.ShadowMatrices;
|
||||
import net.irisshaders.iris.shadows.ShadowRenderer;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static net.irisshaders.iris.gl.uniform.UniformUpdateFrequency.PER_FRAME;
|
||||
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||
|
||||
public final class MatrixUniforms {
|
||||
private MatrixUniforms() {
|
||||
@@ -19,9 +18,8 @@ public final class MatrixUniforms {
|
||||
addMatrix(uniforms, "ModelView", CapturedRenderingState.INSTANCE::getGbufferModelView);
|
||||
addMatrix(uniforms, "Projection", CapturedRenderingState.INSTANCE::getGbufferProjection);
|
||||
addDHMatrix(uniforms, "Projection", DHCompat::getProjection);
|
||||
addShadowMatrix(uniforms, "ModelView", () ->
|
||||
new Matrix4f(ShadowRenderer.createShadowModelView(directives.getSunPathRotation(), directives.getShadowDirectives().getIntervalSize()).last().pose()));
|
||||
addShadowMatrix(uniforms, "Projection", () -> ShadowMatrices.createOrthoMatrix(directives.getShadowDirectives().getDistance(),
|
||||
addShadowMatrix(uniforms, "ModelView", () -> MINECRAFT_SHIM.getShadowModelView(directives.getSunPathRotation(), directives.getShadowDirectives().getIntervalSize()));
|
||||
addShadowMatrix(uniforms, "Projection", () -> MINECRAFT_SHIM.getShadowProjection(directives.getShadowDirectives().getDistance(),
|
||||
directives.getShadowDirectives().getNearPlane() < 0 ? -DHCompat.getRenderDistance() : directives.getShadowDirectives().getNearPlane(),
|
||||
directives.getShadowDirectives().getFarPlane() < 0 ? DHCompat.getRenderDistance() : directives.getShadowDirectives().getFarPlane()));
|
||||
}
|
||||
+36
-4
@@ -1,10 +1,10 @@
|
||||
package org.embeddedt.embeddium.compat.mc;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector2i;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
@@ -12,6 +12,7 @@ import java.util.ServiceLoader;
|
||||
*/
|
||||
public interface MinecraftVersionShimService {
|
||||
MinecraftVersionShimService MINECRAFT_SHIM = ServiceLoader.load(MinecraftVersionShimService.class).findFirst().orElseThrow();
|
||||
Vector2i ZERO2I = new Vector2i();
|
||||
Vector3d ZERO3D = new Vector3d(0);
|
||||
Vector4f ZERO4F = new Vector4f(0);
|
||||
|
||||
@@ -38,6 +39,7 @@ public interface MinecraftVersionShimService {
|
||||
boolean isLevelLoaded();
|
||||
|
||||
int getRenderDistanceInBlocks();
|
||||
int getEffectiveRenderDistance();
|
||||
Vector3d getUnshiftedCameraPosition();
|
||||
float getSkyAngle();
|
||||
void applyRotationYP(Matrix4f preCelestial, float degrees);
|
||||
@@ -74,6 +76,25 @@ public interface MinecraftVersionShimService {
|
||||
boolean isFirstPersonCamera();
|
||||
boolean isSpectator();
|
||||
Vector3d getEyePosition();
|
||||
boolean isOnGround();
|
||||
boolean isHurt();
|
||||
boolean isInvisible();
|
||||
boolean isBurning();
|
||||
boolean isSneaking();
|
||||
boolean isSprinting();
|
||||
Vector3d getSkyColor();
|
||||
float getBlindness();
|
||||
float getDarknessFactor();
|
||||
float getPlayerMood();
|
||||
float getRainStrength();
|
||||
Vector2i getEyeBrightness();
|
||||
float getNightVision();
|
||||
int isEyeInWater();
|
||||
boolean hideGui();
|
||||
boolean isRightHanded();
|
||||
float getScreenBrightness();
|
||||
Vector2i getAtlasSize();
|
||||
Vector2i getTextureSize();
|
||||
|
||||
MCNativeImage createNativeImage(int width, int height, boolean useCalloc);
|
||||
MCNativeImage[] createNativeImageArray(int size);
|
||||
@@ -81,7 +102,18 @@ public interface MinecraftVersionShimService {
|
||||
IResourceLocation makeResourceLocation(String namespace, String path);
|
||||
IResourceLocation makeResourceLocation(String str);
|
||||
|
||||
// TODO(mitchej123): Does this belong here?
|
||||
void reloadIris() throws IOException;
|
||||
boolean irisAllowConcurrentUpdate();
|
||||
String getOsString();
|
||||
|
||||
String getMcVersion();
|
||||
String getBackupVersionNumber();
|
||||
|
||||
void markRendererReloadRequired();
|
||||
|
||||
boolean isDHPresent();
|
||||
|
||||
|
||||
Matrix4f getShadowModelView(float sunPathRotation, float intervalSize);
|
||||
Matrix4f getShadowProjection(float shadowDistance, float nearPlane, float farPlane);
|
||||
|
||||
void bindFramebuffer();
|
||||
}
|
||||
@@ -1,8 +1,18 @@
|
||||
package org.taumc.celeritas.api.v0;
|
||||
|
||||
import net.irisshaders.iris.api.v0.IrisApiConfig;
|
||||
import net.irisshaders.iris.features.FeatureFlags;
|
||||
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
|
||||
import org.embeddedt.embeddium.compat.iris.IBlockEntry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public interface CeleritasShadersApi {
|
||||
CeleritasShadersApi INSTANCE = ServiceLoader.load(CeleritasShadersApi.class).findFirst().orElseThrow();
|
||||
@@ -122,4 +132,43 @@ public interface CeleritasShadersApi {
|
||||
* @since API v0.2
|
||||
*/
|
||||
float getSunPathRotation();
|
||||
|
||||
/**
|
||||
* Reload the Iris
|
||||
* @throws IOException
|
||||
*/
|
||||
void reloadIris() throws IOException;
|
||||
|
||||
/**
|
||||
* Checks whether Iris allows concurrent updates to the shader pack.
|
||||
*
|
||||
* @return true if Iris allows concurrent updates, false otherwise.
|
||||
*/
|
||||
boolean irisAllowConcurrentUpdate();
|
||||
|
mitchej123 marked this conversation as resolved
Outdated
|
||||
|
||||
void handleUnsupportedFeatureFlags(List<FeatureFlags> invalidFlagList, List<String> invalidFeatureFlags);
|
||||
|
||||
void processBiomeMap(BiConsumer<String, String> define);
|
||||
|
||||
/**
|
||||
* Parses a block ID entry.
|
||||
*
|
||||
* @param entry The string representation of the entry. Must not be empty.
|
||||
*/
|
||||
IBlockEntry parseBlockEntry(@NotNull String entry);
|
||||
IBlockEntry createBlockEntry(NamespacedId id);
|
||||
|
||||
|
||||
void onEarlyInitialize();
|
||||
void onRenderSystemInit();
|
||||
void onLoadingComplete();
|
||||
|
||||
void destroyEverything();
|
||||
|
||||
WorldRenderingPipeline createPipeline(NamespacedId dimensionId);
|
||||
WorldRenderingPipeline createVanillaRenderingPipeline();
|
||||
|
||||
void reload();
|
||||
|
||||
Object getDHCompatInstance(IrisRenderingPipeline pipeline, boolean renderDHShadow) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.taumc.celeritas.compat;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public enum InteractionHand {
|
||||
MAIN_HAND,
|
||||
OFF_HAND;
|
||||
|
||||
InteractionHand() {
|
||||
}
|
||||
|
||||
public ItemStack getItemInHand(EntityPlayer player){
|
||||
return player.getHeldItem();
|
||||
}
|
||||
}
|
||||
@@ -12,3 +12,5 @@ private-f net.minecraft.client.renderer.EntityRenderer field_78504_Q # lightmapC
|
||||
public net.minecraft.world.WorldSettings$GameType
|
||||
public net.minecraft.world.WorldSettings.GameType
|
||||
public net.minecraft.client.multiplayer.PlayerControllerMP currentGameType # currentGameType
|
||||
public net.minecraft.entity.Entity fire # fire
|
||||
public net.minecraft.client.renderer.EntityRenderer getNightVisionBrightness(Lnet/minecraft/entity/player/EntityPlayer;F)F # getNightVisionBrightness
|
||||
@@ -1,53 +1,5 @@
|
||||
package net.irisshaders.iris;
|
||||
|
||||
import net.irisshaders.iris.config.IrisConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
|
||||
|
||||
public class Iris {
|
||||
public static final IrisLogging logger = IrisLogging.IRIS_LOGGER;
|
||||
private static boolean initialized;
|
||||
private static IrisConfig irisConfig;
|
||||
|
||||
/**
|
||||
* Called very early on in Minecraft initialization. At this point we *cannot* safely access OpenGL, but we can do
|
||||
* some very basic setup, config loading, and environment checks.
|
||||
*
|
||||
* <p>This is roughly equivalent to Fabric Loader's ClientModInitializer#onInitializeClient entrypoint, except
|
||||
* it's entirely cross platform & we get to decide its exact semantics.</p>
|
||||
*
|
||||
* <p>This is called right before options are loaded, so we can add key bindings here.</p>
|
||||
*/
|
||||
public static void onEarlyInitialize() {
|
||||
// reloadKeybind = new KeyMapping("iris.keybind.reload", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_R, "iris.keybinds");
|
||||
// toggleShadersKeybind = new KeyMapping("iris.keybind.toggleShaders", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_K, "iris.keybinds");
|
||||
// shaderpackScreenKeybind = new KeyMapping("iris.keybind.shaderPackSelection", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_O, "iris.keybinds");
|
||||
// wireframeKeybind = new KeyMapping("iris.keybind.wireframe", InputConstants.Type.KEYSYM, InputConstants.UNKNOWN.getValue(), "iris.keybinds");
|
||||
|
||||
|
||||
// DHCompat.run();
|
||||
|
||||
try {
|
||||
if (!Files.exists(IrisCommon.getShaderpacksDirectory())) {
|
||||
Files.createDirectories(IrisCommon.getShaderpacksDirectory());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.warn("Failed to create the shaderpacks directory!");
|
||||
logger.warn("", e);
|
||||
}
|
||||
|
||||
irisConfig = new IrisConfig(PLATFORM_UTIL.getConfigDir().resolve(IrisConstants.MODID + "-shaders.properties"));
|
||||
|
||||
try {
|
||||
irisConfig.initialize();
|
||||
} catch (IOException e) {
|
||||
logger.error("Failed to initialize Iris configuration, default values will be used instead");
|
||||
logger.error("", e);
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,27 @@
|
||||
package net.irisshaders.iris.apiimpl;
|
||||
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.api.v0.IrisApiConfig;
|
||||
import net.irisshaders.iris.features.FeatureFlags;
|
||||
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.BlockEntry;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.embeddedt.embeddium.compat.iris.IBlockEntry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.taumc.celeritas.api.v0.CeleritasShadersApi;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
||||
|
||||
public class IrisApiV0Impl implements CeleritasShadersApi {
|
||||
@Override
|
||||
public boolean isShaderPackInUse() {
|
||||
@@ -48,4 +67,169 @@ public class IrisApiV0Impl implements CeleritasShadersApi {
|
||||
public float getSunPathRotation() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadIris() throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean irisAllowConcurrentUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUnsupportedFeatureFlags(List<FeatureFlags> invalidFlagList, List<String> invalidFeatureFlags) {
|
||||
// TODO: Implement this method to handle unsupported feature flags on 1.7.10
|
||||
/*
|
||||
if (Minecraft.getInstance().screen instanceof ShaderPackScreen) {
|
||||
MutableComponent component = Component.translatable("iris.unsupported.pack.description", FeatureFlags.getInvalidStatus(invalidFlagList), invalidFeatureFlags.stream()
|
||||
.collect(Collectors.joining(", ", ": ", ".")));
|
||||
if (SystemUtils.IS_OS_MAC) {
|
||||
component = component.append(Component.translatable("iris.unsupported.pack.macos"));
|
||||
}
|
||||
Minecraft.getInstance().setScreen(new FeatureMissingErrorScreen(Minecraft.getInstance().screen, Component.translatable("iris.unsupported.pack"), component));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processBiomeMap(BiConsumer<String, String> define) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockEntry parseBlockEntry(@NotNull String entry) {
|
||||
if (entry.isEmpty()) {
|
||||
throw new IllegalArgumentException("Called BlockEntry::parse with an empty string");
|
||||
}
|
||||
|
||||
// We can assume that this array is of at least array length because the input string is non-empty.
|
||||
final String[] splitStates = entry.split(":");
|
||||
|
||||
// Trivial case: no states, no namespace
|
||||
if (splitStates.length == 1) {
|
||||
return new BlockEntry(new NamespacedId("minecraft", entry), Collections.emptySet());
|
||||
}
|
||||
|
||||
// Examples of what we'll accept
|
||||
// stone
|
||||
// stone:0
|
||||
// minecraft:stone:0
|
||||
// minecraft:stone:0,1,2 # Theoretically valid, but I haven't seen any examples in actual shaders
|
||||
|
||||
// Examples of what we don't (Yet?) accept - Seems to be from MC 1.8+
|
||||
// minecraft:farmland:moisture=0
|
||||
// minecraft:farmland:moisture=1
|
||||
// minecraft:double_plant:half=lower
|
||||
// minecraft:double_plant:half=upper
|
||||
// minecraft:grass:snowy=true
|
||||
// minecraft:unpowered_comparator:powered=false
|
||||
|
||||
|
||||
// Less trivial case: no metas involved, just a namespace
|
||||
//
|
||||
// The first term MUST be a valid ResourceLocation component
|
||||
// The second term, if it is not numeric, must be a valid ResourceLocation component.
|
||||
if (splitStates.length == 2 && !StringUtils.isNumeric(splitStates[1].substring(0, 1))) {
|
||||
return new BlockEntry(new NamespacedId(splitStates[0], splitStates[1]), Collections.emptySet());
|
||||
}
|
||||
|
||||
// Complex case: One or more states involved...
|
||||
final int statesStart;
|
||||
final NamespacedId id;
|
||||
|
||||
if (StringUtils.isNumeric(splitStates[1].substring(0, 1))) {
|
||||
// We have an entry of the form "stone:0"
|
||||
statesStart = 1;
|
||||
id = new NamespacedId("minecraft", splitStates[0]);
|
||||
} else {
|
||||
// We have an entry of the form "minecraft:stone:0"
|
||||
statesStart = 2;
|
||||
id = new NamespacedId(splitStates[0], splitStates[1]);
|
||||
}
|
||||
|
||||
final Set<Integer> metas = new HashSet<>();
|
||||
|
||||
for (int index = statesStart; index < splitStates.length; index++) {
|
||||
// Parse out one or more metadata ids
|
||||
final String[] metaParts = splitStates[index].split(", ");
|
||||
|
||||
for (String metaPart : metaParts) {
|
||||
try {
|
||||
metas.add(Integer.parseInt(metaPart));
|
||||
} catch (NumberFormatException e) {
|
||||
IRIS_LOGGER.warn("Warning: the block ID map entry \"" + entry + "\" could not be fully parsed:");
|
||||
IRIS_LOGGER.warn("- Metadata ids must be a comma separated list of one or more integers, but "+ splitStates[index] + " is not of that form!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new BlockEntry(id, metas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockEntry createBlockEntry(NamespacedId id) {
|
||||
return new BlockEntry(id, Set.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEarlyInitialize() {
|
||||
// reloadKeybind = new KeyMapping("iris.keybind.reload", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_R, "iris.keybinds");
|
||||
// toggleShadersKeybind = new KeyMapping("iris.keybind.toggleShaders", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_K, "iris.keybinds");
|
||||
// shaderpackScreenKeybind = new KeyMapping("iris.keybind.shaderPackSelection", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_O, "iris.keybinds");
|
||||
// wireframeKeybind = new KeyMapping("iris.keybind.wireframe", InputConstants.Type.KEYSYM, InputConstants.UNKNOWN.getValue(), "iris.keybinds");
|
||||
|
||||
|
||||
// DHCompat.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderSystemInit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingComplete() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyEverything() {
|
||||
IrisCommon.getPipelineManager().destroyPipeline();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldRenderingPipeline createPipeline(NamespacedId dimensionId) {
|
||||
if (IrisCommon.getCurrentPack().isEmpty()) {
|
||||
// Completely disables shader-based rendering
|
||||
return CeleritasShadersApi.getInstance().createVanillaRenderingPipeline();
|
||||
}
|
||||
|
||||
|
||||
IRIS_LOGGER.error("Not Implemented");
|
||||
// TODO: This should be reverted if a dimension change causes shaders to compile again
|
||||
IrisCommon.setFallback(true);
|
||||
|
||||
return CeleritasShadersApi.getInstance().createVanillaRenderingPipeline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldRenderingPipeline createVanillaRenderingPipeline() {
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDHCompatInstance(IrisRenderingPipeline pipeline, boolean renderDHShadow)
|
||||
throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package net.irisshaders.iris.uniforms;
|
||||
|
||||
import net.irisshaders.iris.gl.uniform.FloatSupplier;
|
||||
import net.irisshaders.iris.gl.uniform.UniformHolder;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.ToIntFunction;
|
||||
|
||||
|
||||
public class ArchaicBiomeUniforms implements BiomeUniforms {
|
||||
@Override
|
||||
public void addBiomeUniforms(UniformHolder uniforms) {
|
||||
// All based on player's location
|
||||
// "biome", int, BiomeID
|
||||
// "biome_category", int, BiomeCategory - BiomeDictionary.Type should be usable
|
||||
// "biome_precipitation", int, Current Precipitation -- seems enableSnow helps with this
|
||||
// "rainfall", float, rainfall
|
||||
// "temperature", float, temperature
|
||||
|
||||
}
|
||||
|
||||
static IntSupplier playerI(ToIntFunction<EntityPlayer> function) {
|
||||
return () -> {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player == null) {
|
||||
return 0; // TODO: I'm not sure what I'm supposed to do here?
|
||||
} else {
|
||||
return function.applyAsInt(player);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static FloatSupplier playerF(ToFloatFunction<EntityPlayer> function) {
|
||||
return () -> {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player == null) {
|
||||
return 0.0f; // TODO: I'm not sure what I'm supposed to do here?
|
||||
} else {
|
||||
return function.applyAsFloat(player);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ToFloatFunction<T> {
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param value the function argument
|
||||
* @return the function result
|
||||
*/
|
||||
float applyAsFloat(T value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package net.irisshaders.iris.uniforms;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntFunction;
|
||||
import net.irisshaders.iris.api.v0.item.IrisItemLightProvider;
|
||||
import net.irisshaders.iris.gl.uniform.UniformHolder;
|
||||
import net.irisshaders.iris.shaderpack.IdMap;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Vector3f;
|
||||
import org.taumc.celeritas.compat.InteractionHand;
|
||||
|
||||
import static net.irisshaders.iris.gl.uniform.UniformUpdateFrequency.PER_FRAME;
|
||||
|
||||
public class ArchaicIdMapUniforms implements IdMapUniforms {
|
||||
|
||||
public void addIdMapUniforms(FrameUpdateNotifier notifier, UniformHolder uniforms, IdMap idMap, boolean isOldHandLight) {
|
||||
HeldItemSupplier mainHandSupplier = new HeldItemSupplier(InteractionHand.MAIN_HAND, idMap.getItemIdMap(), isOldHandLight);
|
||||
HeldItemSupplier offHandSupplier = new HeldItemSupplier(InteractionHand.OFF_HAND, idMap.getItemIdMap(), false);
|
||||
notifier.addListener(mainHandSupplier::update);
|
||||
notifier.addListener(offHandSupplier::update);
|
||||
|
||||
uniforms
|
||||
.uniform1i(PER_FRAME, "heldItemId", mainHandSupplier::getIntID)
|
||||
.uniform1i(PER_FRAME, "heldItemId2", offHandSupplier::getIntID)
|
||||
.uniform1i(PER_FRAME, "heldBlockLightValue", mainHandSupplier::getLightValue)
|
||||
.uniform1i(PER_FRAME, "heldBlockLightValue2", offHandSupplier::getLightValue)
|
||||
.uniform3f(PER_FRAME, "heldBlockLightColor", mainHandSupplier::getLightColor)
|
||||
.uniform3f(PER_FRAME, "heldBlockLightColor2", offHandSupplier::getLightColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the currently held item, and it's light value, in the given hand as a uniform. Uses the item.properties ID map to map the item
|
||||
* to an integer, and the old hand light value to map offhand to main hand.
|
||||
*/
|
||||
private static class HeldItemSupplier {
|
||||
private final InteractionHand hand;
|
||||
private final Object2IntFunction<NamespacedId> itemIdMap;
|
||||
private final boolean applyOldHandLight;
|
||||
private int intID;
|
||||
private int lightValue;
|
||||
private Vector3f lightColor;
|
||||
|
||||
HeldItemSupplier(InteractionHand hand, Object2IntFunction<NamespacedId> itemIdMap, boolean shouldApplyOldHandLight) {
|
||||
this.hand = hand;
|
||||
this.itemIdMap = itemIdMap;
|
||||
this.applyOldHandLight = shouldApplyOldHandLight && hand == InteractionHand.MAIN_HAND;
|
||||
}
|
||||
|
||||
private void invalidate() {
|
||||
intID = -1;
|
||||
lightValue = 0;
|
||||
lightColor = IrisItemLightProvider.DEFAULT_LIGHT_COLOR;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
if (player == null) {
|
||||
// Not valid when the player doesn't exist
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack heldStack = hand.getItemInHand(player);
|
||||
|
||||
if (heldStack == null) {
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
Item heldItem = heldStack.getItem();
|
||||
|
||||
if (heldItem == null) {
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
ResourceLocation heldItemId = new ResourceLocation(Item.itemRegistry.getNameForObject(heldItem));
|
||||
intID = itemIdMap.applyAsInt(new NamespacedId(heldItemId.getResourceDomain(), heldItemId.getResourcePath()));
|
||||
|
||||
IrisItemLightProvider lightProvider = (IrisItemLightProvider) heldItem;
|
||||
lightValue = lightProvider.getLightEmission(Minecraft.getMinecraft().thePlayer, heldStack);
|
||||
|
||||
if (applyOldHandLight) {
|
||||
lightProvider = applyOldHandLighting(player, lightProvider);
|
||||
}
|
||||
}
|
||||
|
||||
private IrisItemLightProvider applyOldHandLighting(@NotNull EntityPlayer player, IrisItemLightProvider existing) {
|
||||
ItemStack offHandStack = InteractionHand.OFF_HAND.getItemInHand(player);
|
||||
|
||||
if (offHandStack == null) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
Item offHandItem = offHandStack.getItem();
|
||||
|
||||
if (offHandItem == null) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
IrisItemLightProvider lightProvider = (IrisItemLightProvider) offHandItem;
|
||||
int newEmission = lightProvider.getLightEmission(Minecraft.getMinecraft().thePlayer, offHandStack);
|
||||
|
||||
if (lightValue < newEmission) {
|
||||
lightValue = newEmission;
|
||||
return lightProvider;
|
||||
}
|
||||
|
||||
return existing;
|
||||
}
|
||||
|
||||
public int getIntID() {
|
||||
return intID;
|
||||
}
|
||||
|
||||
public int getLightValue() {
|
||||
return lightValue;
|
||||
}
|
||||
|
||||
public Vector3f getLightColor() {
|
||||
return lightColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
+193
-6
@@ -6,25 +6,30 @@ import net.irisshaders.iris.uniforms.CapturedRenderingState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.WorldProviderEnd;
|
||||
import net.minecraft.world.WorldProviderHell;
|
||||
import org.embeddedt.embeddium.compat.mc.IResourceLocation;
|
||||
import org.embeddedt.embeddium.compat.mc.MCNativeImage;
|
||||
import org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService;
|
||||
import org.embeddedt.embeddium.compat.mc.PlatformUtilService;
|
||||
import org.joml.*;
|
||||
import org.joml.Math;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector4f;
|
||||
import org.lwjgl.system.Platform;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class MinecraftArchaicVersionShimImpl implements MinecraftVersionShimService, PlatformUtilService {
|
||||
private static final Minecraft client = Minecraft.getMinecraft();
|
||||
private static final boolean isDevelopmentEnvironment = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
|
||||
|
||||
|
||||
@@ -62,6 +67,11 @@ public class MinecraftArchaicVersionShimImpl implements MinecraftVersionShimServ
|
||||
return Minecraft.getMinecraft().gameSettings.renderDistanceChunks * 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEffectiveRenderDistance() {
|
||||
return Minecraft.getMinecraft().gameSettings.renderDistanceChunks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3d getUnshiftedCameraPosition() {
|
||||
// TODO: Needs to be captured in 1.7.10 via mixins
|
||||
@@ -267,6 +277,149 @@ public class MinecraftArchaicVersionShimImpl implements MinecraftVersionShimServ
|
||||
return eyePosition.set(eye.posX, eye.posY, eye.posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnGround() {
|
||||
return client.thePlayer != null && client.thePlayer.onGround;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHurt() {
|
||||
// Do not use isHurt, that's not what we want!
|
||||
return (client.thePlayer != null && client.thePlayer.hurtTime > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvisible() {
|
||||
return (client.thePlayer != null && client.thePlayer.isInvisible());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBurning() {
|
||||
return client.thePlayer != null && client.thePlayer.fire > 0 && !client.thePlayer.isImmuneToFire();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSneaking() {
|
||||
return (client.thePlayer != null && client.thePlayer.isSneaking());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSprinting() {
|
||||
return (client.thePlayer != null && client.thePlayer.isSprinting());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3d getSkyColor() {
|
||||
if (client.theWorld == null || client.renderViewEntity == null) {
|
||||
return ZERO3D;
|
||||
}
|
||||
final Vec3 skyColor = client.theWorld.getSkyColor(client.renderViewEntity, CapturedRenderingState.INSTANCE.getTickDelta());
|
||||
return new Vector3d(skyColor.xCoord, skyColor.yCoord, skyColor.zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlindness() {
|
||||
final EntityLivingBase cameraEntity = client.renderViewEntity;
|
||||
|
||||
if (cameraEntity instanceof EntityLiving livingEntity && livingEntity.isPotionActive(Potion.blindness)) {
|
||||
final PotionEffect blindness = livingEntity.getActivePotionEffect(Potion.blindness);
|
||||
|
||||
if (blindness != null) {
|
||||
// Guessing that this is what OF uses, based on how vanilla calculates the fog value in BackgroundRenderer
|
||||
// TODO: Add this to ShaderDoc
|
||||
return Math.clamp(0.0F, 1.0F, blindness.getDuration() / 20.0F);
|
||||
}
|
||||
}
|
||||
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDarknessFactor() {
|
||||
// TODO: What should this be?
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPlayerMood() {
|
||||
// TODO: What should this be?
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRainStrength() {
|
||||
if (client.theWorld == null) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
// Note: Ensure this is in the range of 0 to 1 - some custom servers send out of range values.
|
||||
return Math.clamp(0.0F, 1.0F, client.theWorld.getRainStrength(CapturedRenderingState.INSTANCE.getTickDelta()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2i getEyeBrightness() {
|
||||
if (client.renderViewEntity == null || client.theWorld == null) {
|
||||
return ZERO2I;
|
||||
}
|
||||
// This is what ShadersMod did in 1.7.10
|
||||
final int eyeBrightness = client.renderViewEntity.getBrightnessForRender(CapturedRenderingState.INSTANCE.getTickDelta());
|
||||
return new Vector2i((eyeBrightness & 0xffff), (eyeBrightness >> 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getNightVision() {
|
||||
Entity cameraEntity = client.renderViewEntity;
|
||||
|
||||
if (cameraEntity instanceof EntityPlayer entityPlayer) {
|
||||
if (!entityPlayer.isPotionActive(Potion.nightVision)) {
|
||||
return 0.0F;
|
||||
}
|
||||
float nightVisionStrength = client.entityRenderer.getNightVisionBrightness(entityPlayer, CapturedRenderingState.INSTANCE.getTickDelta());
|
||||
|
||||
try {
|
||||
if (nightVisionStrength > 0) {
|
||||
// Just protecting against potential weird mod behavior
|
||||
return Math.clamp(0.0F, 1.0F, nightVisionStrength);
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
return 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isEyeInWater() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hideGui() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRightHanded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getScreenBrightness() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2i getAtlasSize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2i getTextureSize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCNativeImage createNativeImage(int width, int height, boolean useCalloc) {
|
||||
// TODO
|
||||
@@ -290,16 +443,50 @@ public class MinecraftArchaicVersionShimImpl implements MinecraftVersionShimServ
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadIris() throws IOException {
|
||||
public String getOsString() {
|
||||
return switch (Platform.get()) {
|
||||
case Platform.MACOSX -> "MC_OS_MAC";
|
||||
case Platform.LINUX -> "MC_OS_LINUX";
|
||||
case Platform.WINDOWS -> "MC_OS_WINDOWS";
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMcVersion() {
|
||||
return Loader.MC_VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBackupVersionNumber() {
|
||||
return "1.7.10";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markRendererReloadRequired() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean irisAllowConcurrentUpdate() {
|
||||
// TODO
|
||||
public boolean isDHPresent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix4f getShadowModelView(float sunPathRotation, float intervalSize) {
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix4f getShadowProjection(float shadowDistance, float nearPlane, float farPlane) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindFramebuffer() {
|
||||
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoadValid() {
|
||||
return true;
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package org.taumc.celeritas.mixin.shaders;
|
||||
package org.taumc.celeritas.mixin.shaders.startup;
|
||||
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@@ -20,7 +20,7 @@ public class MixinGameSettings {
|
||||
}
|
||||
|
||||
iris$initialized = true;
|
||||
Iris.onEarlyInitialize();
|
||||
IrisCommon.onEarlyInitialize();
|
||||
}
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package org.taumc.celeritas.mixin.shaders.startup;
|
||||
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
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;
|
||||
|
||||
@Mixin(OpenGlHelper.class)
|
||||
public class MixinInitRenderer {
|
||||
@Inject(method = "initializeTextures", at = @At("RETURN"))
|
||||
private static void angelica$initializeRenderer(CallbackInfo ci) {
|
||||
IrisCommon.onRenderSystemInit();
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
net.irisshaders.iris.uniforms.ArchaicBiomeUniforms
|
||||
+1
@@ -0,0 +1 @@
|
||||
net.irisshaders.iris.uniforms.ArchaicIdMapUniforms
|
||||
+1
-1
@@ -25,7 +25,7 @@ public abstract class MixinDebugScreenOverlay {
|
||||
DrawCallTrackingRenderBuffers drawTracker = (DrawCallTrackingRenderBuffers) Minecraft.getInstance().renderBuffers();
|
||||
|
||||
// blank line separator
|
||||
if (true) { // TODO Iris.getIrisConfig().areDebugOptionsEnabled()) {
|
||||
if (true) { // TODO IrisCommon.getIrisConfig().areDebugOptionsEnabled()) {
|
||||
messages.add("");
|
||||
messages.add("[Entity Batching] " + BatchingDebugMessageHelper.getDebugMessage(drawTracker));
|
||||
}
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package net.irisshaders.iris.shaderpack.materialmap;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ModernWorldRenderingSettings {
|
||||
public static final ModernWorldRenderingSettings INSTANCE = new ModernWorldRenderingSettings();
|
||||
|
||||
private Object2IntMap<BlockState> blockStateIds;
|
||||
private FallbackTextureMaterials fallbackTextureMaterialMapping;
|
||||
private Map<Block, RenderType> blockTypeIds;
|
||||
|
||||
public ModernWorldRenderingSettings() {
|
||||
this.blockStateIds = null;
|
||||
this.fallbackTextureMaterialMapping = null;
|
||||
this.blockTypeIds = null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object2IntMap<BlockState> getBlockStateIds() {
|
||||
return blockStateIds;
|
||||
}
|
||||
|
||||
public void setBlockStateIds(Object2IntMap<BlockState> blockStateIds) {
|
||||
if (Objects.equals(this.blockStateIds, blockStateIds)) {
|
||||
return;
|
||||
}
|
||||
WorldRenderingSettings.INSTANCE.setReloadRequired();
|
||||
this.blockStateIds = blockStateIds;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FallbackTextureMaterials getFallbackTextureMaterialMapping() {
|
||||
return fallbackTextureMaterialMapping;
|
||||
}
|
||||
|
||||
public void setFallbackTextureMaterialMapping(FallbackTextureMaterials fallbackTextureMaterialMapping) {
|
||||
if (Objects.equals(this.fallbackTextureMaterialMapping, fallbackTextureMaterialMapping)) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorldRenderingSettings.INSTANCE.setReloadRequired();
|
||||
this.fallbackTextureMaterialMapping = fallbackTextureMaterialMapping;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public Map<Block, RenderType> getBlockTypeIds() {
|
||||
return blockTypeIds;
|
||||
}
|
||||
|
||||
public void setBlockTypeIds(Map<Block, RenderType> blockTypeIds) {
|
||||
if (Objects.equals(this.blockTypeIds, blockTypeIds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorldRenderingSettings.INSTANCE.setReloadRequired();
|
||||
this.blockTypeIds = blockTypeIds;
|
||||
}
|
||||
}
|
||||
@@ -115,10 +115,10 @@ public class Celeritas /*? if fabric {*/ /*implements ClientModInitializer *//*?
|
||||
// TODO remove
|
||||
//? if shaders {
|
||||
modEventBus.addListener((RegisterKeyMappingsEvent ev) -> {
|
||||
ev.register(net.irisshaders.iris.Iris.reloadKeybind);
|
||||
ev.register(net.irisshaders.iris.Iris.shaderpackScreenKeybind);
|
||||
ev.register(net.irisshaders.iris.Iris.toggleShadersKeybind);
|
||||
ev.register(net.irisshaders.iris.Iris.wireframeKeybind);
|
||||
ev.register(net.irisshaders.iris.apiimpl.IrisApiV0Impl.reloadKeybind);
|
||||
ev.register(net.irisshaders.iris.apiimpl.IrisApiV0Impl.shaderpackScreenKeybind);
|
||||
ev.register(net.irisshaders.iris.apiimpl.IrisApiV0Impl.toggleShadersKeybind);
|
||||
ev.register(net.irisshaders.iris.apiimpl.IrisApiV0Impl.wireframeKeybind);
|
||||
});
|
||||
//?}
|
||||
}
|
||||
|
||||
+2
-3
@@ -1,9 +1,8 @@
|
||||
package org.embeddedt.embeddium.impl.modern.render.chunk.compile.pipeline;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.ModernWorldRenderingSettings;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import org.embeddedt.embeddium.impl.model.color.ColorProviderRegistry;
|
||||
import org.embeddedt.embeddium.impl.model.light.LightPipelineProvider;
|
||||
import org.embeddedt.embeddium.impl.model.light.data.ArrayLightDataCache;
|
||||
@@ -50,7 +49,7 @@ public class BlockRenderCache {
|
||||
|
||||
var colorRegistry = new ColorProviderRegistry(client.getBlockColors());
|
||||
|
||||
this.blockRenderer = new BlockRenderer(colorRegistry, lightPipelineProvider, WorldRenderingSettings.INSTANCE.getBlockTypeIds());
|
||||
this.blockRenderer = new BlockRenderer(colorRegistry, lightPipelineProvider, ModernWorldRenderingSettings.INSTANCE.getBlockTypeIds());
|
||||
this.fluidRenderer = new FluidRenderer(colorRegistry, lightPipelineProvider);
|
||||
this.lightPipelineProvider = lightPipelineProvider;
|
||||
this.specialBlockRenderer = new SpecialBlockRenderer();
|
||||
|
||||
@@ -2,34 +2,23 @@ package net.irisshaders.iris;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.mojang.blaze3d.platform.GlDebug;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
//? if fabric
|
||||
/*import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;*/
|
||||
import net.irisshaders.iris.compat.dh.DHCompat;
|
||||
import net.irisshaders.iris.compat.sodium.impl.options.IrisSodiumOptions;
|
||||
import net.irisshaders.iris.config.IrisConfig;
|
||||
import net.irisshaders.iris.gl.shader.ShaderCompileException;
|
||||
import net.irisshaders.iris.gl.shader.StandardMacros;
|
||||
import net.irisshaders.iris.gui.debug.DebugLoadFailedGridScreen;
|
||||
import net.irisshaders.iris.gui.screen.ShaderPackScreen;
|
||||
import net.irisshaders.iris.helpers.OptionalBoolean;
|
||||
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.PipelineManager;
|
||||
import net.irisshaders.iris.pipeline.VanillaRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.irisshaders.iris.shaderpack.DimensionId;
|
||||
import net.irisshaders.iris.shaderpack.ShaderPack;
|
||||
import net.irisshaders.iris.shaderpack.discovery.ShaderpackDirectoryManager;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.irisshaders.iris.shaderpack.option.OptionSet;
|
||||
import net.irisshaders.iris.shaderpack.option.Profile;
|
||||
import net.irisshaders.iris.shaderpack.option.values.MutableOptionValues;
|
||||
import net.irisshaders.iris.shaderpack.option.values.OptionValues;
|
||||
import net.irisshaders.iris.shaderpack.programs.ProgramSet;
|
||||
import net.irisshaders.iris.texture.pbr.PBRTextureManager;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
@@ -38,25 +27,14 @@ import org.embeddedt.embeddium.impl.Celeritas;
|
||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||
import org.embeddedt.embeddium.impl.loader.common.EarlyLoaderServices;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.taumc.celeritas.api.v0.CeleritasShadersApi;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystemNotFoundException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipError;
|
||||
import java.util.zip.ZipException;
|
||||
|
||||
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
||||
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
|
||||
@@ -64,87 +42,45 @@ import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTI
|
||||
public class Iris {
|
||||
|
||||
public static final IrisLogging logger = IRIS_LOGGER;
|
||||
private static final Map<String, String> shaderPackOptionQueue = new HashMap<>();
|
||||
// Change this for snapshots!
|
||||
private static final String backupVersionNumber = "1.20.3";
|
||||
public static NamespacedId lastDimension = null;
|
||||
public static boolean testing = false;
|
||||
private static ShaderpackDirectoryManager shaderpacksDirectoryManager;
|
||||
private static ShaderPack currentPack;
|
||||
private static String currentPackName;
|
||||
private static Optional<Exception> storedError = Optional.empty();
|
||||
private static boolean initialized;
|
||||
private static PipelineManager pipelineManager;
|
||||
private static IrisConfig irisConfig;
|
||||
private static FileSystem zipFileSystem;
|
||||
|
||||
public static KeyMapping reloadKeybind;
|
||||
public static KeyMapping toggleShadersKeybind;
|
||||
public static KeyMapping shaderpackScreenKeybind;
|
||||
public static KeyMapping wireframeKeybind;
|
||||
// Flag variable used when reloading
|
||||
// Used in favor of queueDefaultShaderPackOptionValues() for resetting as the
|
||||
// behavior is more concrete and therefore is more likely to repair a user's issues
|
||||
private static boolean resetShaderPackOptions = false;
|
||||
|
||||
private static boolean fallback;
|
||||
private static boolean loadPackWhenPossible = false;
|
||||
private static boolean renderSystemInit = false;
|
||||
|
||||
public static void loadShaderpackWhenPossible() {
|
||||
loadPackWhenPossible = true;
|
||||
}
|
||||
|
||||
public static boolean isPackInUseQuick() {
|
||||
return pipelineManager.getPipelineNullable() instanceof IrisRenderingPipeline;
|
||||
return IrisCommon.getPipelineManager().getPipelineNullable() instanceof ModernIrisRenderingPipeline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called once RenderSystem#initRenderer has completed. This means that we can safely access OpenGL.
|
||||
*/
|
||||
public static void onRenderSystemInit() {
|
||||
if (!initialized) {
|
||||
IRIS_LOGGER.warn("Iris::onRenderSystemInit was called, but Iris::onEarlyInitialize was not called." +
|
||||
" Trying to avoid a crash but this is an odd state.");
|
||||
return;
|
||||
}
|
||||
|
||||
PBRTextureManager.INSTANCE.init();
|
||||
|
||||
renderSystemInit = true;
|
||||
|
||||
|
||||
// Only load the shader pack when we can access OpenGL
|
||||
if (!EarlyLoaderServices.INSTANCE.isModLoaded("distanthorizons")) {
|
||||
loadShaderpack();
|
||||
IrisCommon.loadShaderpack();
|
||||
}
|
||||
}
|
||||
|
||||
public static void duringRenderSystemInit() {
|
||||
setDebug(irisConfig.areDebugOptionsEnabled());
|
||||
setDebug(IrisCommon.getIrisConfig().areDebugOptionsEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the title screen is initialized for the first time.
|
||||
*/
|
||||
public static void onLoadingComplete() {
|
||||
if (!initialized) {
|
||||
IRIS_LOGGER.warn("Iris::onLoadingComplete was called, but Iris::onEarlyInitialize was not called." +
|
||||
" Trying to avoid a crash but this is an odd state.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize the pipeline now so that we don't increase world loading time. Just going to guess that
|
||||
// the player is in the overworld.
|
||||
// See: https://github.com/IrisShaders/Iris/issues/323
|
||||
lastDimension = DimensionId.OVERWORLD;
|
||||
Iris.getPipelineManager().preparePipeline(DimensionId.OVERWORLD);
|
||||
|
||||
IrisSodiumOptions.init();
|
||||
}
|
||||
|
||||
public static void handleKeybinds(Minecraft minecraft) {
|
||||
if (reloadKeybind.consumeClick()) {
|
||||
if (net.irisshaders.iris.apiimpl.IrisApiV0Impl.reloadKeybind.consumeClick()) {
|
||||
try {
|
||||
reload();
|
||||
|
||||
@@ -159,216 +95,45 @@ public class Iris {
|
||||
minecraft.player.displayClientMessage(Component.translatable("iris.shaders.reloaded.failure", Throwables.getRootCause(e).getMessage()).withStyle(ChatFormatting.RED), false);
|
||||
}
|
||||
}
|
||||
} else if (toggleShadersKeybind.consumeClick()) {
|
||||
} else if (net.irisshaders.iris.apiimpl.IrisApiV0Impl.toggleShadersKeybind.consumeClick()) {
|
||||
try {
|
||||
toggleShaders(minecraft, !irisConfig.areShadersEnabled());
|
||||
toggleShaders(minecraft, !IrisCommon.getIrisConfig().areShadersEnabled());
|
||||
} catch (Exception e) {
|
||||
logger.error("Error while toggling shaders!", e);
|
||||
|
||||
if (minecraft.player != null) {
|
||||
minecraft.player.displayClientMessage(Component.translatable("iris.shaders.toggled.failure", Throwables.getRootCause(e).getMessage()).withStyle(ChatFormatting.RED), false);
|
||||
}
|
||||
setShadersDisabled();
|
||||
fallback = true;
|
||||
IrisCommon.setShadersDisabled();
|
||||
IrisCommon.fallback = true;
|
||||
}
|
||||
} else if (shaderpackScreenKeybind.consumeClick()) {
|
||||
} else if (net.irisshaders.iris.apiimpl.IrisApiV0Impl.shaderpackScreenKeybind.consumeClick()) {
|
||||
minecraft.setScreen(new ShaderPackScreen(null));
|
||||
} else if (wireframeKeybind.consumeClick()) {
|
||||
if (irisConfig.areDebugOptionsEnabled() && minecraft.player != null && !Minecraft.getInstance().isLocalServer()) {
|
||||
} else if (net.irisshaders.iris.apiimpl.IrisApiV0Impl.wireframeKeybind.consumeClick()) {
|
||||
if (IrisCommon.getIrisConfig().areDebugOptionsEnabled() && minecraft.player != null && !Minecraft.getInstance().isLocalServer()) {
|
||||
minecraft.player.displayClientMessage(Component.literal("No cheating; wireframe only in singleplayer!"), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean shouldActivateWireframe() {
|
||||
return irisConfig.areDebugOptionsEnabled() && wireframeKeybind.isDown();
|
||||
return IrisCommon.getIrisConfig().areDebugOptionsEnabled() && net.irisshaders.iris.apiimpl.IrisApiV0Impl.wireframeKeybind.isDown();
|
||||
}
|
||||
|
||||
public static void toggleShaders(Minecraft minecraft, boolean enabled) throws IOException {
|
||||
irisConfig.setShadersEnabled(enabled);
|
||||
irisConfig.save();
|
||||
IrisCommon.getIrisConfig().setShadersEnabled(enabled);
|
||||
IrisCommon.getIrisConfig().save();
|
||||
|
||||
reload();
|
||||
if (minecraft.player != null) {
|
||||
minecraft.player.displayClientMessage(enabled ? Component.translatable("iris.shaders.toggled", currentPackName) : Component.translatable("iris.shaders.disabled"), false);
|
||||
minecraft.player.displayClientMessage(enabled ? Component.translatable("iris.shaders.toggled", IrisCommon.currentPackName) : Component.translatable("iris.shaders.disabled"), false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadShaderpack() {
|
||||
if (irisConfig == null) {
|
||||
if (!initialized) {
|
||||
throw new IllegalStateException("Iris::loadShaderpack was called, but Iris::onInitializeClient wasn't" +
|
||||
" called yet. How did this happen?");
|
||||
} else {
|
||||
throw new NullPointerException("Iris.irisConfig was null unexpectedly");
|
||||
}
|
||||
}
|
||||
|
||||
if (!irisConfig.areShadersEnabled()) {
|
||||
logger.info("Shaders are disabled because enableShaders is set to false in iris.properties");
|
||||
|
||||
setShadersDisabled();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Attempt to load an external shaderpack if it is available
|
||||
Optional<String> externalName = irisConfig.getShaderPackName();
|
||||
|
||||
if (externalName.isEmpty()) {
|
||||
logger.info("Shaders are disabled because no valid shaderpack is selected");
|
||||
|
||||
setShadersDisabled();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!loadExternalShaderpack(externalName.get())) {
|
||||
logger.warn("Falling back to normal rendering without shaders because the shaderpack could not be loaded");
|
||||
setShadersDisabled();
|
||||
fallback = true;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static boolean loadExternalShaderpack(String name) {
|
||||
Path shaderPackRoot;
|
||||
Path shaderPackConfigTxt;
|
||||
|
||||
public static void setDebug(boolean enable) {
|
||||
try {
|
||||
shaderPackRoot = IrisCommon.getShaderpacksDirectory().resolve(name);
|
||||
shaderPackConfigTxt = IrisCommon.getShaderpacksDirectory().resolve(name + ".txt");
|
||||
} catch (InvalidPathException e) {
|
||||
logger.error("Failed to load the shaderpack \"{}\" because it contains invalid characters in its path", name);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isValidShaderpack(shaderPackRoot)) {
|
||||
logger.error("Pack \"{}\" is not valid! Can't load it.", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
Path shaderPackPath;
|
||||
|
||||
if (!Files.isDirectory(shaderPackRoot) && shaderPackRoot.toString().endsWith(".zip")) {
|
||||
Optional<Path> optionalPath;
|
||||
|
||||
try {
|
||||
optionalPath = loadExternalZipShaderpack(shaderPackRoot);
|
||||
} catch (FileSystemNotFoundException | NoSuchFileException e) {
|
||||
logger.error("Failed to load the shaderpack \"{}\" because it does not exist in your shaderpacks folder!", name);
|
||||
|
||||
return false;
|
||||
} catch (ZipException e) {
|
||||
logger.error("The shaderpack \"{}\" appears to be corrupted, please try downloading it again!", name);
|
||||
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
logger.error("Failed to load the shaderpack \"{}\"!", name);
|
||||
logger.error("", e);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (optionalPath.isPresent()) {
|
||||
shaderPackPath = optionalPath.get();
|
||||
} else {
|
||||
logger.error("Could not load the shaderpack \"{}\" because it appears to lack a \"shaders\" directory", name);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!Files.exists(shaderPackRoot)) {
|
||||
logger.error("Failed to load the shaderpack \"{}\" because it does not exist!", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
// If it's a folder-based shaderpack, just use the shaders subdirectory
|
||||
shaderPackPath = shaderPackRoot.resolve("shaders");
|
||||
}
|
||||
|
||||
if (!Files.exists(shaderPackPath)) {
|
||||
logger.error("Could not load the shaderpack \"{}\" because it appears to lack a \"shaders\" directory", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
Map<String, String> changedConfigs = tryReadConfigProperties(shaderPackConfigTxt)
|
||||
.map(properties -> (Map<String, String>) (Object) properties)
|
||||
.orElse(new HashMap<>());
|
||||
|
||||
changedConfigs.putAll(shaderPackOptionQueue);
|
||||
clearShaderPackOptionQueue();
|
||||
|
||||
if (resetShaderPackOptions) {
|
||||
changedConfigs.clear();
|
||||
}
|
||||
resetShaderPackOptions = false;
|
||||
|
||||
try {
|
||||
currentPack = new ShaderPack(shaderPackPath, changedConfigs, StandardMacros.createStandardEnvironmentDefines());
|
||||
|
||||
MutableOptionValues changedConfigsValues = currentPack.getShaderPackOptions().getOptionValues().mutableCopy();
|
||||
|
||||
// Store changed values from those currently in use by the shader pack
|
||||
Properties configsToSave = new Properties();
|
||||
changedConfigsValues.getBooleanValues().forEach((k, v) -> configsToSave.setProperty(k, Boolean.toString(v)));
|
||||
changedConfigsValues.getStringValues().forEach(configsToSave::setProperty);
|
||||
|
||||
tryUpdateConfigPropertiesFile(shaderPackConfigTxt, configsToSave);
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to load the shaderpack \"{}\"!", name);
|
||||
logger.error("", e);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
fallback = false;
|
||||
currentPackName = name;
|
||||
|
||||
logger.info("Using shaderpack: " + name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Optional<Path> loadExternalZipShaderpack(Path shaderpackPath) throws IOException {
|
||||
FileSystem zipSystem = FileSystems.newFileSystem(shaderpackPath, Iris.class.getClassLoader());
|
||||
zipFileSystem = zipSystem;
|
||||
|
||||
// Should only be one root directory for a zip shaderpack
|
||||
Path root = zipSystem.getRootDirectories().iterator().next();
|
||||
|
||||
Path potentialShaderDir = zipSystem.getPath("shaders");
|
||||
|
||||
// If the shaders dir was immediately found return it
|
||||
// Otherwise, manually search through each directory path until it ends with "shaders"
|
||||
if (Files.exists(potentialShaderDir)) {
|
||||
return Optional.of(potentialShaderDir);
|
||||
}
|
||||
|
||||
// Sometimes shaderpacks have their shaders directory within another folder in the shaderpack
|
||||
// For example Sildurs-Vibrant-Shaders.zip/shaders
|
||||
// While other packs have Trippy-Shaderpack-master.zip/Trippy-Shaderpack-master/shaders
|
||||
// This makes it hard to determine what is the actual shaders dir
|
||||
try (Stream<Path> stream = Files.walk(root)) {
|
||||
return stream
|
||||
.filter(Files::isDirectory)
|
||||
.filter(path -> path.endsWith("shaders"))
|
||||
.findFirst();
|
||||
}
|
||||
}
|
||||
|
||||
private static void setShadersDisabled() {
|
||||
currentPack = null;
|
||||
fallback = false;
|
||||
currentPackName = "(off)";
|
||||
|
||||
logger.info("Shaders are disabled");
|
||||
}
|
||||
|
||||
public static void setDebug(boolean enable) {
|
||||
try {
|
||||
irisConfig.setDebugEnabled(enable);
|
||||
irisConfig.save();
|
||||
IrisCommon.getIrisConfig().setDebugEnabled(enable);
|
||||
IrisCommon.getIrisConfig().save();
|
||||
} catch (IOException e) {
|
||||
IRIS_LOGGER.fatal("Failed to save config!", e);
|
||||
}
|
||||
@@ -408,127 +173,19 @@ public class Iris {
|
||||
return Optional.of(properties);
|
||||
}
|
||||
|
||||
private static void tryUpdateConfigPropertiesFile(Path path, Properties properties) {
|
||||
try {
|
||||
if (properties.isEmpty()) {
|
||||
// Delete the file or don't create it if there are no changed configs
|
||||
if (Files.exists(path)) {
|
||||
Files.delete(path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try (OutputStream out = Files.newOutputStream(path)) {
|
||||
properties.store(out, null);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO: Better error handling
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isValidToShowPack(Path pack) {
|
||||
public static boolean isValidToShowPack(Path pack) {
|
||||
return Files.isDirectory(pack) || pack.toString().endsWith(".zip");
|
||||
}
|
||||
|
||||
public static boolean isValidShaderpack(Path pack) {
|
||||
if (Files.isDirectory(pack)) {
|
||||
// Sometimes the shaderpack directory itself can be
|
||||
// identified as a shader pack due to it containing
|
||||
// folders which contain "shaders" folders, this is
|
||||
// necessary to check against that
|
||||
if (pack.equals(IrisCommon.getShaderpacksDirectory())) {
|
||||
return false;
|
||||
}
|
||||
try (Stream<Path> stream = Files.walk(pack)) {
|
||||
return stream
|
||||
.filter(Files::isDirectory)
|
||||
// Prevent a pack simply named "shaders" from being
|
||||
// identified as a valid pack
|
||||
.filter(path -> !path.equals(pack))
|
||||
.anyMatch(path -> path.endsWith("shaders"));
|
||||
} catch (IOException ignored) {
|
||||
// ignored, not a valid shader pack.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (pack.toString().endsWith(".zip")) {
|
||||
try (FileSystem zipSystem = FileSystems.newFileSystem(pack, Iris.class.getClassLoader())) {
|
||||
Path root = zipSystem.getRootDirectories().iterator().next();
|
||||
try (Stream<Path> stream = Files.walk(root)) {
|
||||
return stream
|
||||
.filter(Files::isDirectory)
|
||||
.anyMatch(path -> path.endsWith("shaders"));
|
||||
}
|
||||
} catch (ZipError zipError) {
|
||||
// Java 8 seems to throw a ZipError instead of a subclass of IOException
|
||||
IRIS_LOGGER.warn("The ZIP at " + pack + " is corrupt");
|
||||
} catch (IOException ignored) {
|
||||
// ignored, not a valid shader pack.
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Map<String, String> getShaderPackOptionQueue() {
|
||||
return shaderPackOptionQueue;
|
||||
}
|
||||
|
||||
public static void queueShaderPackOptionsFromProfile(Profile profile) {
|
||||
getShaderPackOptionQueue().putAll(profile.optionValues);
|
||||
}
|
||||
|
||||
public static void queueShaderPackOptionsFromProperties(Properties properties) {
|
||||
queueDefaultShaderPackOptionValues();
|
||||
|
||||
properties.stringPropertyNames().forEach(key ->
|
||||
getShaderPackOptionQueue().put(key, properties.getProperty(key)));
|
||||
}
|
||||
|
||||
// Used in favor of resetShaderPackOptions as the aforementioned requires the pack to be reloaded
|
||||
public static void queueDefaultShaderPackOptionValues() {
|
||||
clearShaderPackOptionQueue();
|
||||
|
||||
getCurrentPack().ifPresent(pack -> {
|
||||
OptionSet options = pack.getShaderPackOptions().getOptionSet();
|
||||
OptionValues values = pack.getShaderPackOptions().getOptionValues();
|
||||
|
||||
options.getStringOptions().forEach((key, mOpt) -> {
|
||||
if (values.getStringValue(key).isPresent()) {
|
||||
getShaderPackOptionQueue().put(key, mOpt.getOption().getDefaultValue());
|
||||
}
|
||||
});
|
||||
options.getBooleanOptions().forEach((key, mOpt) -> {
|
||||
if (values.getBooleanValue(key) != OptionalBoolean.DEFAULT) {
|
||||
getShaderPackOptionQueue().put(key, Boolean.toString(mOpt.getOption().getDefaultValue()));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static void clearShaderPackOptionQueue() {
|
||||
getShaderPackOptionQueue().clear();
|
||||
}
|
||||
|
||||
public static void resetShaderPackOptionsOnNextReload() {
|
||||
resetShaderPackOptions = true;
|
||||
}
|
||||
|
||||
public static boolean shouldResetShaderPackOptionsOnNextReload() {
|
||||
return resetShaderPackOptions;
|
||||
}
|
||||
|
||||
public static void reload() throws IOException {
|
||||
public static void reload() throws IOException {
|
||||
// allows shaderpacks to be changed at runtime
|
||||
irisConfig.initialize();
|
||||
IrisCommon.getIrisConfig().initialize();
|
||||
|
||||
// Destroy all allocated resources
|
||||
destroyEverything();
|
||||
IrisCommon.destroyEverything();
|
||||
|
||||
// Load the new shaderpack
|
||||
loadShaderpack();
|
||||
IrisCommon.loadShaderpack();
|
||||
|
||||
// Very important - we need to re-create the pipeline straight away.
|
||||
// https://github.com/IrisShaders/Iris/issues/1330
|
||||
@@ -537,29 +194,7 @@ public class Iris {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys and deallocates all created OpenGL resources. Useful as part of a reload.
|
||||
*/
|
||||
private static void destroyEverything() {
|
||||
currentPack = null;
|
||||
|
||||
getPipelineManager().destroyPipeline();
|
||||
|
||||
// Close the zip filesystem that the shaderpack was loaded from
|
||||
//
|
||||
// This prevents a FileSystemAlreadyExistsException when reloading shaderpacks.
|
||||
if (zipFileSystem != null) {
|
||||
try {
|
||||
zipFileSystem.close();
|
||||
} catch (NoSuchFileException e) {
|
||||
logger.warn("Failed to close the shaderpack zip when reloading because it was deleted, proceeding anyways.");
|
||||
} catch (IOException e) {
|
||||
logger.error("Failed to close zip file system?", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static NamespacedId getCurrentDimension() {
|
||||
public static NamespacedId getCurrentDimension() {
|
||||
ClientLevel level = Minecraft.getInstance().level;
|
||||
|
||||
if (level != null) {
|
||||
@@ -568,82 +203,28 @@ public class Iris {
|
||||
// This prevents us from reloading the shaderpack unless we need to. Otherwise, if the player is in the
|
||||
// nether and quits the game, we might end up reloading the shaders on exit and on entry to the level
|
||||
// because the code thinks that the dimension changed.
|
||||
return lastDimension;
|
||||
}
|
||||
}
|
||||
|
||||
private static WorldRenderingPipeline createPipeline(NamespacedId dimensionId) {
|
||||
if (currentPack == null) {
|
||||
// Completely disables shader-based rendering
|
||||
return new VanillaRenderingPipeline();
|
||||
}
|
||||
|
||||
ProgramSet programs = currentPack.getProgramSet(dimensionId);
|
||||
|
||||
// We use DeferredWorldRenderingPipeline on 1.16, and NewWorldRendering pipeline on 1.17 when rendering shaders.
|
||||
try {
|
||||
return new IrisRenderingPipeline(programs);
|
||||
} catch (Exception e) {
|
||||
if (irisConfig.areDebugOptionsEnabled()) {
|
||||
Minecraft.getInstance().setScreen(new DebugLoadFailedGridScreen(Minecraft.getInstance().screen, Component.literal(e instanceof ShaderCompileException ? "Failed to compile shaders" : "Exception"), e));
|
||||
} else {
|
||||
if (Minecraft.getInstance().player != null) {
|
||||
Minecraft.getInstance().player.displayClientMessage(Component.translatable(e instanceof ShaderCompileException ? "iris.load.failure.shader" : "iris.load.failure.generic").append(Component.literal("Copy Info").withStyle(arg -> arg.withUnderlined(true).withColor(ChatFormatting.BLUE).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, e.getMessage())))), false);
|
||||
} else {
|
||||
storedError = Optional.of(e);
|
||||
}
|
||||
}
|
||||
logger.error("Failed to create shader rendering pipeline, disabling shaders!", e);
|
||||
// TODO: This should be reverted if a dimension change causes shaders to compile again
|
||||
fallback = true;
|
||||
|
||||
return new VanillaRenderingPipeline();
|
||||
return IrisCommon.getLastDimension();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PipelineManager getPipelineManager() {
|
||||
if (pipelineManager == null) {
|
||||
pipelineManager = new PipelineManager(Iris::createPipeline);
|
||||
}
|
||||
|
||||
if (loadPackWhenPossible && renderSystemInit) {
|
||||
loadPackWhenPossible = false;
|
||||
try {
|
||||
reload();
|
||||
} catch (IOException e) {
|
||||
logger.error("Error while reloading Shaders for " + IrisConstants.MODNAME + "!", e);
|
||||
|
||||
if (Minecraft.getInstance().player != null) {
|
||||
Minecraft.getInstance().player.displayClientMessage(Component.translatable("iris.shaders.reloaded.failure", Throwables.getRootCause(e).getMessage()).withStyle(ChatFormatting.RED), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pipelineManager;
|
||||
return IrisCommon.getPipelineManager();
|
||||
}
|
||||
|
||||
public static Optional<Exception> getStoredError() {
|
||||
Optional<Exception> stored = Iris.storedError;
|
||||
storedError = Optional.empty();
|
||||
Optional<Exception> stored = IrisCommon.getStoredError();
|
||||
IrisCommon.setStoredError(Optional.empty());
|
||||
return stored;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Optional<ShaderPack> getCurrentPack() {
|
||||
return Optional.ofNullable(currentPack);
|
||||
}
|
||||
|
||||
public static String getCurrentPackName() {
|
||||
return currentPackName;
|
||||
return IrisCommon.currentPackName;
|
||||
}
|
||||
|
||||
public static IrisConfig getIrisConfig() {
|
||||
return irisConfig;
|
||||
}
|
||||
|
||||
public static boolean isFallback() {
|
||||
return fallback;
|
||||
return IrisCommon.fallback;
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
@@ -695,48 +276,5 @@ public class Iris {
|
||||
return DHCompat.lastPackIncompatible();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called very early on in Minecraft initialization. At this point we *cannot* safely access OpenGL, but we can do
|
||||
* some very basic setup, config loading, and environment checks.
|
||||
*
|
||||
* <p>This is roughly equivalent to Fabric Loader's ClientModInitializer#onInitializeClient entrypoint, except
|
||||
* it's entirely cross platform & we get to decide its exact semantics.</p>
|
||||
*
|
||||
* <p>This is called right before options are loaded, so we can add key bindings here.</p>
|
||||
*/
|
||||
public static void onEarlyInitialize() {
|
||||
reloadKeybind = new KeyMapping("iris.keybind.reload", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_R, "iris.keybinds");
|
||||
toggleShadersKeybind = new KeyMapping("iris.keybind.toggleShaders", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_K, "iris.keybinds");
|
||||
shaderpackScreenKeybind = new KeyMapping("iris.keybind.shaderPackSelection", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_O, "iris.keybinds");
|
||||
wireframeKeybind = new KeyMapping("iris.keybind.wireframe", InputConstants.Type.KEYSYM, InputConstants.UNKNOWN.getValue(), "iris.keybinds");
|
||||
|
||||
//? if fabric {
|
||||
/*KeyBindingHelper.registerKeyBinding(net.irisshaders.iris.Iris.reloadKeybind);
|
||||
KeyBindingHelper.registerKeyBinding(net.irisshaders.iris.Iris.shaderpackScreenKeybind);
|
||||
KeyBindingHelper.registerKeyBinding(net.irisshaders.iris.Iris.toggleShadersKeybind);
|
||||
KeyBindingHelper.registerKeyBinding(net.irisshaders.iris.Iris.wireframeKeybind);
|
||||
*///?}
|
||||
|
||||
DHCompat.run();
|
||||
|
||||
try {
|
||||
if (!Files.exists(IrisCommon.getShaderpacksDirectory())) {
|
||||
Files.createDirectories(IrisCommon.getShaderpacksDirectory());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.warn("Failed to create the shaderpacks directory!");
|
||||
logger.warn("", e);
|
||||
}
|
||||
|
||||
irisConfig = new IrisConfig(PLATFORM_UTIL.getConfigDir().resolve(IrisConstants.MODID + "-shaders.properties"));
|
||||
|
||||
try {
|
||||
irisConfig.initialize();
|
||||
} catch (IOException e) {
|
||||
logger.error("Failed to initialize Iris configuration, default values will be used instead");
|
||||
logger.error("", e);
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.irisshaders.iris.apiimpl;
|
||||
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.api.v0.IrisApiConfig;
|
||||
import net.irisshaders.iris.config.IrisConfig;
|
||||
|
||||
@@ -11,12 +12,12 @@ import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
||||
public class IrisApiV0ConfigImpl implements IrisApiConfig {
|
||||
@Override
|
||||
public boolean areShadersEnabled() {
|
||||
return Iris.getIrisConfig().areShadersEnabled();
|
||||
return IrisCommon.getIrisConfig().areShadersEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShadersEnabledAndApply(boolean enabled) {
|
||||
IrisConfig config = Iris.getIrisConfig();
|
||||
IrisConfig config = IrisCommon.getIrisConfig();
|
||||
|
||||
config.setShadersEnabled(enabled);
|
||||
|
||||
|
||||
@@ -1,23 +1,63 @@
|
||||
package net.irisshaders.iris.apiimpl;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.IrisConstants;
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.irisshaders.iris.api.v0.IrisApiConfig;
|
||||
import net.irisshaders.iris.api.v0.IrisTextVertexSink;
|
||||
import net.irisshaders.iris.compat.dh.DHCompat;
|
||||
import net.irisshaders.iris.features.FeatureFlags;
|
||||
import net.irisshaders.iris.gl.shader.ShaderCompileException;
|
||||
import net.irisshaders.iris.gui.FeatureMissingErrorScreen;
|
||||
import net.irisshaders.iris.gui.debug.DebugLoadFailedGridScreen;
|
||||
import net.irisshaders.iris.gui.screen.ShaderPackScreen;
|
||||
import net.irisshaders.iris.pipeline.VanillaRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.*;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.BlockEntry;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.irisshaders.iris.shaderpack.programs.ProgramSet;
|
||||
import net.irisshaders.iris.shadows.ShadowRenderingState;
|
||||
import net.irisshaders.iris.texture.pbr.PBRTextureManager;
|
||||
import net.irisshaders.iris.uniforms.ModernBiomeUniforms;
|
||||
import net.irisshaders.iris.vertices.IrisTextVertexSinkImpl;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.embeddedt.embeddium.compat.iris.IBlockEntry;
|
||||
import org.embeddedt.embeddium.impl.loader.common.EarlyLoaderServices;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.taumc.celeritas.api.v0.CeleritasShadersApi;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
||||
import static net.irisshaders.iris.uniforms.BiomeUniforms.BIOME_UNIFORMS;
|
||||
|
||||
public class IrisApiV0Impl implements IrisApi {
|
||||
private static final IrisApiV0ConfigImpl CONFIG = new IrisApiV0ConfigImpl();
|
||||
|
||||
@Override
|
||||
public static KeyMapping reloadKeybind;
|
||||
public static KeyMapping toggleShadersKeybind;
|
||||
public static KeyMapping shaderpackScreenKeybind;
|
||||
public static KeyMapping wireframeKeybind;
|
||||
|
||||
|
||||
@Override
|
||||
public int getMinorApiRevision() {
|
||||
return 2;
|
||||
}
|
||||
@@ -54,7 +94,7 @@ public class IrisApiV0Impl implements IrisApi {
|
||||
|
||||
@Override
|
||||
public boolean areDebugOptionsEnabled() {
|
||||
return Iris.getIrisConfig().areDebugOptionsEnabled();
|
||||
return IrisCommon.getIrisConfig().areDebugOptionsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,4 +127,211 @@ public class IrisApiV0Impl implements IrisApi {
|
||||
|
||||
return pipeline.getSunPathRotation();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void reloadIris() throws IOException {
|
||||
Iris.reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean irisAllowConcurrentUpdate() {
|
||||
return Iris.getPipelineManager().getPipeline().map(WorldRenderingPipeline::allowConcurrentCompute).orElse(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUnsupportedFeatureFlags(List<FeatureFlags> invalidFlagList, List<String> invalidFeatureFlags) {
|
||||
if (Minecraft.getInstance().screen instanceof ShaderPackScreen) {
|
||||
MutableComponent component = Component.translatable("iris.unsupported.pack.description", FeatureFlags.getInvalidStatus(invalidFlagList), invalidFeatureFlags.stream()
|
||||
.collect(Collectors.joining(", ", ": ", ".")));
|
||||
if (SystemUtils.IS_OS_MAC) {
|
||||
component = component.append(Component.translatable("iris.unsupported.pack.macos"));
|
||||
}
|
||||
Minecraft.getInstance().setScreen(new FeatureMissingErrorScreen(Minecraft.getInstance().screen, Component.translatable("iris.unsupported.pack"), component));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processBiomeMap(BiConsumer<String, String> define) {
|
||||
((ModernBiomeUniforms)BIOME_UNIFORMS).getBiomeMap().forEach((biome, id) ->
|
||||
define.accept("BIOME_" + biome.location().getPath().toUpperCase(Locale.ROOT), String.valueOf(id))
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public IBlockEntry parseBlockEntry(@NotNull String entry) {
|
||||
if (entry.isEmpty()) {
|
||||
throw new IllegalArgumentException("Called BlockEntry::parse with an empty string");
|
||||
}
|
||||
|
||||
boolean isTag;
|
||||
|
||||
if (entry.startsWith("%")) {
|
||||
isTag = true;
|
||||
entry = entry.substring(1);
|
||||
} else {
|
||||
isTag = false;
|
||||
}
|
||||
|
||||
// We can assume that this array is of at least array length because the input string is non-empty.
|
||||
String[] splitStates = entry.split(":");
|
||||
|
||||
// Trivial case: no states, no namespace
|
||||
if (splitStates.length == 1) {
|
||||
return new BlockEntry(new NamespacedId("minecraft", entry), Collections.emptyMap(), isTag);
|
||||
}
|
||||
|
||||
// Less trivial case: no states involved, just a namespace
|
||||
//
|
||||
// The first term MUST be a valid ResourceLocation component without an equals sign
|
||||
// The second term, if it does not contain an equals sign, must be a valid ResourceLocation component.
|
||||
if (splitStates.length == 2 && !splitStates[1].contains("=")) {
|
||||
return new BlockEntry(new NamespacedId(splitStates[0], splitStates[1]), Collections.emptyMap(), isTag);
|
||||
}
|
||||
|
||||
// Complex case: One or more states involved...
|
||||
int statesStart;
|
||||
NamespacedId id;
|
||||
|
||||
if (splitStates[1].contains("=")) {
|
||||
// We have an entry of the form "tall_grass:half=upper"
|
||||
statesStart = 1;
|
||||
id = new NamespacedId("minecraft", splitStates[0]);
|
||||
} else {
|
||||
// We have an entry of the form "minecraft:tall_grass:half=upper"
|
||||
statesStart = 2;
|
||||
id = new NamespacedId(splitStates[0], splitStates[1]);
|
||||
}
|
||||
|
||||
// We must parse each property key=value pair from the state entry.
|
||||
//
|
||||
// These pairs act as a filter on the block states. Thus, the shader pack does not have to specify all the
|
||||
// individual block properties itself; rather, it only specifies the parts of the block state that it wishes
|
||||
// to filter in/out.
|
||||
//
|
||||
// For example, some shader packs may make it so that hanging lantern blocks wave. They will put something of
|
||||
// the form "lantern:hanging=false" in the ID map as a result. Note, however, that there are also waterlogged
|
||||
// hanging lanterns, which would have "lantern:hanging=false:waterlogged=true". We must make sure that when the
|
||||
// shader pack author writes "lantern:hanging=false", that we do not just match that individual state, but that
|
||||
// we also match the waterlogged variant too.
|
||||
Map<String, String> map = new HashMap<>();
|
||||
|
||||
for (int index = statesStart; index < splitStates.length; index++) {
|
||||
// Split "key=value" into the key and value
|
||||
String[] propertyParts = splitStates[index].split("=");
|
||||
|
||||
if (propertyParts.length != 2) {
|
||||
IRIS_LOGGER.warn("Warning: the block ID map entry \"" + entry + "\" could not be fully parsed:");
|
||||
IRIS_LOGGER.warn("- Block state property filters must be of the form \"key=value\", but "
|
||||
+ splitStates[index] + " is not of that form!");
|
||||
|
||||
// Continue and ignore the invalid entry.
|
||||
continue;
|
||||
}
|
||||
|
||||
map.put(propertyParts[0], propertyParts[1]);
|
||||
}
|
||||
|
||||
return new BlockEntry(id, map, isTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockEntry createBlockEntry(NamespacedId id) {
|
||||
return new BlockEntry(id, Collections.emptyMap(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEarlyInitialize() {
|
||||
reloadKeybind = new KeyMapping("iris.keybind.reload", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_R, "iris.keybinds");
|
||||
toggleShadersKeybind = new KeyMapping("iris.keybind.toggleShaders", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_K, "iris.keybinds");
|
||||
shaderpackScreenKeybind = new KeyMapping("iris.keybind.shaderPackSelection", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_O, "iris.keybinds");
|
||||
wireframeKeybind = new KeyMapping("iris.keybind.wireframe", InputConstants.Type.KEYSYM, InputConstants.UNKNOWN.getValue(), "iris.keybinds");
|
||||
|
||||
//? if fabric {
|
||||
/*KeyBindingHelper.registerKeyBinding(reloadKeybind);
|
||||
KeyBindingHelper.registerKeyBinding(shaderpackScreenKeybind);
|
||||
KeyBindingHelper.registerKeyBinding(toggleShadersKeybind);
|
||||
KeyBindingHelper.registerKeyBinding(wireframeKeybind);
|
||||
*///?}
|
||||
|
||||
DHCompat.run();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderSystemInit() {
|
||||
|
||||
PBRTextureManager.INSTANCE.init();
|
||||
|
||||
|
||||
// Only load the shader pack when we can access OpenGL
|
||||
if (!EarlyLoaderServices.INSTANCE.isModLoaded("distanthorizons")) {
|
||||
IrisCommon.loadShaderpack();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingComplete() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyEverything() {
|
||||
Iris.getPipelineManager().destroyPipeline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldRenderingPipeline createPipeline(NamespacedId dimensionId) {
|
||||
if (IrisCommon.getCurrentPack().isEmpty()) {
|
||||
// Completely disables shader-based rendering
|
||||
return CeleritasShadersApi.getInstance().createVanillaRenderingPipeline();
|
||||
}
|
||||
|
||||
ProgramSet programs = IrisCommon.getCurrentPack().get().getProgramSet(dimensionId);
|
||||
|
||||
// We use DeferredWorldRenderingPipeline on 1.16, and NewWorldRendering pipeline on 1.17 when rendering shaders.
|
||||
try {
|
||||
return new ModernIrisRenderingPipeline(programs);
|
||||
} catch (Exception e) {
|
||||
if (IrisCommon.getIrisConfig().areDebugOptionsEnabled()) {
|
||||
Minecraft.getInstance().setScreen(new DebugLoadFailedGridScreen(Minecraft.getInstance().screen, Component.literal(e instanceof ShaderCompileException ? "Failed to compile shaders" : "Exception"), e));
|
||||
} else {
|
||||
if (Minecraft.getInstance().player != null) {
|
||||
Minecraft.getInstance().player.displayClientMessage(Component.translatable(e instanceof ShaderCompileException ? "iris.load.failure.shader" : "iris.load.failure.generic").append(Component.literal("Copy Info").withStyle(arg -> arg.withUnderlined(true).withColor(ChatFormatting.BLUE).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, e.getMessage())))), false);
|
||||
} else {
|
||||
IrisCommon.setStoredError(Optional.of(e));
|
||||
}
|
||||
}
|
||||
IRIS_LOGGER.error("Failed to create shader rendering pipeline, disabling shaders!", e);
|
||||
// TODO: This should be reverted if a dimension change causes shaders to compile again
|
||||
IrisCommon.setFallback(true);
|
||||
|
||||
return CeleritasShadersApi.getInstance().createVanillaRenderingPipeline();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldRenderingPipeline createVanillaRenderingPipeline() {
|
||||
return new ModernVanillaRenderingPipeline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
try {
|
||||
Iris.reload();
|
||||
} catch (IOException e) {
|
||||
IRIS_LOGGER.error("Error while reloading Shaders for " + IrisConstants.MODNAME + "!", e);
|
||||
|
||||
if (Minecraft.getInstance().player != null) {
|
||||
Minecraft.getInstance().player.displayClientMessage(Component.translatable("iris.shaders.reloaded.failure", Throwables.getRootCause(e).getMessage()).withStyle(ChatFormatting.RED), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDHCompatInstance(IrisRenderingPipeline pipeline, boolean renderDHShadow) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
|
||||
return Class.forName("net.irisshaders.iris.compat.dh.DHCompatInternal").getDeclaredConstructor(ModernIrisRenderingPipeline.class, boolean.class).newInstance((ModernIrisRenderingPipeline)pipeline, renderDHShadow);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||
import net.irisshaders.iris.gl.framebuffer.GlFramebuffer;
|
||||
import net.irisshaders.iris.gl.texture.DepthBufferFormat;
|
||||
import net.irisshaders.iris.gl.texture.DepthCopyStrategy;
|
||||
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
|
||||
import net.irisshaders.iris.shaderpack.programs.ProgramSource;
|
||||
import net.irisshaders.iris.shaderpack.properties.CloudSetting;
|
||||
import net.irisshaders.iris.targets.Blaze3dRenderTargetExt;
|
||||
@@ -28,7 +28,7 @@ public class DHCompatInternal {
|
||||
public static final DHCompatInternal SHADERLESS = new DHCompatInternal(null, false);
|
||||
static boolean dhEnabled;
|
||||
private static int guiScale = -1;
|
||||
private final IrisRenderingPipeline pipeline;
|
||||
private final ModernIrisRenderingPipeline pipeline;
|
||||
public boolean shouldOverrideShadow;
|
||||
public boolean shouldOverride;
|
||||
private GlFramebuffer dhGenericFramebuffer;
|
||||
@@ -47,7 +47,7 @@ public class DHCompatInternal {
|
||||
private boolean incompatible = false;
|
||||
private int cachedVersion;
|
||||
|
||||
public DHCompatInternal(IrisRenderingPipeline pipeline, boolean dhShadowEnabled) {
|
||||
public DHCompatInternal(ModernIrisRenderingPipeline pipeline, boolean dhShadowEnabled) {
|
||||
this.pipeline = pipeline;
|
||||
|
||||
if (pipeline == null || !DhApi.Delayed.configs.graphics().renderingEnabled().getValue()) {
|
||||
@@ -142,7 +142,7 @@ public class DHCompatInternal {
|
||||
if (DhApi.Delayed.configs == null) return dhEnabled;
|
||||
|
||||
if ((dhEnabled != DhApi.Delayed.configs.graphics().renderingEnabled().getValue() || guiScale != Minecraft.getInstance().options.guiScale().get())
|
||||
&& Iris.getPipelineManager().getPipelineNullable() instanceof IrisRenderingPipeline) {
|
||||
&& Iris.getPipelineManager().getPipelineNullable() instanceof ModernIrisRenderingPipeline) {
|
||||
guiScale = Minecraft.getInstance().options.guiScale().get();
|
||||
dhEnabled = DhApi.Delayed.configs.graphics().renderingEnabled().getValue();
|
||||
try {
|
||||
|
||||
+4
-4
@@ -29,7 +29,7 @@ import net.irisshaders.iris.gl.shader.GlShader;
|
||||
import net.irisshaders.iris.gl.shader.ShaderType;
|
||||
import net.irisshaders.iris.gl.state.FogMode;
|
||||
import net.irisshaders.iris.gl.texture.TextureType;
|
||||
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
|
||||
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
|
||||
import net.irisshaders.iris.pipeline.transform.ShaderPrinter;
|
||||
@@ -73,7 +73,7 @@ public class IrisGenericRenderProgram implements IDhApiGenericObjectShaderProgra
|
||||
private final int uSkyLight;
|
||||
|
||||
// This will bind AbstractVertexAttribute
|
||||
private IrisGenericRenderProgram(String name, boolean isShadowPass, boolean translucent, BlendModeOverride override, BufferBlendOverride[] bufferBlendOverrides, String vertex, String tessControl, String tessEval, String geometry, String fragment, CustomUniforms customUniforms, IrisRenderingPipeline pipeline) {
|
||||
private IrisGenericRenderProgram(String name, boolean isShadowPass, boolean translucent, BlendModeOverride override, BufferBlendOverride[] bufferBlendOverrides, String vertex, String tessControl, String tessEval, String geometry, String fragment, CustomUniforms customUniforms, ModernIrisRenderingPipeline pipeline) {
|
||||
id = GL43C.glCreateProgram();
|
||||
|
||||
GL32.glBindAttribLocation(this.id, 0, "vPosition");
|
||||
@@ -155,7 +155,7 @@ public class IrisGenericRenderProgram implements IDhApiGenericObjectShaderProgra
|
||||
this.uSkyLight = this.tryGetUniformLocation2("uSkyLight");
|
||||
}
|
||||
|
||||
public static IrisGenericRenderProgram createProgram(String name, boolean isShadowPass, boolean translucent, ProgramSource source, CustomUniforms uniforms, IrisRenderingPipeline pipeline) {
|
||||
public static IrisGenericRenderProgram createProgram(String name, boolean isShadowPass, boolean translucent, ProgramSource source, CustomUniforms uniforms, ModernIrisRenderingPipeline pipeline) {
|
||||
Map<PatchShaderType, String> transformed = TransformPatcherBridge.patchDHGeneric(
|
||||
name,
|
||||
source.getVertexSource().orElseThrow(RuntimeException::new),
|
||||
@@ -268,7 +268,7 @@ public class IrisGenericRenderProgram implements IDhApiGenericObjectShaderProgra
|
||||
|
||||
@Override
|
||||
public boolean overrideThisFrame() {
|
||||
return Iris.getPipelineManager().getPipelineNullable() instanceof IrisRenderingPipeline;
|
||||
return Iris.getPipelineManager().getPipelineNullable() instanceof ModernIrisRenderingPipeline;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ import net.irisshaders.iris.gl.shader.GlShader;
|
||||
import net.irisshaders.iris.gl.shader.ShaderType;
|
||||
import net.irisshaders.iris.gl.state.FogMode;
|
||||
import net.irisshaders.iris.gl.texture.TextureType;
|
||||
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
|
||||
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
|
||||
import net.irisshaders.iris.pipeline.transform.ShaderPrinter;
|
||||
@@ -58,7 +58,7 @@ public class IrisLodRenderProgram {
|
||||
private final BufferBlendOverride[] bufferBlendOverrides;
|
||||
|
||||
// This will bind AbstractVertexAttribute
|
||||
private IrisLodRenderProgram(String name, boolean isShadowPass, boolean translucent, BlendModeOverride override, BufferBlendOverride[] bufferBlendOverrides, String vertex, String tessControl, String tessEval, String geometry, String fragment, CustomUniforms customUniforms, IrisRenderingPipeline pipeline) {
|
||||
private IrisLodRenderProgram(String name, boolean isShadowPass, boolean translucent, BlendModeOverride override, BufferBlendOverride[] bufferBlendOverrides, String vertex, String tessControl, String tessEval, String geometry, String fragment, CustomUniforms customUniforms, ModernIrisRenderingPipeline pipeline) {
|
||||
id = GL43C.glCreateProgram();
|
||||
|
||||
GL32.glBindAttribLocation(this.id, 0, "vPosition");
|
||||
@@ -135,7 +135,7 @@ public class IrisLodRenderProgram {
|
||||
clipDistanceUniform = tryGetUniformLocation2("clipDistance");
|
||||
}
|
||||
|
||||
public static IrisLodRenderProgram createProgram(String name, boolean isShadowPass, boolean translucent, ProgramSource source, CustomUniforms uniforms, IrisRenderingPipeline pipeline) {
|
||||
public static IrisLodRenderProgram createProgram(String name, boolean isShadowPass, boolean translucent, ProgramSource source, CustomUniforms uniforms, ModernIrisRenderingPipeline pipeline) {
|
||||
Map<PatchShaderType, String> transformed = TransformPatcherBridge.patchDHTerrain(
|
||||
name,
|
||||
source.getVertexSource().orElseThrow(RuntimeException::new),
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
|
||||
import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
|
||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.OverrideInjector;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.irisshaders.iris.shadows.ShadowRenderer;
|
||||
import net.irisshaders.iris.shadows.ShadowRenderingState;
|
||||
@@ -56,7 +57,7 @@ public class LodRendererEvents {
|
||||
public void afterDistantHorizonsInit(DhApiEventParam<Void> event) {
|
||||
IRIS_LOGGER.info("DH Ready, binding Iris event handlers...");
|
||||
|
||||
Iris.loadShaderpackWhenPossible();
|
||||
IrisCommon.loadShaderpackWhenPossible();
|
||||
|
||||
setupSetDeferredBeforeRenderingEvent();
|
||||
setupReconnectDepthTextureEvent();
|
||||
|
||||
+4
-3
@@ -2,6 +2,7 @@ package net.irisshaders.iris.compat.sodium.impl.options;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.config.IrisConfig;
|
||||
import net.irisshaders.iris.gui.option.IrisVideoSettings;
|
||||
import net.irisshaders.iris.pathways.colorspace.ColorSpace;
|
||||
@@ -25,7 +26,7 @@ public class IrisSodiumOptions {
|
||||
private static final OptionStorage<IrisConfig> irisOpts = new OptionStorage<IrisConfig>() {
|
||||
@Override
|
||||
public IrisConfig getData() {
|
||||
return Iris.getIrisConfig();
|
||||
return IrisCommon.getIrisConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,7 +81,7 @@ public class IrisSodiumOptions {
|
||||
.setBinding((options, value) -> {
|
||||
IrisVideoSettings.shadowDistance = value;
|
||||
try {
|
||||
Iris.getIrisConfig().save();
|
||||
IrisCommon.getIrisConfig().save();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -100,7 +101,7 @@ public class IrisSodiumOptions {
|
||||
.setBinding((options, value) -> {
|
||||
IrisVideoSettings.colorSpace = value;
|
||||
try {
|
||||
Iris.getIrisConfig().save();
|
||||
IrisCommon.getIrisConfig().save();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@ package net.irisshaders.iris.compat.sodium.impl.vertex_format.terrain_xhfp;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMaps;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.FallbackTextureMaterials;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.ModernWorldRenderingSettings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
@@ -47,12 +47,12 @@ public class XHFPTerrainVertex implements ChunkVertexEncoder, ContextAwareChunkV
|
||||
private boolean ignoreMidBlock;
|
||||
private byte lightValue;
|
||||
|
||||
private final Object2IntMap<BlockState> blockStateIds = Objects.requireNonNullElse(WorldRenderingSettings.INSTANCE.getBlockStateIds(), Object2IntMaps.emptyMap());
|
||||
private final Object2IntMap<BlockState> blockStateIds = Objects.requireNonNullElse(ModernWorldRenderingSettings.INSTANCE.getBlockStateIds(), Object2IntMaps.emptyMap());
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private final TextureAtlas blocksAtlas = (TextureAtlas)Minecraft.getInstance().getTextureManager().getTexture(TextureAtlas.LOCATION_BLOCKS);
|
||||
|
||||
private final FallbackTextureMaterials fallbackMaterials = WorldRenderingSettings.INSTANCE.getFallbackTextureMaterialMapping();
|
||||
private final FallbackTextureMaterials fallbackMaterials = ModernWorldRenderingSettings.INSTANCE.getFallbackTextureMaterialMapping();
|
||||
|
||||
private final ChunkVertexEncoder baseEncoder = XHFPModelVertexType.BASE_VERTEX_TYPE.getEncoder();
|
||||
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package net.irisshaders.iris.gl.state;
|
||||
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
|
||||
public class ShaderAttributeInputsBuilder {
|
||||
private boolean color;
|
||||
private boolean tex;
|
||||
private boolean overlay;
|
||||
private boolean light;
|
||||
private boolean normal;
|
||||
private boolean newLines;
|
||||
private boolean glint;
|
||||
private boolean text;
|
||||
|
||||
public ShaderAttributeInputsBuilder(VertexFormat format, boolean isFullbright, boolean isLines, boolean glint, boolean text) {
|
||||
if (format == DefaultVertexFormat.POSITION_COLOR_NORMAL && !isLines) {
|
||||
newLines = true;
|
||||
}
|
||||
|
||||
this.text = text;
|
||||
this.glint = glint;
|
||||
|
||||
format.getElementAttributeNames().forEach(name -> {
|
||||
if ("Color".equals(name)) {
|
||||
color = true;
|
||||
}
|
||||
|
||||
if ("UV0".equals(name)) {
|
||||
tex = true;
|
||||
}
|
||||
|
||||
if ("UV1".equals(name)) {
|
||||
overlay = true;
|
||||
}
|
||||
|
||||
if ("UV2".equals(name) && !isFullbright) {
|
||||
light = true;
|
||||
}
|
||||
|
||||
if ("Normal".equals(name)) {
|
||||
normal = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ShaderAttributeInputs build() {
|
||||
return new ShaderAttributeInputs(color, tex, overlay, light, normal, newLines, glint, text);
|
||||
}
|
||||
}
|
||||
@@ -251,7 +251,7 @@ public class ShaderPackOptionList extends IrisContainerObjectSelectionList<Shade
|
||||
|
||||
private boolean resetButtonClicked(IrisElementRow.TextButtonElement button) {
|
||||
if (Screen.hasShiftDown()) {
|
||||
Iris.resetShaderPackOptionsOnNextReload();
|
||||
IrisCommon.resetShaderPackOptionsOnNextReload();
|
||||
this.screen.applyChanges();
|
||||
GuiUtil.playButtonClickSound();
|
||||
|
||||
@@ -265,7 +265,7 @@ public class ShaderPackOptionList extends IrisContainerObjectSelectionList<Shade
|
||||
GuiUtil.playButtonClickSound();
|
||||
|
||||
// Invalid state to be in
|
||||
if (!Iris.getCurrentPack().isPresent()) {
|
||||
if (!IrisCommon.getCurrentPack().isPresent()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ public class ShaderPackOptionList extends IrisContainerObjectSelectionList<Shade
|
||||
GuiUtil.playButtonClickSound();
|
||||
|
||||
// Invalid state to be in
|
||||
if (!Iris.getCurrentPack().isPresent()) {
|
||||
if (!IrisCommon.getCurrentPack().isPresent()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ public class ShaderPackSelectionList extends IrisObjectSelectionList<ShaderPackS
|
||||
WatchService watcher1;
|
||||
|
||||
this.screen = screen;
|
||||
this.topButtonRow = new TopButtonRowEntry(this, Iris.getIrisConfig().areShadersEnabled());
|
||||
this.topButtonRow = new TopButtonRowEntry(this, IrisCommon.getIrisConfig().areShadersEnabled());
|
||||
try {
|
||||
watcher1 = FileSystems.getDefault().newWatchService();
|
||||
key1 = IrisCommon.getShaderpacksDirectory().register(watcher1,
|
||||
@@ -161,7 +161,7 @@ public class ShaderPackSelectionList extends IrisObjectSelectionList<ShaderPackS
|
||||
public void addPackEntry(int index, String name) {
|
||||
ShaderPackEntry entry = new ShaderPackEntry(index, this, name);
|
||||
|
||||
Iris.getIrisConfig().getShaderPackName().ifPresent(currentPackName -> {
|
||||
IrisCommon.getIrisConfig().getShaderPackName().ifPresent(currentPackName -> {
|
||||
if (name.equals(currentPackName)) {
|
||||
setSelected(entry);
|
||||
setFocused(entry);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package net.irisshaders.iris.gui.element.widget;
|
||||
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.gui.GuiUtil;
|
||||
import net.irisshaders.iris.gui.NavigationController;
|
||||
import net.irisshaders.iris.gui.screen.ShaderPackScreen;
|
||||
@@ -82,7 +82,7 @@ public class BooleanElementWidget extends BaseOptionElementWidget<OptionMenuBool
|
||||
}
|
||||
|
||||
private void queue() {
|
||||
Iris.getShaderPackOptionQueue().put(this.option.getName(), this.getValue());
|
||||
IrisCommon.getShaderPackOptionQueue().put(this.option.getName(), this.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package net.irisshaders.iris.gui.element.widget;
|
||||
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.gui.GuiUtil;
|
||||
import net.irisshaders.iris.gui.NavigationController;
|
||||
import net.irisshaders.iris.gui.screen.ShaderPackScreen;
|
||||
@@ -75,7 +75,7 @@ public class ProfileElementWidget extends BaseOptionElementWidget<OptionMenuProf
|
||||
return false;
|
||||
}
|
||||
|
||||
Iris.queueShaderPackOptionsFromProfile(this.next);
|
||||
IrisCommon.queueShaderPackOptionsFromProfile(this.next);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public class ProfileElementWidget extends BaseOptionElementWidget<OptionMenuProf
|
||||
return false;
|
||||
}
|
||||
|
||||
Iris.queueShaderPackOptionsFromProfile(this.previous);
|
||||
IrisCommon.queueShaderPackOptionsFromProfile(this.previous);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package net.irisshaders.iris.gui.element.widget;
|
||||
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.gui.GuiUtil;
|
||||
import net.irisshaders.iris.gui.NavigationController;
|
||||
import net.irisshaders.iris.gui.screen.ShaderPackScreen;
|
||||
@@ -89,7 +89,7 @@ public class StringElementWidget extends BaseOptionElementWidget<OptionMenuStrin
|
||||
}
|
||||
|
||||
protected void queue() {
|
||||
Iris.getShaderPackOptionQueue().put(this.option.getName(), this.getValue());
|
||||
IrisCommon.getShaderPackOptionQueue().put(this.option.getName(), this.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.irisshaders.iris.gui.screen;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.IrisConstants;
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.irisshaders.iris.gui.GuiUtil;
|
||||
@@ -185,8 +186,8 @@ public class ShaderPackScreen extends Screen implements HudHideable {
|
||||
|
||||
this.shaderPackList = new ShaderPackSelectionList(this, this.minecraft, this.width, this.height, 32, bottomOfList, 0, this.width);
|
||||
|
||||
if (Iris.getCurrentPack().isPresent() && this.navigation != null) {
|
||||
ShaderPack currentPack = Iris.getCurrentPack().get();
|
||||
if (IrisCommon.getCurrentPack().isPresent() && this.navigation != null) {
|
||||
ShaderPack currentPack = IrisCommon.getCurrentPack().get();
|
||||
|
||||
this.shaderOptionList = new ShaderPackOptionList(this, this.navigation, currentPack, this.minecraft, this.width, this.height, 32, bottomOfList, 0, this.width);
|
||||
this.navigation.setActiveOptionList(this.shaderOptionList);
|
||||
@@ -292,8 +293,8 @@ public class ShaderPackScreen extends Screen implements HudHideable {
|
||||
}
|
||||
|
||||
public void refreshForChangedPack() {
|
||||
if (Iris.getCurrentPack().isPresent()) {
|
||||
ShaderPack currentPack = Iris.getCurrentPack().get();
|
||||
if (IrisCommon.getCurrentPack().isPresent()) {
|
||||
ShaderPack currentPack = IrisCommon.getCurrentPack().get();
|
||||
|
||||
this.navigation = new NavigationController(currentPack.getMenuContainer());
|
||||
|
||||
@@ -384,7 +385,7 @@ public class ShaderPackScreen extends Screen implements HudHideable {
|
||||
}
|
||||
|
||||
public void onPackListFilesDrop(List<Path> paths) {
|
||||
List<Path> packs = paths.stream().filter(Iris::isValidShaderpack).toList();
|
||||
List<Path> packs = paths.stream().filter(IrisCommon::isValidShaderpack).toList();
|
||||
|
||||
for (Path pack : packs) {
|
||||
String fileName = pack.getFileName().toString();
|
||||
@@ -489,7 +490,7 @@ public class ShaderPackScreen extends Screen implements HudHideable {
|
||||
Properties properties = new Properties();
|
||||
properties.load(in);
|
||||
|
||||
Iris.queueShaderPackOptionsFromProperties(properties);
|
||||
IrisCommon.queueShaderPackOptionsFromProperties(properties);
|
||||
|
||||
this.notificationDialog = Component.translatable(
|
||||
"options.iris.shaderPackOptions.importedSettings",
|
||||
@@ -538,7 +539,7 @@ public class ShaderPackScreen extends Screen implements HudHideable {
|
||||
public void applyChanges() {
|
||||
ShaderPackSelectionList.BaseEntry base = this.shaderPackList.getSelected();
|
||||
boolean enabled = this.shaderPackList.getTopButtonRow().shadersEnabled;
|
||||
boolean previousShadersEnabled = Iris.getIrisConfig().areShadersEnabled();
|
||||
boolean previousShadersEnabled = IrisCommon.getIrisConfig().areShadersEnabled();
|
||||
|
||||
if (enabled != previousShadersEnabled) {
|
||||
IrisApi.getInstance().getConfig().setShadersEnabledAndApply(enabled);
|
||||
@@ -555,14 +556,14 @@ public class ShaderPackScreen extends Screen implements HudHideable {
|
||||
// If the pack is being changed, clear pending options from the previous pack to
|
||||
// avoid possible undefined behavior from applying one pack's options to another pack
|
||||
if (!name.equals(Iris.getCurrentPackName())) {
|
||||
Iris.clearShaderPackOptionQueue();
|
||||
IrisCommon.clearShaderPackOptionQueue();
|
||||
}
|
||||
|
||||
String previousPackName = Iris.getIrisConfig().getShaderPackName().orElse(null);
|
||||
String previousPackName = IrisCommon.getIrisConfig().getShaderPackName().orElse(null);
|
||||
|
||||
// Only reload if the pack would be different from before, or shaders were toggled, or options were changed, or if we're about to reset options.
|
||||
if (!name.equals(previousPackName) || !Iris.getShaderPackOptionQueue().isEmpty() || Iris.shouldResetShaderPackOptionsOnNextReload()) {
|
||||
Iris.getIrisConfig().setShaderPackName(name);
|
||||
if (!name.equals(previousPackName) || !IrisCommon.getShaderPackOptionQueue().isEmpty() || IrisCommon.shouldResetShaderPackOptionsOnNextReload()) {
|
||||
IrisCommon.getIrisConfig().setShaderPackName(name);
|
||||
IrisApi.getInstance().getConfig().setShadersEnabledAndApply(enabled);
|
||||
}
|
||||
|
||||
@@ -570,7 +571,7 @@ public class ShaderPackScreen extends Screen implements HudHideable {
|
||||
}
|
||||
|
||||
private void discardChanges() {
|
||||
Iris.clearShaderPackOptionQueue();
|
||||
IrisCommon.clearShaderPackOptionQueue();
|
||||
}
|
||||
|
||||
private void openShaderPackFolder() {
|
||||
|
||||
@@ -11,13 +11,14 @@ import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.embeddedt.embeddium.compat.mc.ILevelRenderer;
|
||||
import org.joml.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(LevelRenderer.class)
|
||||
public interface LevelRendererAccessor {
|
||||
public interface LevelRendererAccessor extends ILevelRenderer {
|
||||
@Accessor("entityRenderDispatcher")
|
||||
EntityRenderDispatcher getEntityRenderDispatcher();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.irisshaders.iris.mixin;
|
||||
|
||||
import net.irisshaders.iris.uniforms.BiomeUniforms;
|
||||
import net.irisshaders.iris.uniforms.ModernBiomeUniforms;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
@@ -9,12 +9,14 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import static net.irisshaders.iris.uniforms.BiomeUniforms.BIOME_UNIFORMS;
|
||||
|
||||
@Mixin(Biomes.class)
|
||||
public class MixinBiomes {
|
||||
private static int currentId = 0;
|
||||
|
||||
@Inject(method = "register", at = @At("TAIL"))
|
||||
private static void iris$registerBiome(String string, CallbackInfoReturnable<ResourceKey<Biome>> cir) {
|
||||
BiomeUniforms.getBiomeMap().put(cir.getReturnValue(), currentId++);
|
||||
((ModernBiomeUniforms)BIOME_UNIFORMS).getBiomeMap().put(cir.getReturnValue(), currentId++);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.irisshaders.iris.mixin;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
import org.embeddedt.embeddium.compat.mc.ICamera;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(Camera.class)
|
||||
public class MixinCamera implements ICamera {
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.irisshaders.iris.mixin;
|
||||
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.shaderpack.LanguageMap;
|
||||
import net.irisshaders.iris.shaderpack.ShaderPack;
|
||||
import net.minecraft.client.resources.language.ClientLanguage;
|
||||
@@ -84,7 +85,7 @@ public class MixinClientLanguage {
|
||||
|
||||
@Unique
|
||||
private String iris$lookupOverriddenEntry(String key) {
|
||||
ShaderPack pack = Iris.getCurrentPack().orElse(null);
|
||||
ShaderPack pack = IrisCommon.getCurrentPack().orElse(null);
|
||||
|
||||
if (pack == null) {
|
||||
// If no shaderpack is loaded, do not try to process language overrides.
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.irisshaders.iris.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.gui.option.IrisVideoSettings;
|
||||
import net.minecraft.client.gui.components.DebugScreenOverlay;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -59,9 +60,9 @@ public abstract class MixinDebugScreenOverlay {
|
||||
|
||||
@ModifyExpressionValue(method = "getSystemInformation", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/Lists;newArrayList([Ljava/lang/Object;)Ljava/util/ArrayList;"))
|
||||
private ArrayList<String> redirectRightTextEarly(ArrayList<String> messages) {
|
||||
if (Iris.getIrisConfig().areShadersEnabled()) {
|
||||
if (IrisCommon.getIrisConfig().areShadersEnabled()) {
|
||||
messages.add("Shaderpack: " + Iris.getCurrentPackName() + (Iris.isFallback() ? " (fallback)" : ""));
|
||||
Iris.getCurrentPack().ifPresent(pack -> {
|
||||
IrisCommon.getCurrentPack().ifPresent(pack -> {
|
||||
messages.add(pack.getProfileInfo());
|
||||
});
|
||||
messages.add("Color space: " + IrisVideoSettings.colorSpace.name());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.irisshaders.iris.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.ModernWorldRenderingSettings;
|
||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -19,7 +19,7 @@ import java.util.Map;
|
||||
public class MixinItemBlockRenderTypes {
|
||||
@ModifyExpressionValue(method = "getChunkRenderType", at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;"))
|
||||
private static Object iris$setCustomRenderType(Object defaultRenderType, BlockState state) {
|
||||
Map<Block, RenderType> idMap = WorldRenderingSettings.INSTANCE.getBlockTypeIds();
|
||||
Map<Block, RenderType> idMap = ModernWorldRenderingSettings.INSTANCE.getBlockTypeIds();
|
||||
if (idMap != null) {
|
||||
RenderType type = idMap.get(state.getBlock());
|
||||
return type != null ? type : defaultRenderType;
|
||||
@@ -31,7 +31,7 @@ public class MixinItemBlockRenderTypes {
|
||||
//? if forgelike {
|
||||
@ModifyExpressionValue(method = "getRenderLayers", at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;"))
|
||||
private static Object iris$setCustomRenderTypeForge(Object defaultRenderType, BlockState state) {
|
||||
Map<Block, RenderType> idMap = WorldRenderingSettings.INSTANCE.getBlockTypeIds();
|
||||
Map<Block, RenderType> idMap = ModernWorldRenderingSettings.INSTANCE.getBlockTypeIds();
|
||||
if (idMap != null) {
|
||||
RenderType type = idMap.get(state.getBlock());
|
||||
return type != null ? ChunkRenderTypeSet.of(type) : defaultRenderType;
|
||||
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.embeddedt.embeddium.compat.mc.ICamera;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.opengl.GL43C;
|
||||
@@ -41,6 +41,23 @@ public class MixinLevelRenderer {
|
||||
private static final String RENDER_CLOUDS = "Lnet/minecraft/client/renderer/LevelRenderer;renderClouds(Lcom/mojang/blaze3d/vertex/PoseStack;Lorg/joml/Matrix4f;FDDD)V";
|
||||
private static final String RENDER_WEATHER = "Lnet/minecraft/client/renderer/LevelRenderer;renderSnowAndRain(Lnet/minecraft/client/renderer/LightTexture;FDDD)V";
|
||||
|
||||
|
||||
private static WorldRenderingPhase fromTerrainRenderType(RenderType renderType) {
|
||||
if (renderType == RenderType.solid()) {
|
||||
return WorldRenderingPhase.TERRAIN_SOLID;
|
||||
} else if (renderType == RenderType.cutout()) {
|
||||
return WorldRenderingPhase.TERRAIN_CUTOUT;
|
||||
} else if (renderType == RenderType.cutoutMipped()) {
|
||||
return WorldRenderingPhase.TERRAIN_CUTOUT_MIPPED;
|
||||
} else if (renderType == RenderType.translucent()) {
|
||||
return WorldRenderingPhase.TERRAIN_TRANSLUCENT;
|
||||
} else if (renderType == RenderType.tripwire()) {
|
||||
return WorldRenderingPhase.TRIPWIRE;
|
||||
} else {
|
||||
throw new IllegalStateException("Illegal render type!");
|
||||
}
|
||||
}
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private Minecraft minecraft;
|
||||
@@ -156,7 +173,7 @@ public class MixinLevelRenderer {
|
||||
// Do this before sky rendering so it's ready before the sky render starts.
|
||||
@Inject(method = "renderLevel", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", args = "ldc=sky"))
|
||||
private void iris$renderTerrainShadows(CallbackInfo ci, @Local(ordinal = 0, argsOnly = true) Camera camera) {
|
||||
pipeline.renderShadows((LevelRendererAccessor) this, camera);
|
||||
pipeline.renderShadows((LevelRendererAccessor) this, (ICamera) camera);
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "renderSky", at = @At(value = "HEAD"), index = 5, argsOnly = true)
|
||||
@@ -238,7 +255,7 @@ public class MixinLevelRenderer {
|
||||
|
||||
@Inject(method = RENDER_CHUNK_LAYER, at = @At("HEAD"))
|
||||
private void iris$beginTerrainLayer(CallbackInfo ci, @Local(ordinal = 0, argsOnly = true) RenderType renderType) {
|
||||
pipeline.setPhase(WorldRenderingPhase.fromTerrainRenderType(renderType));
|
||||
pipeline.setPhase(fromTerrainRenderType(renderType));
|
||||
}
|
||||
|
||||
@Inject(method = RENDER_CHUNK_LAYER, at = @At("RETURN"))
|
||||
|
||||
+5
-5
@@ -2,8 +2,8 @@ package net.irisshaders.iris.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -25,7 +25,7 @@ public class MixinMinecraft_PipelineManagement {
|
||||
/*"clearClientLevel"*/
|
||||
, at = @At("HEAD"))
|
||||
public void iris$trackLastDimensionOnLeave(CallbackInfo ci) {
|
||||
Iris.lastDimension = Iris.getCurrentDimension();
|
||||
IrisCommon.lastDimension = Iris.getCurrentDimension();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,7 @@ public class MixinMinecraft_PipelineManagement {
|
||||
*/
|
||||
@Inject(method = "setLevel", at = @At("HEAD"))
|
||||
private void iris$trackLastDimensionOnLevelChange(CallbackInfo ci, @Local(ordinal = 0, argsOnly = true) ClientLevel level) {
|
||||
Iris.lastDimension = Iris.getCurrentDimension();
|
||||
IrisCommon.lastDimension = Iris.getCurrentDimension();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,8 +53,8 @@ public class MixinMinecraft_PipelineManagement {
|
||||
*/
|
||||
@Inject(method = "updateLevelInEngines", at = @At("HEAD"))
|
||||
private void iris$resetPipeline(@Nullable ClientLevel level, CallbackInfo ci) {
|
||||
if (Iris.getCurrentDimension() != Iris.lastDimension) {
|
||||
IRIS_LOGGER.info("Reloading pipeline on dimension change: " + Iris.lastDimension + " => " + Iris.getCurrentDimension());
|
||||
if (Iris.getCurrentDimension() != IrisCommon.lastDimension) {
|
||||
IRIS_LOGGER.info("Reloading pipeline on dimension change: " + IrisCommon.lastDimension + " => " + Iris.getCurrentDimension());
|
||||
// Destroy pipelines when changing dimensions.
|
||||
Iris.getPipelineManager().destroyPipeline();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.irisshaders.iris.mixin;
|
||||
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.minecraft.client.Options;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@@ -20,6 +20,6 @@ public class MixinOptions_Entrypoint {
|
||||
}
|
||||
|
||||
iris$initialized = true;
|
||||
Iris.onEarlyInitialize();
|
||||
IrisCommon.onEarlyInitialize();
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,11 @@ import com.llamalad7.mixinextras.sugar.Local;
|
||||
//? if <1.21.2
|
||||
import com.mojang.blaze3d.shaders.Program;
|
||||
import com.mojang.blaze3d.shaders.Uniform;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.gl.blending.DepthColorStorage;
|
||||
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.ShaderRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.programs.ExtendedShader;
|
||||
@@ -27,10 +26,6 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceProvider;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||
import org.lwjgl.opengl.ARBTextureSwizzle;
|
||||
import org.lwjgl.opengl.GL20C;
|
||||
import org.lwjgl.opengl.GL30C;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import org.lwjgl.opengl.KHRDebug;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
@@ -41,14 +36,12 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
||||
|
||||
@@ -139,7 +132,7 @@ public abstract class MixinShaderInstance implements ShaderInstanceInterface {
|
||||
|
||||
public boolean iris$shouldSkipThis() {
|
||||
// Celeritas always allows unknown shaders
|
||||
if (!Iris.getIrisConfig().isBlockUnknownShaders()) {
|
||||
if (!IrisCommon.getIrisConfig().isBlockUnknownShaders()) {
|
||||
if (ShadowRenderer.ACTIVE) return true;
|
||||
if (!shouldOverrideShaders()) return false;
|
||||
if (shouldSkip == NONE) return false;
|
||||
@@ -159,12 +152,12 @@ public abstract class MixinShaderInstance implements ShaderInstanceInterface {
|
||||
if (!iris$shouldSkipThis()) {
|
||||
if (!isKnownShader() && shouldOverrideShaders()) {
|
||||
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
|
||||
if (pipeline instanceof IrisRenderingPipeline) {
|
||||
if (pipeline instanceof ModernIrisRenderingPipeline) {
|
||||
if (ShadowRenderer.ACTIVE) {
|
||||
// Fallback shadow rendering is disabled by Iris rn
|
||||
//((IrisRenderingPipeline) pipeline).bindDefaultShadow();
|
||||
} else {
|
||||
((IrisRenderingPipeline) pipeline).bindDefault();
|
||||
((ModernIrisRenderingPipeline) pipeline).bindDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,7 +177,7 @@ public abstract class MixinShaderInstance implements ShaderInstanceInterface {
|
||||
if (!iris$shouldSkipThis()) {
|
||||
if (!isKnownShader() && shouldOverrideShaders()) {
|
||||
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
|
||||
if (pipeline instanceof IrisRenderingPipeline) {
|
||||
if (pipeline instanceof ModernIrisRenderingPipeline) {
|
||||
Minecraft.getInstance().getMainRenderTarget().bindWrite(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.irisshaders.iris.mixin;
|
||||
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.minecraft.SystemReport;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -24,7 +25,7 @@ public abstract class MixinSystemReport {
|
||||
|
||||
this.setDetail("Loaded Shaderpack", () -> {
|
||||
StringBuilder sb = new StringBuilder(Iris.getCurrentPackName() + (Iris.isFallback() ? " (fallback)" : ""));
|
||||
Iris.getCurrentPack().ifPresent(pack -> {
|
||||
IrisCommon.getCurrentPack().ifPresent(pack -> {
|
||||
sb.append("\n\t\t");
|
||||
sb.append(pack.getProfileInfo());
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.irisshaders.iris.mixin;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.uniforms.SystemTimeUniforms;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
@@ -41,7 +41,7 @@ public class MixinTheEndPortalRenderer {
|
||||
|
||||
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
|
||||
public void iris$onRender(TheEndPortalBlockEntity entity, float tickDelta, PoseStack poseStack, MultiBufferSource multiBufferSource, int light, int overlay, CallbackInfo ci) {
|
||||
if (!Iris.getCurrentPack().isPresent()) {
|
||||
if (!IrisCommon.getCurrentPack().isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.mojang.blaze3d.platform.DisplayData;
|
||||
import com.mojang.blaze3d.platform.ScreenManager;
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.mojang.blaze3d.platform.WindowEventHandler;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -17,7 +17,7 @@ public class MixinWindow {
|
||||
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwDefaultWindowHints()V"))
|
||||
private void iris$enableDebugContext(WindowEventHandler arg, ScreenManager arg2, DisplayData arg3, String string, String string2) {
|
||||
GLFW.glfwDefaultWindowHints();
|
||||
if (Iris.getIrisConfig().areDebugOptionsEnabled()) {
|
||||
if (IrisCommon.getIrisConfig().areDebugOptionsEnabled()) {
|
||||
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_DEBUG_CONTEXT, GLFW.GLFW_TRUE);
|
||||
IRIS_LOGGER.info("OpenGL debug context activated.");
|
||||
}
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.irisshaders.batchedentityrendering.impl.Groupable;
|
||||
import net.irisshaders.iris.layer.BlockEntityRenderStateShard;
|
||||
import net.irisshaders.iris.layer.OuterWrappedRenderType;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.ModernWorldRenderingSettings;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
|
||||
import net.irisshaders.iris.uniforms.CapturedRenderingState;
|
||||
import net.irisshaders.iris.vertices.ImmediateState;
|
||||
@@ -47,7 +48,7 @@ public class MixinBlockEntityRenderDispatcher {
|
||||
|
||||
BlockState state = blockEntity.getBlockState();
|
||||
|
||||
Object2IntMap<BlockState> blockStateIds = WorldRenderingSettings.INSTANCE.getBlockStateIds();
|
||||
Object2IntMap<BlockState> blockStateIds = ModernWorldRenderingSettings.INSTANCE.getBlockStateIds();
|
||||
|
||||
if (blockStateIds == null || !ImmediateState.isRenderingLevel) {
|
||||
return bufferSource;
|
||||
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
package net.irisshaders.iris.mixin.entity_render_context;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.ModernWorldRenderingSettings;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
|
||||
import net.irisshaders.iris.uniforms.CapturedRenderingState;
|
||||
@@ -30,12 +31,12 @@ public abstract class MixinItemRenderer {
|
||||
if (WorldRenderingSettings.INSTANCE.getItemIds() == null) return;
|
||||
|
||||
if (pItemRenderer0.getItem() instanceof BlockItem blockItem && !(pItemRenderer0.getItem() instanceof SolidBucketItem)) {
|
||||
if (WorldRenderingSettings.INSTANCE.getBlockStateIds() == null) return;
|
||||
if (ModernWorldRenderingSettings.INSTANCE.getBlockStateIds() == null) return;
|
||||
|
||||
previousBeValue = CapturedRenderingState.INSTANCE.getCurrentRenderedBlockEntity();
|
||||
CapturedRenderingState.INSTANCE.setCurrentBlockEntity(1);
|
||||
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(WorldRenderingSettings.INSTANCE.getBlockStateIds().getOrDefault(blockItem.getBlock().defaultBlockState(), 0));
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(ModernWorldRenderingSettings.INSTANCE.getBlockStateIds().getOrDefault(blockItem.getBlock().defaultBlockState(), 0));
|
||||
} else {
|
||||
//? if >=1.19.3 {
|
||||
ResourceLocation location = net.minecraft.core.registries.BuiltInRegistries.ITEM.getKey(pItemRenderer0.getItem());
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package net.irisshaders.iris.mixin.fabulous;
|
||||
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.minecraft.client.GraphicsStatus;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Options;
|
||||
@@ -31,7 +31,7 @@ public class MixinDisableFabulousGraphics {
|
||||
private void iris$disableFabulousGraphics() {
|
||||
Options options = Minecraft.getInstance().options;
|
||||
|
||||
if (!Iris.getIrisConfig().areShadersEnabled()) {
|
||||
if (!IrisCommon.getIrisConfig().areShadersEnabled()) {
|
||||
// Nothing to do here, shaders are disabled.
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,6 +18,6 @@ public abstract class MixinAbstractTexture implements MCAbstractTexture {
|
||||
// Inject after the newly-generated texture ID has been stored into the id field
|
||||
@Inject(method = "getId()I", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/TextureUtil;generateTextureId()I", shift = Shift.BY, by = 2))
|
||||
private void iris$afterGenerateId(CallbackInfoReturnable<Integer> cir) {
|
||||
TextureTracker.INSTANCE.trackTexture(id, (AbstractTexture) (Object) this);
|
||||
TextureTracker.INSTANCE.trackTexture(id, this);
|
||||
}
|
||||
}
|
||||
+15
-13
@@ -19,7 +19,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.compat.dh.DHCompat;
|
||||
import net.irisshaders.iris.features.FeatureFlags;
|
||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||
@@ -38,6 +38,7 @@ import net.irisshaders.iris.gl.sampler.SamplerLimits;
|
||||
import net.irisshaders.iris.gl.shader.ShaderCompileException;
|
||||
import net.irisshaders.iris.gl.state.FogMode;
|
||||
import net.irisshaders.iris.gl.state.ShaderAttributeInputs;
|
||||
import net.irisshaders.iris.gl.state.ShaderAttributeInputsBuilder;
|
||||
import net.irisshaders.iris.gl.texture.DepthBufferFormat;
|
||||
import net.irisshaders.iris.gl.texture.TextureType;
|
||||
import net.irisshaders.iris.gui.option.IrisVideoSettings;
|
||||
@@ -45,7 +46,6 @@ import net.irisshaders.iris.helpers.FakeChainedJsonException;
|
||||
import net.irisshaders.iris.helpers.OptionalBoolean;
|
||||
import net.irisshaders.iris.helpers.Tri;
|
||||
import net.irisshaders.iris.mixin.GlStateManagerAccessor;
|
||||
import net.irisshaders.iris.mixin.LevelRendererAccessor;
|
||||
import net.irisshaders.iris.pathways.CenterDepthSampler;
|
||||
import net.irisshaders.iris.pathways.HorizonRenderer;
|
||||
import net.irisshaders.iris.pathways.colorspace.ColorSpace;
|
||||
@@ -63,6 +63,7 @@ import net.irisshaders.iris.shaderpack.ShaderPack;
|
||||
import net.irisshaders.iris.shaderpack.loading.ProgramId;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.BlockMaterialMapping;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.ModelTextureAnalyzer;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.ModernWorldRenderingSettings;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
|
||||
import net.irisshaders.iris.shaderpack.programs.ComputeSource;
|
||||
import net.irisshaders.iris.shaderpack.programs.ProgramFallbackResolver;
|
||||
@@ -89,7 +90,6 @@ import net.irisshaders.iris.uniforms.CapturedRenderingState;
|
||||
import net.irisshaders.iris.uniforms.CommonUniforms;
|
||||
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
|
||||
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.DimensionSpecialEffects;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
@@ -97,13 +97,15 @@ import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.embeddedt.embeddium.compat.mc.ICamera;
|
||||
import org.embeddedt.embeddium.compat.mc.ILevelRenderer;
|
||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector4f;
|
||||
import org.lwjgl.opengl.*;
|
||||
|
||||
public class IrisRenderingPipeline implements WorldRenderingPipeline, ShaderRenderingPipeline, RenderTargetStateListener {
|
||||
public class ModernIrisRenderingPipeline implements IrisRenderingPipeline, WorldRenderingPipeline, ShaderRenderingPipeline, RenderTargetStateListener {
|
||||
private final RenderTargets renderTargets;
|
||||
private final ShaderMap shaderMap;
|
||||
private final CustomUniforms customUniforms;
|
||||
@@ -177,7 +179,7 @@ public class IrisRenderingPipeline implements WorldRenderingPipeline, ShaderRend
|
||||
private GlFramebuffer defaultFBShadow;
|
||||
|
||||
|
||||
public IrisRenderingPipeline(ProgramSet programSet) {
|
||||
public ModernIrisRenderingPipeline(ProgramSet programSet) {
|
||||
ShaderPrinter.resetPrintState();
|
||||
|
||||
this.shouldRenderUnderwaterOverlay = programSet.getPackDirectives().underwaterOverlay();
|
||||
@@ -693,7 +695,7 @@ public class IrisRenderingPipeline implements WorldRenderingPipeline, ShaderRend
|
||||
boolean isLines = programId == ProgramId.Line && resolver.has(ProgramId.Line);
|
||||
|
||||
|
||||
ShaderAttributeInputs inputs = new ShaderAttributeInputs(vertexFormat, isFullbright, isLines, isGlint, isText);
|
||||
ShaderAttributeInputs inputs = new ShaderAttributeInputsBuilder(vertexFormat, isFullbright, isLines, isGlint, isText).build();
|
||||
|
||||
Supplier<ImmutableSet<Integer>> flipped =
|
||||
() -> isBeforeTranslucent ? flippedAfterPrepare : flippedAfterTranslucent;
|
||||
@@ -747,7 +749,7 @@ public class IrisRenderingPipeline implements WorldRenderingPipeline, ShaderRend
|
||||
GlFramebuffer framebuffer = shadowRenderTargets.createShadowFramebuffer(ImmutableSet.of(), source.getDirectives().hasUnknownDrawBuffers() ? new int[]{0, 1} : source.getDirectives().getDrawBuffers());
|
||||
boolean isLines = programId == ProgramId.Line && resolver.has(ProgramId.Line);
|
||||
|
||||
ShaderAttributeInputs inputs = new ShaderAttributeInputs(vertexFormat, isFullbright, isLines, false, isText);
|
||||
ShaderAttributeInputs inputs = new ShaderAttributeInputsBuilder(vertexFormat, isFullbright, isLines, false, isText).build();
|
||||
|
||||
Supplier<ImmutableSet<Integer>> flipped = () -> flippedBeforeShadow;
|
||||
|
||||
@@ -884,13 +886,13 @@ public class IrisRenderingPipeline implements WorldRenderingPipeline, ShaderRend
|
||||
isRenderingWorld = true;
|
||||
|
||||
if (blockIdsNeedPopulation) {
|
||||
WorldRenderingSettings.INSTANCE.setBlockStateIds(
|
||||
ModernWorldRenderingSettings.INSTANCE.setBlockStateIds(
|
||||
BlockMaterialMapping.createBlockStateIdMap(pack.getIdMap().getBlockProperties()));
|
||||
WorldRenderingSettings.INSTANCE.setBlockTypeIds(BlockMaterialMapping.createBlockTypeMap(pack.getIdMap().getBlockRenderTypeMap()));
|
||||
if (Iris.getIrisConfig().isEnableTextureMaterialFallback()) {
|
||||
WorldRenderingSettings.INSTANCE.setFallbackTextureMaterialMapping(ModelTextureAnalyzer.runAnalysisSync(WorldRenderingSettings.INSTANCE.getBlockStateIds()));
|
||||
ModernWorldRenderingSettings.INSTANCE.setBlockTypeIds(BlockMaterialMapping.createBlockTypeMap(pack.getIdMap().getBlockRenderTypeMap()));
|
||||
if (IrisCommon.getIrisConfig().isEnableTextureMaterialFallback()) {
|
||||
ModernWorldRenderingSettings.INSTANCE.setFallbackTextureMaterialMapping(ModelTextureAnalyzer.runAnalysisSync(ModernWorldRenderingSettings.INSTANCE.getBlockStateIds()));
|
||||
} else {
|
||||
WorldRenderingSettings.INSTANCE.setFallbackTextureMaterialMapping(null);
|
||||
ModernWorldRenderingSettings.INSTANCE.setFallbackTextureMaterialMapping(null);
|
||||
}
|
||||
WorldRenderingSettings.INSTANCE.reloadRendererIfRequired();
|
||||
blockIdsNeedPopulation = false;
|
||||
@@ -1058,7 +1060,7 @@ public class IrisRenderingPipeline implements WorldRenderingPipeline, ShaderRend
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderShadows(LevelRendererAccessor worldRenderer, Camera playerCamera) {
|
||||
public void renderShadows(ILevelRenderer worldRenderer, ICamera playerCamera) {
|
||||
if (shadowRenderer != null) {
|
||||
this.shadowRenderer.renderShadows(worldRenderer, playerCamera);
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package net.irisshaders.iris.pipeline;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.ModernWorldRenderingSettings;
|
||||
import net.irisshaders.iris.shaderpack.properties.ParticleRenderingSettings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class ModernVanillaRenderingPipeline extends VanillaRenderingPipeline {
|
||||
public ModernVanillaRenderingPipeline() {
|
||||
super();
|
||||
ModernWorldRenderingSettings.INSTANCE.setBlockTypeIds(null);
|
||||
ModernWorldRenderingSettings.INSTANCE.setFallbackTextureMaterialMapping(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ParticleRenderingSettings getParticleRenderingSettings() {
|
||||
return Minecraft.useShaderTransparency() ? ParticleRenderingSettings.AFTER : ParticleRenderingSettings.MIXED;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package net.irisshaders.iris.pipeline;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
||||
public enum WorldRenderingPhase {
|
||||
NONE,
|
||||
SKY,
|
||||
SUNSET,
|
||||
CUSTOM_SKY,
|
||||
SUN,
|
||||
MOON,
|
||||
STARS,
|
||||
VOID,
|
||||
TERRAIN_SOLID,
|
||||
TERRAIN_CUTOUT_MIPPED,
|
||||
TERRAIN_CUTOUT,
|
||||
ENTITIES,
|
||||
BLOCK_ENTITIES,
|
||||
DESTROY,
|
||||
OUTLINE,
|
||||
DEBUG,
|
||||
HAND_SOLID,
|
||||
TERRAIN_TRANSLUCENT,
|
||||
TRIPWIRE,
|
||||
PARTICLES,
|
||||
CLOUDS,
|
||||
RAIN_SNOW,
|
||||
WORLD_BORDER,
|
||||
HAND_TRANSLUCENT;
|
||||
|
||||
public static WorldRenderingPhase fromTerrainRenderType(RenderType renderType) {
|
||||
if (renderType == RenderType.solid()) {
|
||||
return WorldRenderingPhase.TERRAIN_SOLID;
|
||||
} else if (renderType == RenderType.cutout()) {
|
||||
return WorldRenderingPhase.TERRAIN_CUTOUT;
|
||||
} else if (renderType == RenderType.cutoutMipped()) {
|
||||
return WorldRenderingPhase.TERRAIN_CUTOUT_MIPPED;
|
||||
} else if (renderType == RenderType.translucent()) {
|
||||
return WorldRenderingPhase.TERRAIN_TRANSLUCENT;
|
||||
} else if (renderType == RenderType.tripwire()) {
|
||||
return WorldRenderingPhase.TRIPWIRE;
|
||||
} else {
|
||||
throw new IllegalStateException("Illegal render type!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,11 @@ import java.util.function.Consumer;
|
||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
|
||||
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
||||
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||
|
||||
import com.mojang.blaze3d.preprocessor.GlslPreprocessor;
|
||||
import com.mojang.blaze3d.shaders.Program;
|
||||
import com.mojang.blaze3d.shaders.Uniform;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||
import net.irisshaders.iris.gl.blending.AlphaTest;
|
||||
import net.irisshaders.iris.gl.blending.BlendModeOverride;
|
||||
@@ -28,7 +26,7 @@ import net.irisshaders.iris.gl.program.ProgramUniforms;
|
||||
import net.irisshaders.iris.gl.sampler.SamplerHolder;
|
||||
import net.irisshaders.iris.gl.texture.TextureType;
|
||||
import net.irisshaders.iris.gl.uniform.DynamicLocationalUniformHolder;
|
||||
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
|
||||
import net.irisshaders.iris.samplers.IrisSamplers;
|
||||
import net.irisshaders.iris.uniforms.CapturedRenderingState;
|
||||
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
|
||||
@@ -62,7 +60,7 @@ public class ExtendedShader extends ShaderInstance implements ShaderInstanceInte
|
||||
private final Uniform projectionInverse;
|
||||
private final Uniform normalMatrix;
|
||||
private final CustomUniforms customUniforms;
|
||||
private final IrisRenderingPipeline parent;
|
||||
private final ModernIrisRenderingPipeline parent;
|
||||
private final ProgramUniforms uniforms;
|
||||
private final ProgramSamplers samplers;
|
||||
private final ProgramImages images;
|
||||
@@ -81,7 +79,7 @@ public class ExtendedShader extends ShaderInstance implements ShaderInstanceInte
|
||||
GlFramebuffer writingToBeforeTranslucent, GlFramebuffer writingToAfterTranslucent,
|
||||
BlendModeOverride blendModeOverride, AlphaTest alphaTest,
|
||||
Consumer<DynamicLocationalUniformHolder> uniformCreator, BiConsumer<SamplerHolder, ImageHolder> samplerCreator, boolean isIntensity,
|
||||
IrisRenderingPipeline parent, @Nullable List<BufferBlendOverride> bufferBlendOverrides, CustomUniforms customUniforms) throws IOException {
|
||||
ModernIrisRenderingPipeline parent, @Nullable List<BufferBlendOverride> bufferBlendOverrides, CustomUniforms customUniforms) throws IOException {
|
||||
super(resourceFactory, string, vertexFormat);
|
||||
|
||||
GLDebug.nameObject(KHRDebug.GL_SHADER, this.getVertexProgram().getId(), string + "_vertex.vsh");
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||
import net.irisshaders.iris.gl.blending.BlendModeOverride;
|
||||
import net.irisshaders.iris.gl.framebuffer.GlFramebuffer;
|
||||
import net.irisshaders.iris.gl.texture.TextureType;
|
||||
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
|
||||
import net.irisshaders.iris.samplers.IrisSamplers;
|
||||
import net.irisshaders.iris.uniforms.CapturedRenderingState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -21,7 +21,7 @@ import net.minecraft.server.packs.resources.ResourceProvider;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FallbackShader extends ShaderInstance {
|
||||
private final IrisRenderingPipeline parent;
|
||||
private final ModernIrisRenderingPipeline parent;
|
||||
private final BlendModeOverride blendModeOverride;
|
||||
private final GlFramebuffer writingToBeforeTranslucent;
|
||||
private final GlFramebuffer writingToAfterTranslucent;
|
||||
@@ -37,7 +37,7 @@ public class FallbackShader extends ShaderInstance {
|
||||
|
||||
public FallbackShader(ResourceProvider resourceFactory, String string, VertexFormat vertexFormat,
|
||||
GlFramebuffer writingToBeforeTranslucent, GlFramebuffer writingToAfterTranslucent,
|
||||
BlendModeOverride blendModeOverride, float alphaValue, IrisRenderingPipeline parent) throws IOException {
|
||||
BlendModeOverride blendModeOverride, float alphaValue, ModernIrisRenderingPipeline parent) throws IOException {
|
||||
super(resourceFactory, string, vertexFormat);
|
||||
|
||||
this.parent = parent;
|
||||
|
||||
@@ -10,7 +10,8 @@ import net.irisshaders.iris.gl.blending.BufferBlendOverride;
|
||||
import net.irisshaders.iris.gl.framebuffer.GlFramebuffer;
|
||||
import net.irisshaders.iris.gl.state.FogMode;
|
||||
import net.irisshaders.iris.gl.state.ShaderAttributeInputs;
|
||||
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
|
||||
import net.irisshaders.iris.gl.state.ShaderAttributeInputsBuilder;
|
||||
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.fallback.ShaderSynthesizer;
|
||||
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
|
||||
@@ -55,7 +56,7 @@ public class ShaderCreator {
|
||||
public static CompletableFuture<ExtendedShader> create(WorldRenderingPipeline pipeline, Executor syncExecutor, String name, ProgramSource source, ProgramId programId, GlFramebuffer writingToBeforeTranslucent,
|
||||
GlFramebuffer writingToAfterTranslucent, AlphaTest fallbackAlpha,
|
||||
VertexFormat vertexFormat, ShaderAttributeInputs inputs, FrameUpdateNotifier updateNotifier,
|
||||
IrisRenderingPipeline parent, Supplier<ImmutableSet<Integer>> flipped, FogMode fogMode, boolean isIntensity,
|
||||
ModernIrisRenderingPipeline parent, Supplier<ImmutableSet<Integer>> flipped, FogMode fogMode, boolean isIntensity,
|
||||
boolean isFullbright, boolean isShadowPass, boolean isLines, CustomUniforms customUniforms) throws IOException {
|
||||
AlphaTest alpha = source.getDirectives().getAlphaTestOverride().orElse(fallbackAlpha);
|
||||
BlendModeOverride blendModeOverride = source.getDirectives().getBlendModeOverride().orElse(programId.getBlendModeOverride());
|
||||
@@ -140,9 +141,9 @@ public class ShaderCreator {
|
||||
public static FallbackShader createFallback(String name, GlFramebuffer writingToBeforeTranslucent,
|
||||
GlFramebuffer writingToAfterTranslucent, AlphaTest alpha,
|
||||
VertexFormat vertexFormat, BlendModeOverride blendModeOverride,
|
||||
IrisRenderingPipeline parent, FogMode fogMode, boolean entityLighting,
|
||||
ModernIrisRenderingPipeline parent, FogMode fogMode, boolean entityLighting,
|
||||
boolean isGlint, boolean isText, boolean intensityTex, boolean isFullbright) throws IOException {
|
||||
ShaderAttributeInputs inputs = new ShaderAttributeInputs(vertexFormat, isFullbright, false, isGlint, isText);
|
||||
ShaderAttributeInputs inputs = new ShaderAttributeInputsBuilder(vertexFormat, isFullbright, false, isGlint, isText).build();
|
||||
|
||||
// TODO: Is this check sound in newer versions?
|
||||
boolean isLeash = vertexFormat == DefaultVertexFormat.POSITION_COLOR_LIGHTMAP;
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ public class ShaderpackDirectoryManager {
|
||||
// formatting in the file name so that they have fancy text when displayed in the shaders list.
|
||||
// If debug mode is on, show unzipped packs above zipped ones.
|
||||
|
||||
boolean debug = Iris.getIrisConfig().areDebugOptionsEnabled();
|
||||
boolean debug = IrisCommon.getIrisConfig().areDebugOptionsEnabled();
|
||||
|
||||
Comparator<String> baseComparator = String.CASE_INSENSITIVE_ORDER.thenComparing(Comparator.naturalOrder());
|
||||
Comparator<Path> comparator = (a, b) -> {
|
||||
|
||||
+3
-90
@@ -1,111 +1,24 @@
|
||||
package net.irisshaders.iris.shaderpack.materialmap;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import net.irisshaders.iris.Iris;
|
||||
//? if <1.19.3 {
|
||||
/*import net.minecraft.core.Registry;
|
||||
*///?} else {
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
//?}
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import org.embeddedt.embeddium.compat.iris.IBlockEntry;
|
||||
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
||||
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||
|
||||
public record BlockEntry(NamespacedId id, Map<String, String> propertyPredicates, boolean isTag) {
|
||||
|
||||
/**
|
||||
* Parses a block ID entry.
|
||||
*
|
||||
* @param entry The string representation of the entry. Must not be empty.
|
||||
*/
|
||||
@NotNull
|
||||
public static BlockEntry parse(@NotNull String entry) {
|
||||
if (entry.isEmpty()) {
|
||||
throw new IllegalArgumentException("Called BlockEntry::parse with an empty string");
|
||||
}
|
||||
|
||||
boolean isTag;
|
||||
|
||||
if (entry.startsWith("%")) {
|
||||
isTag = true;
|
||||
entry = entry.substring(1);
|
||||
} else {
|
||||
isTag = false;
|
||||
}
|
||||
|
||||
// We can assume that this array is of at least array length because the input string is non-empty.
|
||||
String[] splitStates = entry.split(":");
|
||||
|
||||
// Trivial case: no states, no namespace
|
||||
if (splitStates.length == 1) {
|
||||
return new BlockEntry(new NamespacedId("minecraft", entry), Collections.emptyMap(), isTag);
|
||||
}
|
||||
|
||||
// Less trivial case: no states involved, just a namespace
|
||||
//
|
||||
// The first term MUST be a valid ResourceLocation component without an equals sign
|
||||
// The second term, if it does not contain an equals sign, must be a valid ResourceLocation component.
|
||||
if (splitStates.length == 2 && !splitStates[1].contains("=")) {
|
||||
return new BlockEntry(new NamespacedId(splitStates[0], splitStates[1]), Collections.emptyMap(), isTag);
|
||||
}
|
||||
|
||||
// Complex case: One or more states involved...
|
||||
int statesStart;
|
||||
NamespacedId id;
|
||||
|
||||
if (splitStates[1].contains("=")) {
|
||||
// We have an entry of the form "tall_grass:half=upper"
|
||||
statesStart = 1;
|
||||
id = new NamespacedId("minecraft", splitStates[0]);
|
||||
} else {
|
||||
// We have an entry of the form "minecraft:tall_grass:half=upper"
|
||||
statesStart = 2;
|
||||
id = new NamespacedId(splitStates[0], splitStates[1]);
|
||||
}
|
||||
|
||||
// We must parse each property key=value pair from the state entry.
|
||||
//
|
||||
// These pairs act as a filter on the block states. Thus, the shader pack does not have to specify all the
|
||||
// individual block properties itself; rather, it only specifies the parts of the block state that it wishes
|
||||
// to filter in/out.
|
||||
//
|
||||
// For example, some shader packs may make it so that hanging lantern blocks wave. They will put something of
|
||||
// the form "lantern:hanging=false" in the ID map as a result. Note, however, that there are also waterlogged
|
||||
// hanging lanterns, which would have "lantern:hanging=false:waterlogged=true". We must make sure that when the
|
||||
// shader pack author writes "lantern:hanging=false", that we do not just match that individual state, but that
|
||||
// we also match the waterlogged variant too.
|
||||
Map<String, String> map = new HashMap<>();
|
||||
|
||||
for (int index = statesStart; index < splitStates.length; index++) {
|
||||
// Split "key=value" into the key and value
|
||||
String[] propertyParts = splitStates[index].split("=");
|
||||
|
||||
if (propertyParts.length != 2) {
|
||||
IRIS_LOGGER.warn("Warning: the block ID map entry \"" + entry + "\" could not be fully parsed:");
|
||||
IRIS_LOGGER.warn("- Block state property filters must be of the form \"key=value\", but "
|
||||
+ splitStates[index] + " is not of that form!");
|
||||
|
||||
// Continue and ignore the invalid entry.
|
||||
continue;
|
||||
}
|
||||
|
||||
map.put(propertyParts[0], propertyParts[1]);
|
||||
}
|
||||
|
||||
return new BlockEntry(id, map, isTag);
|
||||
}
|
||||
|
||||
public Iterable<BlockEntry> expandEntries() {
|
||||
public record BlockEntry(NamespacedId id, Map<String, String> propertyPredicates, boolean isTag) implements IBlockEntry {
|
||||
public Iterable<IBlockEntry> expandEntries() {
|
||||
if (!this.isTag) {
|
||||
return Collections.singletonList(this);
|
||||
} else {
|
||||
|
||||
+4
-4
@@ -2,7 +2,6 @@ package net.irisshaders.iris.shaderpack.materialmap;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.*;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -14,6 +13,7 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import org.embeddedt.embeddium.compat.iris.IBlockEntry;
|
||||
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -22,13 +22,13 @@ import java.util.*;
|
||||
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
||||
|
||||
public class BlockMaterialMapping {
|
||||
public static Object2IntMap<BlockState> createBlockStateIdMap(Int2ObjectMap<List<BlockEntry>> blockPropertiesMap) {
|
||||
public static Object2IntMap<BlockState> createBlockStateIdMap(Int2ObjectMap<List<IBlockEntry>> blockPropertiesMap) {
|
||||
Object2IntMap<BlockState> blockStateIds = new Object2IntOpenHashMap<>();
|
||||
|
||||
blockStateIds.defaultReturnValue(-1);
|
||||
|
||||
blockPropertiesMap.forEach((intId, entries) -> {
|
||||
for (BlockEntry entry : entries) {
|
||||
for (IBlockEntry entry : entries) {
|
||||
addBlockStates(entry, blockStateIds, intId);
|
||||
}
|
||||
});
|
||||
@@ -84,7 +84,7 @@ public class BlockMaterialMapping {
|
||||
});
|
||||
}
|
||||
|
||||
private static void addBlockStates(BlockEntry entry, Object2IntMap<BlockState> idMap, int intId) {
|
||||
private static void addBlockStates(IBlockEntry entry, Object2IntMap<BlockState> idMap, int intId) {
|
||||
if (entry.isTag()) {
|
||||
entry.expandEntries().forEach(nested -> addBlockStates(nested, idMap, intId));
|
||||
return;
|
||||
|
||||
@@ -13,13 +13,13 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMaps;
|
||||
import net.irisshaders.batchedentityrendering.impl.*;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.IrisConstants;
|
||||
import net.irisshaders.iris.compat.dh.DHCompat;
|
||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||
import net.irisshaders.iris.gui.option.IrisVideoSettings;
|
||||
import net.irisshaders.iris.mixin.LevelRendererAccessor;
|
||||
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
|
||||
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
|
||||
import net.irisshaders.iris.shaderpack.programs.ProgramSource;
|
||||
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
||||
import net.irisshaders.iris.shaderpack.properties.PackShadowDirectives;
|
||||
@@ -47,6 +47,8 @@ import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import org.embeddedt.embeddium.compat.mc.ICamera;
|
||||
import org.embeddedt.embeddium.compat.mc.ILevelRenderer;
|
||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.ViewportProvider;
|
||||
import org.embeddedt.embeddium.impl.util.WorldUtil;
|
||||
@@ -77,7 +79,7 @@ public class ShadowRenderer {
|
||||
private final ShadowRenderTargets targets;
|
||||
private final ShadowCullState packCullingState;
|
||||
private final ShadowCompositeRenderer compositeRenderer;
|
||||
private final IrisRenderingPipeline pipeline;
|
||||
private final ModernIrisRenderingPipeline pipeline;
|
||||
private final boolean shouldRenderTerrain;
|
||||
private final boolean shouldRenderTranslucent;
|
||||
private final boolean shouldRenderEntities;
|
||||
@@ -98,7 +100,7 @@ public class ShadowRenderer {
|
||||
private int renderedShadowEntities = 0;
|
||||
private int renderedShadowBlockEntities = 0;
|
||||
|
||||
public ShadowRenderer(IrisRenderingPipeline pipeline, ProgramSource shadow, PackDirectives directives,
|
||||
public ShadowRenderer(ModernIrisRenderingPipeline pipeline, ProgramSource shadow, PackDirectives directives,
|
||||
ShadowRenderTargets shadowRenderTargets, ShadowCompositeRenderer compositeRenderer, CustomUniforms customUniforms, boolean separateHardwareSamplers) {
|
||||
|
||||
this.pipeline = pipeline;
|
||||
@@ -360,10 +362,11 @@ public class ShadowRenderer {
|
||||
RENDER_SYSTEM.glViewport(0, 0, resolution, resolution);
|
||||
}
|
||||
|
||||
public void renderShadows(LevelRendererAccessor levelRenderer, Camera playerCamera) {
|
||||
public void renderShadows(ILevelRenderer levelRendererIn, ICamera playerCamera) {
|
||||
if (IrisVideoSettings.getOverriddenShadowDistance(IrisVideoSettings.shadowDistance) == 0) {
|
||||
return;
|
||||
}
|
||||
LevelRendererAccessor levelRenderer = (LevelRendererAccessor) levelRendererIn;
|
||||
|
||||
Minecraft client = Minecraft.getInstance();
|
||||
|
||||
@@ -426,7 +429,7 @@ public class ShadowRenderer {
|
||||
levelRenderer.setShouldRegenerateClouds(regenerateClouds);
|
||||
|
||||
// Execute the vanilla terrain setup / culling routines using our shadow frustum.
|
||||
levelRenderer.invokeSetupRender(playerCamera, terrainFrustumHolder.getFrustum(), false, false);
|
||||
levelRenderer.invokeSetupRender((Camera) playerCamera, terrainFrustumHolder.getFrustum(), false, false);
|
||||
|
||||
// Don't forget to increment the frame counter! This variable is arbitrary and only used in terrain setup,
|
||||
// and if it's not incremented, the vanilla culling code will get confused and think that it's already seen
|
||||
@@ -531,7 +534,7 @@ public class ShadowRenderer {
|
||||
}
|
||||
|
||||
if (shouldRenderLightBlockEntities || shouldRenderBlockEntities) {
|
||||
renderedShadowBlockEntities = celeritasRenderer.renderBlockEntities(modelView, buffers, Long2ObjectMaps.emptyMap(), playerCamera, tickDelta, blockEntityFilter);
|
||||
renderedShadowBlockEntities = celeritasRenderer.renderBlockEntities(modelView, buffers, Long2ObjectMaps.emptyMap(), (Camera) playerCamera, tickDelta, blockEntityFilter);
|
||||
}
|
||||
|
||||
levelRenderer.getLevel().getProfiler().popPush("draw entities");
|
||||
@@ -715,7 +718,7 @@ public class ShadowRenderer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Iris.getIrisConfig().areDebugOptionsEnabled()) {
|
||||
if (IrisCommon.getIrisConfig().areDebugOptionsEnabled()) {
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Maps: " + debugStringOverall);
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Distance Terrain: " + terrainFrustumHolder.getDistanceInfo() + " Entity: " + entityFrustumHolder.getDistanceInfo());
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Culling Terrain: " + terrainFrustumHolder.getCullingInfo() + " Entity: " + entityFrustumHolder.getCullingInfo());
|
||||
|
||||
@@ -1,354 +0,0 @@
|
||||
package net.irisshaders.iris.uniforms;
|
||||
|
||||
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
|
||||
import static net.irisshaders.iris.gl.uniform.UniformUpdateFrequency.*;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.irisshaders.iris.compat.dh.DHCompat;
|
||||
import net.irisshaders.iris.gl.state.FogMode;
|
||||
import net.irisshaders.iris.gl.state.StateUpdateNotifiers;
|
||||
import net.irisshaders.iris.gl.uniform.DynamicUniformHolder;
|
||||
import net.irisshaders.iris.gl.uniform.UniformHolder;
|
||||
import net.irisshaders.iris.helpers.JomlConversions;
|
||||
import net.irisshaders.iris.layer.GbufferPrograms;
|
||||
import net.irisshaders.iris.mixin.GlStateManagerAccessor;
|
||||
import net.irisshaders.iris.mixin.statelisteners.BooleanStateAccessor;
|
||||
import net.irisshaders.iris.mixin.texture.TextureAtlasAccessor;
|
||||
import net.irisshaders.iris.shaderpack.IdMap;
|
||||
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
||||
import net.irisshaders.iris.texture.TextureInfoCache;
|
||||
import net.irisshaders.iris.texture.TextureInfoCache.TextureInfo;
|
||||
import net.irisshaders.iris.texture.TextureTracker;
|
||||
import net.irisshaders.iris.uniforms.transforms.SmoothedFloat;
|
||||
import net.irisshaders.iris.uniforms.transforms.SmoothedVec2f;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.HumanoidArm;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.material.FogType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.*;
|
||||
import org.joml.Math;
|
||||
|
||||
public final class CommonUniforms {
|
||||
private static final Minecraft client = Minecraft.getInstance();
|
||||
private static final Vector2i ZERO_VECTOR_2i = new Vector2i();
|
||||
private static final Vector4i ZERO_VECTOR_4i = new Vector4i(0, 0, 0, 0);
|
||||
private static final Vector3d ZERO_VECTOR_3d = new Vector3d();
|
||||
|
||||
static {
|
||||
GbufferPrograms.init();
|
||||
}
|
||||
|
||||
private CommonUniforms() {
|
||||
// no construction allowed
|
||||
}
|
||||
|
||||
// Needs to use a LocationalUniformHolder as we need it for the common uniforms
|
||||
public static void addDynamicUniforms(DynamicUniformHolder uniforms, FogMode fogMode) {
|
||||
ExternallyManagedUniforms.addExternallyManagedUniforms117(uniforms);
|
||||
FogUniforms.addFogUniforms(uniforms, fogMode);
|
||||
IrisInternalUniforms.addFogUniforms(uniforms, fogMode);
|
||||
|
||||
// This is a fallback for when entityId via attributes cannot be used. (lightning)
|
||||
uniforms.uniform1i("entityId", CapturedRenderingState.INSTANCE::getCurrentRenderedEntity, StateUpdateNotifiers.fallbackEntityNotifier);
|
||||
|
||||
// TODO: OptiFine doesn't think that atlasSize is a "dynamic" uniform,
|
||||
// but we do. How will custom uniforms depending on atlasSize work?
|
||||
//
|
||||
// Note: on 1.17+ we don't need to reset this when textures are bound, since
|
||||
// the shader will always be setup (and therefore uniforms will be re-uploaded)
|
||||
// after the texture is changed and before rendering starts.
|
||||
uniforms.uniform2i("atlasSize", () -> {
|
||||
int glId = RENDER_SYSTEM.getShaderTexture(0);
|
||||
|
||||
AbstractTexture texture = TextureTracker.INSTANCE.getTexture(glId);
|
||||
if (texture instanceof TextureAtlas atlas) {
|
||||
TextureAtlasAccessor atlasAccessor = (TextureAtlasAccessor) atlas;
|
||||
return new Vector2i(atlasAccessor.callGetWidth(), atlasAccessor.callGetHeight());
|
||||
}
|
||||
|
||||
return ZERO_VECTOR_2i;
|
||||
}, listener -> {
|
||||
});
|
||||
|
||||
uniforms.uniform2i("gtextureSize", () -> {
|
||||
int glId = GlStateManagerAccessor.getTEXTURES()[0].binding;
|
||||
|
||||
TextureInfo info = TextureInfoCache.INSTANCE.getInfo(glId);
|
||||
return new Vector2i(info.getWidth(), info.getHeight());
|
||||
|
||||
}, StateUpdateNotifiers.bindTextureNotifier);
|
||||
|
||||
uniforms.uniform4i("blendFunc", () -> {
|
||||
GlStateManager.BlendState blend = GlStateManagerAccessor.getBLEND();
|
||||
|
||||
if (((BooleanStateAccessor) blend.mode).isEnabled()) {
|
||||
return new Vector4i(blend.srcRgb, blend.dstRgb, blend.srcAlpha, blend.dstAlpha);
|
||||
} else {
|
||||
return ZERO_VECTOR_4i;
|
||||
}
|
||||
}, StateUpdateNotifiers.blendFuncNotifier);
|
||||
|
||||
uniforms.uniform1i("renderStage", () -> GbufferPrograms.getCurrentPhase().ordinal(), StateUpdateNotifiers.phaseChangeNotifier);
|
||||
}
|
||||
|
||||
public static void addCommonUniforms(DynamicUniformHolder uniforms, IdMap idMap, PackDirectives directives, FrameUpdateNotifier updateNotifier, FogMode fogMode) {
|
||||
CommonUniforms.addNonDynamicUniforms(uniforms, idMap, directives, updateNotifier);
|
||||
CommonUniforms.addDynamicUniforms(uniforms, fogMode);
|
||||
}
|
||||
|
||||
public static void addNonDynamicUniforms(UniformHolder uniforms, IdMap idMap, PackDirectives directives, FrameUpdateNotifier updateNotifier) {
|
||||
CameraUniforms.addCameraUniforms(uniforms, updateNotifier);
|
||||
ViewportUniforms.addViewportUniforms(uniforms);
|
||||
WorldTimeUniforms.addWorldTimeUniforms(uniforms);
|
||||
SystemTimeUniforms.addSystemTimeUniforms(uniforms);
|
||||
BiomeUniforms.addBiomeUniforms(uniforms);
|
||||
new CelestialUniforms(directives.getSunPathRotation()).addCelestialUniforms(uniforms);
|
||||
IrisExclusiveUniforms.addIrisExclusiveUniforms(uniforms);
|
||||
IrisTimeUniforms.addTimeUniforms(uniforms);
|
||||
MatrixUniforms.addMatrixUniforms(uniforms, directives);
|
||||
IdMapUniforms.addIdMapUniforms(updateNotifier, uniforms, idMap, directives.isOldHandLight());
|
||||
CommonUniforms.generalCommonUniforms(uniforms, updateNotifier, directives);
|
||||
}
|
||||
|
||||
public static void generalCommonUniforms(UniformHolder uniforms, FrameUpdateNotifier updateNotifier, PackDirectives directives) {
|
||||
ExternallyManagedUniforms.addExternallyManagedUniforms117(uniforms);
|
||||
|
||||
SmoothedVec2f eyeBrightnessSmooth = new SmoothedVec2f(directives.getEyeBrightnessHalfLife(), directives.getEyeBrightnessHalfLife(), CommonUniforms::getEyeBrightness, updateNotifier);
|
||||
|
||||
uniforms
|
||||
.uniform1b(PER_FRAME, "hideGUI", () -> client.options.hideGui)
|
||||
.uniform1b(PER_FRAME, "isRightHanded", () -> client.options.mainHand().get() == HumanoidArm.RIGHT)
|
||||
.uniform1i(PER_FRAME, "isEyeInWater", CommonUniforms::isEyeInWater)
|
||||
.uniform1f(PER_FRAME, "blindness", CommonUniforms::getBlindness)
|
||||
.uniform1f(PER_FRAME, "darknessFactor", CommonUniforms::getDarknessFactor)
|
||||
.uniform1f(PER_FRAME, "darknessLightFactor", CapturedRenderingState.INSTANCE::getDarknessLightFactor)
|
||||
.uniform1f(PER_FRAME, "nightVision", CommonUniforms::getNightVision)
|
||||
.uniform1b(PER_FRAME, "is_sneaking", CommonUniforms::isSneaking)
|
||||
.uniform1b(PER_FRAME, "is_sprinting", CommonUniforms::isSprinting)
|
||||
.uniform1b(PER_FRAME, "is_hurt", CommonUniforms::isHurt)
|
||||
.uniform1b(PER_FRAME, "is_invisible", CommonUniforms::isInvisible)
|
||||
.uniform1b(PER_FRAME, "is_burning", CommonUniforms::isBurning)
|
||||
.uniform1b(PER_FRAME, "is_on_ground", CommonUniforms::isOnGround)
|
||||
// TODO: Do we need to clamp this to avoid fullbright breaking shaders? Or should shaders be able to detect
|
||||
// that the player is trying to turn on fullbright?
|
||||
.uniform1f(PER_FRAME, "screenBrightness", () -> client.options.gamma().get())
|
||||
// just a dummy value for shaders where entityColor isn't supplied through a vertex attribute (and thus is
|
||||
// not available) - suppresses warnings. See AttributeShaderTransformer for the actual entityColor code.
|
||||
.uniform4f(ONCE, "entityColor", () -> new Vector4f(0, 0, 0, 0))
|
||||
.uniform1i(ONCE, "blockEntityId", () -> -1)
|
||||
.uniform1i(ONCE, "currentRenderedItemId", () -> -1)
|
||||
.uniform1f(ONCE, "pi", () -> Math.PI)
|
||||
.uniform1f(PER_TICK, "playerMood", CommonUniforms::getPlayerMood)
|
||||
.uniform2i(PER_FRAME, "eyeBrightness", CommonUniforms::getEyeBrightness)
|
||||
.uniform2i(PER_FRAME, "eyeBrightnessSmooth", () -> {
|
||||
Vector2f smoothed = eyeBrightnessSmooth.get();
|
||||
return new Vector2i((int) smoothed.x(), (int) smoothed.y());
|
||||
})
|
||||
.uniform1f(PER_TICK, "rainStrength", CommonUniforms::getRainStrength)
|
||||
.uniform1f(PER_TICK, "wetness", new SmoothedFloat(directives.getWetnessHalfLife(), directives.getDrynessHalfLife(), CommonUniforms::getRainStrength, updateNotifier))
|
||||
.uniform3d(PER_FRAME, "skyColor", CommonUniforms::getSkyColor)
|
||||
.uniform1f(PER_FRAME, "dhFarPlane", DHCompat::getFarPlane)
|
||||
.uniform1f(PER_FRAME, "dhNearPlane", DHCompat::getNearPlane)
|
||||
.uniform1i(PER_FRAME, "dhRenderDistance", DHCompat::getRenderDistance);
|
||||
}
|
||||
|
||||
private static boolean isOnGround() {
|
||||
return client.player != null && client.player.onGround();
|
||||
}
|
||||
|
||||
private static boolean isHurt() {
|
||||
if (client.player != null) {
|
||||
return client.player.hurtTime > 0; // Do not use isHurt, that's not what we want!
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isInvisible() {
|
||||
if (client.player != null) {
|
||||
return client.player.isInvisible();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isBurning() {
|
||||
if (client.player != null) {
|
||||
return client.player.isOnFire();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isSneaking() {
|
||||
if (client.player != null) {
|
||||
return client.player.isCrouching();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isSprinting() {
|
||||
if (client.player != null) {
|
||||
return client.player.isSprinting();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector3d getSkyColor() {
|
||||
if (client.level == null || client.cameraEntity == null) {
|
||||
return ZERO_VECTOR_3d;
|
||||
}
|
||||
|
||||
return JomlConversions.fromVec3(client.level.getSkyColor(client.cameraEntity.position(),
|
||||
CapturedRenderingState.INSTANCE.getTickDelta()));
|
||||
}
|
||||
|
||||
static float getBlindness() {
|
||||
Entity cameraEntity = client.getCameraEntity();
|
||||
|
||||
if (cameraEntity instanceof LivingEntity) {
|
||||
MobEffectInstance blindness = ((LivingEntity) cameraEntity).getEffect(MobEffects.BLINDNESS);
|
||||
|
||||
if (blindness != null) {
|
||||
// Guessing that this is what OF uses, based on how vanilla calculates the fog value in FogRenderer
|
||||
// TODO: Add this to ShaderDoc
|
||||
if (blindness.isInfiniteDuration()) {
|
||||
return 1.0f;
|
||||
} else {
|
||||
return Math.clamp(0.0F, 1.0F, blindness.getDuration() / 20.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
static float getDarknessFactor() {
|
||||
Entity cameraEntity = client.getCameraEntity();
|
||||
|
||||
if (cameraEntity instanceof LivingEntity) {
|
||||
MobEffectInstance darkness = ((LivingEntity) cameraEntity).getEffect(MobEffects.DARKNESS);
|
||||
|
||||
//? if <1.20.6 {
|
||||
if (darkness != null && darkness.getFactorData().isPresent()) {
|
||||
return darkness.getFactorData().get().getFactor((LivingEntity) cameraEntity, CapturedRenderingState.INSTANCE.getTickDelta());
|
||||
}
|
||||
//?} else {
|
||||
/*if (darkness != null) {
|
||||
return darkness.getBlendFactor((LivingEntity) cameraEntity, CapturedRenderingState.INSTANCE.getTickDelta());
|
||||
}
|
||||
*///?}
|
||||
}
|
||||
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
private static float getPlayerMood() {
|
||||
if (!(client.cameraEntity instanceof LocalPlayer)) {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
// This should always be 0 to 1 anyways but just making sure
|
||||
return Math.clamp(0.0F, 1.0F, ((LocalPlayer) client.cameraEntity).getCurrentMood());
|
||||
}
|
||||
|
||||
static float getRainStrength() {
|
||||
if (client.level == null) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
// Note: Ensure this is in the range of 0 to 1 - some custom servers send out of range values.
|
||||
return Math.clamp(0.0F, 1.0F,
|
||||
client.level.getRainLevel(CapturedRenderingState.INSTANCE.getTickDelta()));
|
||||
}
|
||||
|
||||
private static Vector2i getEyeBrightness() {
|
||||
if (client.cameraEntity == null || client.level == null) {
|
||||
return ZERO_VECTOR_2i;
|
||||
}
|
||||
|
||||
Vec3 feet = client.cameraEntity.position();
|
||||
Vec3 eyes = new Vec3(feet.x, client.cameraEntity.getEyeY(), feet.z);
|
||||
BlockPos eyeBlockPos = BlockPos.containing(eyes);
|
||||
|
||||
int blockLight = client.level.getBrightness(LightLayer.BLOCK, eyeBlockPos);
|
||||
int skyLight = client.level.getBrightness(LightLayer.SKY, eyeBlockPos);
|
||||
|
||||
return new Vector2i(blockLight * 16, skyLight * 16);
|
||||
}
|
||||
|
||||
private static float getNightVision() {
|
||||
Entity cameraEntity = client.getCameraEntity();
|
||||
|
||||
if (cameraEntity instanceof LivingEntity livingEntity) {
|
||||
|
||||
try {
|
||||
// See MixinGameRenderer#iris$safecheckNightvisionStrength.
|
||||
//
|
||||
// We modify the behavior of getNightVisionScale so that it's safe for us to call it even on entities
|
||||
// that don't have the effect, allowing us to pick up modified night vision strength values from mods
|
||||
// like Origins.
|
||||
//
|
||||
// See: https://github.com/apace100/apoli/blob/320b0ef547fbbf703de7154f60909d30366f6500/src/main/java/io/github/apace100/apoli/mixin/GameRendererMixin.java#L153
|
||||
float nightVisionStrength =
|
||||
GameRenderer.getNightVisionScale(livingEntity, CapturedRenderingState.INSTANCE.getTickDelta());
|
||||
|
||||
if (nightVisionStrength > 0) {
|
||||
// Just protecting against potential weird mod behavior
|
||||
return Math.clamp(0.0F, 1.0F, nightVisionStrength);
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
// If our injection didn't get applied, a NullPointerException will occur from calling that method if
|
||||
// the entity doesn't currently have night vision. This isn't pretty but it's functional.
|
||||
return 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
// Conduit power gives the player a sort-of night vision effect when underwater.
|
||||
// This lets existing shaderpacks be compatible with conduit power automatically.
|
||||
//
|
||||
// Yes, this should be the player entity, to match LightTexture.
|
||||
if (client.player != null && client.player.hasEffect(MobEffects.CONDUIT_POWER)) {
|
||||
float underwaterVisibility = client.player.getWaterVision();
|
||||
|
||||
if (underwaterVisibility > 0.0f) {
|
||||
// Just protecting against potential weird mod behavior
|
||||
return Math.clamp(0.0F, 1.0F, underwaterVisibility);
|
||||
}
|
||||
}
|
||||
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
static int isEyeInWater() {
|
||||
// Note: With certain utility / cheat mods, this method will return air even when the player is submerged when
|
||||
// the "No Overlay" feature is enabled.
|
||||
//
|
||||
// I'm not sure what the best way to deal with this is, but the current approach seems to be an acceptable one -
|
||||
// after all, disabling the overlay results in the intended effect of it not really looking like you're
|
||||
// underwater on most shaderpacks. For now, I will leave this as-is, but it is something to keep in mind.
|
||||
FogType submersionType = client.gameRenderer.getMainCamera().getFluidInCamera();
|
||||
|
||||
if (submersionType == FogType.WATER) {
|
||||
return 1;
|
||||
} else if (submersionType == FogType.LAVA) {
|
||||
return 2;
|
||||
} else if (submersionType == FogType.POWDER_SNOW) {
|
||||
return 3;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
package net.irisshaders.iris.uniforms;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntFunction;
|
||||
import net.irisshaders.iris.api.v0.item.IrisItemLightProvider;
|
||||
import net.irisshaders.iris.gl.uniform.UniformHolder;
|
||||
import net.irisshaders.iris.gl.uniform.UniformUpdateFrequency;
|
||||
import net.irisshaders.iris.shaderpack.IdMap;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import static net.irisshaders.iris.gl.uniform.UniformUpdateFrequency.PER_FRAME;
|
||||
|
||||
public final class IdMapUniforms {
|
||||
|
||||
private IdMapUniforms() {
|
||||
}
|
||||
|
||||
public static void addIdMapUniforms(FrameUpdateNotifier notifier, UniformHolder uniforms, IdMap idMap, boolean isOldHandLight) {
|
||||
HeldItemSupplier mainHandSupplier = new HeldItemSupplier(InteractionHand.MAIN_HAND, idMap.getItemIdMap(), isOldHandLight);
|
||||
HeldItemSupplier offHandSupplier = new HeldItemSupplier(InteractionHand.OFF_HAND, idMap.getItemIdMap(), false);
|
||||
notifier.addListener(mainHandSupplier::update);
|
||||
notifier.addListener(offHandSupplier::update);
|
||||
|
||||
uniforms
|
||||
.uniform1i(UniformUpdateFrequency.PER_FRAME, "heldItemId", mainHandSupplier::getIntID)
|
||||
.uniform1i(UniformUpdateFrequency.PER_FRAME, "heldItemId2", offHandSupplier::getIntID)
|
||||
.uniform1i(PER_FRAME, "heldBlockLightValue", mainHandSupplier::getLightValue)
|
||||
.uniform1i(PER_FRAME, "heldBlockLightValue2", offHandSupplier::getLightValue)
|
||||
.uniform3f(PER_FRAME, "heldBlockLightColor", mainHandSupplier::getLightColor)
|
||||
.uniform3f(PER_FRAME, "heldBlockLightColor2", offHandSupplier::getLightColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the currently held item, and it's light value, in the given hand as a uniform. Uses the item.properties ID map to map the item
|
||||
* to an integer, and the old hand light value to map offhand to main hand.
|
||||
*/
|
||||
private static class HeldItemSupplier {
|
||||
private final InteractionHand hand;
|
||||
private final Object2IntFunction<NamespacedId> itemIdMap;
|
||||
private final boolean applyOldHandLight;
|
||||
private int intID;
|
||||
private int lightValue;
|
||||
private Vector3f lightColor;
|
||||
|
||||
HeldItemSupplier(InteractionHand hand, Object2IntFunction<NamespacedId> itemIdMap, boolean shouldApplyOldHandLight) {
|
||||
this.hand = hand;
|
||||
this.itemIdMap = itemIdMap;
|
||||
this.applyOldHandLight = shouldApplyOldHandLight && hand == InteractionHand.MAIN_HAND;
|
||||
}
|
||||
|
||||
private void invalidate() {
|
||||
intID = -1;
|
||||
lightValue = 0;
|
||||
lightColor = IrisItemLightProvider.DEFAULT_LIGHT_COLOR;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
LocalPlayer player = Minecraft.getInstance().player;
|
||||
|
||||
if (player == null) {
|
||||
// Not valid when the player doesn't exist
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack heldStack = player.getItemInHand(hand);
|
||||
|
||||
if (heldStack == null) {
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
Item heldItem = heldStack.getItem();
|
||||
|
||||
if (heldItem == null) {
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
ResourceLocation heldItemId = BuiltInRegistries.ITEM.getKey(heldItem);
|
||||
intID = itemIdMap.applyAsInt(new NamespacedId(heldItemId.getNamespace(), heldItemId.getPath()));
|
||||
|
||||
IrisItemLightProvider lightProvider = (IrisItemLightProvider) heldItem;
|
||||
lightValue = lightProvider.getLightEmission(Minecraft.getInstance().player, heldStack);
|
||||
|
||||
if (applyOldHandLight) {
|
||||
lightProvider = applyOldHandLighting(player, lightProvider);
|
||||
}
|
||||
|
||||
lightColor = lightProvider.getLightColor(Minecraft.getInstance().player, heldStack);
|
||||
}
|
||||
|
||||
private IrisItemLightProvider applyOldHandLighting(@NotNull LocalPlayer player, IrisItemLightProvider existing) {
|
||||
ItemStack offHandStack = player.getItemInHand(InteractionHand.OFF_HAND);
|
||||
|
||||
if (offHandStack == null) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
Item offHandItem = offHandStack.getItem();
|
||||
|
||||
if (offHandItem == null) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
IrisItemLightProvider lightProvider = (IrisItemLightProvider) offHandItem;
|
||||
int newEmission = lightProvider.getLightEmission(Minecraft.getInstance().player, offHandStack);
|
||||
|
||||
if (lightValue < newEmission) {
|
||||
lightValue = newEmission;
|
||||
return lightProvider;
|
||||
}
|
||||
|
||||
return existing;
|
||||
}
|
||||
|
||||
public int getIntID() {
|
||||
return intID;
|
||||
}
|
||||
|
||||
public int getLightValue() {
|
||||
return lightValue;
|
||||
}
|
||||
|
||||
public Vector3f getLightColor() {
|
||||
return lightColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -18,14 +18,14 @@ import java.util.function.ToIntFunction;
|
||||
|
||||
import static net.irisshaders.iris.gl.uniform.UniformUpdateFrequency.PER_TICK;
|
||||
|
||||
public class BiomeUniforms {
|
||||
private static final Object2IntMap<ResourceKey<Biome>> biomeMap = new Object2IntOpenHashMap<>();
|
||||
public class ModernBiomeUniforms implements BiomeUniforms {
|
||||
private final Object2IntMap<ResourceKey<Biome>> biomeMap = new Object2IntOpenHashMap<>();
|
||||
|
||||
public static Object2IntMap<ResourceKey<Biome>> getBiomeMap() {
|
||||
public Object2IntMap<ResourceKey<Biome>> getBiomeMap() {
|
||||
return biomeMap;
|
||||
}
|
||||
|
||||
public static void addBiomeUniforms(UniformHolder uniforms) {
|
||||
public void addBiomeUniforms(UniformHolder uniforms) {
|
||||
uniforms
|
||||
.uniform1i(PER_TICK, "biome", playerI(player ->
|
||||
biomeMap.getInt(player.level().getBiome(player.blockPosition()).unwrapKey().orElse(null))))
|
||||
@@ -0,0 +1,133 @@
|
||||
package net.irisshaders.iris.uniforms;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntFunction;
|
||||
import net.irisshaders.iris.api.v0.item.IrisItemLightProvider;
|
||||
import net.irisshaders.iris.gl.uniform.UniformHolder;
|
||||
import net.irisshaders.iris.shaderpack.IdMap;
|
||||
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import static net.irisshaders.iris.gl.uniform.UniformUpdateFrequency.PER_FRAME;
|
||||
|
||||
public class ModernIdMapUniforms implements IdMapUniforms {
|
||||
|
||||
public void addIdMapUniforms(FrameUpdateNotifier notifier, UniformHolder uniforms, IdMap idMap, boolean isOldHandLight) {
|
||||
HeldItemSupplier mainHandSupplier = new HeldItemSupplier(InteractionHand.MAIN_HAND, idMap.getItemIdMap(), isOldHandLight);
|
||||
HeldItemSupplier offHandSupplier = new HeldItemSupplier(InteractionHand.OFF_HAND, idMap.getItemIdMap(), false);
|
||||
notifier.addListener(mainHandSupplier::update);
|
||||
notifier.addListener(offHandSupplier::update);
|
||||
|
||||
uniforms
|
||||
.uniform1i(PER_FRAME, "heldItemId", mainHandSupplier::getIntID)
|
||||
.uniform1i(PER_FRAME, "heldItemId2", offHandSupplier::getIntID)
|
||||
.uniform1i(PER_FRAME, "heldBlockLightValue", mainHandSupplier::getLightValue)
|
||||
.uniform1i(PER_FRAME, "heldBlockLightValue2", offHandSupplier::getLightValue)
|
||||
.uniform3f(PER_FRAME, "heldBlockLightColor", mainHandSupplier::getLightColor)
|
||||
.uniform3f(PER_FRAME, "heldBlockLightColor2", offHandSupplier::getLightColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the currently held item, and it's light value, in the given hand as a uniform. Uses the item.properties ID map to map the item
|
||||
* to an integer, and the old hand light value to map offhand to main hand.
|
||||
*/
|
||||
private static class HeldItemSupplier {
|
||||
private final InteractionHand hand;
|
||||
private final Object2IntFunction<NamespacedId> itemIdMap;
|
||||
private final boolean applyOldHandLight;
|
||||
private int intID;
|
||||
private int lightValue;
|
||||
private Vector3f lightColor;
|
||||
|
||||
HeldItemSupplier(InteractionHand hand, Object2IntFunction<NamespacedId> itemIdMap, boolean shouldApplyOldHandLight) {
|
||||
this.hand = hand;
|
||||
this.itemIdMap = itemIdMap;
|
||||
this.applyOldHandLight = shouldApplyOldHandLight && hand == InteractionHand.MAIN_HAND;
|
||||
}
|
||||
|
||||
private void invalidate() {
|
||||
intID = -1;
|
||||
lightValue = 0;
|
||||
lightColor = IrisItemLightProvider.DEFAULT_LIGHT_COLOR;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
LocalPlayer player = Minecraft.getInstance().player;
|
||||
|
||||
if (player == null) {
|
||||
// Not valid when the player doesn't exist
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack heldStack = player.getItemInHand(hand);
|
||||
|
||||
if (heldStack == null) {
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
Item heldItem = heldStack.getItem();
|
||||
|
||||
if (heldItem == null) {
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
ResourceLocation heldItemId = BuiltInRegistries.ITEM.getKey(heldItem);
|
||||
intID = itemIdMap.applyAsInt(new NamespacedId(heldItemId.getNamespace(), heldItemId.getPath()));
|
||||
|
||||
IrisItemLightProvider lightProvider = (IrisItemLightProvider) heldItem;
|
||||
lightValue = lightProvider.getLightEmission(Minecraft.getInstance().player, heldStack);
|
||||
|
||||
if (applyOldHandLight) {
|
||||
lightProvider = applyOldHandLighting(player, lightProvider);
|
||||
}
|
||||
|
||||
lightColor = lightProvider.getLightColor(Minecraft.getInstance().player, heldStack);
|
||||
}
|
||||
|
||||
private IrisItemLightProvider applyOldHandLighting(@NotNull LocalPlayer player, IrisItemLightProvider existing) {
|
||||
ItemStack offHandStack = player.getItemInHand(InteractionHand.OFF_HAND);
|
||||
|
||||
if (offHandStack == null) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
Item offHandItem = offHandStack.getItem();
|
||||
|
||||
if (offHandItem == null) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
IrisItemLightProvider lightProvider = (IrisItemLightProvider) offHandItem;
|
||||
int newEmission = lightProvider.getLightEmission(Minecraft.getInstance().player, offHandStack);
|
||||
|
||||
if (lightValue < newEmission) {
|
||||
lightValue = newEmission;
|
||||
return lightProvider;
|
||||
}
|
||||
|
||||
return existing;
|
||||
}
|
||||
|
||||
public int getIntID() {
|
||||
return intID;
|
||||
}
|
||||
|
||||
public int getLightValue() {
|
||||
return lightValue;
|
||||
}
|
||||
|
||||
public Vector3f getLightColor() {
|
||||
return lightColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
+326
-9
@@ -5,31 +5,48 @@ import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.mojang.math.Axis;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.helpers.JomlConversions;
|
||||
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.irisshaders.iris.mixin.GlStateManagerAccessor;
|
||||
import net.irisshaders.iris.mixin.texture.TextureAtlasAccessor;
|
||||
import net.irisshaders.iris.shaderpack.DimensionId;
|
||||
import net.irisshaders.iris.shadows.ShadowMatrices;
|
||||
import net.irisshaders.iris.shadows.ShadowRenderer;
|
||||
import net.irisshaders.iris.texture.TextureInfoCache;
|
||||
import net.irisshaders.iris.texture.TextureTracker;
|
||||
import net.irisshaders.iris.uniforms.CameraUniforms;
|
||||
import net.irisshaders.iris.uniforms.CapturedRenderingState;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.HumanoidArm;
|
||||
import net.minecraft.world.entity.LightningBolt;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.material.FogType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.embeddedt.embeddium.compat.mc.IResourceLocation;
|
||||
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
||||
import org.embeddedt.embeddium.compat.mc.MCNativeImage;
|
||||
import org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.embeddedt.embeddium.impl.loader.common.EarlyLoaderServices;
|
||||
import org.joml.*;
|
||||
import org.joml.Math;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
|
||||
|
||||
|
||||
public class MinecraftModernVersionShimImpl implements MinecraftVersionShimService {
|
||||
|
||||
@Override
|
||||
@@ -82,6 +99,11 @@ public class MinecraftModernVersionShimImpl implements MinecraftVersionShimServi
|
||||
return Minecraft.getInstance().options.getEffectiveRenderDistance() * 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEffectiveRenderDistance() {
|
||||
return Minecraft.getInstance().options.getEffectiveRenderDistance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3d getUnshiftedCameraPosition() {
|
||||
return JomlConversions.fromVec3(Minecraft.getInstance().gameRenderer.getMainCamera().getPosition());
|
||||
@@ -301,6 +323,263 @@ public class MinecraftModernVersionShimImpl implements MinecraftVersionShimServi
|
||||
return new Vector3d(pos.x, pos.y, pos.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnGround() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
return client.player != null && client.player.onGround();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHurt() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
if (client.player != null) {
|
||||
return client.player.hurtTime > 0; // Do not use isHurt, that's not what we want!
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvisible() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
if (client.player != null) {
|
||||
return client.player.isInvisible();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBurning() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
if (client.player != null) {
|
||||
return client.player.isOnFire();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSneaking() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
if (client.player != null) {
|
||||
return client.player.isCrouching();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSprinting() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
if (client.player != null) {
|
||||
return client.player.isSprinting();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3d getSkyColor() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
if (client.level == null || client.cameraEntity == null) {
|
||||
return ZERO3D;
|
||||
}
|
||||
|
||||
return JomlConversions.fromVec3(client.level.getSkyColor(client.cameraEntity.position(),
|
||||
CapturedRenderingState.INSTANCE.getTickDelta()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlindness() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
Entity cameraEntity = client.getCameraEntity();
|
||||
|
||||
if (cameraEntity instanceof LivingEntity) {
|
||||
MobEffectInstance blindness = ((LivingEntity) cameraEntity).getEffect(MobEffects.BLINDNESS);
|
||||
|
||||
if (blindness != null) {
|
||||
// Guessing that this is what OF uses, based on how vanilla calculates the fog value in FogRenderer
|
||||
// TODO: Add this to ShaderDoc
|
||||
if (blindness.isInfiniteDuration()) {
|
||||
return 1.0f;
|
||||
} else {
|
||||
return Math.clamp(0.0F, 1.0F, blindness.getDuration() / 20.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDarknessFactor() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
Entity cameraEntity = client.getCameraEntity();
|
||||
|
||||
if (cameraEntity instanceof LivingEntity) {
|
||||
MobEffectInstance darkness = ((LivingEntity) cameraEntity).getEffect(MobEffects.DARKNESS);
|
||||
|
||||
//? if <1.20.6 {
|
||||
if (darkness != null && darkness.getFactorData().isPresent()) {
|
||||
return darkness.getFactorData().get().getFactor((LivingEntity) cameraEntity, CapturedRenderingState.INSTANCE.getTickDelta());
|
||||
}
|
||||
//?} else {
|
||||
/*if (darkness != null) {
|
||||
return darkness.getBlendFactor((LivingEntity) cameraEntity, CapturedRenderingState.INSTANCE.getTickDelta());
|
||||
}
|
||||
*///?}
|
||||
}
|
||||
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPlayerMood() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
if (!(client.cameraEntity instanceof LocalPlayer)) {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
// This should always be 0 to 1 anyways but just making sure
|
||||
return Math.clamp(0.0F, 1.0F, ((LocalPlayer) client.cameraEntity).getCurrentMood());
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRainStrength() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
if (client.level == null) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
// Note: Ensure this is in the range of 0 to 1 - some custom servers send out of range values.
|
||||
return Math.clamp(0.0F, 1.0F,
|
||||
client.level.getRainLevel(CapturedRenderingState.INSTANCE.getTickDelta()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2i getEyeBrightness() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
if (client.cameraEntity == null || client.level == null) {
|
||||
return ZERO2I;
|
||||
}
|
||||
|
||||
Vec3 feet = client.cameraEntity.position();
|
||||
Vec3 eyes = new Vec3(feet.x, client.cameraEntity.getEyeY(), feet.z);
|
||||
BlockPos eyeBlockPos = BlockPos.containing(eyes);
|
||||
|
||||
int blockLight = client.level.getBrightness(LightLayer.BLOCK, eyeBlockPos);
|
||||
int skyLight = client.level.getBrightness(LightLayer.SKY, eyeBlockPos);
|
||||
|
||||
return new Vector2i(blockLight * 16, skyLight * 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getNightVision() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
Entity cameraEntity = client.getCameraEntity();
|
||||
|
||||
if (cameraEntity instanceof LivingEntity livingEntity) {
|
||||
|
||||
try {
|
||||
// See MixinGameRenderer#iris$safecheckNightvisionStrength.
|
||||
//
|
||||
// We modify the behavior of getNightVisionScale so that it's safe for us to call it even on entities
|
||||
// that don't have the effect, allowing us to pick up modified night vision strength values from mods
|
||||
// like Origins.
|
||||
//
|
||||
// See: https://github.com/apace100/apoli/blob/320b0ef547fbbf703de7154f60909d30366f6500/src/main/java/io/github/apace100/apoli/mixin/GameRendererMixin.java#L153
|
||||
float nightVisionStrength =
|
||||
GameRenderer.getNightVisionScale(livingEntity, CapturedRenderingState.INSTANCE.getTickDelta());
|
||||
|
||||
if (nightVisionStrength > 0) {
|
||||
// Just protecting against potential weird mod behavior
|
||||
return Math.clamp(0.0F, 1.0F, nightVisionStrength);
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
// If our injection didn't get applied, a NullPointerException will occur from calling that method if
|
||||
// the entity doesn't currently have night vision. This isn't pretty but it's functional.
|
||||
return 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
// Conduit power gives the player a sort-of night vision effect when underwater.
|
||||
// This lets existing shaderpacks be compatible with conduit power automatically.
|
||||
//
|
||||
// Yes, this should be the player entity, to match LightTexture.
|
||||
if (client.player != null && client.player.hasEffect(MobEffects.CONDUIT_POWER)) {
|
||||
float underwaterVisibility = client.player.getWaterVision();
|
||||
|
||||
if (underwaterVisibility > 0.0f) {
|
||||
// Just protecting against potential weird mod behavior
|
||||
return Math.clamp(0.0F, 1.0F, underwaterVisibility);
|
||||
}
|
||||
}
|
||||
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isEyeInWater() {
|
||||
// Note: With certain utility / cheat mods, this method will return air even when the player is submerged when
|
||||
// the "No Overlay" feature is enabled.
|
||||
//
|
||||
// I'm not sure what the best way to deal with this is, but the current approach seems to be an acceptable one -
|
||||
// after all, disabling the overlay results in the intended effect of it not really looking like you're
|
||||
// underwater on most shaderpacks. For now, I will leave this as-is, but it is something to keep in mind.
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
FogType submersionType = client.gameRenderer.getMainCamera().getFluidInCamera();
|
||||
|
||||
if (submersionType == FogType.WATER) {
|
||||
return 1;
|
||||
} else if (submersionType == FogType.LAVA) {
|
||||
return 2;
|
||||
} else if (submersionType == FogType.POWDER_SNOW) {
|
||||
return 3;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hideGui() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
return client.options.hideGui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRightHanded() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
return client.options.mainHand().get() == HumanoidArm.RIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getScreenBrightness() {
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
return client.options.gamma().get().floatValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2i getAtlasSize() {
|
||||
int glId = RENDER_SYSTEM.getShaderTexture(0);
|
||||
|
||||
MCAbstractTexture texture = TextureTracker.INSTANCE.getTexture(glId);
|
||||
if (texture instanceof TextureAtlas atlas) {
|
||||
TextureAtlasAccessor atlasAccessor = (TextureAtlasAccessor) atlas;
|
||||
return new Vector2i(atlasAccessor.callGetWidth(), atlasAccessor.callGetHeight());
|
||||
}
|
||||
|
||||
return ZERO2I;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2i getTextureSize() {
|
||||
int glId = GlStateManagerAccessor.getTEXTURES()[0].binding;
|
||||
|
||||
TextureInfoCache.TextureInfo info = TextureInfoCache.INSTANCE.getInfo(glId);
|
||||
return new Vector2i(info.getWidth(), info.getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCNativeImage createNativeImage(int width, int height, boolean useCalloc) {
|
||||
return (MCNativeImage)(Object) new NativeImage(width, height, useCalloc);
|
||||
@@ -330,14 +609,52 @@ public class MinecraftModernVersionShimImpl implements MinecraftVersionShimServi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadIris() throws IOException {
|
||||
Iris.reload();
|
||||
public String getOsString() {
|
||||
return switch (Util.getPlatform()) {
|
||||
case OSX -> "MC_OS_MAC";
|
||||
case LINUX -> "MC_OS_LINUX";
|
||||
case WINDOWS -> "MC_OS_WINDOWS";
|
||||
// Note: Optifine doesn't have a macro for Solaris. https://github.com/sp614x/optifine/blob/9c6a5b5326558ccc57c6490b66b3be3b2dc8cbef/OptiFineDoc/doc/shaders.txt#L709-L714
|
||||
default -> "MC_OS_UNKNOWN";
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getMcVersion() {
|
||||
return Iris.getReleaseTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean irisAllowConcurrentUpdate() {
|
||||
return Iris.getPipelineManager().getPipeline().map(WorldRenderingPipeline::allowConcurrentCompute).orElse(false);
|
||||
public String getBackupVersionNumber() {
|
||||
return Iris.getBackupVersionNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markRendererReloadRequired() {
|
||||
if (Minecraft.getInstance().levelRenderer != null) {
|
||||
Minecraft.getInstance().levelRenderer.allChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDHPresent() {
|
||||
return EarlyLoaderServices.INSTANCE.isModLoaded("distanthorizons");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix4f getShadowModelView(float sunPathRotation, float intervalSize) {
|
||||
return new Matrix4f(ShadowRenderer.createShadowModelView(sunPathRotation, intervalSize).last().pose());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix4f getShadowProjection(float shadowDistance, float nearPlane, float farPlane) {
|
||||
return ShadowMatrices.createOrthoMatrix(shadowDistance, nearPlane, farPlane);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindFramebuffer() {
|
||||
Minecraft.getInstance().getMainRenderTarget().bindWrite(true);
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
net.irisshaders.iris.uniforms.ModernBiomeUniforms
|
||||
+1
@@ -0,0 +1 @@
|
||||
net.irisshaders.iris.uniforms.ModernIdMapUniforms
|
||||
Reference in new issue
Block a user
As far as I know we intend for
CeleritasShadersApito be publicly facing API (likeIrisApi). Most of these newly added helpers appear to be internal shims, so they should probably be in a separate, internal interface.