framebuffer name consistency fix
This commit is contained in:
+2
-3
@@ -30,7 +30,6 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftGLW
|
||||
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.apache.logging.log4j.LogManager;
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
|
||||
@@ -135,8 +134,8 @@ public class FadeRenderer
|
||||
this.init();
|
||||
|
||||
// resize the framebuffer if necessary
|
||||
int width = MC_RENDER.getTargetFrameBufferViewportWidth();
|
||||
int height = MC_RENDER.getTargetFrameBufferViewportHeight();
|
||||
int width = MC_RENDER.getTargetFramebufferViewportWidth();
|
||||
int height = MC_RENDER.getTargetFramebufferViewportHeight();
|
||||
if (this.width != width || this.height != height)
|
||||
{
|
||||
this.width = width;
|
||||
|
||||
@@ -108,8 +108,8 @@ public class FogRenderer
|
||||
this.init();
|
||||
|
||||
// resize the framebuffer if necessary
|
||||
int width = MC_RENDER.getTargetFrameBufferViewportWidth();
|
||||
int height = MC_RENDER.getTargetFrameBufferViewportHeight();
|
||||
int width = MC_RENDER.getTargetFramebufferViewportWidth();
|
||||
int height = MC_RENDER.getTargetFramebufferViewportHeight();
|
||||
if (this.width != width || this.height != height)
|
||||
{
|
||||
this.width = width;
|
||||
|
||||
+24
-25
@@ -86,7 +86,7 @@ public class LodRenderer
|
||||
public QuadElementBuffer quadIBO = null;
|
||||
private boolean renderObjectsCreated = false;
|
||||
|
||||
// frameBuffer and texture ID's for this renderer
|
||||
// framebuffer and texture ID's for this renderer
|
||||
private IDhApiFramebuffer framebuffer;
|
||||
/** will be null if MC's framebuffer is being used since MC already has a color texture */
|
||||
@Nullable
|
||||
@@ -96,7 +96,7 @@ public class LodRenderer
|
||||
* If true the {@link LodRenderer#framebuffer} is the same as MC's.
|
||||
* This should only be true in the case of Optifine so LODs won't be overwritten when shaders are enabled.
|
||||
*/
|
||||
private boolean usingMcFrameBuffer = false;
|
||||
private boolean usingMcFramebuffer = false;
|
||||
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ public class LodRenderer
|
||||
// optifine clean up //
|
||||
//===================//
|
||||
|
||||
if (this.usingMcFrameBuffer)
|
||||
if (this.usingMcFramebuffer)
|
||||
{
|
||||
// If MC's framebuffer is being used the depth needs to be cleared to prevent rendering on top of MC.
|
||||
// This should only happen when Optifine shaders are being used.
|
||||
@@ -283,7 +283,7 @@ public class LodRenderer
|
||||
|
||||
|
||||
//=============================//
|
||||
// Apply to the MC FrameBuffer //
|
||||
// Apply to the MC Framebuffer //
|
||||
//=============================//
|
||||
|
||||
boolean cancelApplyShader = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeApplyShaderRenderEvent.class, renderParams);
|
||||
@@ -352,14 +352,14 @@ public class LodRenderer
|
||||
//===================//
|
||||
|
||||
// get the active framebuffer
|
||||
IDhApiFramebuffer frameBuffer = this.framebuffer;
|
||||
IDhApiFramebuffer framebuffer = this.framebuffer;
|
||||
IDhApiFramebuffer framebufferOverride = OverrideInjector.INSTANCE.get(IDhApiFramebuffer.class);
|
||||
if (framebufferOverride != null && framebufferOverride.overrideThisFrame())
|
||||
{
|
||||
frameBuffer = framebufferOverride;
|
||||
framebuffer = framebufferOverride;
|
||||
}
|
||||
this.activeFramebufferId = frameBuffer.getId();
|
||||
frameBuffer.bind();
|
||||
this.activeFramebufferId = framebuffer.getId();
|
||||
framebuffer.bind();
|
||||
|
||||
|
||||
|
||||
@@ -409,8 +409,8 @@ public class LodRenderer
|
||||
//===============//
|
||||
|
||||
// resize the textures if needed
|
||||
if (MC_RENDER.getTargetFrameBufferViewportWidth() != this.textureWidth
|
||||
|| MC_RENDER.getTargetFrameBufferViewportHeight() != this.textureHeight)
|
||||
if (MC_RENDER.getTargetFramebufferViewportWidth() != this.textureWidth
|
||||
|| MC_RENDER.getTargetFramebufferViewportHeight() != this.textureHeight)
|
||||
{
|
||||
// just resizing the textures doesn't work when Optifine is present,
|
||||
// so recreate the textures with the new size instead
|
||||
@@ -427,9 +427,8 @@ public class LodRenderer
|
||||
}
|
||||
else
|
||||
{
|
||||
// get MC's color texture
|
||||
int mcColorTextureId = GL32.glGetFramebufferAttachmentParameteri(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
|
||||
this.activeColorTextureId = mcColorTextureId;
|
||||
// get MC's color texture
|
||||
this.activeColorTextureId = GL32.glGetFramebufferAttachmentParameteri(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
|
||||
}
|
||||
|
||||
|
||||
@@ -443,11 +442,11 @@ public class LodRenderer
|
||||
GL32.glGetFloatv(GL32.GL_COLOR_CLEAR_VALUE, clearColorValues);
|
||||
GL32.glClearColor(clearColorValues[0], clearColorValues[1], clearColorValues[2], 1.0f);
|
||||
|
||||
if (this.usingMcFrameBuffer && framebufferOverride == null)
|
||||
if (this.usingMcFramebuffer && framebufferOverride == null)
|
||||
{
|
||||
// Due to using MC/Optifine's framebuffer we need to re-bind the depth texture,
|
||||
// otherwise we'll be writing to MC/Optifine's depth texture which causes rendering issues
|
||||
frameBuffer.addDepthAttachment(this.depthTexture.getTextureId(), EDhDepthBufferFormat.DEPTH32F.isCombinedStencil());
|
||||
framebuffer.addDepthAttachment(this.depthTexture.getTextureId(), EDhDepthBufferFormat.DEPTH32F.isCombinedStencil());
|
||||
|
||||
|
||||
// don't clear the color texture, that removes the sky
|
||||
@@ -489,16 +488,16 @@ public class LodRenderer
|
||||
// create or get the frame buffer
|
||||
if (AbstractOptifineAccessor.optifinePresent())
|
||||
{
|
||||
// use MC/Optifine's default FrameBuffer so shaders won't remove the LODs
|
||||
int currentFrameBufferId = MC_RENDER.getTargetFrameBuffer();
|
||||
this.framebuffer = new DhFramebuffer(currentFrameBufferId);
|
||||
this.usingMcFrameBuffer = true;
|
||||
// use MC/Optifine's default Framebuffer so shaders won't remove the LODs
|
||||
int currentFramebufferId = MC_RENDER.getTargetFramebuffer();
|
||||
this.framebuffer = new DhFramebuffer(currentFramebufferId);
|
||||
this.usingMcFramebuffer = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal use case
|
||||
this.framebuffer = new DhFramebuffer();
|
||||
this.usingMcFrameBuffer = false;
|
||||
this.usingMcFramebuffer = false;
|
||||
}
|
||||
|
||||
// create and bind the necessary textures
|
||||
@@ -507,7 +506,7 @@ public class LodRenderer
|
||||
if(this.framebuffer.getStatus() != GL32.GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
// This generally means something wasn't bound, IE missing either the color or depth texture
|
||||
LOGGER.warn("FrameBuffer ["+this.framebuffer.getId()+"] isn't complete.");
|
||||
LOGGER.warn("Framebuffer ["+this.framebuffer.getId()+"] isn't complete.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -517,12 +516,13 @@ public class LodRenderer
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings( "deprecation" )
|
||||
private void createAndBindTextures()
|
||||
{
|
||||
int oldWidth = this.textureWidth;
|
||||
int oldHeight = this.textureHeight;
|
||||
this.textureWidth = MC_RENDER.getTargetFrameBufferViewportWidth();
|
||||
this.textureHeight = MC_RENDER.getTargetFrameBufferViewportHeight();
|
||||
this.textureWidth = MC_RENDER.getTargetFramebufferViewportWidth();
|
||||
this.textureHeight = MC_RENDER.getTargetFramebufferViewportHeight();
|
||||
|
||||
DhApiTextureCreatedParam textureCreatedParam = new DhApiTextureCreatedParam(
|
||||
oldWidth, oldHeight,
|
||||
@@ -547,7 +547,7 @@ public class LodRenderer
|
||||
}
|
||||
|
||||
// if we are using MC's frame buffer, a color texture is already present and shouldn't need to be bound
|
||||
if (!this.usingMcFrameBuffer)
|
||||
if (!this.usingMcFramebuffer)
|
||||
{
|
||||
this.nullableColorTexture = DhColorTexture.builder().setDimensions(this.textureWidth, this.textureHeight)
|
||||
.setInternalFormat(EDhInternalTextureFormat.RGBA8)
|
||||
@@ -582,7 +582,6 @@ public class LodRenderer
|
||||
// debug wireframe setup //
|
||||
//=======================//
|
||||
|
||||
// TODO move this logic into LodRenderer so all the GL states can be handled there
|
||||
boolean renderWireframe = Config.Client.Advanced.Debugging.renderWireframe.get();
|
||||
if (renderWireframe)
|
||||
{
|
||||
|
||||
+1
-1
@@ -142,7 +142,7 @@ public class RenderParams extends DhApiRenderParam
|
||||
}
|
||||
|
||||
if (AbstractOptifineAccessor.optifinePresent()
|
||||
&& MC_RENDER.getTargetFrameBuffer() == -1)
|
||||
&& MC_RENDER.getTargetFramebuffer() == -1)
|
||||
{
|
||||
// wait for MC to finish setting up their renderer
|
||||
return "Optifine Target Frame Buffer not set";
|
||||
|
||||
+2
-2
@@ -107,8 +107,8 @@ public class SSAORenderer
|
||||
this.init();
|
||||
|
||||
// resize the framebuffer if necessary
|
||||
int width = MC_RENDER.getTargetFrameBufferViewportWidth();
|
||||
int height = MC_RENDER.getTargetFrameBufferViewportHeight();
|
||||
int width = MC_RENDER.getTargetFramebufferViewportWidth();
|
||||
int height = MC_RENDER.getTargetFramebufferViewportHeight();
|
||||
if (this.width != width || this.height != height)
|
||||
{
|
||||
this.width = width;
|
||||
|
||||
+2
-2
@@ -104,8 +104,8 @@ public class TestRenderer
|
||||
// TODO fix for MC 1.21.5+
|
||||
this.init();
|
||||
|
||||
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, MC_RENDER.getTargetFrameBuffer());
|
||||
GL32.glViewport(0, 0, MC_RENDER.getTargetFrameBufferViewportWidth(), MC_RENDER.getTargetFrameBufferViewportHeight());
|
||||
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, MC_RENDER.getTargetFramebuffer());
|
||||
GL32.glViewport(0, 0, MC_RENDER.getTargetFramebufferViewportWidth(), MC_RENDER.getTargetFramebufferViewportHeight());
|
||||
GL32.glPolygonMode(GL32.GL_FRONT_AND_BACK, GL32.GL_FILL);
|
||||
|
||||
GLMC.disableFaceCulling();
|
||||
|
||||
+2
-2
@@ -52,8 +52,8 @@ public abstract class AbstractShaderRenderer
|
||||
|
||||
this.onApplyUniforms(partialTicks);
|
||||
|
||||
int width = MC_RENDER.getTargetFrameBufferViewportWidth();
|
||||
int height = MC_RENDER.getTargetFrameBufferViewportHeight();
|
||||
int width = MC_RENDER.getTargetFramebufferViewportWidth();
|
||||
int height = MC_RENDER.getTargetFramebufferViewportHeight();
|
||||
GL32.glViewport(0, 0, width, height);
|
||||
|
||||
this.onRender();
|
||||
|
||||
+2
-5
@@ -26,12 +26,9 @@ import com.seibel.distanthorizons.core.render.glObject.shader.ShaderProgram;
|
||||
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 org.apache.logging.log4j.LogManager;
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* Copies {@link LodRenderer}'s currently active color and depth texture to Minecraft's framebuffer.
|
||||
*/
|
||||
@@ -89,7 +86,7 @@ public class DhApplyShader extends AbstractShaderRenderer
|
||||
// TODO merge duplicate code between these to render methods
|
||||
private void renderToFrameBuffer()
|
||||
{
|
||||
int targetFrameBuffer = MC_RENDER.getTargetFrameBuffer();
|
||||
int targetFrameBuffer = MC_RENDER.getTargetFramebuffer();
|
||||
if (targetFrameBuffer == -1)
|
||||
{
|
||||
return;
|
||||
@@ -143,7 +140,7 @@ public class DhApplyShader extends AbstractShaderRenderer
|
||||
return;
|
||||
}
|
||||
|
||||
int mcFrameBufferId = MC_RENDER.getTargetFrameBuffer();
|
||||
int mcFrameBufferId = MC_RENDER.getTargetFramebuffer();
|
||||
if (mcFrameBufferId == -1)
|
||||
{
|
||||
return;
|
||||
|
||||
+1
-2
@@ -20,7 +20,6 @@
|
||||
package com.seibel.distanthorizons.core.render.renderer.shaders;
|
||||
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.render.glObject.GLState;
|
||||
import com.seibel.distanthorizons.core.render.glObject.shader.ShaderProgram;
|
||||
import com.seibel.distanthorizons.core.render.renderer.FadeRenderer;
|
||||
import com.seibel.distanthorizons.core.render.renderer.LodRenderer;
|
||||
@@ -121,7 +120,7 @@ public class FadeApplyShader extends AbstractShaderRenderer
|
||||
|
||||
// apply the rendered Fade to Minecraft's framebuffer
|
||||
GLMC.glBindFramebuffer(GL32.GL_READ_FRAMEBUFFER, FadeShader.INSTANCE.frameBuffer);
|
||||
GLMC.glBindFramebuffer(GL32.GL_DRAW_FRAMEBUFFER, MC_RENDER.getTargetFrameBuffer());
|
||||
GLMC.glBindFramebuffer(GL32.GL_DRAW_FRAMEBUFFER, MC_RENDER.getTargetFramebuffer());
|
||||
|
||||
ScreenQuad.INSTANCE.render();
|
||||
|
||||
|
||||
+2
-2
@@ -99,8 +99,8 @@ public class SSAOApplyShader extends AbstractShaderRenderer
|
||||
if (this.gViewSizeUniform >= 0)
|
||||
{
|
||||
GL32.glUniform2f(this.gViewSizeUniform,
|
||||
MC_RENDER.getTargetFrameBufferViewportWidth(),
|
||||
MC_RENDER.getTargetFrameBufferViewportHeight());
|
||||
MC_RENDER.getTargetFramebufferViewportWidth(),
|
||||
MC_RENDER.getTargetFramebufferViewportHeight());
|
||||
}
|
||||
|
||||
if (this.gNearUniform >= 0)
|
||||
|
||||
@@ -19,18 +19,13 @@
|
||||
|
||||
package com.seibel.distanthorizons.core.util;
|
||||
|
||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.level.IDhClientLevel;
|
||||
import com.seibel.distanthorizons.core.world.IDhClientWorld;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.util.MathUtil;
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
|
||||
/**
|
||||
* This holds miscellaneous helper code
|
||||
@@ -177,7 +172,7 @@ public class RenderUtil
|
||||
// therefore, the FOV is left at a fixed value of 70 (MC's default)
|
||||
double fov = 70;
|
||||
|
||||
double aspectRatio = (double) MC_RENDER.getTargetFrameBufferViewportWidth() / MC_RENDER.getTargetFrameBufferViewportHeight();
|
||||
double aspectRatio = (double) MC_RENDER.getTargetFramebufferViewportWidth() / MC_RENDER.getTargetFramebufferViewportHeight();
|
||||
|
||||
// source: https://stackoverflow.com/questions/8101119/how-do-i-methodically-choose-the-near-clip-plane-distance-for-a-perspective-proj/8101234#8101234
|
||||
return (float) (nearClipPlane
|
||||
|
||||
+3
-3
@@ -65,12 +65,12 @@ public interface IMinecraftRenderWrapper extends IBindable
|
||||
boolean runningLegacyOpenGL();
|
||||
|
||||
/** @return -1 if no valid framebuffer is available yet */
|
||||
int getTargetFrameBuffer(); // Note: Iris is now hooking onto this for DH + Iris compat, try not to change (unless we wanna deal with some annoyances)
|
||||
int getTargetFramebuffer(); // Note: Iris is now hooking onto this for DH + Iris compat, try not to change (unless we wanna deal with some annoyances)
|
||||
// Iris commit: https://github.com/IrisShaders/Iris/commit/a76a240527e93780bbcba57c09bef377419d47a7#diff-7b9ded0c79bbcdb130010373387756a28ee8d3640d522c0a5b7acd0abbfc20aeR16
|
||||
int getDepthTextureId();
|
||||
int getColorTextureId();
|
||||
int getTargetFrameBufferViewportWidth();
|
||||
int getTargetFrameBufferViewportHeight();
|
||||
int getTargetFramebufferViewportWidth();
|
||||
int getTargetFramebufferViewportHeight();
|
||||
|
||||
/**
|
||||
* generally shouldn't be needed, the frame buffer should generally stay the same
|
||||
|
||||
Reference in New Issue
Block a user