From ad3e310f2aa1a75b066d0959e943ea5e1c60a49e Mon Sep 17 00:00:00 2001 From: makamys Date: Fri, 24 Nov 2023 05:02:20 +0100 Subject: Only check if fog is enabled once per frame GL calls were being made every time `shouldRenderMesh` was called, oops. This could cause worse performance with Nd than without it if `renderFog` is set to `auto` (added in 0.1.5) --- src/main/java/makamys/neodymium/renderer/NeoRenderer.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java index 7dd94bf..b3564ff 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -61,6 +61,8 @@ public class NeoRenderer { public boolean forceRenderFog; public boolean hasIncompatibilities; + private boolean fogEnabled; + private static int MAX_MESHES; private int VAO; @@ -334,6 +336,8 @@ public class NeoRenderer { fogStartEnd.put(glGetFloat(GL_FOG_END)); fogStartEnd.flip(); + + fogEnabled = GL11.glIsEnabled(GL11.GL_FOG) && !OFUtil.isFogOff(); } private void updateUniforms(double alpha, int pass) { @@ -623,14 +627,14 @@ public class NeoRenderer { return ((forceRenderFog || isFogEnabled()) ? shaderProgramsFog : shaderProgramsNoFog)[pass]; } - private static boolean isFogEnabled() { + private boolean isFogEnabled() { switch(Config.renderFog) { case TRUE: return true; case FALSE: return false; default: - return GL11.glIsEnabled(GL11.GL_FOG) && !OFUtil.isFogOff(); + return fogEnabled; } } -- cgit