start separating out uniform logic
This commit is contained in:
+8
@@ -28,7 +28,9 @@ import com.seibel.distanthorizons.core.render.glObject.GLProxy;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.ILodContainerUniformBufferWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.IMcLodRenderer;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.IUniformBufferWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.IVertexBufferWrapper;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
@@ -46,6 +48,8 @@ public class LodBufferContainer implements AutoCloseable
|
||||
{
|
||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||
|
||||
private static final IWrapperFactory WRAPPER_FACTORY = SingletonInjector.INSTANCE.get(IWrapperFactory.class);
|
||||
|
||||
/** number of bytes a single quad takes */
|
||||
public static final int QUADS_BYTE_SIZE = LodUtil.DH_VERTEX_FORMAT.getByteSize() * 4;
|
||||
/** how big a single VBO can be in bytes */
|
||||
@@ -63,6 +67,8 @@ public class LodBufferContainer implements AutoCloseable
|
||||
public IVertexBufferWrapper[] vbos;
|
||||
public IVertexBufferWrapper[] vbosTransparent;
|
||||
|
||||
public ILodContainerUniformBufferWrapper uniforms = WRAPPER_FACTORY.createLodContainerUniformWrapper();
|
||||
|
||||
private final AtomicReference<CompletableFuture<LodBufferContainer>> uploadFutureRef = new AtomicReference<>(null);
|
||||
|
||||
|
||||
@@ -305,6 +311,8 @@ public class LodBufferContainer implements AutoCloseable
|
||||
buffer.close();
|
||||
}
|
||||
}
|
||||
|
||||
this.uniforms.close();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+2
-20
@@ -237,6 +237,7 @@ public class McLodRenderer
|
||||
DebugRenderer.INSTANCE.render(renderParams);
|
||||
}
|
||||
|
||||
profiler.popPush("Apply to MC");
|
||||
lodRenderer.applyToMcTexture();
|
||||
|
||||
}
|
||||
@@ -307,26 +308,7 @@ public class McLodRenderer
|
||||
SortedArraySet<LodBufferContainer> lodBufferContainer = lodBufferHandler.getColumnRenderBuffers();
|
||||
if (lodBufferContainer != null)
|
||||
{
|
||||
for (int lodIndex = 0; lodIndex < lodBufferContainer.size(); lodIndex++)
|
||||
{
|
||||
LodBufferContainer bufferContainer = lodBufferContainer.get(lodIndex);
|
||||
// TODO match buffer builder debugger
|
||||
//if (bufferContainer.pos != DhSectionPos.encode((byte)6, 1,0))
|
||||
//{
|
||||
// continue;
|
||||
//}
|
||||
|
||||
Vec3d camPos = renderEventParam.exactCameraPosition;
|
||||
Vec3f modelPos = new Vec3f(
|
||||
(float) (bufferContainer.minCornerBlockPos.getX() - camPos.x),
|
||||
(float) (bufferContainer.minCornerBlockPos.getY() - camPos.y),
|
||||
(float) (bufferContainer.minCornerBlockPos.getZ() - camPos.z));
|
||||
|
||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeBufferRenderEvent.class, new DhApiBeforeBufferRenderEvent.EventParam(renderEventParam, modelPos));
|
||||
|
||||
IVertexBufferWrapper[] vbos = opaquePass ? bufferContainer.vbos : bufferContainer.vbosTransparent;
|
||||
lodRenderer.render(renderEventParam, opaquePass, modelPos, vbos, profilerWrapper);
|
||||
}
|
||||
lodRenderer.render(renderEventParam, opaquePass, lodBufferContainer, profilerWrapper);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
+3
@@ -24,7 +24,9 @@ import com.seibel.distanthorizons.core.level.IDhLevel;
|
||||
import com.seibel.distanthorizons.core.render.renderer.generic.IInstancedVboContainer;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.ILodContainerUniformBufferWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.IMcGenericRenderer;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.IUniformBufferWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.IVertexBufferWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
@@ -108,6 +110,7 @@ public interface IWrapperFactory extends IDhApiWrapperFactory, IBindable
|
||||
|
||||
|
||||
IVertexBufferWrapper createVboWrapper();
|
||||
ILodContainerUniformBufferWrapper createLodContainerUniformWrapper();
|
||||
|
||||
IInstancedVboContainer createInstancedVboContainer();
|
||||
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
+3
-1
@@ -20,7 +20,9 @@
|
||||
package com.seibel.distanthorizons.core.wrapperInterfaces.render;
|
||||
|
||||
import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
|
||||
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodBufferContainer;
|
||||
import com.seibel.distanthorizons.core.render.renderer.RenderParams;
|
||||
import com.seibel.distanthorizons.core.util.objects.SortedArraySet;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IProfilerWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable;
|
||||
|
||||
@@ -28,7 +30,7 @@ public interface IMcLodRenderer extends IBindable
|
||||
{
|
||||
void render(
|
||||
RenderParams renderEventParam, boolean opaquePass,
|
||||
DhApiVec3f modelPos, IVertexBufferWrapper[] bufferList,
|
||||
SortedArraySet<LodBufferContainer> bufferContainers,
|
||||
IProfilerWrapper profiler);
|
||||
|
||||
int getVertexSize();
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.core.wrapperInterfaces.render;
|
||||
|
||||
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable;
|
||||
|
||||
public interface IUniformBufferWrapper extends IBindable, AutoCloseable
|
||||
{
|
||||
void upload();
|
||||
|
||||
@Override
|
||||
void close();
|
||||
|
||||
}
|
||||
@@ -11,7 +11,12 @@ out vec4 vertexColor;
|
||||
out vec3 vertexWorldPos;
|
||||
out float vertexYPos;
|
||||
|
||||
layout (std140) uniform vertUniformBlock
|
||||
layout (std140) uniform vertUniqueUniformBlock
|
||||
{
|
||||
vec3 uModelOffset;
|
||||
};
|
||||
|
||||
layout (std140) uniform vertSharedUniformBlock
|
||||
{
|
||||
bool uIsWhiteWorld;
|
||||
|
||||
@@ -19,8 +24,6 @@ layout (std140) uniform vertUniformBlock
|
||||
float uMircoOffset;
|
||||
float uEarthRadius;
|
||||
|
||||
vec3 uModelOffset;
|
||||
|
||||
mat4 uCombinedMatrix;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user