diff --git a/dependencies.gradle b/dependencies.gradle index 1a9d70a72..8fbff67a7 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -144,7 +144,7 @@ dependencies { compileOnly(rfg.deobf("curse.maven:campfirebackport-387444:4611675")) compileOnly(rfg.deobf("curse.maven:xaeros-minimap-263420:5060684")) compileOnly(rfg.deobf("curse.maven:security-craft-64760:2818228")) - compileOnly(rfg.deobf("curse.maven:et-futurum-requiem-441392:5873837")) + compileOnly("ganymedes01.etfuturum:Et-Futurum-Requiem:2.6.49-GTNH:dev") compileOnly(rfg.deobf("curse.maven:biomes-o-plenty-220318:2499612")) devOnlyNonPublishable("com.github.GTNewHorizons:CosmeticArmorReworked:1.0.3-GTNH:dev") diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/etfuturum/EndFlashCompat.java b/src/main/java/com/gtnewhorizons/angelica/compat/etfuturum/EndFlashCompat.java new file mode 100644 index 000000000..8e39e9c0d --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/compat/etfuturum/EndFlashCompat.java @@ -0,0 +1,30 @@ +package com.gtnewhorizons.angelica.compat.etfuturum; + +import cpw.mods.fml.common.Loader; +import ganymedes01.etfuturum.api.client.EndFlashAPI; + +/** + * Use EFR to power End flash uniforms. + */ +public final class EndFlashCompat { + + private static final boolean AVAILABLE = Loader.isModLoaded("etfuturum"); + + private EndFlashCompat() {} + + public static boolean isAvailable() { + return AVAILABLE; + } + + public static float getIntensity(float partialTicks) { + return AVAILABLE ? EndFlashAPI.getIntensity(partialTicks) : 0.0F; + } + + public static float getXAngle() { + return AVAILABLE ? EndFlashAPI.getXAngle() : 0.0F; + } + + public static float getYAngle() { + return AVAILABLE ? EndFlashAPI.getYAngle() : 0.0F; + } +} diff --git a/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java index f17d4f2f9..d1ddd03e4 100644 --- a/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java @@ -170,6 +170,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R private final CloudSetting cloudSetting; private final boolean shouldRenderUnderwaterOverlay; private final boolean shouldRenderVignette; + private final boolean supportsEndFlash; private final boolean shouldRenderSun; private final boolean shouldRenderMoon; private final boolean shouldRenderStars; @@ -231,6 +232,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R this.cloudSetting = programs.getPackDirectives().getCloudSetting(); this.shouldRenderUnderwaterOverlay = programs.getPackDirectives().underwaterOverlay(); this.shouldRenderVignette = programs.getPackDirectives().vignette(); + this.supportsEndFlash = programs.getPackDirectives().isSupportsEndFlash(); this.shouldRenderSun = programs.getPackDirectives().shouldRenderSun(); this.shouldRenderMoon = programs.getPackDirectives().shouldRenderMoon(); this.shouldRenderStars = programs.getPackDirectives().shouldRenderStars(); @@ -651,6 +653,11 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R return shouldRenderVignette; } + @Override + public boolean supportsEndFlash() { + return supportsEndFlash; + } + @Override public boolean shouldRenderSun() { return shouldRenderSun; diff --git a/src/main/java/net/coderbot/iris/pipeline/FixedFunctionWorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/FixedFunctionWorldRenderingPipeline.java index 6c278462a..f03cc16c8 100644 --- a/src/main/java/net/coderbot/iris/pipeline/FixedFunctionWorldRenderingPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/FixedFunctionWorldRenderingPipeline.java @@ -152,6 +152,11 @@ public class FixedFunctionWorldRenderingPipeline implements WorldRenderingPipeli return false; } + @Override + public boolean supportsEndFlash() { + return false; + } + @Override public CloudSetting getCloudSetting() { return CloudSetting.DEFAULT; diff --git a/src/main/java/net/coderbot/iris/pipeline/WorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/WorldRenderingPipeline.java index 61f544c84..7f1ac6f53 100644 --- a/src/main/java/net/coderbot/iris/pipeline/WorldRenderingPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/WorldRenderingPipeline.java @@ -49,6 +49,7 @@ public interface WorldRenderingPipeline { boolean shouldDisableVanillaEntityShadows(); boolean shouldDisableDirectionalShading(); + boolean supportsEndFlash(); CloudSetting getCloudSetting(); boolean shouldRenderUnderwaterOverlay(); boolean shouldRenderVignette(); diff --git a/src/main/java/net/coderbot/iris/shaderpack/PackDirectives.java b/src/main/java/net/coderbot/iris/shaderpack/PackDirectives.java index d0fa8df5d..b1e368351 100644 --- a/src/main/java/net/coderbot/iris/shaderpack/PackDirectives.java +++ b/src/main/java/net/coderbot/iris/shaderpack/PackDirectives.java @@ -48,6 +48,7 @@ public class PackDirectives { @Getter private boolean oldHandLight; @Getter private boolean prepareBeforeShadow; @Getter private boolean supportsColorCorrection; + @Getter private boolean supportsEndFlash; @Getter private int fallbackTex; private Object2ObjectMap> explicitFlips = new Object2ObjectOpenHashMap<>(); private Object2ObjectMap scaleOverrides = new Object2ObjectOpenHashMap<>(); @@ -93,6 +94,7 @@ public class PackDirectives { oldLighting = properties.getOldLighting().orElse(false); fallbackTex = properties.getFallbackTex(); supportsColorCorrection = properties.getSupportsColorCorrection().orElse(false); + supportsEndFlash = properties.getSupportsEndFlash().orElse(false); concurrentCompute = properties.getConcurrentCompute().orElse(false); oldHandLight = properties.getOldHandLight().orElse(true); explicitFlips = properties.getExplicitFlips(); @@ -112,6 +114,7 @@ public class PackDirectives { frustumCulling = directives.frustumCulling; occlusionCulling = directives.occlusionCulling; oldLighting = directives.oldLighting; + supportsEndFlash = directives.supportsEndFlash; concurrentCompute = directives.concurrentCompute; explicitFlips = directives.explicitFlips; scaleOverrides = directives.scaleOverrides; diff --git a/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java b/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java index 73b4b9da9..7511d0092 100644 --- a/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java +++ b/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java @@ -70,6 +70,7 @@ public class ShaderProperties { @Getter private OptionalBoolean shadowPlayer = OptionalBoolean.DEFAULT; @Getter private OptionalBoolean shadowBlockEntities = OptionalBoolean.DEFAULT; @Getter private OptionalBoolean shadowLightBlockEntities = OptionalBoolean.DEFAULT; + @Getter private OptionalBoolean supportsEndFlash = OptionalBoolean.DEFAULT; @Getter private OptionalBoolean underwaterOverlay = OptionalBoolean.DEFAULT; @Getter private OptionalBoolean sun = OptionalBoolean.DEFAULT; @Getter private OptionalBoolean moon = OptionalBoolean.DEFAULT; @@ -205,6 +206,7 @@ public class ShaderProperties { handleBooleanDirective(key, value, "shadowPlayer", bool -> shadowPlayer = bool); handleBooleanDirective(key, value, "shadowBlockEntities", bool -> shadowBlockEntities = bool); handleBooleanDirective(key, value, "shadowLightBlockEntities", bool -> shadowLightBlockEntities = bool); + handleBooleanDirective(key, value, "endFlashShadows", bool -> supportsEndFlash = bool); handleBooleanDirective(key, value, "underwaterOverlay", bool -> underwaterOverlay = bool); handleBooleanDirective(key, value, "sun", bool -> sun = bool); handleBooleanDirective(key, value, "moon", bool -> moon = bool); diff --git a/src/main/java/net/coderbot/iris/shadow/ShadowMatrices.java b/src/main/java/net/coderbot/iris/shadow/ShadowMatrices.java index f5480f9ab..db33909f5 100644 --- a/src/main/java/net/coderbot/iris/shadow/ShadowMatrices.java +++ b/src/main/java/net/coderbot/iris/shadow/ShadowMatrices.java @@ -1,6 +1,12 @@ package net.coderbot.iris.shadow; +import com.gtnewhorizons.angelica.compat.etfuturum.EndFlashCompat; import com.gtnewhorizons.angelica.compat.toremove.MatrixStack; +import net.coderbot.iris.Iris; +import net.coderbot.iris.pipeline.WorldRenderingPipeline; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.world.WorldProviderEnd; import org.joml.Matrix4f; import static com.gtnewhorizons.angelica.compat.mojang.Constants.DEGREES_TO_RADIANS; @@ -40,23 +46,41 @@ public class ShadowMatrices { } public static void createBaselineModelViewMatrix(MatrixStack target, float shadowAngle, float sunPathRotation) { - final float skyAngle; - - if (shadowAngle < 0.25f) { - skyAngle = shadowAngle + 0.75f; - } else { - skyAngle = shadowAngle - 0.25f; - } - target.peek().getNormal().identity(); target.peek().getModel().identity(); target.peek().getModel().translate(0.0f, 0.0f, -100.0f); - target.rotateX(90F * DEGREES_TO_RADIANS); - target.rotateZ(skyAngle * -360.0f * DEGREES_TO_RADIANS); - target.rotateX(sunPathRotation * DEGREES_TO_RADIANS); + + if (isEndFlashShadow()) { + // Project shadows from the End flash direction instead of the sun/moon. + target.rotateX((0.0f - EndFlashCompat.getXAngle()) * DEGREES_TO_RADIANS); + target.rotateY(EndFlashCompat.getYAngle() * DEGREES_TO_RADIANS); + } else { + final float skyAngle; + + if (shadowAngle < 0.25f) { + skyAngle = shadowAngle + 0.75f; + } else { + skyAngle = shadowAngle - 0.25f; + } + + target.rotateX(90F * DEGREES_TO_RADIANS); + target.rotateZ(skyAngle * -360.0f * DEGREES_TO_RADIANS); + target.rotateX(sunPathRotation * DEGREES_TO_RADIANS); + } } + private static boolean isEndFlashShadow() { + final Minecraft mc = Minecraft.getMinecraft(); + if (mc == null) { + return false; + } + final WorldClient world = mc.theWorld; + return world != null && world.provider instanceof WorldProviderEnd + && EndFlashCompat.isAvailable() + && Iris.getPipelineManager().getPipeline().map(WorldRenderingPipeline::supportsEndFlash).orElse(false); + } + public static void snapModelViewToGrid(MatrixStack target, float shadowIntervalSize, double cameraX, double cameraY, double cameraZ) { if (Math.abs(shadowIntervalSize) == 0.0F) { // Avoid a division by zero - semantically, this just means that the snapping does not take place, diff --git a/src/main/java/net/coderbot/iris/uniforms/CelestialUniforms.java b/src/main/java/net/coderbot/iris/uniforms/CelestialUniforms.java index d35bdd2d3..c5d30e82d 100644 --- a/src/main/java/net/coderbot/iris/uniforms/CelestialUniforms.java +++ b/src/main/java/net/coderbot/iris/uniforms/CelestialUniforms.java @@ -1,10 +1,14 @@ package net.coderbot.iris.uniforms; +import com.gtnewhorizons.angelica.compat.etfuturum.EndFlashCompat; import com.gtnewhorizons.angelica.compat.mojang.Constants; import com.gtnewhorizons.angelica.rendering.RenderingState; +import net.coderbot.iris.Iris; import net.coderbot.iris.gl.uniform.UniformHolder; +import net.coderbot.iris.pipeline.WorldRenderingPipeline; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.world.WorldProviderEnd; import org.joml.Matrix4f; import org.joml.Vector4f; @@ -18,9 +22,12 @@ import static net.coderbot.iris.gl.uniform.UniformUpdateFrequency.PER_FRAME; public final class CelestialUniforms { private static final Vector4f upPositionCache = new Vector4f(); private static final Matrix4f upMatrixCache = new Matrix4f(); + private static final Vector4f ZERO_VECTOR_4f = new Vector4f(0.0F, 0.0F, 0.0F, 0.0F); private final Vector4f positionCache = new Vector4f(); private final Matrix4f celestialMatrixCache = new Matrix4f(); + private final Vector4f endFlashPositionCache = new Vector4f(); + private final Matrix4f endFlashMatrixCache = new Matrix4f(); private final float sunPathRotation; public CelestialUniforms(float sunPathRotation) { @@ -34,9 +41,46 @@ public final class CelestialUniforms { .uniformTruncated3f(PER_FRAME, "moonPosition", this::getMoonPosition) .uniform1f(PER_FRAME, "shadowAngle", CelestialUniforms::getShadowAngle) .uniformTruncated3f(PER_FRAME, "shadowLightPosition", this::getShadowLightPosition) + .uniformTruncated3f(PER_FRAME, "endFlashPosition", this::getEndFlashPosition) .uniformTruncated3f(PER_FRAME, "upPosition", CelestialUniforms::getUpPosition); } + private Vector4f getEndFlashPosition() { + final WorldClient world = Minecraft.getMinecraft().theWorld; + if (world == null || !(world.provider instanceof WorldProviderEnd) || !EndFlashCompat.isAvailable()) { + return ZERO_VECTOR_4f; + } + + final float yAngle = EndFlashCompat.getYAngle(); + final float xAngle = EndFlashCompat.getXAngle(); + + endFlashPositionCache.set(0.0F, 100.0F, 0.0F, 0.0F); + endFlashMatrixCache.set(RenderingState.INSTANCE.getModelViewMatrix()); + endFlashMatrixCache.rotateY((180.0F - yAngle) * Constants.DEGREES_TO_RADIANS); + endFlashMatrixCache.rotateX((-90.0F - xAngle) * Constants.DEGREES_TO_RADIANS); + endFlashMatrixCache.transform(endFlashPositionCache); + return endFlashPositionCache; + } + + private Vector4f getEndFlashPositionInWorldSpace() { + final float yAngle = EndFlashCompat.getYAngle(); + final float xAngle = EndFlashCompat.getXAngle(); + + endFlashPositionCache.set(0.0F, 100.0F, 0.0F, 0.0F); + endFlashMatrixCache.identity(); + endFlashMatrixCache.rotateY((180.0F - yAngle) * Constants.DEGREES_TO_RADIANS); + endFlashMatrixCache.rotateX((-90.0F - xAngle) * Constants.DEGREES_TO_RADIANS); + endFlashMatrixCache.transform(endFlashPositionCache); + return endFlashPositionCache; + } + + private static boolean isEndFlashShadowActive() { + final WorldClient world = Minecraft.getMinecraft().theWorld; + return world != null && world.provider instanceof WorldProviderEnd + && EndFlashCompat.isAvailable() + && Iris.getPipelineManager().getPipeline().map(WorldRenderingPipeline::supportsEndFlash).orElse(false); + } + public static float getSunAngle() { final float skyAngle = getSkyAngle(); @@ -66,10 +110,16 @@ public final class CelestialUniforms { } public Vector4f getShadowLightPosition() { + if (isEndFlashShadowActive()) { + return getEndFlashPosition(); + } return isDay() ? getSunPosition() : getMoonPosition(); } public Vector4f getShadowLightPositionInWorldSpace() { + if (isEndFlashShadowActive()) { + return getEndFlashPositionInWorldSpace(); + } return isDay() ? getCelestialPositionInWorldSpace(100.0F) : getCelestialPositionInWorldSpace(-100.0F); } diff --git a/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java b/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java index f1da55d93..f308c24ca 100644 --- a/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java +++ b/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java @@ -58,7 +58,7 @@ public final class CommonUniforms { SystemTimeUniforms.addSystemTimeUniforms(uniforms); BiomeUniforms.addBiomeUniforms(uniforms); new CelestialUniforms(directives.getSunPathRotation()).addCelestialUniforms(uniforms); - IrisExclusiveUniforms.addIrisExclusiveUniforms(uniforms); + IrisExclusiveUniforms.addIrisExclusiveUniforms(uniforms, updateNotifier); IdMapUniforms.addIdMapUniforms(updateNotifier, uniforms, idMap, directives.isOldHandLight()); MatrixUniforms.addMatrixUniforms(uniforms, directives); diff --git a/src/main/java/net/coderbot/iris/uniforms/EndFlashStorage.java b/src/main/java/net/coderbot/iris/uniforms/EndFlashStorage.java new file mode 100644 index 000000000..c3a2078b7 --- /dev/null +++ b/src/main/java/net/coderbot/iris/uniforms/EndFlashStorage.java @@ -0,0 +1,19 @@ +package net.coderbot.iris.uniforms; + +import com.gtnewhorizons.angelica.compat.etfuturum.EndFlashCompat; +import lombok.Getter; + +/** + * Holds the current and previous-frame End flash intensity. + */ +@Getter +public class EndFlashStorage { + private float lastEndFlash; + private float currentEndFlash; + + public void tick() { + lastEndFlash = currentEndFlash; + currentEndFlash = EndFlashCompat.getIntensity(CapturedRenderingState.INSTANCE.getTickDelta()); + } + +} diff --git a/src/main/java/net/coderbot/iris/uniforms/IrisExclusiveUniforms.java b/src/main/java/net/coderbot/iris/uniforms/IrisExclusiveUniforms.java index ceb534177..36c374780 100644 --- a/src/main/java/net/coderbot/iris/uniforms/IrisExclusiveUniforms.java +++ b/src/main/java/net/coderbot/iris/uniforms/IrisExclusiveUniforms.java @@ -41,9 +41,13 @@ public class IrisExclusiveUniforms { private static int cachedSelectedFrame = -1; private static int cachedSelectedBlockId; - public static void addIrisExclusiveUniforms(UniformHolder uniforms) { + public static void addIrisExclusiveUniforms(UniformHolder uniforms, FrameUpdateNotifier updateNotifier) { WorldInfoUniforms.addWorldInfoUniforms(uniforms); + // Et Futurum Requiem backports the End Flash + final EndFlashStorage endFlashStorage = new EndFlashStorage(); + updateNotifier.addListener(endFlashStorage::tick); + //All Iris-exclusive uniforms (uniforms which do not exist in either OptiFine or ShadersMod) should be registered here. uniforms.uniform1f(UniformUpdateFrequency.PER_FRAME, "thunderStrength", IrisExclusiveUniforms::getThunderStrength); uniforms.uniform1f(UniformUpdateFrequency.PER_TICK, "currentPlayerHealth", IrisExclusiveUniforms::getCurrentHealth); @@ -59,6 +63,8 @@ public class IrisExclusiveUniforms { uniforms.uniform3d(UniformUpdateFrequency.PER_FRAME, "relativeEyePosition", IrisExclusiveUniforms::getRelativeEyePosition); uniforms.uniform4f(UniformUpdateFrequency.PER_TICK, "lightningBoltPosition", IrisExclusiveUniforms::getLightningBoltPosition); uniforms.uniform1f(UniformUpdateFrequency.PER_FRAME, "cloudTime", IrisExclusiveUniforms::getCloudTime); + uniforms.uniform1f(UniformUpdateFrequency.PER_TICK, "endFlashIntensity", endFlashStorage::getCurrentEndFlash); + uniforms.uniform1f(UniformUpdateFrequency.PER_TICK, "previousEndFlashIntensity", endFlashStorage::getLastEndFlash); uniforms.uniform1b(UniformUpdateFrequency.PER_TICK, "feetInWater", IrisExclusiveUniforms::isFeetInWater); uniforms.uniform1b(UniformUpdateFrequency.PER_TICK, "isRiding", IrisExclusiveUniforms::isRiding); uniforms.uniform1b(UniformUpdateFrequency.PER_TICK, "vehicleInWater", IrisExclusiveUniforms::isVehicleInWater);