Only upload unique LOD uniforms once

This commit is contained in:
James Seibel
2026-03-09 13:51:44 -05:00
parent 39dd1c8509
commit e1a932cf38
3 changed files with 11 additions and 5 deletions
@@ -66,7 +66,7 @@ public class LodBufferContainer implements AutoCloseable
public IVertexBufferWrapper[] vbos;
public IVertexBufferWrapper[] vbosTransparent;
public ILodContainerUniformBufferWrapper uniforms = WRAPPER_FACTORY.createLodContainerUniformWrapper();
public ILodContainerUniformBufferWrapper uniformContainer = WRAPPER_FACTORY.createLodContainerUniformWrapper();
private final AtomicReference<CompletableFuture<LodBufferContainer>> uploadFutureRef = new AtomicReference<>(null);
@@ -82,6 +82,8 @@ public class LodBufferContainer implements AutoCloseable
this.minCornerBlockPos = minCornerBlockPos;
this.vbos = new IVertexBufferWrapper[0];
this.vbosTransparent = new IVertexBufferWrapper[0];
this.uniformContainer.createUniformData(this);
}
@@ -311,7 +313,7 @@ public class LodBufferContainer implements AutoCloseable
}
}
this.uniforms.close();
this.uniformContainer.close();
});
}
@@ -20,9 +20,12 @@
package com.seibel.distanthorizons.core.wrapperInterfaces.render;
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodBufferContainer;
import com.seibel.distanthorizons.core.render.renderer.RenderParams;
public interface ILodContainerUniformBufferWrapper extends IUniformBufferWrapper
{
void createBufferData(RenderParams renderEventParam, LodBufferContainer bufferContainer);
void createUniformData(LodBufferContainer bufferContainer);
void tryUpload();
}
@@ -24,6 +24,7 @@ layout (std140) uniform vertSharedUniformBlock
float uMircoOffset;
float uEarthRadius;
vec3 uCameraPos;
mat4 uCombinedMatrix;
};
@@ -36,7 +37,7 @@ void main()
{
vPos = vPosition; // This is so it can be passed to the fragment shader
vertexWorldPos = vPosition.xyz + uModelOffset;
vertexWorldPos = vPosition.xyz + (uModelOffset - uCameraPos);
vertexYPos = vPosition.y + uWorldYOffset;