diff --git a/dependencies.gradle b/dependencies.gradle index 79dc28d2f..ec0f58f45 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -81,6 +81,9 @@ dependencies { compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.0:dev") { transitive = false } compileOnly(rfg.deobf('maven.modrinth:backhand:1.4.1')) { transitive = false } + compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.0:dev") { transitive = false } + compileOnly(rfg.deobf('maven.modrinth:backhand:1.4.1')) { transitive = false } + compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.1:api") { transitive = false } compileOnly("com.falsepattern:endlessids-mc1.7.10:1.5-beta0003:dev") { transitive = false } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd4917..e6441136f 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/toremove/DrawState.java b/src/main/java/com/gtnewhorizons/angelica/compat/toremove/DrawState.java deleted file mode 100644 index 76aa2221e..000000000 --- a/src/main/java/com/gtnewhorizons/angelica/compat/toremove/DrawState.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.gtnewhorizons.angelica.compat.toremove; - -import com.gtnewhorizons.angelica.compat.mojang.VertexFormat; -import lombok.Getter; - -@Deprecated -public class DrawState { - @Getter - private final VertexFormat format; - @Getter - private final int vertexCount; - @Getter - private final int mode; - - public DrawState(VertexFormat format, int vertexCount, int mode) { - this.format = format; - this.vertexCount = vertexCount; - this.mode = mode; - } - -} diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/toremove/OverlayTexture.java b/src/main/java/com/gtnewhorizons/angelica/compat/toremove/OverlayTexture.java deleted file mode 100644 index 54a3ab1f1..000000000 --- a/src/main/java/com/gtnewhorizons/angelica/compat/toremove/OverlayTexture.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.gtnewhorizons.angelica.compat.toremove; - -@Deprecated -public class OverlayTexture { - - // This is definitely wrong - public static final int NO_OVERLAY = 0; -} diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/toremove/RenderLayer.java b/src/main/java/com/gtnewhorizons/angelica/compat/toremove/RenderLayer.java index 690b84662..821051cd4 100644 --- a/src/main/java/com/gtnewhorizons/angelica/compat/toremove/RenderLayer.java +++ b/src/main/java/com/gtnewhorizons/angelica/compat/toremove/RenderLayer.java @@ -140,7 +140,6 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris private final RenderPhase.DepthTest depthTest; private final RenderPhase.Cull cull; private final RenderPhase.Lightmap lightmap; - private final RenderPhase.Overlay overlay; private final RenderPhase.Fog fog; private final RenderPhase.Layering layering; private final RenderPhase.Target target; @@ -150,7 +149,7 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris private final OutlineMode outlineMode; private final ImmutableList phases; - private MultiPhaseParameters(RenderPhase.Texture texture, RenderPhase.Transparency transparency, RenderPhase.DiffuseLighting diffuseLighting, RenderPhase.ShadeModel shadeModel, RenderPhase.Alpha alpha, RenderPhase.DepthTest depthTest, RenderPhase.Cull cull, RenderPhase.Lightmap lightmap, RenderPhase.Overlay overlay, RenderPhase.Fog fog, RenderPhase.Layering layering, RenderPhase.Target target, RenderPhase.Texturing texturing, RenderPhase.WriteMaskState writeMaskState, RenderPhase.LineWidth lineWidth, OutlineMode outlineMode) { + private MultiPhaseParameters(RenderPhase.Texture texture, RenderPhase.Transparency transparency, RenderPhase.DiffuseLighting diffuseLighting, RenderPhase.ShadeModel shadeModel, RenderPhase.Alpha alpha, RenderPhase.DepthTest depthTest, RenderPhase.Cull cull, RenderPhase.Lightmap lightmap, RenderPhase.Fog fog, RenderPhase.Layering layering, RenderPhase.Target target, RenderPhase.Texturing texturing, RenderPhase.WriteMaskState writeMaskState, RenderPhase.LineWidth lineWidth, OutlineMode outlineMode) { this.texture = texture; this.transparency = transparency; this.diffuseLighting = diffuseLighting; @@ -159,7 +158,6 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris this.depthTest = depthTest; this.cull = cull; this.lightmap = lightmap; - this.overlay = overlay; this.fog = fog; this.layering = layering; this.target = target; @@ -167,7 +165,7 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris this.writeMaskState = writeMaskState; this.lineWidth = lineWidth; this.outlineMode = outlineMode; - this.phases = ImmutableList.of(this.texture, this.transparency, this.diffuseLighting, this.shadeModel, this.alpha, this.depthTest, this.cull, this.lightmap, this.overlay, this.fog, this.layering, this.target, new RenderPhase[]{this.texturing, this.writeMaskState, this.lineWidth}); + this.phases = ImmutableList.of(this.texture, this.transparency, this.diffuseLighting, this.shadeModel, this.alpha, this.depthTest, this.cull, this.lightmap, this.fog, this.layering, this.target, this.texturing, this.writeMaskState, this.lineWidth); } public boolean equals(Object object) { @@ -202,7 +200,6 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris private RenderPhase.DepthTest depthTest; private RenderPhase.Cull cull; private RenderPhase.Lightmap lightmap; - private RenderPhase.Overlay overlay; private RenderPhase.Fog fog; private RenderPhase.Layering layering; private RenderPhase.Target target; @@ -219,7 +216,6 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris this.depthTest = RenderPhase.LEQUAL_DEPTH_TEST; this.cull = RenderPhase.ENABLE_CULLING; this.lightmap = RenderPhase.DISABLE_LIGHTMAP; - this.overlay = RenderPhase.DISABLE_OVERLAY_COLOR; this.fog = RenderPhase.FOG; this.layering = RenderPhase.NO_LAYERING; this.target = RenderPhase.MAIN_TARGET; @@ -263,11 +259,6 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris return this; } - public Builder overlay(RenderPhase.Overlay overlay) { - this.overlay = overlay; - return this; - } - public Builder fog(RenderPhase.Fog fog) { this.fog = fog; return this; @@ -288,7 +279,7 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris } public MultiPhaseParameters build(OutlineMode outlineMode) { - return new MultiPhaseParameters(this.texture, this.transparency, this.diffuseLighting, this.shadeModel, this.alpha, this.depthTest, this.cull, this.lightmap, this.overlay, this.fog, this.layering, this.target, this.texturing, this.writeMaskState, this.lineWidth, outlineMode); + return new MultiPhaseParameters(this.texture, this.transparency, this.diffuseLighting, this.shadeModel, this.alpha, this.depthTest, this.cull, this.lightmap, this.fog, this.layering, this.target, this.texturing, this.writeMaskState, this.lineWidth, outlineMode); } } } diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/toremove/RenderPhase.java b/src/main/java/com/gtnewhorizons/angelica/compat/toremove/RenderPhase.java index 6ba033e3b..46d9d363a 100644 --- a/src/main/java/com/gtnewhorizons/angelica/compat/toremove/RenderPhase.java +++ b/src/main/java/com/gtnewhorizons/angelica/compat/toremove/RenderPhase.java @@ -69,8 +69,6 @@ public abstract class RenderPhase { protected static final Texturing ENTITY_GLINT_TEXTURING; protected static final Lightmap ENABLE_LIGHTMAP; protected static final Lightmap DISABLE_LIGHTMAP; - protected static final Overlay ENABLE_OVERLAY_COLOR; - protected static final Overlay DISABLE_OVERLAY_COLOR; protected static final DiffuseLighting ENABLE_DIFFUSE_LIGHTING; protected static final DiffuseLighting DISABLE_DIFFUSE_LIGHTING; protected static final Cull ENABLE_CULLING; @@ -177,8 +175,6 @@ public abstract class RenderPhase { }); ENABLE_LIGHTMAP = new Lightmap(true); DISABLE_LIGHTMAP = new Lightmap(false); - ENABLE_OVERLAY_COLOR = new Overlay(true); - DISABLE_OVERLAY_COLOR = new Overlay(false); ENABLE_DIFFUSE_LIGHTING = new DiffuseLighting(true); DISABLE_DIFFUSE_LIGHTING = new DiffuseLighting(false); ENABLE_CULLING = new Cull(true); @@ -505,25 +501,6 @@ public abstract class RenderPhase { } - public static class Overlay extends Toggleable { - public Overlay(boolean overlayColor) { - super("overlay", () -> { - if (overlayColor) { - throw new RuntimeException("Not Implemented Yet"); -// MinecraftClient.getInstance().gameRenderer.getOverlayTexture().setupOverlayColor(); - } - - }, () -> { - if (overlayColor) { - throw new RuntimeException("Not Implemented Yet"); -// MinecraftClient.getInstance().gameRenderer.getOverlayTexture().teardownOverlayColor(); - } - - }, overlayColor); - } - } - - public static class Lightmap extends Toggleable { public Lightmap(boolean lightmap) { super("lightmap", () -> { diff --git a/src/main/java/com/gtnewhorizons/angelica/config/AngelicaConfig.java b/src/main/java/com/gtnewhorizons/angelica/config/AngelicaConfig.java index 176b82c85..6c7301ef9 100644 --- a/src/main/java/com/gtnewhorizons/angelica/config/AngelicaConfig.java +++ b/src/main/java/com/gtnewhorizons/angelica/config/AngelicaConfig.java @@ -35,13 +35,11 @@ public class AngelicaConfig { @Config.Comment("Enable Iris Shaders [Requires Sodium]") @Config.DefaultBoolean(false) @Config.RequiresMcRestart - @Config.Ignore() public static boolean enableIris; @Config.Comment("Enable MCPatcherForge features, still in Alpha. Individual features are toggled in mcpatcher.json") @Config.DefaultBoolean(false) @Config.RequiresMcRestart - @Config.Ignore() public static boolean enableMCPatcherForgeFeatures; @Config.Comment("Replace some vanilla render paths with more optimized versions. Disable if you encounter mixin conflicts.") @@ -86,7 +84,7 @@ public class AngelicaConfig { public static boolean enableFontRenderer; @Config.Comment("Enable Dynamic Lights") - @Config.DefaultBoolean(false) + @Config.DefaultBoolean(true) @Config.RequiresMcRestart public static boolean enableDynamicLights; diff --git a/src/main/java/com/gtnewhorizons/angelica/dynamiclights/DynamicLights.java b/src/main/java/com/gtnewhorizons/angelica/dynamiclights/DynamicLights.java index 2c6404335..34b2fb1e4 100644 --- a/src/main/java/com/gtnewhorizons/angelica/dynamiclights/DynamicLights.java +++ b/src/main/java/com/gtnewhorizons/angelica/dynamiclights/DynamicLights.java @@ -49,7 +49,7 @@ public class DynamicLights { } public static boolean isEnabled() { - return Mode.isEnabled() && AngelicaConfig.enableDynamicLights; + return AngelicaConfig.enableDynamicLights && Mode.isEnabled() && !IrisApi.getInstance().isShaderPackInUse(); } /** diff --git a/src/main/java/com/gtnewhorizons/angelica/glsm/GLDebug.java b/src/main/java/com/gtnewhorizons/angelica/glsm/GLDebug.java index 5d5f16de9..8c1de9fb7 100644 --- a/src/main/java/com/gtnewhorizons/angelica/glsm/GLDebug.java +++ b/src/main/java/com/gtnewhorizons/angelica/glsm/GLDebug.java @@ -271,17 +271,20 @@ public final class GLDebug { private static DebugState debugState; - private interface DebugState { + private interface DebugState { void nameObject(int id, int object, String name); void pushGroup(String name); void popGroup(); void debugMessage(String name); - } + + String getObjectLabel(int glProgram, int program); + } private static class KHRDebugState implements DebugState { private static final int ID = 0; private int depth = 0; private static final int maxDepth = GL11.glGetInteger(KHRDebug.GL_MAX_DEBUG_GROUP_STACK_DEPTH); + private static final int maxNameLength = GL11.glGetInteger(KHRDebug.GL_MAX_LABEL_LENGTH); @Override public void nameObject(int id, int object, String name) { @@ -310,6 +313,14 @@ public final class GLDebug { public void debugMessage(String message) { KHRDebug.glDebugMessageInsert(KHRDebug.GL_DEBUG_SOURCE_APPLICATION, KHRDebug.GL_DEBUG_TYPE_MARKER, ID, KHRDebug.GL_DEBUG_SEVERITY_NOTIFICATION, message); } + + @Override + public String getObjectLabel(int glProgram, int program) { + if(program == 0) + return ""; + + return KHRDebug.glGetObjectLabel(glProgram, program, maxNameLength); + } } private static class UnsupportedDebugState implements DebugState { @@ -329,6 +340,11 @@ public final class GLDebug { public void debugMessage(String name) { } + + @Override + public String getObjectLabel(int glProgram, int program) { + return ""; + } } public static void initDebugState() { @@ -359,4 +375,12 @@ public final class GLDebug { debugState.debugMessage(message); } } + public static String getObjectLabel(int glProgram, int program) { + if(debugState != null && Thread.currentThread() == GLStateManager.getMainThread()) { + return debugState.getObjectLabel(glProgram, program); + } + return ""; + } + + } diff --git a/src/main/java/com/gtnewhorizons/angelica/glsm/GLStateManager.java b/src/main/java/com/gtnewhorizons/angelica/glsm/GLStateManager.java index ee4c3e0d6..bb0e349bb 100644 --- a/src/main/java/com/gtnewhorizons/angelica/glsm/GLStateManager.java +++ b/src/main/java/com/gtnewhorizons/angelica/glsm/GLStateManager.java @@ -59,6 +59,7 @@ import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL14; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GLContext; +import org.lwjgl.opengl.KHRDebug; import java.lang.Math; import java.nio.ByteBuffer; @@ -134,6 +135,8 @@ public class GLStateManager { @Getter protected static final ViewPortStateStack viewportState = new ViewPortStateStack(); + @Getter protected static int activeProgram = 0; + public static void reset() { runningSplash = true; while(!attribs.isEmpty()) { @@ -399,6 +402,7 @@ public class GLStateManager { case GL14.GL_BLEND_DST_RGB -> blendState.getDstRgb(); case GL14.GL_BLEND_SRC_ALPHA -> blendState.getSrcAlpha(); case GL14.GL_BLEND_SRC_RGB -> blendState.getSrcRgb(); + case GL20.GL_CURRENT_PROGRAM -> activeProgram; default -> GL11.glGetInteger(pname); }; @@ -845,9 +849,6 @@ public class GLStateManager { } else if (textureUnit == IrisSamplers.LIGHTMAP_TEXTURE_UNIT) { StateTracker.INSTANCE.lightmapSampler = true; updatePipeline = true; - } else if (textureUnit == IrisSamplers.OVERLAY_TEXTURE_UNIT) { - StateTracker.INSTANCE.overlaySampler = true; - updatePipeline = true; } if (updatePipeline) { @@ -868,9 +869,6 @@ public class GLStateManager { } else if (textureUnit == IrisSamplers.LIGHTMAP_TEXTURE_UNIT) { StateTracker.INSTANCE.lightmapSampler = false; updatePipeline = true; - } else if (textureUnit == IrisSamplers.OVERLAY_TEXTURE_UNIT) { - StateTracker.INSTANCE.overlaySampler = false; - updatePipeline = true; } if (updatePipeline) { @@ -1569,4 +1567,18 @@ public class GLStateManager { public static void glDepthRange(double near, double far) { GL11.glDepthRange(near, far); } + + public static void glUseProgram(int program) { + if(program != activeProgram || shouldBypassCache()) { + activeProgram = program; + if(AngelicaMod.lwjglDebug) { + final String programName = GLDebug.getObjectLabel(KHRDebug.GL_PROGRAM, program); + GLDebug.debugMessage("Activating Program - " + program + ":" + programName); + } + GL20.glUseProgram(program); + } + } + + + } diff --git a/src/main/java/com/gtnewhorizons/angelica/loading/AngelicaTweaker.java b/src/main/java/com/gtnewhorizons/angelica/loading/AngelicaTweaker.java index b665f46a4..af0c54e93 100644 --- a/src/main/java/com/gtnewhorizons/angelica/loading/AngelicaTweaker.java +++ b/src/main/java/com/gtnewhorizons/angelica/loading/AngelicaTweaker.java @@ -48,11 +48,6 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader { } ctx.updateLoggers(); - // Too many bug reports because people refuse to read or just want to try it - so make these only able - // to be enabled by system properties for now. - AngelicaConfig.enableIris = Boolean.parseBoolean(System.getProperty("angelica.enableShaders", "false")); - AngelicaConfig.enableMCPatcherForgeFeatures = Boolean.parseBoolean(System.getProperty("angelica.enableMCPatcherForgeFeatures", "false")); - // Debug features AngelicaConfig.enableTestBlocks = Boolean.parseBoolean(System.getProperty("angelica.enableTestBlocks", "false")); diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java b/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java index b622271c8..72f1e104d 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java @@ -140,13 +140,18 @@ public enum Mixins { IRIS_RENDERING(new Builder("Iris Shaders").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT) .setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addMixinClasses( "shaders.MixinEntityRenderer" + ,"shaders.MixinGuiIngameForge" ,"shaders.MixinFramebuffer" ,"shaders.MixinItem" ,"shaders.MixinLocale" ,"shaders.MixinOpenGlHelper" ,"shaders.MixinRender" + ,"shaders.MixinRenderDragon" + ,"shaders.MixinRenderEnderman" + ,"shaders.MixinRendererLivingEntity" ,"shaders.MixinRenderGlobal" - ,"shaders.MixinRenderManager" + ,"shaders.MixinRenderSpider" + ,"shaders.MixinTileEntityBeaconRenderer" ) ), diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/MixinEntityRenderer.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/MixinEntityRenderer.java index 5ff484814..5d2f8e469 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/MixinEntityRenderer.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/MixinEntityRenderer.java @@ -24,7 +24,7 @@ public abstract class MixinEntityRenderer { ); } - @ModifyArg(method = "setupCameraTransform", at = @At(value = "INVOKE", target = "Lorg/lwjgl/util/glu/Project;gluPerspective(FFFF)V", ordinal = 0), index = 0) + @ModifyArg(method = "setupCameraTransform", at = @At(value = "INVOKE", target = "Lorg/lwjgl/util/glu/Project;gluPerspective(FFFF)V", ordinal = 0, remap = false), index = 0) private float captureFov(float fov) { RenderingState.INSTANCE.setFov(fov); return fov; diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/archaic/MixinGuiIngameForge.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/archaic/MixinGuiIngameForge.java index e9fe26039..e8b046dd7 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/archaic/MixinGuiIngameForge.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/archaic/MixinGuiIngameForge.java @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -@Mixin(GuiIngameForge.class) +@Mixin(value=GuiIngameForge.class, remap = false) public class MixinGuiIngameForge { @Redirect(method = "renderHUDText", at = @At(value = "FIELD", target = "Lnet/minecraft/world/biome/BiomeGenBase;biomeName:Ljava/lang/String;")) private String getModNameWithBiome(BiomeGenBase biome) { diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/ctm/MixinRenderBlocks.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/ctm/MixinRenderBlocks.java index c94b31d21..9e1a99dcc 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/ctm/MixinRenderBlocks.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/ctm/MixinRenderBlocks.java @@ -510,7 +510,7 @@ public abstract class MixinRenderBlocks { * @author roadhog360 */ @SuppressWarnings("UnreachableCode") - @Inject(method = "renderBlockStainedGlassPane", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockPane;canPaneConnectTo(Lnet/minecraft/world/IBlockAccess;IIILnet/minecraftforge/common/util/ForgeDirection;)Z", ordinal = 3, shift = At.Shift.BY, by = 2), cancellable = true) + @Inject(method = "renderBlockStainedGlassPane", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockPane;canPaneConnectTo(Lnet/minecraft/world/IBlockAccess;IIILnet/minecraftforge/common/util/ForgeDirection;)Z", ordinal = 3, shift = At.Shift.BY, by = 2, remap = false), cancellable = true) private void tweakStainedPaneRenderer(Block block, int x, int y, int z, CallbackInfoReturnable cir, @Local(name = "iicon") IIcon iicon, @Local(name = "d22") double d22, @Local(name = "d0") double d0, @Local(name = "d1") double d1, @Local(name = "d2") double d2, diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/notfine/toggle/MixinEntityRenderer.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/notfine/toggle/MixinEntityRenderer.java index 8f8f513d8..9f5ce761b 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/notfine/toggle/MixinEntityRenderer.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/notfine/toggle/MixinEntityRenderer.java @@ -52,7 +52,8 @@ abstract public class MixinEntityRenderer { at = @At( value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V", - ordinal = 14 + ordinal = 14, + remap = false ) ) private void notFine$nearFogDistance(int mode, float value) { diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/notfine/toggle/MixinGuiIngame.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/notfine/toggle/MixinGuiIngame.java index 04be41fc7..8bd21600b 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/notfine/toggle/MixinGuiIngame.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/notfine/toggle/MixinGuiIngame.java @@ -17,7 +17,7 @@ public abstract class MixinGuiIngame { target = "Lnet/minecraft/client/Minecraft;isFancyGraphicsEnabled()Z" ) ) - private boolean notFine$toggleVignette(float whyAndHowIsThisAFloat) { + private boolean notFine$toggleVignette() { return SettingsManager.vignette; } diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinFramebuffer.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinFramebuffer.java index 5d7027f6d..bba408060 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinFramebuffer.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinFramebuffer.java @@ -71,6 +71,9 @@ public abstract class MixinFramebuffer implements IRenderTargetExt { @Inject(method="createFramebuffer(II)V", at=@At(value="FIELD", target="Lnet/minecraft/client/shader/Framebuffer;useDepth:Z", shift=At.Shift.BEFORE, ordinal = 1)) private void iris$createDepthTexture(int width, int height, CallbackInfo ci) { if(this.iris$useDepth) { + if(this.iris$depthTextureId == -1) { + this.iris$depthTextureId = GL11.glGenTextures(); + } GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, this.iris$depthTextureId); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinGuiIngameForge.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinGuiIngameForge.java new file mode 100644 index 000000000..7d2102be1 --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinGuiIngameForge.java @@ -0,0 +1,17 @@ +package com.gtnewhorizons.angelica.mixins.early.shaders; + +import net.minecraftforge.client.GuiIngameForge; +import org.lwjgl.opengl.GL11; +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(value = GuiIngameForge.class, remap = false) +public class MixinGuiIngameForge { + @Inject(method="renderCrosshairs", at= @At(value = "INVOKE", target = "Lnet/minecraftforge/client/GuiIngameForge;bind(Lnet/minecraft/util/ResourceLocation;)V", shift = At.Shift.AFTER)) + private void renderCrosshairs(CallbackInfo ci) { + // Set the same state as vanilla so we don't break with textures that set a color value on transparent pixels for the crosshairs + GL11.glEnable(GL11.GL_ALPHA_TEST); + } +} diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRenderDragon.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRenderDragon.java new file mode 100644 index 000000000..dc2ed645f --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRenderDragon.java @@ -0,0 +1,18 @@ +package com.gtnewhorizons.angelica.mixins.early.shaders; + +import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition; +import net.coderbot.iris.layer.GbufferPrograms; +import net.minecraft.client.renderer.entity.RenderDragon; +import net.minecraft.entity.boss.EntityDragon; +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.CallbackInfoReturnable; + +@Mixin(RenderDragon.class) +public class MixinRenderDragon { + @Inject(method = "Lnet/minecraft/client/renderer/entity/RenderDragon;shouldRenderPass(Lnet/minecraft/entity/boss/EntityDragon;IF)I", at = @At(value="RETURN", ordinal = 1)) + private void onShouldRenderPass(EntityDragon entity, int pass, float partialTicks, CallbackInfoReturnable cir) { + GbufferPrograms.setupSpecialRenderCondition(SpecialCondition.ENTITY_EYES); + } +} diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRenderEnderman.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRenderEnderman.java new file mode 100644 index 000000000..f1fdca2ad --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRenderEnderman.java @@ -0,0 +1,19 @@ +package com.gtnewhorizons.angelica.mixins.early.shaders; + +import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition; +import net.coderbot.iris.layer.GbufferPrograms; +import net.minecraft.client.renderer.entity.RenderEnderman; +import net.minecraft.entity.monster.EntityEnderman; +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.CallbackInfoReturnable; + +@Mixin(RenderEnderman.class) +public class MixinRenderEnderman { + @Inject(method = "Lnet/minecraft/client/renderer/entity/RenderEnderman;shouldRenderPass(Lnet/minecraft/entity/monster/EntityEnderman;IF)I", at = @At(value="RETURN", ordinal = 1)) + private void onShouldRenderPass(EntityEnderman entity, int pass, float partialTicks, CallbackInfoReturnable cir) { + GbufferPrograms.setupSpecialRenderCondition(SpecialCondition.ENTITY_EYES); + } + +} diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRenderManager.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRenderManager.java deleted file mode 100644 index 377b3383c..000000000 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRenderManager.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.gtnewhorizons.angelica.mixins.early.shaders; - -import net.coderbot.iris.layer.GbufferPrograms; -import net.coderbot.iris.uniforms.CapturedRenderingState; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.Entity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(RenderManager.class) -public class MixinRenderManager { - - @Unique - private static final String DO_RENDER = "Lnet/minecraft/client/renderer/entity/Render;doRender(Lnet/minecraft/entity/Entity;DDDFF)V"; - - @Inject(method = "func_147939_a", at = @At(value = "INVOKE", target = DO_RENDER)) - private void iris$onRenderEntityPre(Entity entity, double x, double y, double z, float yaw, float partialTicks, boolean rebuild, CallbackInfoReturnable cir) { - CapturedRenderingState.INSTANCE.setCurrentEntity(entity.getEntityId()); - GbufferPrograms.beginEntities(); - } - - @Inject(method = "func_147939_a", at = @At(value = "INVOKE", target = DO_RENDER, shift = At.Shift.AFTER)) - private void iris$onRenderEntityPost(Entity entity, double x, double y, double z, float yaw, float partialTicks, boolean rebuild, CallbackInfoReturnable cir) { - CapturedRenderingState.INSTANCE.setCurrentEntity(-1); - GbufferPrograms.endEntities(); - } -} diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRenderSpider.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRenderSpider.java new file mode 100644 index 000000000..a4f9751ef --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRenderSpider.java @@ -0,0 +1,19 @@ +package com.gtnewhorizons.angelica.mixins.early.shaders; + +import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition; +import net.coderbot.iris.layer.GbufferPrograms; +import net.minecraft.client.renderer.entity.RenderSpider; +import net.minecraft.entity.monster.EntitySpider; +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.CallbackInfoReturnable; + +@Mixin(RenderSpider.class) +public class MixinRenderSpider { + @Inject(method = "Lnet/minecraft/client/renderer/entity/RenderSpider;shouldRenderPass(Lnet/minecraft/entity/monster/EntitySpider;IF)I", at = @At(value="RETURN", ordinal = 1)) + private void onShouldRenderPass(EntitySpider entity, int pass, float partialTicks, CallbackInfoReturnable cir) { + GbufferPrograms.setupSpecialRenderCondition(SpecialCondition.ENTITY_EYES); + } + +} diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRendererLivingEntity.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRendererLivingEntity.java new file mode 100644 index 000000000..cf375e851 --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinRendererLivingEntity.java @@ -0,0 +1,38 @@ +package com.gtnewhorizons.angelica.mixins.early.shaders; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import net.coderbot.iris.layer.GbufferPrograms; +import net.coderbot.iris.uniforms.CapturedRenderingState; +import net.minecraft.client.renderer.entity.RendererLivingEntity; +import net.minecraft.entity.EntityLivingBase; +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(RendererLivingEntity.class) +public class MixinRendererLivingEntity { + + @WrapOperation( + method="doRender", + at=@At(value="INVOKE", target="Lnet/minecraft/client/renderer/entity/RendererLivingEntity;getColorMultiplier(Lnet/minecraft/entity/EntityLivingBase;FF)I") + ) + private int iris$setEntityColor(RendererLivingEntity instance, EntityLivingBase elb, float f0, float f1, Operation original) { + final int j = original.call(instance, elb, f0, f1); + final float a = (j >> 24 & 255) / 255.0F; + final float r = (j >> 16 & 255) / 255.0F; + final float g = (j >> 8 & 255) / 255.0F; + final float b = (j & 255) / 255.0F; + CapturedRenderingState.INSTANCE.setCurrentEntityColor(r, g, b, 1.0F - a); + return j; + } + + @Inject( + method="Lnet/minecraft/client/renderer/entity/RendererLivingEntity;doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V", at=@At(value="INVOKE", + target="Lnet/minecraft/client/renderer/entity/RendererLivingEntity;renderEquippedItems(Lnet/minecraft/entity/EntityLivingBase;F)V", shift=At.Shift.BEFORE) + ) + private void iris$teardownSpecialRenderConditions(EntityLivingBase entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) { + GbufferPrograms.teardownSpecialRenderCondition(); + } +} diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinTileEntityBeaconRenderer.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinTileEntityBeaconRenderer.java new file mode 100644 index 000000000..b83b8713b --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinTileEntityBeaconRenderer.java @@ -0,0 +1,26 @@ +package com.gtnewhorizons.angelica.mixins.early.shaders; + +import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition; +import net.coderbot.iris.layer.GbufferPrograms; +import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer; +import net.minecraft.tileentity.TileEntityBeacon; +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(TileEntityBeaconRenderer.class) +public class MixinTileEntityBeaconRenderer { + + @Inject(method="Lnet/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer;renderTileEntityAt(Lnet/minecraft/tileentity/TileEntityBeacon;DDDF)V", at=@At("HEAD")) + private void onRenderTileEntityAt(TileEntityBeacon beacon, double x, double y, double z, float partialTicks, CallbackInfo ci) { + GbufferPrograms.setupSpecialRenderCondition(SpecialCondition.BEACON_BEAM); + } + + @Inject(method="Lnet/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer;renderTileEntityAt(Lnet/minecraft/tileentity/TileEntityBeacon;DDDF)V", at=@At("RETURN")) + private void afterRenderTileEntityAt(TileEntityBeacon beacon, double x, double y, double z, float partialTicks, CallbackInfo ci) { + GbufferPrograms.teardownSpecialRenderCondition(); + } + + +} diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/sodium/MixinRenderGlobal.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/sodium/MixinRenderGlobal.java index 63afccc58..6342609a5 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/sodium/MixinRenderGlobal.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/sodium/MixinRenderGlobal.java @@ -6,15 +6,19 @@ import com.gtnewhorizons.angelica.config.AngelicaConfig; import com.gtnewhorizons.angelica.mixins.interfaces.IRenderGlobalExt; import com.gtnewhorizons.angelica.rendering.AngelicaRenderQueue; import com.gtnewhorizons.angelica.rendering.RenderingState; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import lombok.Getter; import me.jellysquid.mods.sodium.client.gl.device.RenderDevice; import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer; import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass; import net.coderbot.iris.Iris; +import net.coderbot.iris.layer.GbufferPrograms; import net.coderbot.iris.pipeline.HandRenderer; import net.coderbot.iris.pipeline.ShadowRenderer; import net.coderbot.iris.pipeline.WorldRenderingPhase; import net.coderbot.iris.pipeline.WorldRenderingPipeline; +import net.coderbot.iris.uniforms.CapturedRenderingState; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.PlayerControllerMP; import net.minecraft.client.multiplayer.WorldClient; @@ -23,10 +27,14 @@ import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.culling.Frustrum; import net.minecraft.client.renderer.culling.ICamera; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.init.Blocks; import org.lwjgl.opengl.GL11; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; @@ -49,6 +57,8 @@ public class MixinRenderGlobal implements IRenderGlobalExt { @Shadow public int renderDistanceChunks; @Shadow public WorldRenderer[] worldRenderers; @Shadow public WorldRenderer[] sortedWorldRenderers; + @Shadow @Final private TextureManager renderEngine; + @Getter @Unique private SodiumWorldRenderer renderer; @@ -141,9 +151,10 @@ public class MixinRenderGlobal implements IRenderGlobalExt { pipeline = null; } else { pipeline = Iris.getPipelineManager().getPipelineNullable(); - pipeline.setPhase(WorldRenderingPhase.TERRAIN_CUTOUT); - - if(pass == 1) { + if(pass == 0) { + pipeline.setPhase(WorldRenderingPhase.TERRAIN_CUTOUT); + } else if(pass == 1) { + pipeline.setPhase(WorldRenderingPhase.TERRAIN_TRANSLUCENT); final Camera camera = new Camera(mc.renderViewEntity, (float) partialTicks); // iris$beginTranslucents @@ -151,6 +162,7 @@ public class MixinRenderGlobal implements IRenderGlobalExt { HandRenderer.INSTANCE.renderSolid(null /*poseStack*/, (float) partialTicks, camera, mc.renderGlobal, pipeline); mc.mcProfiler.endStartSection("iris_pre_translucent"); pipeline.beginTranslucents(); + this.renderEngine.bindTexture(TextureMap.locationBlocksTexture); } } // Handle view distance change @@ -172,6 +184,7 @@ public class MixinRenderGlobal implements IRenderGlobalExt { try { final MatrixStack matrixStack = new MatrixStack(ShadowRenderer.ACTIVE ? ShadowRenderer.MODELVIEW : RenderingState.INSTANCE.getModelViewMatrix()); + mc.mcProfiler.endStartSection("draw_chunk_layer_" + pass); this.renderer.drawChunkLayer(BlockRenderPass.VALUES[pass], matrixStack, x, y, z); } finally { RenderDevice.exitManagedCode(); @@ -285,6 +298,19 @@ public class MixinRenderGlobal implements IRenderGlobalExt { this.renderChunksDeep = 0; } + @WrapOperation(method="renderEntities", at=@At(value="INVOKE", target="Lnet/minecraft/client/renderer/entity/RenderManager;renderEntitySimple(Lnet/minecraft/entity/Entity;F)Z")) + private boolean angelica$renderEntitySimple(RenderManager instance, Entity entity, float partialTicks, Operation original) { + CapturedRenderingState.INSTANCE.setCurrentEntity(entity.getEntityId()); + GbufferPrograms.beginEntities(); + try { + return original.call(instance, entity, partialTicks); + } finally { + CapturedRenderingState.INSTANCE.setCurrentEntity(-1); + GbufferPrograms.endEntities(); + } + } + + @Inject(method="renderEntities", at=@At(value="INVOKE", target="Lnet/minecraft/client/renderer/RenderHelper;enableStandardItemLighting()V", shift = At.Shift.AFTER)) public void sodium$renderTileEntities(EntityLivingBase entity, ICamera camera, float partialTicks, CallbackInfo ci) { this.renderer.renderTileEntities(entity, camera, partialTicks); diff --git a/src/main/java/com/gtnewhorizons/angelica/transform/RedirectorTransformer.java b/src/main/java/com/gtnewhorizons/angelica/transform/RedirectorTransformer.java index 16405afe6..037f2ec2c 100644 --- a/src/main/java/com/gtnewhorizons/angelica/transform/RedirectorTransformer.java +++ b/src/main/java/com/gtnewhorizons/angelica/transform/RedirectorTransformer.java @@ -204,6 +204,7 @@ public class RedirectorTransformer implements IClassTransformer { ); methodRedirects.put(GL20, RedirectMap.newMap() .add("glBlendEquationSeparate") + .add("glUseProgram") ); methodRedirects.put(OpenGlHelper, RedirectMap.newMap() .add("glBlendFunc", "tryBlendFuncSeparate") diff --git a/src/main/java/me/jellysquid/mods/sodium/client/gl/shader/GlProgram.java b/src/main/java/me/jellysquid/mods/sodium/client/gl/shader/GlProgram.java index c7a8618fb..bc262afe1 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/gl/shader/GlProgram.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/gl/shader/GlProgram.java @@ -1,5 +1,6 @@ package me.jellysquid.mods.sodium.client.gl.shader; +import com.gtnewhorizons.angelica.glsm.GLDebug; import me.jellysquid.mods.sodium.client.gl.GlObject; import me.jellysquid.mods.sodium.client.gl.device.RenderDevice; import net.minecraft.util.ResourceLocation; @@ -7,7 +8,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL20; - +import org.lwjgl.opengl.KHRDebug; /** * An OpenGL shader program. @@ -47,7 +48,7 @@ public abstract class GlProgram extends GlObject { * @throws NullPointerException If no uniform exists with the given name */ public int getUniformLocation(String name) { - int index = GL20.glGetUniformLocation(this.handle(), name); + final int index = GL20.glGetUniformLocation(this.handle(), name); if (index < 0) { throw new NullPointerException("No uniform exists with name: " + name); @@ -69,6 +70,7 @@ public abstract class GlProgram extends GlObject { public Builder(ResourceLocation name) { this.name = name; this.program = GL20.glCreateProgram(); + GLDebug.nameObject(KHRDebug.GL_PROGRAM, program, name.toString()); } public Builder attachShader(GlShader shader) { @@ -89,13 +91,13 @@ public abstract class GlProgram extends GlObject { public

P build(ProgramFactory

factory) { GL20.glLinkProgram(this.program); - String log = GL20.glGetProgramInfoLog(this.program, GL20.GL_INFO_LOG_LENGTH); + final String log = GL20.glGetProgramInfoLog(this.program, GL20.GL_INFO_LOG_LENGTH); if (!log.isEmpty()) { LOGGER.warn("Program link log for " + this.name + ": " + log); } - int result = GL20.glGetProgrami(this.program, GL20.GL_LINK_STATUS); + final int result = GL20.glGetProgrami(this.program, GL20.GL_LINK_STATUS); if (result != GL11.GL_TRUE) { throw new RuntimeException("Shader program linking failed, see log for details"); diff --git a/src/main/java/me/jellysquid/mods/sodium/client/gui/SodiumGameOptionPages.java b/src/main/java/me/jellysquid/mods/sodium/client/gui/SodiumGameOptionPages.java index 745a9cfd1..8475100cf 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/gui/SodiumGameOptionPages.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/gui/SodiumGameOptionPages.java @@ -187,6 +187,7 @@ public class SodiumGameOptionPages { .setImpact(OptionImpact.LOW) .build()) .add(Settings.PARTICLES_ENC_TABLE.option) + .add(Settings.PARTICLES_VOID.option) .add(OptionImpl.createBuilder(GraphicsQuality.class, sodiumOpts) .setName(I18n.format("sodium.options.grass_quality.name")) .setTooltip(I18n.format("sodium.options.grass_quality.tooltip")) diff --git a/src/main/java/me/jellysquid/mods/sodium/client/model/light/smooth/SmoothLightPipeline.java b/src/main/java/me/jellysquid/mods/sodium/client/model/light/smooth/SmoothLightPipeline.java index eacc1b449..0981e65fe 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/model/light/smooth/SmoothLightPipeline.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/model/light/smooth/SmoothLightPipeline.java @@ -72,7 +72,7 @@ public class SmoothLightPipeline implements LightPipeline { public void calculate(ModelQuadView quad, BlockPosImpl pos, QuadLightData out, ForgeDirection cullFace, ForgeDirection face, boolean shade) { this.updateCachedData(pos.asLong()); - int flags = quad.getFlags(); + final int flags = quad.getFlags(); final AoNeighborInfo neighborInfo = AoNeighborInfo.get(face); @@ -102,7 +102,7 @@ public class SmoothLightPipeline implements LightPipeline { * Flags: IS_ALIGNED, !IS_PARTIAL */ private void applyAlignedFullFace(AoNeighborInfo neighborInfo, BlockPosImpl pos, ForgeDirection dir, QuadLightData out) { - AoFaceData faceData = this.getCachedFaceData(pos, dir, true); + final AoFaceData faceData = this.getCachedFaceData(pos, dir, true); neighborInfo.mapCorners(faceData.lm, faceData.ao, out.lm, out.br); } @@ -113,11 +113,11 @@ public class SmoothLightPipeline implements LightPipeline { private void applyAlignedPartialFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPosImpl pos, ForgeDirection dir, QuadLightData out) { for (int i = 0; i < 4; i++) { // Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting - float cx = clamp(quad.getX(i)); - float cy = clamp(quad.getY(i)); - float cz = clamp(quad.getZ(i)); + final float cx = clamp(quad.getX(i)); + final float cy = clamp(quad.getY(i)); + final float cz = clamp(quad.getZ(i)); - float[] weights = this.weights; + final float[] weights = this.weights; neighborInfo.calculateCornerWeights(cx, cy, cz, weights); this.applyAlignedPartialFaceVertex(pos, dir, weights, i, out, true); } @@ -133,14 +133,14 @@ public class SmoothLightPipeline implements LightPipeline { private void applyParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPosImpl pos, ForgeDirection dir, QuadLightData out) { for (int i = 0; i < 4; i++) { // Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting - float cx = clamp(quad.getX(i)); - float cy = clamp(quad.getY(i)); - float cz = clamp(quad.getZ(i)); + final float cx = clamp(quad.getX(i)); + final float cy = clamp(quad.getY(i)); + final float cz = clamp(quad.getZ(i)); - float[] weights = this.weights; + final float[] weights = this.weights; neighborInfo.calculateCornerWeights(cx, cy, cz, weights); - float depth = neighborInfo.getDepth(cx, cy, cz); + final float depth = neighborInfo.getDepth(cx, cy, cz); // If the quad is approximately grid-aligned (not inset) to the other side of the block, avoid unnecessary // computation by treating it is as aligned @@ -160,14 +160,14 @@ public class SmoothLightPipeline implements LightPipeline { private void applyNonParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPosImpl pos, ForgeDirection dir, QuadLightData out) { for (int i = 0; i < 4; i++) { // Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting - float cx = clamp(quad.getX(i)); - float cy = clamp(quad.getY(i)); - float cz = clamp(quad.getZ(i)); + final float cx = clamp(quad.getX(i)); + final float cy = clamp(quad.getY(i)); + final float cz = clamp(quad.getZ(i)); - float[] weights = this.weights; + final float[] weights = this.weights; neighborInfo.calculateCornerWeights(cx, cy, cz, weights); - float depth = neighborInfo.getDepth(cx, cy, cz); + final float depth = neighborInfo.getDepth(cx, cy, cz); // If the quad is approximately grid-aligned (not inset), avoid unnecessary computation by treating it is as aligned if (DoubleMath.fuzzyEquals(depth, 0.0F, TOLERANCE)) { @@ -183,22 +183,22 @@ public class SmoothLightPipeline implements LightPipeline { } private void applyAlignedPartialFaceVertex(BlockPosImpl pos, ForgeDirection dir, float[] w, int i, QuadLightData out, boolean offset) { - AoFaceData faceData = this.getCachedFaceData(pos, dir, offset); + final AoFaceData faceData = this.getCachedFaceData(pos, dir, offset); if (!faceData.hasUnpackedLightData()) { faceData.unpackLightData(); } - float sl = faceData.getBlendedSkyLight(w); - float bl = faceData.getBlendedBlockLight(w); - float ao = faceData.getBlendedShade(w); + final float sl = faceData.getBlendedSkyLight(w); + final float bl = faceData.getBlendedBlockLight(w); + final float ao = faceData.getBlendedShade(w); out.br[i] = ao; out.lm[i] = getLightMapCoord(sl, bl); } private void applyInsetPartialFaceVertex(BlockPosImpl pos, ForgeDirection dir, float n1d, float n2d, float[] w, int i, QuadLightData out) { - AoFaceData n1 = this.getCachedFaceData(pos, dir, false); + final AoFaceData n1 = this.getCachedFaceData(pos, dir, false); if (!n1.hasUnpackedLightData()) { n1.unpackLightData(); @@ -211,9 +211,9 @@ public class SmoothLightPipeline implements LightPipeline { } // Blend between the direct neighbors and above based on the passed weights - float ao = (n1.getBlendedShade(w) * n1d) + (n2.getBlendedShade(w) * n2d); - float sl = (n1.getBlendedSkyLight(w) * n1d) + (n2.getBlendedSkyLight(w) * n2d); - float bl = (n1.getBlendedBlockLight(w) * n1d) + (n2.getBlendedBlockLight(w) * n2d); + final float ao = (n1.getBlendedShade(w) * n1d) + (n2.getBlendedShade(w) * n2d); + final float sl = (n1.getBlendedSkyLight(w) * n1d) + (n2.getBlendedSkyLight(w) * n2d); + final float bl = (n1.getBlendedBlockLight(w) * n1d) + (n2.getBlendedBlockLight(w) * n2d); out.br[i] = ao; out.lm[i] = getLightMapCoord(sl, bl); @@ -224,8 +224,8 @@ public class SmoothLightPipeline implements LightPipeline { return; } - float brightness = this.lightCache.getWorld().getBrightness(face, shade); - float[] br = out.br; + final float brightness = this.lightCache.getWorld().getBrightness(face, shade); + final float[] br = out.br; for (int i = 0; i < br.length; i++) { br[i] *= brightness; @@ -236,7 +236,7 @@ public class SmoothLightPipeline implements LightPipeline { * Returns the cached data for a given facing or calculates it if it hasn't been cached. */ private AoFaceData getCachedFaceData(BlockPosImpl pos, ForgeDirection face, boolean offset) { - AoFaceData data = this.cachedFaceData[offset ? face.ordinal() : face.ordinal() + 6]; + final AoFaceData data = this.cachedFaceData[offset ? face.ordinal() : face.ordinal() + 6]; if (!data.hasLightData()) { data.initLightData(this.lightCache, pos, face, offset); diff --git a/src/main/java/me/jellysquid/mods/sodium/client/render/SodiumWorldRenderer.java b/src/main/java/me/jellysquid/mods/sodium/client/render/SodiumWorldRenderer.java index 927854899..e2e35d613 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/render/SodiumWorldRenderer.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/render/SodiumWorldRenderer.java @@ -30,10 +30,13 @@ import me.jellysquid.mods.sodium.client.util.math.FrustumExtended; import me.jellysquid.mods.sodium.client.world.ChunkStatusListener; import me.jellysquid.mods.sodium.common.util.ListUtil; import net.coderbot.iris.block_rendering.BlockRenderingSettings; +import net.coderbot.iris.layer.GbufferPrograms; import net.coderbot.iris.pipeline.ShadowRenderer; import net.coderbot.iris.shadows.ShadowRenderingState; import net.coderbot.iris.sodium.shadow_map.SwappableChunkRenderManager; import net.coderbot.iris.sodium.vertex_format.IrisModelVertexFormats; +import net.coderbot.iris.uniforms.CapturedRenderingState; +import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.renderer.WorldRenderer; @@ -339,7 +342,13 @@ public class SodiumWorldRenderer implements ChunkStatusListener { return; try { + if(AngelicaConfig.enableIris) { + final Block block = tileEntity.getWorldObj().getBlock(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); + CapturedRenderingState.INSTANCE.setCurrentBlockEntity(Block.getIdFromBlock(block)); + GbufferPrograms.beginBlockEntities(); + } TileEntityRendererDispatcher.instance.renderTileEntity(tileEntity, partialTicks); + } catch(RuntimeException e) { if(tileEntity.isInvalid()) { SodiumClientMod.logger().error("Suppressing crash from invalid tile entity", e); @@ -347,10 +356,16 @@ public class SodiumWorldRenderer implements ChunkStatusListener { throw e; } } + finally { + if(AngelicaConfig.enableIris) { + CapturedRenderingState.INSTANCE.setCurrentBlockEntity(-1); + GbufferPrograms.endBlockEntities(); + } + } } public void renderTileEntities(EntityLivingBase entity, ICamera camera, float partialTicks) { - int pass = MinecraftForgeClient.getRenderPass(); + final int pass = MinecraftForgeClient.getRenderPass(); for (TileEntity tileEntity : this.chunkRenderManager.getVisibleTileEntities()) { renderTE(tileEntity, pass, partialTicks); } diff --git a/src/main/java/net/coderbot/batchedentityrendering/impl/BufferBuilderExt.java b/src/main/java/net/coderbot/batchedentityrendering/impl/BufferBuilderExt.java deleted file mode 100644 index cc0a98ae1..000000000 --- a/src/main/java/net/coderbot/batchedentityrendering/impl/BufferBuilderExt.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.coderbot.batchedentityrendering.impl; - -import com.gtnewhorizons.angelica.compat.toremove.DrawState; - -import java.nio.ByteBuffer; - -public interface BufferBuilderExt { - -} diff --git a/src/main/java/net/coderbot/batchedentityrendering/impl/BufferSegment.java b/src/main/java/net/coderbot/batchedentityrendering/impl/BufferSegment.java index 237aa54f4..f46bbe951 100644 --- a/src/main/java/net/coderbot/batchedentityrendering/impl/BufferSegment.java +++ b/src/main/java/net/coderbot/batchedentityrendering/impl/BufferSegment.java @@ -1,6 +1,5 @@ package net.coderbot.batchedentityrendering.impl; -import com.gtnewhorizons.angelica.compat.toremove.DrawState; import com.gtnewhorizons.angelica.compat.toremove.RenderLayer; import lombok.Getter; @@ -9,12 +8,10 @@ import java.nio.ByteBuffer; public class BufferSegment { private final ByteBuffer slice; @Getter - private final DrawState drawState; private final RenderLayer type; - public BufferSegment(ByteBuffer slice, DrawState drawState, RenderLayer type) { + public BufferSegment(ByteBuffer slice, RenderLayer type) { this.slice = slice; - this.drawState = drawState; this.type = type; } diff --git a/src/main/java/net/coderbot/iris/gbuffer_overrides/matching/InputAvailability.java b/src/main/java/net/coderbot/iris/gbuffer_overrides/matching/InputAvailability.java index cf0899196..bdd9e729f 100644 --- a/src/main/java/net/coderbot/iris/gbuffer_overrides/matching/InputAvailability.java +++ b/src/main/java/net/coderbot/iris/gbuffer_overrides/matching/InputAvailability.java @@ -5,29 +5,19 @@ public class InputAvailability { public final boolean texture; public final boolean lightmap; - public final boolean overlay; - public InputAvailability(boolean texture, boolean lightmap, boolean overlay) { + public InputAvailability(boolean texture, boolean lightmap) { this.texture = texture; this.lightmap = lightmap; - this.overlay = overlay; - } - - public InputAvailability withoutOverlay() { - return new InputAvailability(texture, lightmap, false); } public static InputAvailability unpack(int packed) { - return new InputAvailability((packed & 1) == 1, (packed & 2) == 2, (packed & 4) == 4); + return new InputAvailability((packed & 1) == 1, (packed & 2) == 2); } public int pack() { int packed = 0; - if (overlay) { - packed |= 4; - } - if (lightmap) { packed |= 2; } @@ -44,7 +34,6 @@ public class InputAvailability { return "InputAvailability{" + "texture=" + texture + ", lightmap=" + lightmap + - ", overlay=" + overlay + '}'; } @@ -53,7 +42,6 @@ public class InputAvailability { final int prime = 31; int result = 1; result = prime * result + (lightmap ? 1231 : 1237); - result = prime * result + (overlay ? 1231 : 1237); result = prime * result + (texture ? 1231 : 1237); return result; } @@ -69,8 +57,6 @@ public class InputAvailability { InputAvailability other = (InputAvailability) obj; if (lightmap != other.lightmap) return false; - if (overlay != other.overlay) - return false; if (texture != other.texture) return false; return true; diff --git a/src/main/java/net/coderbot/iris/gbuffer_overrides/state/StateTracker.java b/src/main/java/net/coderbot/iris/gbuffer_overrides/state/StateTracker.java index bf6c6e982..46f38a6fc 100644 --- a/src/main/java/net/coderbot/iris/gbuffer_overrides/state/StateTracker.java +++ b/src/main/java/net/coderbot/iris/gbuffer_overrides/state/StateTracker.java @@ -11,12 +11,8 @@ public class StateTracker { public boolean albedoSampler; // LightmapStateShard / TextureUnit.LIGHTMAP public boolean lightmapSampler; - // OverlayStateShard / TextureUnit.OVERLAY - public boolean overlaySampler; public InputAvailability getInputs() { - return new InputAvailability(albedoSampler, - lightmapSampler, - overlaySampler); + return new InputAvailability(albedoSampler, lightmapSampler); } } diff --git a/src/main/java/net/coderbot/iris/layer/BlockEntityRenderStateShard.java b/src/main/java/net/coderbot/iris/layer/BlockEntityRenderStateShard.java deleted file mode 100644 index 67d8ea954..000000000 --- a/src/main/java/net/coderbot/iris/layer/BlockEntityRenderStateShard.java +++ /dev/null @@ -1,42 +0,0 @@ -package net.coderbot.iris.layer; - -import com.gtnewhorizons.angelica.compat.toremove.RenderPhase; -import net.coderbot.iris.uniforms.CapturedRenderingState; - -public final class BlockEntityRenderStateShard extends RenderPhase { - private static final BlockEntityRenderStateShard UNIDENTIFIED = new BlockEntityRenderStateShard(-1); - - private final int entityId; - - private BlockEntityRenderStateShard(int entityId) { - super("iris:is_block_entity", () -> { - CapturedRenderingState.INSTANCE.setCurrentBlockEntity(entityId); - GbufferPrograms.beginBlockEntities(); - }, () -> { - CapturedRenderingState.INSTANCE.setCurrentBlockEntity(-1); - GbufferPrograms.endBlockEntities(); - }); - - this.entityId = entityId; - } - - public static BlockEntityRenderStateShard forId(int entityId) { - if (entityId == -1) { - return UNIDENTIFIED; - } else { - // TODO: Cache all created render phases to avoid allocations? - return new BlockEntityRenderStateShard(entityId); - } - } - - @Override - public boolean equals(Object object) { - if (object == null || object.getClass() != this.getClass()) { - return false; - } - - BlockEntityRenderStateShard other = (BlockEntityRenderStateShard) object; - - return this.entityId == other.entityId; - } -} diff --git a/src/main/java/net/coderbot/iris/layer/EntityRenderStateShard.java b/src/main/java/net/coderbot/iris/layer/EntityRenderStateShard.java deleted file mode 100644 index d47d627cb..000000000 --- a/src/main/java/net/coderbot/iris/layer/EntityRenderStateShard.java +++ /dev/null @@ -1,42 +0,0 @@ -package net.coderbot.iris.layer; - -import com.gtnewhorizons.angelica.compat.toremove.RenderPhase; -import net.coderbot.iris.uniforms.CapturedRenderingState; - -public final class EntityRenderStateShard extends RenderPhase { - private static final EntityRenderStateShard UNIDENTIFIED = new EntityRenderStateShard(-1); - - private final int entityId; - - private EntityRenderStateShard(int entityId) { - super("iris:is_entity", () -> { - CapturedRenderingState.INSTANCE.setCurrentEntity(entityId); - GbufferPrograms.beginEntities(); - }, () -> { - CapturedRenderingState.INSTANCE.setCurrentEntity(-1); - GbufferPrograms.endEntities(); - }); - - this.entityId = entityId; - } - - public static EntityRenderStateShard forId(int entityId) { - if (entityId == -1) { - return UNIDENTIFIED; - } else { - // TODO: Cache all created render phases to avoid allocations? - return new EntityRenderStateShard(entityId); - } - } - - @Override - public boolean equals(Object object) { - if (object == null || object.getClass() != this.getClass()) { - return false; - } - - EntityRenderStateShard other = (EntityRenderStateShard) object; - - return this.entityId == other.entityId; - } -} diff --git a/src/main/java/net/coderbot/iris/layer/GbufferPrograms.java b/src/main/java/net/coderbot/iris/layer/GbufferPrograms.java index 42f048099..fdde3525d 100644 --- a/src/main/java/net/coderbot/iris/layer/GbufferPrograms.java +++ b/src/main/java/net/coderbot/iris/layer/GbufferPrograms.java @@ -65,7 +65,7 @@ public class GbufferPrograms { } public static WorldRenderingPhase getCurrentPhase() { - WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable(); + final WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable(); if (pipeline != null) { return pipeline.getPhase(); @@ -75,7 +75,7 @@ public class GbufferPrograms { } private static void setPhase(WorldRenderingPhase phase) { - WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable(); + final WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable(); if (pipeline != null) { pipeline.setPhase(phase); @@ -83,7 +83,7 @@ public class GbufferPrograms { } public static void setOverridePhase(WorldRenderingPhase phase) { - WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable(); + final WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable(); if (pipeline != null) { pipeline.setOverridePhase(phase); @@ -100,7 +100,7 @@ public class GbufferPrograms { Iris.getPipelineManager().getPipeline().ifPresent(p -> p.setSpecialCondition(override)); } - public static void teardownSpecialRenderCondition(SpecialCondition override) { + public static void teardownSpecialRenderCondition() { Iris.getPipelineManager().getPipeline().ifPresent(p -> p.setSpecialCondition(null)); } diff --git a/src/main/java/net/coderbot/iris/layer/IsBlockEntityRenderStateShard.java b/src/main/java/net/coderbot/iris/layer/IsBlockEntityRenderStateShard.java deleted file mode 100644 index f18af5669..000000000 --- a/src/main/java/net/coderbot/iris/layer/IsBlockEntityRenderStateShard.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.coderbot.iris.layer; - -import com.gtnewhorizons.angelica.compat.toremove.RenderPhase; - -public class IsBlockEntityRenderStateShard extends RenderPhase { - public static final IsBlockEntityRenderStateShard INSTANCE = new IsBlockEntityRenderStateShard(); - - private IsBlockEntityRenderStateShard() { - super("iris:is_block_entity", GbufferPrograms::beginBlockEntities, GbufferPrograms::endBlockEntities); - } -} diff --git a/src/main/java/net/coderbot/iris/layer/IsEntityRenderStateShard.java b/src/main/java/net/coderbot/iris/layer/IsEntityRenderStateShard.java deleted file mode 100644 index a3daa0920..000000000 --- a/src/main/java/net/coderbot/iris/layer/IsEntityRenderStateShard.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.coderbot.iris.layer; - -import com.gtnewhorizons.angelica.compat.toremove.RenderPhase; - -public class IsEntityRenderStateShard extends RenderPhase { - public static final IsEntityRenderStateShard INSTANCE = new IsEntityRenderStateShard(); - - private IsEntityRenderStateShard() { - super("iris:is_entity", GbufferPrograms::beginEntities, GbufferPrograms::endEntities); - } -} diff --git a/src/main/java/net/coderbot/iris/layer/IsOutlineRenderStateShard.java b/src/main/java/net/coderbot/iris/layer/IsOutlineRenderStateShard.java deleted file mode 100644 index 2c2edc836..000000000 --- a/src/main/java/net/coderbot/iris/layer/IsOutlineRenderStateShard.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.coderbot.iris.layer; - -import com.gtnewhorizons.angelica.compat.toremove.RenderPhase; - -public class IsOutlineRenderStateShard extends RenderPhase { - public static final IsOutlineRenderStateShard INSTANCE = new IsOutlineRenderStateShard(); - - private IsOutlineRenderStateShard() { - super("iris:is_outline", GbufferPrograms::beginOutline, GbufferPrograms::endOutline); - } -} diff --git a/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java index 570cd98f9..440ea7dea 100644 --- a/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java @@ -145,7 +145,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R private WorldRenderingPhase phase = WorldRenderingPhase.NONE; private boolean isBeforeTranslucent; private boolean isRenderingShadow = false; - private InputAvailability inputs = new InputAvailability(false, false, false); + private InputAvailability inputs = new InputAvailability(false, false); private SpecialCondition special = null; private boolean shouldBindPBR; @@ -344,7 +344,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R if (programs.getPackDirectives().getShadowDirectives().isShadowEnabled().orElse(true)) { this.shadowRenderer = new ShadowRenderer(programs.getShadow().orElse(null), programs.getPackDirectives(), shadowRenderTargets); - Program shadowProgram = table.match(RenderCondition.SHADOW, new InputAvailability(true, true, true)).getProgram(); + Program shadowProgram = table.match(RenderCondition.SHADOW, new InputAvailability(true, true)).getProgram(); shadowRenderer.setUsesImages(shadowProgram != null && shadowProgram.getActiveImages() > 0); } else { shadowRenderer = null; @@ -367,7 +367,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureManager.getCustomTextureIdMap(TextureStage.GBUFFERS_AND_SHADOW)); IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, flipped, renderTargets, false); - IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true, false)); + IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true)); IrisSamplers.addWorldDepthSamplers(customTextureSamplerInterceptor, renderTargets); IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, customTextureManager.getNoiseTexture()); @@ -395,7 +395,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureManager.getCustomTextureIdMap(TextureStage.GBUFFERS_AND_SHADOW)); IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flippedAfterPrepare, renderTargets, false); - IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true, false)); + IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true)); IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, customTextureManager.getNoiseTexture()); // Only initialize these samplers if the shadow map renderer exists. Otherwise, this program shouldn't be used at all? @@ -548,7 +548,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R } if (sodiumTerrainRendering) { - beginPass(table.match(getCondition(getPhase()), new InputAvailability(true, true, false))); + beginPass(table.match(getCondition(getPhase()), new InputAvailability(true, true))); return; } @@ -967,7 +967,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, flipped, renderTargets, false); IrisImages.addRenderTargetImages(builder, flipped, renderTargets); - IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true, false)); + IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true)); IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, customTextureManager.getNoiseTexture()); diff --git a/src/main/java/net/coderbot/iris/pipeline/transform/AttributeTransformer.java b/src/main/java/net/coderbot/iris/pipeline/transform/AttributeTransformer.java index bf0c333cd..805951b70 100644 --- a/src/main/java/net/coderbot/iris/pipeline/transform/AttributeTransformer.java +++ b/src/main/java/net/coderbot/iris/pipeline/transform/AttributeTransformer.java @@ -36,7 +36,7 @@ class AttributeTransformer { // lightmap texture coordinate. // See https://github.com/IrisShaders/Iris/issues/1149 if (parameters.inputs.lightmap) { - root.rename("gl_MultiTexCoord1", "gl_MultiTexCoord2"); + root.rename("gl_MultiTexCoord2", "gl_MultiTexCoord1"); } Stream stream = Stream.empty(); @@ -59,10 +59,6 @@ class AttributeTransformer { patchTextureMatrices(t, tree, root, parameters.inputs.lightmap); - if (parameters.inputs.overlay) { - patchOverlayColor(t, tree, root, parameters); - } - if (parameters.type.glShaderType == ShaderType.VERTEX && root.identifierIndex.has("gl_MultiTexCoord3") && !root.identifierIndex.has("mc_midTexCoord")) { @@ -91,7 +87,7 @@ class AttributeTransformer { "const float iris_ONE_OVER_32 = iris_ONE_OVER_256 * 8;"); if (hasLightmap) { tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_FUNCTIONS, - "mat4 iris_LightmapTextureMatrix = gl_TextureMatrix[2];"); + "mat4 iris_LightmapTextureMatrix = gl_TextureMatrix[1];"); } else { tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_FUNCTIONS, "mat4 iris_LightmapTextureMatrix =" + "mat4(iris_ONE_OVER_256, 0.0, 0.0, 0.0," + @@ -112,56 +108,4 @@ class AttributeTransformer { "mat4(1.0)" + ");"); } - - private static final AutoHintedMatcher uniformVec4EntityColor = new AutoHintedMatcher<>( - "uniform vec4 entityColor;", Matcher.externalDeclarationPattern); - - // Add entity color -> overlay color attribute support. - private static void patchOverlayColor( - ASTParser t, - TranslationUnit tree, - Root root, - AttributeParameters parameters) { - // delete original declaration - root.processMatches(t, uniformVec4EntityColor, ASTNode::detachAndDelete); - - if (parameters.type.glShaderType == ShaderType.VERTEX) { - // add our own declarations - // TODO: We're exposing entityColor to this stage even if it isn't declared in - // this stage. But this is needed for the pass-through behavior. - tree.parseAndInjectNodes(t, ASTInjectionPoint.BEFORE_FUNCTIONS, - "uniform sampler2D iris_overlay;", - "varying vec4 entityColor;"); - - // this is so we can pass through the overlay color at the end to the geometry - // or fragment stage. - tree.prependMain(t, - "vec4 overlayColor = texture2D(iris_overlay, (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy);", - "entityColor = vec4(overlayColor.rgb, 1.0 - overlayColor.a);", - // Workaround for a shader pack bug: - // https://github.com/IrisShaders/Iris/issues/1549 - // Some shader packs incorrectly ignore the alpha value, and assume that rgb - // will be - // zero if there is no hit flash, we try to emulate that here - "entityColor.rgb *= float(entityColor.a != 0.0);"); - } else if (parameters.type.glShaderType == ShaderType.GEOMETRY) { - // replace read references to grab the color from the first vertex. - root.replaceReferenceExpressions(t, "entityColor", "entityColor[0]"); - - // TODO: this is passthrough behavior - tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_FUNCTIONS, - "out vec4 entityColorGS;"); - tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_FUNCTIONS, - "in vec4 entityColor[];"); - tree.prependMain(t, "entityColorGS = entityColor[0];"); - } else if (parameters.type.glShaderType == ShaderType.FRAGMENT) { - tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_DECLARATIONS, - "varying vec4 entityColor;"); - - // Different output name to avoid a name collision in the geometry shader. - if (parameters.hasGeometry) { - root.rename("entityColor", "entityColorGS"); - } - } - } } diff --git a/src/main/java/net/coderbot/iris/samplers/IrisSamplers.java b/src/main/java/net/coderbot/iris/samplers/IrisSamplers.java index 4ffef547d..bc0a52953 100644 --- a/src/main/java/net/coderbot/iris/samplers/IrisSamplers.java +++ b/src/main/java/net/coderbot/iris/samplers/IrisSamplers.java @@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableSet; import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability; import net.coderbot.iris.gl.sampler.SamplerHolder; import net.coderbot.iris.gl.state.StateUpdateNotifiers; +import net.coderbot.iris.pipeline.DeferredWorldRenderingPipeline; import net.coderbot.iris.pipeline.WorldRenderingPipeline; import net.coderbot.iris.rendertarget.RenderTarget; import net.coderbot.iris.rendertarget.RenderTargets; @@ -18,15 +19,13 @@ import java.util.function.Supplier; public class IrisSamplers { public static final int ALBEDO_TEXTURE_UNIT = 0; - // TODO: Find equivalent in 1.7.10 - public static final int OVERLAY_TEXTURE_UNIT = 1; public static final int LIGHTMAP_TEXTURE_UNIT = 1; - public static final ImmutableSet WORLD_RESERVED_TEXTURE_UNITS = ImmutableSet.of(0, 1, 2); + public static final ImmutableSet WORLD_RESERVED_TEXTURE_UNITS = ImmutableSet.of(0, 1); // TODO: In composite programs, there shouldn't be any reserved textures. // We need a way to restore these texture bindings. - public static final ImmutableSet COMPOSITE_RESERVED_TEXTURE_UNITS = ImmutableSet.of(1, 2); + public static final ImmutableSet COMPOSITE_RESERVED_TEXTURE_UNITS = ImmutableSet.of(1); private IrisSamplers() { // no construction allowed @@ -139,14 +138,6 @@ public class IrisSamplers { samplers.addDynamicSampler(whitePixel::getGlTextureId, "lightmap"); } - if (availability.overlay) { - // TODO: Overlay equivalent in 1.7.10? -// samplers.addExternalSampler(OVERLAY_TEXTURE_UNIT, "iris_overlay"); - samplers.addDynamicSampler(whitePixel::getGlTextureId, "iris_overlay"); - } else { - samplers.addDynamicSampler(whitePixel::getGlTextureId, "iris_overlay"); - } - samplers.addDynamicSampler(pipeline::getCurrentNormalTexture, StateUpdateNotifiers.normalTextureChangeNotifier, "normals"); samplers.addDynamicSampler(pipeline::getCurrentSpecularTexture, StateUpdateNotifiers.specularTextureChangeNotifier, "specular"); } @@ -158,11 +149,8 @@ public class IrisSamplers { } public static void addCompositeSamplers(SamplerHolder samplers, RenderTargets renderTargets) { - samplers.addDynamicSampler(renderTargets::getDepthTexture, - "gdepthtex", "depthtex0"); - samplers.addDynamicSampler(renderTargets.getDepthTextureNoTranslucents()::getTextureId, - "depthtex1"); - samplers.addDynamicSampler(renderTargets.getDepthTextureNoHand()::getTextureId, - "depthtex2"); + samplers.addDynamicSampler(renderTargets::getDepthTexture, "gdepthtex", "depthtex0"); + samplers.addDynamicSampler(renderTargets.getDepthTextureNoTranslucents()::getTextureId, "depthtex1"); + samplers.addDynamicSampler(renderTargets.getDepthTextureNoHand()::getTextureId, "depthtex2"); } } diff --git a/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/EntityVertexBufferWriterNio.java b/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/EntityVertexBufferWriterNio.java index a649ff0be..c5bdcd882 100644 --- a/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/EntityVertexBufferWriterNio.java +++ b/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/EntityVertexBufferWriterNio.java @@ -1,6 +1,5 @@ package net.coderbot.iris.sodium.vertex_format.entity_xhfp; -import com.gtnewhorizons.angelica.compat.toremove.OverlayTexture; import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView; import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterNio; import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink; @@ -53,7 +52,7 @@ public class EntityVertexBufferWriterNio extends VertexBufferWriterNio implement @Override public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) { - writeQuad(x, y, z, color, u, v, light, OverlayTexture.NO_OVERLAY, 0); + writeQuad(x, y, z, color, u, v, light, 0, 0); } private void endQuad(int normal) { diff --git a/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/EntityVertexBufferWriterUnsafe.java b/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/EntityVertexBufferWriterUnsafe.java index bbb0e3913..c697bec3b 100644 --- a/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/EntityVertexBufferWriterUnsafe.java +++ b/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/EntityVertexBufferWriterUnsafe.java @@ -1,7 +1,6 @@ package net.coderbot.iris.sodium.vertex_format.entity_xhfp; import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil; -import com.gtnewhorizons.angelica.compat.toremove.OverlayTexture; import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView; import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe; import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink; @@ -51,7 +50,7 @@ public class EntityVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe imp @Override public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) { - writeQuad(x, y, z, color, u, v, light, OverlayTexture.NO_OVERLAY, 0); + writeQuad(x, y, z, color, u, v, light, 0, 0); } private void endQuad(int normal) { diff --git a/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/GlyphVertexBufferWriterNio.java b/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/GlyphVertexBufferWriterNio.java index e2b0d4bce..fb7a45074 100644 --- a/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/GlyphVertexBufferWriterNio.java +++ b/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/GlyphVertexBufferWriterNio.java @@ -1,6 +1,5 @@ package net.coderbot.iris.sodium.vertex_format.entity_xhfp; -import com.gtnewhorizons.angelica.compat.toremove.OverlayTexture; import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView; import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterNio; import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink; @@ -52,7 +51,7 @@ public class GlyphVertexBufferWriterNio extends VertexBufferWriterNio implements @Override public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) { - writeQuad(x, y, z, color, u, v, light, OverlayTexture.NO_OVERLAY, 0); + writeQuad(x, y, z, color, u, v, light, 0, 0); } private void endQuad(int normal) { diff --git a/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/GlyphVertexBufferWriterUnsafe.java b/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/GlyphVertexBufferWriterUnsafe.java index 66e087d61..70d4d719b 100644 --- a/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/GlyphVertexBufferWriterUnsafe.java +++ b/src/main/java/net/coderbot/iris/sodium/vertex_format/entity_xhfp/GlyphVertexBufferWriterUnsafe.java @@ -1,7 +1,6 @@ package net.coderbot.iris.sodium.vertex_format.entity_xhfp; import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil; -import com.gtnewhorizons.angelica.compat.toremove.OverlayTexture; import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView; import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe; import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink; @@ -50,7 +49,7 @@ public class GlyphVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe impl @Override public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) { - writeQuad(x, y, z, color, u, v, light, OverlayTexture.NO_OVERLAY, 0); + writeQuad(x, y, z, color, u, v, light, 0, 0); } private void endQuad(int normal) { diff --git a/src/main/java/net/coderbot/iris/uniforms/CapturedRenderingState.java b/src/main/java/net/coderbot/iris/uniforms/CapturedRenderingState.java index dd9699e3b..92ad32267 100644 --- a/src/main/java/net/coderbot/iris/uniforms/CapturedRenderingState.java +++ b/src/main/java/net/coderbot/iris/uniforms/CapturedRenderingState.java @@ -3,6 +3,8 @@ package net.coderbot.iris.uniforms; import lombok.Getter; import net.coderbot.iris.gl.state.ValueUpdateNotifier; +import org.joml.Vector4f; + public class CapturedRenderingState { public static final CapturedRenderingState INSTANCE = new CapturedRenderingState(); @@ -16,6 +18,10 @@ public class CapturedRenderingState { private int currentRenderedEntity = -1; private Runnable entityIdListener = null; + @Getter + private final Vector4f currentEntityColor = new Vector4f(); + private Runnable entityColorListener = null; + private CapturedRenderingState() { } @@ -39,6 +45,14 @@ public class CapturedRenderingState { } } + public void setCurrentEntityColor(float r, float g, float b, float a) { + this.currentEntityColor.set(r, g, b, a); + + if (this.entityColorListener != null) { + this.entityColorListener.run(); + } + } + public ValueUpdateNotifier getEntityIdNotifier() { return listener -> this.entityIdListener = listener; } @@ -46,4 +60,6 @@ public class CapturedRenderingState { public ValueUpdateNotifier getBlockEntityIdNotifier() { return listener -> this.blockEntityIdListener = listener; } + + public ValueUpdateNotifier getEntityColorNotifier() { return listener -> this.entityColorListener = listener; } } diff --git a/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java b/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java index 4dde1fb34..dcec1b6fe 100644 --- a/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java +++ b/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java @@ -91,6 +91,8 @@ public final class CommonUniforms { uniforms.uniform1i("renderStage", () -> GbufferPrograms.getCurrentPhase().ordinal(), StateUpdateNotifiers.phaseChangeNotifier); + uniforms.uniform4f("entityColor", CapturedRenderingState.INSTANCE::getCurrentEntityColor, CapturedRenderingState.INSTANCE.getEntityColorNotifier()); + CommonUniforms.generalCommonUniforms(uniforms, updateNotifier, directives); } @@ -115,8 +117,7 @@ public final class CommonUniforms { .uniform1f(PER_FRAME, "screenBrightness", () -> client.gameSettings.gammaSetting) // 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", Vector4f::new) - .uniform1f(PER_TICK, "playerMood", CommonUniforms::getPlayerMood) + .uniform1f(PER_TICK, "playerMood", CommonUniforms::getPlayerMood) .uniform2i(PER_FRAME, "eyeBrightness", CommonUniforms::getEyeBrightness) .uniform2i(PER_FRAME, "eyeBrightnessSmooth", () -> { final Vector2f smoothed = eyeBrightnessSmooth.get(); diff --git a/src/main/resources/assets/angelica/lang/en_US.lang b/src/main/resources/assets/angelica/lang/en_US.lang index 529535131..9257fb6ab 100644 --- a/src/main/resources/assets/angelica/lang/en_US.lang +++ b/src/main/resources/assets/angelica/lang/en_US.lang @@ -127,7 +127,7 @@ options.iris.shadowDistance.disabled=Your current shader pack has already set a options.iris.gui.hide=Hide GUI options.iris.gui.show=Show GUI options.dynamic_lights=Dynamic Lights -options.dynamic_lights.tooltip=Enables dynamic lights. Modes: OFF - off, FASTEST - 500ms delay, FAST - 250ms delay, FANCY - no delay +options.dynamic_lights.tooltip=Enables dynamic lights. Modes: OFF - off, FASTEST - 500ms delay, FAST - 250ms delay, FANCY - no delay. Disabled if shaders are in use. pack.iris.select.title=Select pack.iris.configure.title=Configure label.iris.true=On