diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/DhFadeRenderer.java b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/DhFadeRenderer.java
index ff3728f99..a06cd386b 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/DhFadeRenderer.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/DhFadeRenderer.java
@@ -23,23 +23,22 @@ import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.render.glObject.GLState;
-import com.seibel.distanthorizons.core.render.renderer.shaders.DhFadeApplyShader;
import com.seibel.distanthorizons.core.render.renderer.shaders.DhFadeShader;
+import com.seibel.distanthorizons.core.render.renderer.shaders.FadeApplyShader;
import com.seibel.distanthorizons.core.util.math.Mat4f;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftGLWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IProfilerWrapper;
-import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import org.lwjgl.opengl.GL32;
import java.nio.ByteBuffer;
/**
- * Handles fading MC and DH together via {@link DhFadeShader} and {@link DhFadeApplyShader}.
+ * Handles fading MC and DH together via {@link DhFadeShader} and {@link FadeApplyShader}.
*
* {@link DhFadeShader} - draws the Fade to a texture.
- * {@link DhFadeApplyShader} - draws the Fade texture to MC's FrameBuffer.
+ * {@link FadeApplyShader} - draws the Fade texture to DH's framebuffer.
*/
public class DhFadeRenderer
{
@@ -74,7 +73,7 @@ public class DhFadeRenderer
this.init = true;
DhFadeShader.INSTANCE.init();
- DhFadeApplyShader.INSTANCE.init();
+ FadeApplyShader.INSTANCE.init();
}
private void createFramebuffer(int width, int height)
@@ -139,8 +138,10 @@ public class DhFadeRenderer
profiler.popPush("Fade Apply");
- DhFadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
- DhFadeApplyShader.INSTANCE.render(partialTicks);
+ FadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
+ FadeApplyShader.INSTANCE.readFramebuffer = DhFadeShader.INSTANCE.frameBuffer;
+ FadeApplyShader.INSTANCE.drawFramebuffer = LodRenderer.INSTANCE.getActiveFramebufferId();
+ FadeApplyShader.INSTANCE.render(partialTicks);
}
catch (Exception e)
{
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/VanillaFadeRenderer.java b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/VanillaFadeRenderer.java
index 83f8ded32..8bc72c6f2 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/VanillaFadeRenderer.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/VanillaFadeRenderer.java
@@ -22,7 +22,8 @@ package com.seibel.distanthorizons.core.render.renderer;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.render.glObject.GLState;
-import com.seibel.distanthorizons.core.render.renderer.shaders.VanillaFadeApplyShader;
+import com.seibel.distanthorizons.core.render.renderer.shaders.DhFadeShader;
+import com.seibel.distanthorizons.core.render.renderer.shaders.FadeApplyShader;
import com.seibel.distanthorizons.core.render.renderer.shaders.VanillaFadeShader;
import com.seibel.distanthorizons.core.util.math.Mat4f;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
@@ -36,10 +37,10 @@ import org.lwjgl.opengl.GL32;
import java.nio.ByteBuffer;
/**
- * Handles fading MC and DH together via {@link VanillaFadeShader} and {@link VanillaFadeApplyShader}.
+ * Handles fading MC and DH together via {@link VanillaFadeShader} and {@link FadeApplyShader}.
*
* {@link VanillaFadeShader} - draws the Fade to a texture.
- * {@link VanillaFadeApplyShader} - draws the Fade texture to MC's FrameBuffer.
+ * {@link FadeApplyShader} - draws the Fade texture to MC's FrameBuffer.
*/
public class VanillaFadeRenderer
{
@@ -74,7 +75,7 @@ public class VanillaFadeRenderer
this.init = true;
VanillaFadeShader.INSTANCE.init();
- VanillaFadeApplyShader.INSTANCE.init();
+ FadeApplyShader.INSTANCE.init();
}
private void createFramebuffer(int width, int height)
@@ -149,14 +150,16 @@ public class VanillaFadeRenderer
VanillaFadeShader.INSTANCE.setLevelMaxHeight(level.getMaxHeight());
VanillaFadeShader.INSTANCE.render(partialTicks);
- profiler.popPush("Vanilla Fade Apply");
-
// Applying the fade texture is only needed if MC is drawing to their own frame buffer,
// otherwise we can directly render to their texture
if (MC_RENDER.mcRendersToFrameBuffer())
{
- VanillaFadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
- VanillaFadeApplyShader.INSTANCE.render(partialTicks);
+ profiler.popPush("Vanilla Fade Apply");
+
+ FadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
+ FadeApplyShader.INSTANCE.readFramebuffer = DhFadeShader.INSTANCE.frameBuffer;
+ FadeApplyShader.INSTANCE.drawFramebuffer = LodRenderer.INSTANCE.getActiveFramebufferId();
+ FadeApplyShader.INSTANCE.render(partialTicks);
}
profiler.pop();
@@ -176,7 +179,7 @@ public class VanillaFadeRenderer
public void free()
{
VanillaFadeShader.INSTANCE.free();
- VanillaFadeApplyShader.INSTANCE.free();
+ FadeApplyShader.INSTANCE.free();
}
}
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/DhFadeShader.java b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/DhFadeShader.java
index 9d84f8037..065b95821 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/DhFadeShader.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/DhFadeShader.java
@@ -100,8 +100,6 @@ public class DhFadeShader extends AbstractShaderRenderer
float dhFarClipDistance = RenderUtil.getFarClipPlaneDistanceInBlocks();
-
- // measured in blocks
float fadeStartDistance = dhFarClipDistance * 0.5f;
float fadeEndDistance = dhFarClipDistance * 0.9f;
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/DhFadeApplyShader.java b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/FadeApplyShader.java
similarity index 83%
rename from core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/DhFadeApplyShader.java
rename to core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/FadeApplyShader.java
index c77cb196c..b2f3bfd56 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/DhFadeApplyShader.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/FadeApplyShader.java
@@ -21,8 +21,7 @@ package com.seibel.distanthorizons.core.render.renderer.shaders;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.render.glObject.shader.ShaderProgram;
-import com.seibel.distanthorizons.core.render.renderer.DhFadeRenderer;
-import com.seibel.distanthorizons.core.render.renderer.LodRenderer;
+import com.seibel.distanthorizons.core.render.renderer.VanillaFadeRenderer;
import com.seibel.distanthorizons.core.render.renderer.ScreenQuad;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftGLWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
@@ -32,12 +31,12 @@ import org.lwjgl.opengl.GL32;
* Draws the Fade texture onto Minecraft's FrameBuffer.
*
* See Also:
- * {@link DhFadeRenderer} - Parent to this shader.
- * {@link DhFadeShader} - draws the Fade texture.
+ * {@link VanillaFadeRenderer} - Parent to this shader.
+ * {@link VanillaFadeShader} - draws the Fade texture.
*/
-public class DhFadeApplyShader extends AbstractShaderRenderer
+public class FadeApplyShader extends AbstractShaderRenderer
{
- public static DhFadeApplyShader INSTANCE = new DhFadeApplyShader();
+ public static FadeApplyShader INSTANCE = new FadeApplyShader();
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
private static final IMinecraftGLWrapper GLMC = SingletonInjector.INSTANCE.get(IMinecraftGLWrapper.class);
@@ -46,6 +45,9 @@ public class DhFadeApplyShader extends AbstractShaderRenderer
public int fadeTexture;
+ public int readFramebuffer;
+ public int drawFramebuffer;
+
// uniforms
public int uFadeColorTextureUniform = -1;
@@ -102,8 +104,8 @@ public class DhFadeApplyShader extends AbstractShaderRenderer
// apply the rendered Fade to Minecraft's framebuffer
- GLMC.glBindFramebuffer(GL32.GL_READ_FRAMEBUFFER, DhFadeShader.INSTANCE.frameBuffer);
- GLMC.glBindFramebuffer(GL32.GL_DRAW_FRAMEBUFFER, LodRenderer.INSTANCE.getActiveFramebufferId());
+ GLMC.glBindFramebuffer(GL32.GL_READ_FRAMEBUFFER, this.readFramebuffer);
+ GLMC.glBindFramebuffer(GL32.GL_DRAW_FRAMEBUFFER, this.drawFramebuffer);
ScreenQuad.INSTANCE.render();
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/VanillaFadeApplyShader.java b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/VanillaFadeApplyShader.java
deleted file mode 100644
index 6e1e9d7b7..000000000
--- a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/VanillaFadeApplyShader.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * This file is part of the Distant Horizons mod
- * licensed under the GNU LGPL v3 License.
- *
- * Copyright (C) 2020 James Seibel
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package com.seibel.distanthorizons.core.render.renderer.shaders;
-
-import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
-import com.seibel.distanthorizons.core.render.glObject.shader.ShaderProgram;
-import com.seibel.distanthorizons.core.render.renderer.VanillaFadeRenderer;
-import com.seibel.distanthorizons.core.render.renderer.LodRenderer;
-import com.seibel.distanthorizons.core.render.renderer.ScreenQuad;
-import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftGLWrapper;
-import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
-import org.lwjgl.opengl.GL32;
-
-/**
- * Draws the Fade texture onto Minecraft's FrameBuffer.
- *
- * See Also:
- * {@link VanillaFadeRenderer} - Parent to this shader.
- * {@link VanillaFadeShader} - draws the Fade texture.
- */
-public class VanillaFadeApplyShader extends AbstractShaderRenderer
-{
- public static VanillaFadeApplyShader INSTANCE = new VanillaFadeApplyShader();
-
- private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
- private static final IMinecraftGLWrapper GLMC = SingletonInjector.INSTANCE.get(IMinecraftGLWrapper.class);
-
-
-
- public int fadeTexture;
-
- // uniforms
- public int uFadeColorTextureUniform = -1;
-
-
-
- //=============//
- // constructor //
- //=============//
-
- @Override
- public void onInit()
- {
- this.shader = new ShaderProgram(
- "shaders/normal.vert",
- "shaders/fade/apply.frag",
- "fragColor",
- new String[]{ "vPosition" });
-
- // uniform setup
- this.uFadeColorTextureUniform = this.shader.getUniformLocation("uFadeColorTextureUniform");
-
- }
-
-
-
- //=============//
- // render prep //
- //=============//
-
- @Override
- protected void onApplyUniforms(float partialTicks)
- {
- GLMC.glActiveTexture(GL32.GL_TEXTURE0);
- GLMC.glBindTexture(this.fadeTexture);
- GL32.glUniform1i(this.uFadeColorTextureUniform, 0);
-
- }
-
-
-
- //========//
- // render //
- //========//
-
- @Override
- protected void onRender()
- {
- if (!MC_RENDER.mcRendersToFrameBuffer())
- {
- throw new IllegalStateException("If Minecraft is directly rendering to a texture the apply shader isn't needed, just draw the fade directly to the MC color texture.");
- }
-
-
- GLMC.disableBlend();
-
- // Depth testing must be disabled otherwise this application shader won't apply anything.
- // setting this isn't necessary in vanilla, but some mods may change this, requiring it to be set manually,
- // it should be automatically restored after rendering is complete.
- GLMC.disableDepthTest();
-
-
- // apply the rendered Fade to Minecraft's framebuffer
- GLMC.glBindFramebuffer(GL32.GL_READ_FRAMEBUFFER, VanillaFadeShader.INSTANCE.frameBuffer);
- GLMC.glBindFramebuffer(GL32.GL_DRAW_FRAMEBUFFER, MC_RENDER.getTargetFramebuffer());
-
- ScreenQuad.INSTANCE.render();
-
- GLMC.enableDepthTest();
-
- }
-
-
-
-}