From 66ea9ae2bafe45b4bcd9b057d0c9066a111d4d57 Mon Sep 17 00:00:00 2001 From: ev chang Date: Thu, 4 Jul 2024 22:39:41 +0900 Subject: [PATCH] generalize binding framebuffer to every time its called when blur is working --- gradle.properties | 2 +- .../polyblur/blurs/monkey/MonkeyBlur.java | 5 ++-- .../polyblur/mixin/FramebufferMixin.java | 23 +++++++++++++++++++ .../polyblur/mixin/RenderGlobalMixin.java | 19 --------------- .../mixin/SBAEntityOutlineRendererMixin.java | 21 ----------------- .../SkyHanniEntityOutlineRendererMixin.java | 22 ------------------ src/main/resources/mixins.polyblur.json | 6 ++--- 7 files changed, 29 insertions(+), 69 deletions(-) create mode 100644 src/main/java/org/polyfrost/polyblur/mixin/FramebufferMixin.java delete mode 100644 src/main/java/org/polyfrost/polyblur/mixin/RenderGlobalMixin.java delete mode 100644 src/main/java/org/polyfrost/polyblur/mixin/SBAEntityOutlineRendererMixin.java delete mode 100644 src/main/java/org/polyfrost/polyblur/mixin/SkyHanniEntityOutlineRendererMixin.java diff --git a/gradle.properties b/gradle.properties index ec6ead1..4015aea 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ mod_name = PolyBlur mod_id = polyblur -mod_version = 1.0.1 +mod_version = 1.0.2 mod_archives_name=PolyBlur # Gradle Configuration -- DO NOT TOUCH THESE VALUES. diff --git a/src/main/java/org/polyfrost/polyblur/blurs/monkey/MonkeyBlur.java b/src/main/java/org/polyfrost/polyblur/blurs/monkey/MonkeyBlur.java index 22662fc..7d5d6f1 100644 --- a/src/main/java/org/polyfrost/polyblur/blurs/monkey/MonkeyBlur.java +++ b/src/main/java/org/polyfrost/polyblur/blurs/monkey/MonkeyBlur.java @@ -27,6 +27,7 @@ public class MonkeyBlur { private final Minecraft mc = Minecraft.getMinecraft(); public MonkeyBuffer frameBuffer = null; + public boolean drawingBuffer = false; public Shader monkeyblurShader = null; private final FloatBuffer projection = BufferUtils.createFloatBuffer(16); @@ -78,6 +79,7 @@ public void startFrame() { bindFb(); clearFb(); + drawingBuffer = true; } public void endFrame() { @@ -106,10 +108,9 @@ public void endFrame() { previousCameraPosY = cameraPosY; previousCameraPosZ = cameraPosZ; } + drawingBuffer = false; if (!isEnabled()) return; - //mc.renderGlobal.renderEntityOutlineFramebuffer(); - unbindFb(); if (monkeyblurShader == null) { diff --git a/src/main/java/org/polyfrost/polyblur/mixin/FramebufferMixin.java b/src/main/java/org/polyfrost/polyblur/mixin/FramebufferMixin.java new file mode 100644 index 0000000..d7f94eb --- /dev/null +++ b/src/main/java/org/polyfrost/polyblur/mixin/FramebufferMixin.java @@ -0,0 +1,23 @@ +package org.polyfrost.polyblur.mixin; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.shader.Framebuffer; +import org.polyfrost.polyblur.blurs.monkey.MonkeyBlur; +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.CallbackInfo; + +@Mixin(Framebuffer.class) +public class FramebufferMixin { + + @Unique private final Framebuffer polyBlur$self = (Framebuffer) (Object) this; + + @Inject(method = "bindFramebuffer", at = @At("TAIL")) + private void onBindFramebuffer(boolean p_147610_1_, CallbackInfo ci) { + if (MonkeyBlur.instance.drawingBuffer && polyBlur$self == Minecraft.getMinecraft().getFramebuffer()) { + MonkeyBlur.instance.bindFb(); + } + } +} diff --git a/src/main/java/org/polyfrost/polyblur/mixin/RenderGlobalMixin.java b/src/main/java/org/polyfrost/polyblur/mixin/RenderGlobalMixin.java deleted file mode 100644 index 92d7215..0000000 --- a/src/main/java/org/polyfrost/polyblur/mixin/RenderGlobalMixin.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.polyfrost.polyblur.mixin; - -import net.minecraft.client.renderer.RenderGlobal; -import net.minecraft.client.renderer.culling.ICamera; -import net.minecraft.entity.Entity; -import org.polyfrost.polyblur.blurs.monkey.MonkeyBlur; -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(RenderGlobal.class) -public abstract class RenderGlobalMixin { - - @Inject(method = "renderEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/shader/Framebuffer;bindFramebuffer(Z)V", ordinal = 1, shift = At.Shift.AFTER)) - private void onRenderEntitiesPre(Entity renderViewEntity, ICamera camera, float partialTicks, CallbackInfo ci) { - MonkeyBlur.instance.bindFb(); - } -} diff --git a/src/main/java/org/polyfrost/polyblur/mixin/SBAEntityOutlineRendererMixin.java b/src/main/java/org/polyfrost/polyblur/mixin/SBAEntityOutlineRendererMixin.java deleted file mode 100644 index ad10fe9..0000000 --- a/src/main/java/org/polyfrost/polyblur/mixin/SBAEntityOutlineRendererMixin.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.polyfrost.polyblur.mixin; - -import net.minecraft.client.renderer.culling.ICamera; -import org.polyfrost.polyblur.blurs.monkey.MonkeyBlur; -import org.spongepowered.asm.mixin.Dynamic; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Pseudo -@Mixin(targets = "codes.biscuit.skyblockaddons.features.EntityOutlines.EntityOutlineRenderer") -public class SBAEntityOutlineRendererMixin { - - @Dynamic("SBA") - @Inject(method = "renderEntityOutlines", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/shader/Framebuffer;bindFramebuffer(Z)V", ordinal = 3, shift = At.Shift.AFTER, remap = true), remap = false) - private static void onRenderEntityOutlinesPre(ICamera camera, float partialTicks, double x, double y, double z, CallbackInfoReturnable ci) { - MonkeyBlur.instance.bindFb(); - } -} diff --git a/src/main/java/org/polyfrost/polyblur/mixin/SkyHanniEntityOutlineRendererMixin.java b/src/main/java/org/polyfrost/polyblur/mixin/SkyHanniEntityOutlineRendererMixin.java deleted file mode 100644 index b107bf0..0000000 --- a/src/main/java/org/polyfrost/polyblur/mixin/SkyHanniEntityOutlineRendererMixin.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.polyfrost.polyblur.mixin; - -import net.minecraft.client.renderer.culling.ICamera; -import org.polyfrost.polyblur.blurs.monkey.MonkeyBlur; -import org.spongepowered.asm.mixin.Dynamic; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Coerce; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Pseudo -@Mixin(targets = "at.hannibal2.skyhanni.utils.EntityOutlineRenderer") -public class SkyHanniEntityOutlineRendererMixin { - - @Dynamic("SkyHanni") - @Inject(method = "renderEntityOutlines", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/shader/Framebuffer;bindFramebuffer(Z)V", ordinal = 3, shift = At.Shift.AFTER, remap = true), remap = false) - private static void onRenderEntityOutlinesPre(ICamera camera, float partialTicks, @Coerce Object a, CallbackInfoReturnable ci) { - MonkeyBlur.instance.bindFb(); - } -} diff --git a/src/main/resources/mixins.polyblur.json b/src/main/resources/mixins.polyblur.json index 1cb1dc8..b5e6892 100644 --- a/src/main/resources/mixins.polyblur.json +++ b/src/main/resources/mixins.polyblur.json @@ -12,11 +12,9 @@ "BlurModMixin", "EntityRendererMixin", "EntityRendererMixin_PhosphorBlur", + "FramebufferMixin", "MinecraftMixin", "OptifineConfigMixin", - "RenderGlobalMixin", - "SBAEntityOutlineRendererMixin", - "ShaderGroupAccessor", - "SkyHanniEntityOutlineRendererMixin" + "ShaderGroupAccessor" ] } \ No newline at end of file