From 71c84808dacc346c4be3bd07f0204b68653d18e2 Mon Sep 17 00:00:00 2001 From: blagdorfinguy Date: Fri, 29 Dec 2023 12:08:54 -0600 Subject: [PATCH 1/4] Modified config file to specify new shader compatibility, and changed FXWisp/Spark to render without transparency for shader compatibility (with GLSL deferred shading) --- .../botania/forge/ForgeBotaniaConfig.java | 4 +-- .../vazkii/botania/client/fx/FXSparkle.java | 24 ++++++++++++----- .../java/vazkii/botania/client/fx/FXWisp.java | 26 ++++++++++++++----- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/Forge/src/main/java/vazkii/botania/forge/ForgeBotaniaConfig.java b/Forge/src/main/java/vazkii/botania/forge/ForgeBotaniaConfig.java index 38ceacfcbb..5217329114 100644 --- a/Forge/src/main/java/vazkii/botania/forge/ForgeBotaniaConfig.java +++ b/Forge/src/main/java/vazkii/botania/forge/ForgeBotaniaConfig.java @@ -15,9 +15,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.config.ModConfigEvent; - import org.apache.commons.lang3.tuple.Pair; - import vazkii.botania.common.lib.LibMisc; import vazkii.botania.xplat.BotaniaConfig; import vazkii.botania.xplat.XplatAbstractions; @@ -52,7 +50,7 @@ private static class Client implements BotaniaConfig.ClientConfigAccess { public Client(ForgeConfigSpec.Builder builder) { builder.push("rendering"); useShaders = builder - .comment("Set this to false to disable the use of shaders for some of the mod's renders. (Requires game restart)") + .comment("Set this to false to disable the use of shaders for some of the mod's renders and render translucent particles as opaque, for shader compatibility with some shaders which implement a deferred lighting pass. (Requires game restart, and enabling without shaders may impact aesthetics)") .define("shaders", true); boundBlockWireframe = builder .comment("Set this to false to disable the wireframe when looking a block bound to something (spreaders, flowers, etc).") diff --git a/Xplat/src/main/java/vazkii/botania/client/fx/FXSparkle.java b/Xplat/src/main/java/vazkii/botania/client/fx/FXSparkle.java index 4adec4f3f4..8378f4a82a 100644 --- a/Xplat/src/main/java/vazkii/botania/client/fx/FXSparkle.java +++ b/Xplat/src/main/java/vazkii/botania/client/fx/FXSparkle.java @@ -13,23 +13,22 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexFormat; - import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.ParticleRenderType; import net.minecraft.client.particle.SpriteSet; import net.minecraft.client.particle.TextureSheetParticle; +import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.texture.AbstractTexture; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.phys.Vec3; - import org.jetbrains.annotations.NotNull; import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.helper.CoreShaders; +import vazkii.botania.xplat.BotaniaConfig; import vazkii.botania.xplat.ClientXplatAbstractions; public class FXSparkle extends TextureSheetParticle { @@ -156,13 +155,26 @@ private void wiggleAround(double x, double y, double z) { private static void beginRenderCommon(BufferBuilder buffer, TextureManager textureManager) { Minecraft.getInstance().gameRenderer.lightTexture().turnOnLightLayer(); RenderSystem.enableDepthTest(); - RenderSystem.depthMask(false); - RenderSystem.enableBlend(); - RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + + if(!BotaniaConfig.client().useShaders()) { //Shader compatibility mode enabled + RenderSystem.disableBlend(); + RenderSystem.depthMask(true); + RenderSystem.setShader(GameRenderer::getParticleShader); + } + else { //Shader compatibility mode disabled + RenderSystem.depthMask(false); + RenderSystem.enableBlend(); + RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 0.7f); + } + RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_PARTICLES); AbstractTexture tex = textureManager.getTexture(TextureAtlas.LOCATION_PARTICLES); ClientXplatAbstractions.INSTANCE.setFilterSave(tex, true, false); buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); + + + } private static void endRenderCommon() { diff --git a/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java b/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java index 8cb3768d47..21f43739b3 100644 --- a/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java +++ b/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java @@ -13,18 +13,17 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexFormat; - import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.ParticleRenderType; import net.minecraft.client.particle.TextureSheetParticle; +import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.texture.AbstractTexture; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureManager; - import org.jetbrains.annotations.NotNull; import org.lwjgl.opengl.GL11; - +import vazkii.botania.xplat.BotaniaConfig; import vazkii.botania.xplat.ClientXplatAbstractions; public class FXWisp extends TextureSheetParticle { @@ -104,14 +103,29 @@ public void setGravity(float value) { private static void beginRenderCommon(BufferBuilder bufferBuilder, TextureManager textureManager) { Minecraft.getInstance().gameRenderer.lightTexture().turnOnLightLayer(); - RenderSystem.depthMask(false); - RenderSystem.enableBlend(); - RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + if(!BotaniaConfig.client().useShaders()) { //Shader compatibility mode enabled + RenderSystem.disableBlend(); + RenderSystem.depthMask(true); + RenderSystem.setShader(GameRenderer::getParticleShader); + } + else { //Shader compatibility mode disabled + RenderSystem.depthMask(false); + RenderSystem.enableBlend(); + RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 0.7f); + } RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_PARTICLES); AbstractTexture tex = textureManager.getTexture(TextureAtlas.LOCATION_PARTICLES); ClientXplatAbstractions.INSTANCE.setFilterSave(tex, true, false); bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); + + //--- +// RenderSystem.disableBlend(); +// RenderSystem.depthMask(true); +// RenderSystem.setShader(GameRenderer::getParticleShader); +// RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_PARTICLES); +// $$0.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); } private static void endRenderCommon() { From 4f8c5edcd27685415a86bd83f68af822d152fedb Mon Sep 17 00:00:00 2001 From: blagdorfinguy Date: Fri, 29 Dec 2023 12:24:43 -0600 Subject: [PATCH 2/4] Forgot to run Spotless :/ --- .../java/vazkii/botania/forge/ForgeBotaniaConfig.java | 2 ++ .../main/java/vazkii/botania/client/fx/FXSparkle.java | 10 +++++----- .../src/main/java/vazkii/botania/client/fx/FXWisp.java | 8 +++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Forge/src/main/java/vazkii/botania/forge/ForgeBotaniaConfig.java b/Forge/src/main/java/vazkii/botania/forge/ForgeBotaniaConfig.java index 5217329114..33264404c0 100644 --- a/Forge/src/main/java/vazkii/botania/forge/ForgeBotaniaConfig.java +++ b/Forge/src/main/java/vazkii/botania/forge/ForgeBotaniaConfig.java @@ -15,7 +15,9 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.config.ModConfigEvent; + import org.apache.commons.lang3.tuple.Pair; + import vazkii.botania.common.lib.LibMisc; import vazkii.botania.xplat.BotaniaConfig; import vazkii.botania.xplat.XplatAbstractions; diff --git a/Xplat/src/main/java/vazkii/botania/client/fx/FXSparkle.java b/Xplat/src/main/java/vazkii/botania/client/fx/FXSparkle.java index 8378f4a82a..d49f53f0b5 100644 --- a/Xplat/src/main/java/vazkii/botania/client/fx/FXSparkle.java +++ b/Xplat/src/main/java/vazkii/botania/client/fx/FXSparkle.java @@ -13,6 +13,7 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexFormat; + import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.ParticleRenderType; @@ -25,8 +26,10 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.phys.Vec3; + import org.jetbrains.annotations.NotNull; import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.CoreShaders; import vazkii.botania.xplat.BotaniaConfig; import vazkii.botania.xplat.ClientXplatAbstractions; @@ -156,12 +159,11 @@ private static void beginRenderCommon(BufferBuilder buffer, TextureManager textu Minecraft.getInstance().gameRenderer.lightTexture().turnOnLightLayer(); RenderSystem.enableDepthTest(); - if(!BotaniaConfig.client().useShaders()) { //Shader compatibility mode enabled + if (!BotaniaConfig.client().useShaders()) { //Shader compatibility mode enabled RenderSystem.disableBlend(); RenderSystem.depthMask(true); RenderSystem.setShader(GameRenderer::getParticleShader); - } - else { //Shader compatibility mode disabled + } else { //Shader compatibility mode disabled RenderSystem.depthMask(false); RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); @@ -173,8 +175,6 @@ private static void beginRenderCommon(BufferBuilder buffer, TextureManager textu ClientXplatAbstractions.INSTANCE.setFilterSave(tex, true, false); buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); - - } private static void endRenderCommon() { diff --git a/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java b/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java index 21f43739b3..9c497f6a9c 100644 --- a/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java +++ b/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java @@ -13,6 +13,7 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexFormat; + import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.ParticleRenderType; @@ -21,8 +22,10 @@ import net.minecraft.client.renderer.texture.AbstractTexture; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureManager; + import org.jetbrains.annotations.NotNull; import org.lwjgl.opengl.GL11; + import vazkii.botania.xplat.BotaniaConfig; import vazkii.botania.xplat.ClientXplatAbstractions; @@ -103,12 +106,11 @@ public void setGravity(float value) { private static void beginRenderCommon(BufferBuilder bufferBuilder, TextureManager textureManager) { Minecraft.getInstance().gameRenderer.lightTexture().turnOnLightLayer(); - if(!BotaniaConfig.client().useShaders()) { //Shader compatibility mode enabled + if (!BotaniaConfig.client().useShaders()) { //Shader compatibility mode enabled RenderSystem.disableBlend(); RenderSystem.depthMask(true); RenderSystem.setShader(GameRenderer::getParticleShader); - } - else { //Shader compatibility mode disabled + } else { //Shader compatibility mode disabled RenderSystem.depthMask(false); RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); From 4a7e873c56c19214f3c2cf55b2c68a105708647a Mon Sep 17 00:00:00 2001 From: blagdorfinguy Date: Fri, 29 Dec 2023 16:29:37 -0600 Subject: [PATCH 3/4] Implemented for fabric, and created seperate config setting --- .../vazkii/botania/fabric/FiberBotaniaConfig.java | 11 +++++++++++ .../vazkii/botania/forge/ForgeBotaniaConfig.java | 13 ++++++++++++- .../java/vazkii/botania/client/fx/FXSparkle.java | 4 ++-- .../main/java/vazkii/botania/client/fx/FXWisp.java | 4 ++-- .../java/vazkii/botania/xplat/BotaniaConfig.java | 1 + 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Fabric/src/main/java/vazkii/botania/fabric/FiberBotaniaConfig.java b/Fabric/src/main/java/vazkii/botania/fabric/FiberBotaniaConfig.java index 2f447d77e0..21fe808056 100644 --- a/Fabric/src/main/java/vazkii/botania/fabric/FiberBotaniaConfig.java +++ b/Fabric/src/main/java/vazkii/botania/fabric/FiberBotaniaConfig.java @@ -87,6 +87,7 @@ private static class Client implements BotaniaConfig.ClientConfigAccess { public final PropertyMirror referencesEnabled = PropertyMirror.create(BOOLEAN); public final PropertyMirror splashesEnabled = PropertyMirror.create(BOOLEAN); public final PropertyMirror useShaders = PropertyMirror.create(BOOLEAN); + public final PropertyMirror opaqueParticles = PropertyMirror.create(BOOLEAN); public ConfigTree configure(ConfigTreeBuilder builder) { builder.fork("rendering") @@ -94,6 +95,10 @@ public ConfigTree configure(ConfigTreeBuilder builder) { .withComment("Set this to false to disable the use of shaders for some of the mod's renders. (Requires game restart)") .finishValue(useShaders::mirror) + .beginValue("opaqueParticles", BOOLEAN, false) + .withComment("Set this to true to disable translucent particles, for shader compatibility with some shaders which implement a deferred lighting pass. (Enabling without shaders may impact aesthetics)") + .finishValue(opaqueParticles::mirror) + .beginValue("boundBlockWireframe", BOOLEAN, true) .withComment("Set this to false to disable the wireframe when looking a block bound to something (spreaders, flowers, etc).") .finishValue(boundBlockWireframe::mirror) @@ -252,6 +257,12 @@ public boolean splashesEnabled() { public boolean useShaders() { return this.useShaders.getValue(); } + + @Override + public boolean opaqueParticles() { + return this.useShaders.getValue(); + } + } private static final Client CLIENT = new Client(); diff --git a/Forge/src/main/java/vazkii/botania/forge/ForgeBotaniaConfig.java b/Forge/src/main/java/vazkii/botania/forge/ForgeBotaniaConfig.java index 33264404c0..c25efed991 100644 --- a/Forge/src/main/java/vazkii/botania/forge/ForgeBotaniaConfig.java +++ b/Forge/src/main/java/vazkii/botania/forge/ForgeBotaniaConfig.java @@ -30,6 +30,7 @@ public final class ForgeBotaniaConfig { private static class Client implements BotaniaConfig.ClientConfigAccess { public final ForgeConfigSpec.BooleanValue useShaders; + public final ForgeConfigSpec.BooleanValue opaqueParticles; public final ForgeConfigSpec.BooleanValue lexiconRotatingItems; public final ForgeConfigSpec.BooleanValue subtlePowerSystem; public final ForgeConfigSpec.BooleanValue staticWandBeam; @@ -52,8 +53,11 @@ private static class Client implements BotaniaConfig.ClientConfigAccess { public Client(ForgeConfigSpec.Builder builder) { builder.push("rendering"); useShaders = builder - .comment("Set this to false to disable the use of shaders for some of the mod's renders and render translucent particles as opaque, for shader compatibility with some shaders which implement a deferred lighting pass. (Requires game restart, and enabling without shaders may impact aesthetics)") + .comment("Set this to false to disable the use of shaders for some of the mod's renders. (Requires game restart)") .define("shaders", true); + opaqueParticles = builder + .comment("Set this to true to disable translucent particles, for shader compatibility with some shaders which implement a deferred lighting pass. (Enabling without shaders may impact aesthetics)") + .define("opaqueParticles", false); boundBlockWireframe = builder .comment("Set this to false to disable the wireframe when looking a block bound to something (spreaders, flowers, etc).") .define("boundBlockWireframe", true); @@ -198,6 +202,13 @@ public boolean splashesEnabled() { public boolean useShaders() { return this.useShaders.get(); } + + @Override + public boolean opaqueParticles() { + return this.opaqueParticles.get(); + } + + } public static final Client CLIENT; diff --git a/Xplat/src/main/java/vazkii/botania/client/fx/FXSparkle.java b/Xplat/src/main/java/vazkii/botania/client/fx/FXSparkle.java index d49f53f0b5..97232ffe37 100644 --- a/Xplat/src/main/java/vazkii/botania/client/fx/FXSparkle.java +++ b/Xplat/src/main/java/vazkii/botania/client/fx/FXSparkle.java @@ -159,11 +159,11 @@ private static void beginRenderCommon(BufferBuilder buffer, TextureManager textu Minecraft.getInstance().gameRenderer.lightTexture().turnOnLightLayer(); RenderSystem.enableDepthTest(); - if (!BotaniaConfig.client().useShaders()) { //Shader compatibility mode enabled + if (BotaniaConfig.client().opaqueParticles()) { RenderSystem.disableBlend(); RenderSystem.depthMask(true); RenderSystem.setShader(GameRenderer::getParticleShader); - } else { //Shader compatibility mode disabled + } else { RenderSystem.depthMask(false); RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); diff --git a/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java b/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java index 9c497f6a9c..57f4a46fbc 100644 --- a/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java +++ b/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java @@ -106,11 +106,11 @@ public void setGravity(float value) { private static void beginRenderCommon(BufferBuilder bufferBuilder, TextureManager textureManager) { Minecraft.getInstance().gameRenderer.lightTexture().turnOnLightLayer(); - if (!BotaniaConfig.client().useShaders()) { //Shader compatibility mode enabled + if (BotaniaConfig.client().opaqueParticles()) { RenderSystem.disableBlend(); RenderSystem.depthMask(true); RenderSystem.setShader(GameRenderer::getParticleShader); - } else { //Shader compatibility mode disabled + } else { RenderSystem.depthMask(false); RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); diff --git a/Xplat/src/main/java/vazkii/botania/xplat/BotaniaConfig.java b/Xplat/src/main/java/vazkii/botania/xplat/BotaniaConfig.java index 1cbfdbcfae..cfee0d30df 100644 --- a/Xplat/src/main/java/vazkii/botania/xplat/BotaniaConfig.java +++ b/Xplat/src/main/java/vazkii/botania/xplat/BotaniaConfig.java @@ -42,6 +42,7 @@ public interface ClientConfigAccess { boolean referencesEnabled(); boolean splashesEnabled(); boolean useShaders(); + boolean opaqueParticles(); } private static ConfigAccess config = null; From 8ffdf8cd775e1d7adf854a33cd1479e26b7c32bf Mon Sep 17 00:00:00 2001 From: blagdorfinguy Date: Sat, 30 Dec 2023 12:05:57 -0600 Subject: [PATCH 4/4] Comment deleted, correct value read for fabric config --- .../main/java/vazkii/botania/fabric/FiberBotaniaConfig.java | 2 +- Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Fabric/src/main/java/vazkii/botania/fabric/FiberBotaniaConfig.java b/Fabric/src/main/java/vazkii/botania/fabric/FiberBotaniaConfig.java index 21fe808056..1836feec21 100644 --- a/Fabric/src/main/java/vazkii/botania/fabric/FiberBotaniaConfig.java +++ b/Fabric/src/main/java/vazkii/botania/fabric/FiberBotaniaConfig.java @@ -260,7 +260,7 @@ public boolean useShaders() { @Override public boolean opaqueParticles() { - return this.useShaders.getValue(); + return this.opaqueParticles.getValue(); } } diff --git a/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java b/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java index 57f4a46fbc..4fb3836b53 100644 --- a/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java +++ b/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java @@ -122,12 +122,6 @@ private static void beginRenderCommon(BufferBuilder bufferBuilder, TextureManage ClientXplatAbstractions.INSTANCE.setFilterSave(tex, true, false); bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); - //--- -// RenderSystem.disableBlend(); -// RenderSystem.depthMask(true); -// RenderSystem.setShader(GameRenderer::getParticleShader); -// RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_PARTICLES); -// $$0.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); } private static void endRenderCommon() {