diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/bufferBuilding/LodBufferContainer.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/bufferBuilding/LodBufferContainer.java index 4b2d9f91b..7d320dcf7 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/bufferBuilding/LodBufferContainer.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/bufferBuilding/LodBufferContainer.java @@ -43,7 +43,7 @@ public class LodBufferContainer implements AutoCloseable private static final DhLogger LOGGER = new DhLoggerBuilder().build(); /** number of bytes a single quad takes */ - public static final int QUADS_BYTE_SIZE = LodUtil.LOD_VERTEX_FORMAT.getByteSize() * 4; + public static final int QUADS_BYTE_SIZE = LodUtil.DH_VERTEX_FORMAT.getByteSize() * 4; /** how big a single VBO can be in bytes */ public static final int MAX_VBO_BYTE_SIZE = 10 * 1024 * 1024; // 10 MB public static final int MAX_QUADS_PER_BUFFER = MAX_VBO_BYTE_SIZE / QUADS_BYTE_SIZE; @@ -207,7 +207,7 @@ public class LodBufferContainer implements AutoCloseable try { vbo.bind(); - vbo.uploadBuffer(buffer, size / LodUtil.LOD_VERTEX_FORMAT.getByteSize(), uploadMethod, FULL_SIZED_BUFFER); + vbo.uploadBuffer(buffer, size / LodUtil.DH_VERTEX_FORMAT.getByteSize(), uploadMethod, FULL_SIZED_BUFFER); } catch (Exception e) { diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/DhTerrainShaderProgram.java b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/DhTerrainShaderProgram.java index 892f236e0..066807fc4 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/DhTerrainShaderProgram.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/DhTerrainShaderProgram.java @@ -102,8 +102,6 @@ public class DhTerrainShaderProgram extends ShaderProgram implements IDhApiShade this.uIsWhiteWorld = this.getUniformLocation("uIsWhiteWorld"); - // TODO: Add better use of the LODFormat thing - int vertexByteCount = LodUtil.LOD_VERTEX_FORMAT.getByteSize(); if (GLProxy.getInstance().vertexAttributeBufferBindingSupported) { this.vao = new VertexAttributePostGL43(); // also binds AbstractVertexAttribute @@ -124,11 +122,12 @@ public class DhTerrainShaderProgram extends ShaderProgram implements IDhApiShade try { + int vertexByteCount = LodUtil.DH_VERTEX_FORMAT.getByteSize(); this.vao.completeAndCheck(vertexByteCount); } catch (RuntimeException e) { - System.out.println(LodUtil.LOD_VERTEX_FORMAT); + System.out.println(LodUtil.DH_VERTEX_FORMAT); throw e; } @@ -175,7 +174,6 @@ public class DhTerrainShaderProgram extends ShaderProgram implements IDhApiShade this.setUniform(this.uCombinedMatrix, combinedMatrix); this.setUniform(this.uMircoOffset, 0.01f); // 0.01 block offset - // setUniform(skyLightUniform, skyLight); this.setUniform(this.uLightMap, 0); // TODO this should probably be passed in this.setUniform(this.uWorldYOffset, (float) renderParameters.worldYOffset); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/vertexFormat/DefaultLodVertexFormats.java b/core/src/main/java/com/seibel/distanthorizons/core/render/vertexFormat/VertexFormats.java similarity index 55% rename from core/src/main/java/com/seibel/distanthorizons/core/render/vertexFormat/DefaultLodVertexFormats.java rename to core/src/main/java/com/seibel/distanthorizons/core/render/vertexFormat/VertexFormats.java index 6db6a4a67..8d6850734 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/vertexFormat/DefaultLodVertexFormats.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/vertexFormat/VertexFormats.java @@ -24,17 +24,11 @@ import com.google.common.collect.ImmutableList; /** * A (almost) exact copy of MC's * DefaultVertexFormats class. - * - * @author James Seibel - * @version 12-8-2021 */ -public class DefaultLodVertexFormats +public class VertexFormats { public static final LodVertexFormatElement ELEMENT_POSITION = new LodVertexFormatElement(3, LodVertexFormatElement.DataType.USHORT, 3, false); public static final LodVertexFormatElement ELEMENT_COLOR = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.UBYTE, 4, false); - public static final LodVertexFormatElement ELEMENT_UV = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.FLOAT, 2, false); - public static final LodVertexFormatElement ELEMENT_LIGHT_MAP_UV = new LodVertexFormatElement(1, LodVertexFormatElement.DataType.SHORT, 2, false); - public static final LodVertexFormatElement ELEMENT_NORMAL = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.BYTE, 3, false); public static final LodVertexFormatElement ELEMENT_BYTE_PADDING = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.BYTE, 1, true); public static final LodVertexFormatElement ELEMENT_LIGHT = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.UBYTE, 1, false); @@ -42,20 +36,6 @@ public class DefaultLodVertexFormats public static final LodVertexFormatElement ELEMENT_IRIS_NORMAL_INDEX = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.BYTE, 1, false); - public static final LodVertexFormat POSITION = new LodVertexFormat(ImmutableList.builder().add(ELEMENT_POSITION).build()); - public static final LodVertexFormat POSITION_COLOR = new LodVertexFormat(ImmutableList.builder().add(ELEMENT_POSITION).add(ELEMENT_COLOR).build()); - public static final LodVertexFormat POSITION_COLOR_LIGHTMAP = new LodVertexFormat(ImmutableList.builder().add(ELEMENT_POSITION).add(ELEMENT_COLOR).add(ELEMENT_LIGHT_MAP_UV).build()); - public static final LodVertexFormat POSITION_TEX = new LodVertexFormat(ImmutableList.builder().add(ELEMENT_POSITION).add(ELEMENT_UV).build()); - public static final LodVertexFormat POSITION_COLOR_TEX = new LodVertexFormat(ImmutableList.builder().add(ELEMENT_POSITION).add(ELEMENT_COLOR).add(ELEMENT_UV).build()); - public static final LodVertexFormat POSITION_COLOR_TEX_LIGHTMAP = new LodVertexFormat(ImmutableList.builder().add(ELEMENT_POSITION).add(ELEMENT_COLOR).add(ELEMENT_UV).add(ELEMENT_LIGHT_MAP_UV).build()); - - public static final LodVertexFormat POSITION_COLOR_BLOCK_LIGHT_SKY_LIGHT = new LodVertexFormat(ImmutableList.builder() - .add(ELEMENT_POSITION) - .add(ELEMENT_BYTE_PADDING) - .add(ELEMENT_LIGHT) - .add(ELEMENT_COLOR) - .build()); - public static final LodVertexFormat POSITION_COLOR_BLOCK_LIGHT_SKY_LIGHT_MATERIAL_ID_NORMAL_INDEX = new LodVertexFormat(ImmutableList.builder() .add(ELEMENT_POSITION) .add(ELEMENT_BYTE_PADDING) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/LodUtil.java b/core/src/main/java/com/seibel/distanthorizons/core/util/LodUtil.java index a4047ad45..92516bc46 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/LodUtil.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/LodUtil.java @@ -19,11 +19,8 @@ package com.seibel.distanthorizons.core.util; -import java.util.Arrays; -import java.util.List; - import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; -import com.seibel.distanthorizons.core.render.vertexFormat.DefaultLodVertexFormats; +import com.seibel.distanthorizons.core.render.vertexFormat.VertexFormats; import com.seibel.distanthorizons.core.render.vertexFormat.LodVertexFormat; import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper; import com.seibel.distanthorizons.core.logging.DhLogger; @@ -112,7 +109,7 @@ public class LodUtil public static final int MAX_ALLOCATABLE_DIRECT_MEMORY = 64 * 1024 * 1024; /** the format of data stored in the GPU buffers */ - public static final LodVertexFormat LOD_VERTEX_FORMAT = DefaultLodVertexFormats.POSITION_COLOR_BLOCK_LIGHT_SKY_LIGHT_MATERIAL_ID_NORMAL_INDEX; + public static final LodVertexFormat DH_VERTEX_FORMAT = VertexFormats.POSITION_COLOR_BLOCK_LIGHT_SKY_LIGHT_MATERIAL_ID_NORMAL_INDEX;