Skip to content

Commit

Permalink
Only check if fog is enabled once per frame
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
makamys committed Nov 24, 2023
1 parent 76261b9 commit ad3e310
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/makamys/neodymium/renderer/NeoRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class NeoRenderer {
public boolean forceRenderFog;
public boolean hasIncompatibilities;

private boolean fogEnabled;

private static int MAX_MESHES;

private int VAO;
Expand Down Expand Up @@ -334,6 +336,8 @@ private void updateGLValues() {
fogStartEnd.put(glGetFloat(GL_FOG_END));

fogStartEnd.flip();

fogEnabled = GL11.glIsEnabled(GL11.GL_FOG) && !OFUtil.isFogOff();
}

private void updateUniforms(double alpha, int pass) {
Expand Down Expand Up @@ -623,14 +627,14 @@ private int getShaderProgram(int pass) {
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;
}
}

Expand Down

0 comments on commit ad3e310

Please sign in to comment.