Fix rare fade error when restarting the LodRenderer

This commit is contained in:
James Seibel
2025-06-28 10:45:36 -05:00
parent 7d87347199
commit d2becd2c03
2 changed files with 18 additions and 3 deletions
@@ -804,6 +804,9 @@ public class LodRenderer
if (this.depthTexture != null)
this.depthTexture.destroy();
this.setActiveDepthTextureId(-1);
this.setActiveColorTextureId(-1);
EVENT_LOGGER.info("Renderer Cleanup Complete");
});
}
@@ -155,6 +155,19 @@ public class FadeShader extends AbstractShaderRenderer
@Override
protected void onRender()
{
int depthTextureId = LodRenderer.getActiveDepthTextureId();
int colorTextureId = LodRenderer.getActiveColorTextureId();
if (depthTextureId == -1
|| colorTextureId == -1)
{
// the renderer is currently being re-built and/or inactive,
// we don't need to/can't render fading
return;
}
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, this.frameBuffer);
GLMC.disableScissorTest();
GLMC.disableDepthTest();
@@ -165,8 +178,7 @@ public class FadeShader extends AbstractShaderRenderer
GL32.glUniform1i(this.uMcDepthTexture, 0);
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
// FIXME it's possible for this to return an invalid texture ID if the renderer is being re-built at the same time
GLMC.glBindTexture(LodRenderer.getActiveDepthTextureId());
GLMC.glBindTexture(depthTextureId);
GL32.glUniform1i(this.uDhDepthTexture, 1);
GLMC.glActiveTexture(GL32.GL_TEXTURE2);
@@ -174,7 +186,7 @@ public class FadeShader extends AbstractShaderRenderer
GL32.glUniform1i(this.uCombinedMcDhColorTexture, 2);
GLMC.glActiveTexture(GL32.GL_TEXTURE3);
GLMC.glBindTexture(LodRenderer.getActiveColorTextureId());
GLMC.glBindTexture(colorTextureId);
GL32.glUniform1i(this.uDhColorTexture, 3);