fix blaze3d rendering
This commit is contained in:
+18
-16
@@ -38,6 +38,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
@@ -138,26 +139,27 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
|
|||||||
}
|
}
|
||||||
private void createPipelines()
|
private void createPipelines()
|
||||||
{
|
{
|
||||||
VertexFormat vertexFormat = VertexFormat.builder()
|
RenderPipelineBuilderWrapper pipelineBuilder = new RenderPipelineBuilderWrapper();
|
||||||
//.add("vPosition", BlazeDhVertexFormatUtil.FLOAT_XYZ_POS)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
|
|
||||||
{
|
{
|
||||||
pipelineBuilder.withCull(false);
|
pipelineBuilder.withFaceCulling(false);
|
||||||
//pipelineBuilder.withDepthWrite(true);
|
pipelineBuilder.withDepthWrite(true);
|
||||||
//pipelineBuilder.withDepthTestFunction(DepthTestFunction.LESS_DEPTH_TEST);
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.LESS);
|
||||||
//pipelineBuilder.withColorWrite(true);
|
pipelineBuilder.withColorWrite(true);
|
||||||
//pipelineBuilder.withoutBlend();
|
pipelineBuilder.withoutBlend();
|
||||||
pipelineBuilder.withPolygonMode(PolygonMode.WIREFRAME);
|
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.WIREFRAME);
|
||||||
pipelineBuilder.withLocation(Identifier.parse("distanthorizons:debug_wireframe_renderer"));
|
pipelineBuilder.withName("debug_wireframe_renderer");
|
||||||
|
|
||||||
pipelineBuilder.withVertexShader(Identifier.fromNamespaceAndPath("distanthorizons", "debug/blaze/vert"));
|
pipelineBuilder.withVertexShader("debug/blaze/vert");
|
||||||
pipelineBuilder.withFragmentShader(Identifier.fromNamespaceAndPath("distanthorizons", "debug/blaze/frag"));
|
pipelineBuilder.withFragmentShader("debug/blaze/frag");
|
||||||
|
|
||||||
pipelineBuilder.withUniform("uniformBlock", UniformType.UNIFORM_BUFFER);
|
pipelineBuilder.withUniformBuffer("uniformBlock");
|
||||||
|
|
||||||
pipelineBuilder.withVertexFormat(vertexFormat, VertexFormat.Mode.DEBUG_LINES);
|
|
||||||
|
VertexFormat vertexFormat = VertexFormat.builder()
|
||||||
|
.add("vPosition", BlazeDhVertexFormatUtil.FLOAT_XYZ_POS)
|
||||||
|
.build();
|
||||||
|
pipelineBuilder.withVertexFormat(vertexFormat);
|
||||||
|
pipelineBuilder.withVertexMode(RenderPipelineBuilderWrapper.EDhVertexMode.LINES);
|
||||||
}
|
}
|
||||||
this.pipeline = pipelineBuilder.build();
|
this.pipeline = pipelineBuilder.build();
|
||||||
|
|
||||||
|
|||||||
+24
-21
@@ -48,6 +48,7 @@ import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
|
|||||||
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBoxGroupShading;
|
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBoxGroupShading;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.objects.BlazeGenericObjectVertexContainer;
|
import com.seibel.distanthorizons.common.render.blaze.objects.BlazeGenericObjectVertexContainer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
||||||
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
||||||
@@ -107,8 +108,6 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
// rendering setup
|
// rendering setup
|
||||||
private boolean init = false;
|
private boolean init = false;
|
||||||
|
|
||||||
private VertexFormat vertexFormat;
|
|
||||||
|
|
||||||
private RenderPipeline pipeline;
|
private RenderPipeline pipeline;
|
||||||
|
|
||||||
private GpuBuffer vertUniformBuffer;
|
private GpuBuffer vertUniformBuffer;
|
||||||
@@ -130,12 +129,6 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
}
|
}
|
||||||
this.init = true;
|
this.init = true;
|
||||||
|
|
||||||
this.vertexFormat = VertexFormat.builder()
|
|
||||||
//.add("vPosition", BlazeDhVertexFormatUtil.FLOAT_XYZ_POS)
|
|
||||||
//.add("aColor", BlazeDhVertexFormatUtil.RGBA_UBYTE_COLOR)
|
|
||||||
//.add("aMaterial", BlazeDhVertexFormatUtil.IRIS_MATERIAL)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
this.createPipelines();
|
this.createPipelines();
|
||||||
|
|
||||||
if (RENDER_DEBUG_OBJECTS)
|
if (RENDER_DEBUG_OBJECTS)
|
||||||
@@ -145,26 +138,36 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
}
|
}
|
||||||
private void createPipelines()
|
private void createPipelines()
|
||||||
{
|
{
|
||||||
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
|
RenderPipelineBuilderWrapper pipelineBuilder = new RenderPipelineBuilderWrapper();
|
||||||
{
|
{
|
||||||
pipelineBuilder.withCull(true);
|
pipelineBuilder.withFaceCulling(true);
|
||||||
//pipelineBuilder.withDepthWrite(true);
|
pipelineBuilder.withDepthWrite(true);
|
||||||
//pipelineBuilder.withDepthTestFunction(DepthTestFunction.LESS_DEPTH_TEST);
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.LESS);
|
||||||
//pipelineBuilder.withBlend(BlendFunction.TRANSLUCENT);
|
pipelineBuilder.withBlend(BlendFunction.TRANSLUCENT); // TRANSLUCENT = new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
//pipelineBuilder.withColorWrite(true);
|
pipelineBuilder.withColorWrite(true);
|
||||||
pipelineBuilder.withPolygonMode(PolygonMode.FILL);
|
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.FILL);
|
||||||
pipelineBuilder.withLocation(Identifier.parse("distanthorizons:generic"));
|
pipelineBuilder.withName("generic_objects");
|
||||||
|
|
||||||
pipelineBuilder.withVertexShader(Identifier.fromNamespaceAndPath("distanthorizons", "generic/blaze/vert"));
|
pipelineBuilder.withVertexShader("generic/blaze/vert");
|
||||||
pipelineBuilder.withFragmentShader(Identifier.fromNamespaceAndPath("distanthorizons", "generic/blaze/frag"));
|
pipelineBuilder.withFragmentShader("generic/blaze/frag");
|
||||||
|
|
||||||
pipelineBuilder.withSampler("uLightMap");
|
pipelineBuilder.withSampler("uLightMap");
|
||||||
|
|
||||||
pipelineBuilder.withUniform("vertUniformBlock", UniformType.UNIFORM_BUFFER);
|
pipelineBuilder.withUniformBuffer("vertUniformBlock");
|
||||||
|
|
||||||
pipelineBuilder.withVertexFormat(this.vertexFormat, VertexFormat.Mode.TRIANGLES);
|
VertexFormat vertexFormat = VertexFormat.builder()
|
||||||
this.pipeline = pipelineBuilder.build();
|
.add("vPosition", BlazeDhVertexFormatUtil.FLOAT_XYZ_POS)
|
||||||
|
.add("aColor", BlazeDhVertexFormatUtil.RGBA_UBYTE_COLOR)
|
||||||
|
.add("aMaterial", BlazeDhVertexFormatUtil.IRIS_MATERIAL)
|
||||||
|
|
||||||
|
.add("paddingOne", BlazeDhVertexFormatUtil.BYTE_PAD)
|
||||||
|
.add("paddingTwo", BlazeDhVertexFormatUtil.BYTE_PAD)
|
||||||
|
.add("paddingThree", BlazeDhVertexFormatUtil.BYTE_PAD)
|
||||||
|
.build();
|
||||||
|
pipelineBuilder.withVertexFormat(vertexFormat);
|
||||||
|
pipelineBuilder.withVertexMode(RenderPipelineBuilderWrapper.EDhVertexMode.TRIANGLES);
|
||||||
}
|
}
|
||||||
|
this.pipeline = pipelineBuilder.build();
|
||||||
}
|
}
|
||||||
private void addGenericDebugObjects()
|
private void addGenericDebugObjects()
|
||||||
{
|
{
|
||||||
|
|||||||
+35
-28
@@ -21,6 +21,7 @@ import com.mojang.blaze3d.vertex.VertexFormat;
|
|||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeBufferRenderEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeBufferRenderEvent;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeLodUniformBufferWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeLodUniformBufferWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.buffer.BlazeVertexBufferWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.buffer.BlazeVertexBufferWrapper;
|
||||||
@@ -41,6 +42,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhTe
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper;
|
||||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
@@ -83,46 +85,48 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
VertexFormat vertexFormat = VertexFormat.builder()
|
RenderPipelineBuilderWrapper pipelineBuilder = new RenderPipelineBuilderWrapper();
|
||||||
//.add("vPosition", BlazeDhVertexFormatUtil.SHORT_XYZ_POS)
|
|
||||||
//.add("meta", BlazeDhVertexFormatUtil.META)
|
|
||||||
//.add("vColor", BlazeDhVertexFormatUtil.RGBA_UBYTE_COLOR)
|
|
||||||
//.add("irisMaterial", BlazeDhVertexFormatUtil.IRIS_MATERIAL)
|
|
||||||
//.add("irisNormal", BlazeDhVertexFormatUtil.IRIS_NORMAL)
|
|
||||||
//.add("paddingTwo", BlazeDhVertexFormatUtil.BYTE_PAD)
|
|
||||||
//.add("paddingThree", BlazeDhVertexFormatUtil.BYTE_PAD) // padding is to make sure the format is a multiple of 4
|
|
||||||
.build();
|
|
||||||
|
|
||||||
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
|
|
||||||
{
|
{
|
||||||
pipelineBuilder.withCull(true);
|
pipelineBuilder.withFaceCulling(true);
|
||||||
//pipelineBuilder.withDepthWrite(true);
|
pipelineBuilder.withDepthWrite(true);
|
||||||
//pipelineBuilder.withDepthTestFunction(DepthTestFunction.LESS_DEPTH_TEST);
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.LESS);
|
||||||
//pipelineBuilder.withColorWrite(true);
|
pipelineBuilder.withColorWrite(true);
|
||||||
pipelineBuilder.withPolygonMode(PolygonMode.FILL);
|
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.FILL);
|
||||||
pipelineBuilder.withLocation(Identifier.parse("distanthorizons:lod_render"));
|
pipelineBuilder.withName("terrain");
|
||||||
|
|
||||||
pipelineBuilder.withVertexShader(Identifier.fromNamespaceAndPath("distanthorizons", "lod/blaze/vert"));
|
|
||||||
pipelineBuilder.withFragmentShader(Identifier.fromNamespaceAndPath("distanthorizons", "lod/blaze/frag"));
|
|
||||||
|
|
||||||
pipelineBuilder.withSampler("uLightMap");
|
pipelineBuilder.withSampler("uLightMap");
|
||||||
|
|
||||||
pipelineBuilder.withUniform("vertUniqueUniformBlock", UniformType.UNIFORM_BUFFER);
|
pipelineBuilder.withVertexShader("lod/blaze/vert");
|
||||||
pipelineBuilder.withUniform("vertSharedUniformBlock", UniformType.UNIFORM_BUFFER);
|
pipelineBuilder.withFragmentShader("lod/blaze/frag");
|
||||||
pipelineBuilder.withUniform("fragUniformBlock", UniformType.UNIFORM_BUFFER);
|
|
||||||
|
|
||||||
pipelineBuilder.withVertexFormat(vertexFormat, VertexFormat.Mode.TRIANGLES);
|
pipelineBuilder.withUniformBuffer("vertUniqueUniformBlock");
|
||||||
|
pipelineBuilder.withUniformBuffer("vertSharedUniformBlock");
|
||||||
|
pipelineBuilder.withUniformBuffer("fragUniformBlock");
|
||||||
|
|
||||||
|
VertexFormat vertexFormat = VertexFormat.builder()
|
||||||
|
.add("vPosition", BlazeDhVertexFormatUtil.SHORT_XYZ_POS)
|
||||||
|
.add("meta", BlazeDhVertexFormatUtil.META)
|
||||||
|
.add("vColor", BlazeDhVertexFormatUtil.RGBA_UBYTE_COLOR)
|
||||||
|
.add("irisMaterial", BlazeDhVertexFormatUtil.IRIS_MATERIAL)
|
||||||
|
.add("irisNormal", BlazeDhVertexFormatUtil.IRIS_NORMAL)
|
||||||
|
.add("paddingTwo", BlazeDhVertexFormatUtil.BYTE_PAD)
|
||||||
|
.add("paddingThree", BlazeDhVertexFormatUtil.BYTE_PAD) // padding is to make sure the format is a multiple of 4
|
||||||
|
.build();
|
||||||
|
pipelineBuilder.withVertexFormat(vertexFormat);
|
||||||
|
|
||||||
|
pipelineBuilder.withVertexMode(RenderPipelineBuilderWrapper.EDhVertexMode.TRIANGLES);
|
||||||
}
|
}
|
||||||
|
|
||||||
// opaque
|
// opaque
|
||||||
{
|
{
|
||||||
//pipelineBuilder.withoutBlend();
|
pipelineBuilder.withoutBlend();
|
||||||
this.opaquePipeline = pipelineBuilder.build();
|
this.opaquePipeline = pipelineBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
// transparent
|
// transparent
|
||||||
{
|
{
|
||||||
//pipelineBuilder.withBlend(BlendFunction.TRANSLUCENT);
|
// TRANSLUCENT = new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
|
pipelineBuilder.withBlend(BlendFunction.TRANSLUCENT);
|
||||||
this.transparentPipeline = pipelineBuilder.build();
|
this.transparentPipeline = pipelineBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +193,7 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
.putMat4f() // uCombinedMatrix
|
.putMat4f() // uCombinedMatrix
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
ByteBuffer buffer = ByteBuffer.allocateDirect(uniformBufferSize);
|
ByteBuffer buffer = MemoryUtil.memAlloc(uniformBufferSize);
|
||||||
buffer.order(ByteOrder.nativeOrder());
|
buffer.order(ByteOrder.nativeOrder());
|
||||||
Std140Builder.intoBuffer(buffer)
|
Std140Builder.intoBuffer(buffer)
|
||||||
.putInt(0) // uIsWhiteWorld
|
.putInt(0) // uIsWhiteWorld
|
||||||
@@ -209,6 +213,8 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.vertSharedUniformBuffer, 0, uniformBufferSize);
|
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.vertSharedUniformBuffer, 0, uniformBufferSize);
|
||||||
|
|
||||||
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
|
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
|
||||||
|
|
||||||
|
MemoryUtil.memFree(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
profiler.popPush("set frag uniforms");
|
profiler.popPush("set frag uniforms");
|
||||||
@@ -235,7 +241,7 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
|
|
||||||
// upload data //
|
// upload data //
|
||||||
|
|
||||||
ByteBuffer buffer = ByteBuffer.allocateDirect(uniformBufferSize);
|
ByteBuffer buffer = MemoryUtil.memAlloc(uniformBufferSize);
|
||||||
buffer.order(ByteOrder.nativeOrder());
|
buffer.order(ByteOrder.nativeOrder());
|
||||||
buffer = Std140Builder.intoBuffer(buffer)
|
buffer = Std140Builder.intoBuffer(buffer)
|
||||||
.putFloat(dhNearClipDistance) // uClipDistance
|
.putFloat(dhNearClipDistance) // uClipDistance
|
||||||
@@ -251,6 +257,7 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.fragUniformBuffer, 0, uniformBufferSize);
|
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.fragUniformBuffer, 0, uniformBufferSize);
|
||||||
|
|
||||||
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
|
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
|
||||||
|
MemoryUtil.memFree(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+36
-33
@@ -27,8 +27,6 @@ public class BlazeDhApplyRenderer {}
|
|||||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
import com.mojang.blaze3d.buffers.GpuBuffer;
|
||||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
import com.mojang.blaze3d.pipeline.BlendFunction;
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import com.mojang.blaze3d.platform.PolygonMode;
|
|
||||||
import com.mojang.blaze3d.shaders.UniformType;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
import com.mojang.blaze3d.systems.RenderPass;
|
||||||
@@ -36,12 +34,13 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||||||
import com.mojang.blaze3d.textures.*;
|
import com.mojang.blaze3d.textures.*;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
import net.minecraft.resources.Identifier;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -80,6 +79,10 @@ public class BlazeDhApplyRenderer
|
|||||||
private final BlazeTextureViewWrapper sourceDepthTextureViewWrapper = new BlazeTextureViewWrapper();
|
private final BlazeTextureViewWrapper sourceDepthTextureViewWrapper = new BlazeTextureViewWrapper();
|
||||||
|
|
||||||
private final BlazeTextureViewWrapper destinationColorTextureViewWrapper = new BlazeTextureViewWrapper();
|
private final BlazeTextureViewWrapper destinationColorTextureViewWrapper = new BlazeTextureViewWrapper();
|
||||||
|
/** We don't want to actually write any depth data, but blaze3D complains if we don't bind a depth texture. */
|
||||||
|
private final BlazeTextureWrapper dummyDepthTextureWrapper = BlazeTextureWrapper.createDepth("apply_dummy_depth");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can be set for special application shaders that need
|
* Can be set for special application shaders that need
|
||||||
@@ -132,9 +135,13 @@ public class BlazeDhApplyRenderer
|
|||||||
GpuTexture sourceColorTexture,
|
GpuTexture sourceColorTexture,
|
||||||
GpuTexture sourceDepthTexture,
|
GpuTexture sourceDepthTexture,
|
||||||
GpuTexture destinationColorTexture)
|
GpuTexture destinationColorTexture)
|
||||||
|
{
|
||||||
|
// one-time setup
|
||||||
|
if (this.pipeline == null)
|
||||||
{
|
{
|
||||||
this.createPipeline();
|
this.createPipeline();
|
||||||
this.vboGpuBuffer = BlazePostProcessUtil.createAndUploadScreenVertexData(this.name);
|
this.vboGpuBuffer = BlazePostProcessUtil.createAndUploadScreenVertexData(this.name);
|
||||||
|
}
|
||||||
|
|
||||||
this.sourceColorTextureViewWrapper.tryWrap(sourceColorTexture);
|
this.sourceColorTextureViewWrapper.tryWrap(sourceColorTexture);
|
||||||
this.sourceDepthTextureViewWrapper.tryWrap(sourceDepthTexture);
|
this.sourceDepthTextureViewWrapper.tryWrap(sourceDepthTexture);
|
||||||
@@ -144,48 +151,42 @@ public class BlazeDhApplyRenderer
|
|||||||
}
|
}
|
||||||
private void createPipeline()
|
private void createPipeline()
|
||||||
{
|
{
|
||||||
if (this.pipeline != null)
|
RenderPipelineBuilderWrapper pipelineBuilder = new RenderPipelineBuilderWrapper();
|
||||||
{
|
{
|
||||||
return;
|
pipelineBuilder.withFaceCulling(false);
|
||||||
|
pipelineBuilder.withDepthWrite(false);
|
||||||
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.NONE);
|
||||||
|
pipelineBuilder.withColorWrite(true);
|
||||||
|
|
||||||
|
if (this.blendFunction != null)
|
||||||
|
{
|
||||||
|
pipelineBuilder.withBlend(this.blendFunction);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pipelineBuilder.withoutBlend();
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexFormat vertexFormat = VertexFormat.builder()
|
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.FILL);
|
||||||
//.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
|
pipelineBuilder.withName(this.name);
|
||||||
.build();
|
|
||||||
|
|
||||||
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
|
pipelineBuilder.withVertexShader(this.vertexShaderPath);
|
||||||
{
|
pipelineBuilder.withFragmentShader(this.fragmentShaderPath);
|
||||||
pipelineBuilder.withCull(false);
|
|
||||||
//pipelineBuilder.withDepthWrite(false);
|
|
||||||
//pipelineBuilder.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST);
|
|
||||||
//pipelineBuilder.withColorWrite(true);
|
|
||||||
|
|
||||||
//if (this.blendFunction != null)
|
|
||||||
//{
|
|
||||||
// pipelineBuilder.withBlend(this.blendFunction);
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// pipelineBuilder.withoutBlend();
|
|
||||||
//}
|
|
||||||
|
|
||||||
pipelineBuilder.withPolygonMode(PolygonMode.FILL);
|
|
||||||
pipelineBuilder.withLocation(Identifier.parse(this.identifierName)); // TODO will complain if capital letters are included
|
|
||||||
|
|
||||||
// TODO manually validate paths to confirm they exist and end with ".fsh" or ".vsh", MC silently fails if the files are missing/improperly named
|
|
||||||
pipelineBuilder.withVertexShader(Identifier.fromNamespaceAndPath("distanthorizons", this.vertexShaderPath));
|
|
||||||
pipelineBuilder.withFragmentShader(Identifier.fromNamespaceAndPath("distanthorizons", this.fragmentShaderPath));
|
|
||||||
|
|
||||||
for (int i = 0; i < this.uniformNames.length; i++)
|
for (int i = 0; i < this.uniformNames.length; i++)
|
||||||
{
|
{
|
||||||
String uniformName = this.uniformNames[i];
|
String uniformName = this.uniformNames[i];
|
||||||
pipelineBuilder.withUniform(uniformName, UniformType.UNIFORM_BUFFER);
|
pipelineBuilder.withUniformBuffer(uniformName);
|
||||||
}
|
}
|
||||||
|
|
||||||
pipelineBuilder.withSampler("uSourceColorTexture");
|
pipelineBuilder.withSampler("uSourceColorTexture");
|
||||||
pipelineBuilder.withSampler("uSourceDepthTexture");
|
pipelineBuilder.withSampler("uSourceDepthTexture");
|
||||||
|
|
||||||
pipelineBuilder.withVertexFormat(vertexFormat, VertexFormat.Mode.TRIANGLE_FAN);
|
VertexFormat vertexFormat = VertexFormat.builder()
|
||||||
|
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
|
||||||
|
.build();
|
||||||
|
pipelineBuilder.withVertexFormat(vertexFormat);
|
||||||
|
pipelineBuilder.withVertexMode(RenderPipelineBuilderWrapper.EDhVertexMode.TRIANGLE_FAN);
|
||||||
}
|
}
|
||||||
this.pipeline = pipelineBuilder.build();
|
this.pipeline = pipelineBuilder.build();
|
||||||
}
|
}
|
||||||
@@ -222,11 +223,13 @@ public class BlazeDhApplyRenderer
|
|||||||
{
|
{
|
||||||
this.tryInit(sourceColorTexture, sourceDepthTexture, destinationColorTexture);
|
this.tryInit(sourceColorTexture, sourceDepthTexture, destinationColorTexture);
|
||||||
|
|
||||||
|
this.dummyDepthTextureWrapper.tryCreateOrResize();
|
||||||
|
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
||||||
this::getIdentifierName,
|
this::getIdentifierName,
|
||||||
this.destinationColorTextureViewWrapper.textureView,
|
this.destinationColorTextureViewWrapper.textureView,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||||
/*depthTexture*/ null,
|
this.dummyDepthTextureWrapper.textureView,
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
||||||
{
|
{
|
||||||
renderPass.bindTexture("uSourceColorTexture", this.sourceColorTextureViewWrapper.textureView, this.sourceColorTextureViewWrapper.textureSampler);
|
renderPass.bindTexture("uSourceColorTexture", this.sourceColorTextureViewWrapper.textureView, this.sourceColorTextureViewWrapper.textureSampler);
|
||||||
|
|||||||
+25
-21
@@ -26,19 +26,17 @@ public class BlazeDhCopyRenderer {}
|
|||||||
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
import com.mojang.blaze3d.buffers.GpuBuffer;
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import com.mojang.blaze3d.platform.PolygonMode;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
import com.mojang.blaze3d.systems.RenderPass;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.textures.*;
|
import com.mojang.blaze3d.textures.*;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import net.minecraft.resources.Identifier;
|
|
||||||
|
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
@@ -62,6 +60,8 @@ public class BlazeDhCopyRenderer
|
|||||||
|
|
||||||
private GpuBuffer vboGpuBuffer;
|
private GpuBuffer vboGpuBuffer;
|
||||||
|
|
||||||
|
private BlazeTextureWrapper dummyDepthTextureWrapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=============//
|
//=============//
|
||||||
@@ -80,23 +80,25 @@ public class BlazeDhCopyRenderer
|
|||||||
this.init = true;
|
this.init = true;
|
||||||
|
|
||||||
|
|
||||||
|
this.dummyDepthTextureWrapper = BlazeTextureWrapper.createDepth("dh_copy_depth_texture");
|
||||||
|
|
||||||
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
|
RenderPipelineBuilderWrapper pipelineBuilder = new RenderPipelineBuilderWrapper();
|
||||||
{
|
{
|
||||||
pipelineBuilder.withCull(false);
|
pipelineBuilder.withFaceCulling(false);
|
||||||
//pipelineBuilder.withDepthWrite(false);
|
pipelineBuilder.withDepthWrite(false);
|
||||||
//pipelineBuilder.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST);
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.NONE);
|
||||||
//pipelineBuilder.withColorWrite(true);
|
pipelineBuilder.withColorWrite(true);
|
||||||
//pipelineBuilder.withoutBlend();
|
pipelineBuilder.withoutBlend();
|
||||||
pipelineBuilder.withPolygonMode(PolygonMode.FILL);
|
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.FILL);
|
||||||
pipelineBuilder.withLocation(Identifier.parse("distanthorizons:copy_render"));
|
pipelineBuilder.withName("copy");
|
||||||
|
|
||||||
pipelineBuilder.withVertexShader(Identifier.fromNamespaceAndPath("distanthorizons", "copy/blaze/vert"));
|
pipelineBuilder.withVertexShader("copy/blaze/vert");
|
||||||
pipelineBuilder.withFragmentShader(Identifier.fromNamespaceAndPath("distanthorizons", "copy/blaze/frag"));
|
pipelineBuilder.withFragmentShader("copy/blaze/frag");
|
||||||
|
|
||||||
pipelineBuilder.withSampler("uCopyTexture");
|
pipelineBuilder.withSampler("uCopyTexture");
|
||||||
|
|
||||||
pipelineBuilder.withVertexFormat(BlazePostProcessUtil.createVertexFormat(), VertexFormat.Mode.TRIANGLE_FAN);
|
pipelineBuilder.withVertexFormat(BlazePostProcessUtil.createVertexFormat());
|
||||||
|
pipelineBuilder.withVertexMode(RenderPipelineBuilderWrapper.EDhVertexMode.TRIANGLE_FAN);
|
||||||
}
|
}
|
||||||
this.pipeline = pipelineBuilder.build();
|
this.pipeline = pipelineBuilder.build();
|
||||||
|
|
||||||
@@ -118,17 +120,17 @@ public class BlazeDhCopyRenderer
|
|||||||
BlazeTextureWrapper sourceColorTextureWrapper,
|
BlazeTextureWrapper sourceColorTextureWrapper,
|
||||||
BlazeTextureViewWrapper destinationColorTextureWrapper)
|
BlazeTextureViewWrapper destinationColorTextureWrapper)
|
||||||
{
|
{
|
||||||
//this.render(
|
this.render(
|
||||||
// sourceColorTextureWrapper.textureView, sourceColorTextureWrapper.textureSampler,
|
sourceColorTextureWrapper.textureView, sourceColorTextureWrapper.textureSampler,
|
||||||
// destinationColorTextureWrapper.textureView);
|
destinationColorTextureWrapper.textureView);
|
||||||
}
|
}
|
||||||
public void render(
|
public void render(
|
||||||
BlazeTextureWrapper sourceColorTextureWrapper,
|
BlazeTextureWrapper sourceColorTextureWrapper,
|
||||||
BlazeTextureWrapper destinationColorTextureWrapper)
|
BlazeTextureWrapper destinationColorTextureWrapper)
|
||||||
{
|
{
|
||||||
//this.render(
|
this.render(
|
||||||
// sourceColorTextureWrapper.textureView, sourceColorTextureWrapper.textureSampler,
|
sourceColorTextureWrapper.textureView, sourceColorTextureWrapper.textureSampler,
|
||||||
// destinationColorTextureWrapper.textureView);
|
destinationColorTextureWrapper.textureView);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void render(
|
private void render(
|
||||||
@@ -138,11 +140,13 @@ public class BlazeDhCopyRenderer
|
|||||||
{
|
{
|
||||||
this.tryInit();
|
this.tryInit();
|
||||||
|
|
||||||
|
this.dummyDepthTextureWrapper.tryCreateOrResize();
|
||||||
|
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
destinationTextureView,
|
destinationTextureView,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||||
/*depthTexture*/ null,
|
this.dummyDepthTextureWrapper.textureView,
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
||||||
{
|
{
|
||||||
renderPass.bindTexture("uCopyTexture", sourceTextureView, sourceTextureSampler);
|
renderPass.bindTexture("uCopyTexture", sourceTextureView, sourceTextureSampler);
|
||||||
|
|||||||
+5
@@ -179,6 +179,11 @@ public class BlazeGenericObjectVertexContainer implements IDhGenericObjectVertex
|
|||||||
this.vertexBuffer.put(a);
|
this.vertexBuffer.put(a);
|
||||||
|
|
||||||
this.vertexBuffer.put(box.material);
|
this.vertexBuffer.put(box.material);
|
||||||
|
|
||||||
|
// padding so the vertex format's byte count is a multiple of 4
|
||||||
|
this.vertexBuffer.put((byte)0);
|
||||||
|
this.vertexBuffer.put((byte)0);
|
||||||
|
this.vertexBuffer.put((byte)0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.vertexBuffer.flip();
|
this.vertexBuffer.flip();
|
||||||
|
|||||||
+22
-19
@@ -29,17 +29,15 @@ import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
|||||||
import com.mojang.blaze3d.buffers.Std140Builder;
|
import com.mojang.blaze3d.buffers.Std140Builder;
|
||||||
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import com.mojang.blaze3d.platform.PolygonMode;
|
|
||||||
import com.mojang.blaze3d.shaders.UniformType;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
import com.mojang.blaze3d.systems.RenderPass;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
|
||||||
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhCopyRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhCopyRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
@@ -49,7 +47,6 @@ import com.seibel.distanthorizons.core.util.RenderUtil;
|
|||||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhFarFadeRenderer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhFarFadeRenderer;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.Identifier;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
@@ -75,8 +72,11 @@ public class BlazeDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
|
|
||||||
private GpuBuffer vboGpuBuffer;
|
private GpuBuffer vboGpuBuffer;
|
||||||
|
|
||||||
public final BlazeTextureWrapper dhFadeColorTextureWrapper = BlazeTextureWrapper.createColor("DhFadeColorTexture");
|
private final BlazeTextureWrapper dhFadeColorTextureWrapper = BlazeTextureWrapper.createColor("dh_far_fade_color_texture");
|
||||||
public final BlazeTextureViewWrapper mcColorTextureViewWrapper = new BlazeTextureViewWrapper();
|
/** We don't want to actually write any depth data, but blaze3D complains if we don't bind a depth texture. */
|
||||||
|
private final BlazeTextureWrapper dhFadeDepthTextureWrapper = BlazeTextureWrapper.createDepth("dh_far_fade_depth_texture");
|
||||||
|
|
||||||
|
private final BlazeTextureViewWrapper mcColorTextureViewWrapper = new BlazeTextureViewWrapper();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -97,27 +97,28 @@ public class BlazeDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
|
RenderPipelineBuilderWrapper pipelineBuilder = new RenderPipelineBuilderWrapper();
|
||||||
{
|
{
|
||||||
pipelineBuilder.withCull(false);
|
pipelineBuilder.withFaceCulling(false);
|
||||||
//pipelineBuilder.withDepthWrite(false);
|
pipelineBuilder.withDepthWrite(false);
|
||||||
//pipelineBuilder.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST);
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.NONE);
|
||||||
//pipelineBuilder.withColorWrite(true);
|
pipelineBuilder.withColorWrite(true);
|
||||||
//pipelineBuilder.withoutBlend();
|
pipelineBuilder.withoutBlend();
|
||||||
pipelineBuilder.withPolygonMode(PolygonMode.FILL);
|
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.FILL);
|
||||||
pipelineBuilder.withLocation(Identifier.parse("distanthorizons:far_fade"));
|
pipelineBuilder.withName("far_fade");
|
||||||
|
|
||||||
pipelineBuilder.withVertexShader(Identifier.fromNamespaceAndPath("distanthorizons", "fade/blaze/vert"));
|
pipelineBuilder.withVertexShader("fade/blaze/vert");
|
||||||
pipelineBuilder.withFragmentShader(Identifier.fromNamespaceAndPath("distanthorizons", "fade/blaze/dh_fade"));
|
pipelineBuilder.withFragmentShader("fade/blaze/dh_fade");
|
||||||
|
|
||||||
pipelineBuilder.withSampler("uMcColorTexture");
|
pipelineBuilder.withSampler("uMcColorTexture");
|
||||||
|
|
||||||
pipelineBuilder.withSampler("uDhDepthTexture");
|
pipelineBuilder.withSampler("uDhDepthTexture");
|
||||||
pipelineBuilder.withSampler("uDhColorTexture");
|
pipelineBuilder.withSampler("uDhColorTexture");
|
||||||
|
|
||||||
pipelineBuilder.withUniform("fragUniformBlock", UniformType.UNIFORM_BUFFER);
|
pipelineBuilder.withUniformBuffer("fragUniformBlock");
|
||||||
|
|
||||||
pipelineBuilder.withVertexFormat(BlazePostProcessUtil.createVertexFormat(), VertexFormat.Mode.TRIANGLE_FAN);
|
pipelineBuilder.withVertexFormat(BlazePostProcessUtil.createVertexFormat());
|
||||||
|
pipelineBuilder.withVertexMode(RenderPipelineBuilderWrapper.EDhVertexMode.TRIANGLE_FAN);
|
||||||
}
|
}
|
||||||
this.pipeline = pipelineBuilder.build();
|
this.pipeline = pipelineBuilder.build();
|
||||||
|
|
||||||
@@ -152,6 +153,8 @@ public class BlazeDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
this.dhFadeColorTextureWrapper.tryCreateOrResize();
|
this.dhFadeColorTextureWrapper.tryCreateOrResize();
|
||||||
this.mcColorTextureViewWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getColorTexture());
|
this.mcColorTextureViewWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getColorTexture());
|
||||||
|
|
||||||
|
this.dhFadeDepthTextureWrapper.tryCreateOrResize();
|
||||||
|
|
||||||
{
|
{
|
||||||
int uniformBufferSize = new Std140SizeCalculator()
|
int uniformBufferSize = new Std140SizeCalculator()
|
||||||
.putFloat() // uStartFadeBlockDistance
|
.putFloat() // uStartFadeBlockDistance
|
||||||
@@ -205,7 +208,7 @@ public class BlazeDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
this.dhFadeColorTextureWrapper.textureView,
|
this.dhFadeColorTextureWrapper.textureView,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||||
/*depthTexture*/ null,
|
this.dhFadeDepthTextureWrapper.textureView,
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
||||||
{
|
{
|
||||||
// MC texture
|
// MC texture
|
||||||
|
|||||||
+19
-19
@@ -31,19 +31,17 @@ import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
|||||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
import com.mojang.blaze3d.pipeline.BlendFunction;
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import com.mojang.blaze3d.platform.DestFactor;
|
import com.mojang.blaze3d.platform.DestFactor;
|
||||||
import com.mojang.blaze3d.platform.PolygonMode;
|
|
||||||
import com.mojang.blaze3d.platform.SourceFactor;
|
import com.mojang.blaze3d.platform.SourceFactor;
|
||||||
import com.mojang.blaze3d.shaders.UniformType;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
import com.mojang.blaze3d.systems.RenderPass;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogColorMode;
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogColorMode;
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
||||||
@@ -57,7 +55,6 @@ import com.seibel.distanthorizons.core.util.math.Mat4f;
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhFogRenderer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhFogRenderer;
|
||||||
import net.minecraft.resources.Identifier;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@@ -90,7 +87,9 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
|
|||||||
|
|
||||||
private GpuBuffer vboGpuBuffer;
|
private GpuBuffer vboGpuBuffer;
|
||||||
|
|
||||||
public BlazeTextureWrapper fogColorTextureWrapper = BlazeTextureWrapper.createColor("DhFogColorTexture");
|
private final BlazeTextureWrapper fogColorTextureWrapper = BlazeTextureWrapper.createColor("dh_fog_color_texture");
|
||||||
|
/** We don't want to actually write any depth data, but blaze3D complains if we don't bind a depth texture. */
|
||||||
|
private final BlazeTextureWrapper fogDepthTextureWrapper = BlazeTextureWrapper.createDepth("dh_fog_depth_texture");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -118,24 +117,25 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
|
|||||||
"apply/blaze/vert", "apply/blaze/frag"
|
"apply/blaze/vert", "apply/blaze/frag"
|
||||||
);
|
);
|
||||||
|
|
||||||
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
|
RenderPipelineBuilderWrapper pipelineBuilder = new RenderPipelineBuilderWrapper();
|
||||||
{
|
{
|
||||||
pipelineBuilder.withCull(false);
|
pipelineBuilder.withFaceCulling(false);
|
||||||
//pipelineBuilder.withDepthWrite(false);
|
pipelineBuilder.withDepthWrite(false);
|
||||||
//pipelineBuilder.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST);
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.NONE);
|
||||||
//pipelineBuilder.withColorWrite(true);
|
pipelineBuilder.withColorWrite(true);
|
||||||
//pipelineBuilder.withoutBlend();
|
pipelineBuilder.withoutBlend();
|
||||||
pipelineBuilder.withPolygonMode(PolygonMode.FILL);
|
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.FILL);
|
||||||
pipelineBuilder.withLocation(Identifier.parse("distanthorizons:fog_render"));
|
pipelineBuilder.withName("fog_render");
|
||||||
|
|
||||||
pipelineBuilder.withVertexShader(Identifier.fromNamespaceAndPath("distanthorizons", "fog/blaze/vert"));
|
pipelineBuilder.withVertexShader("fog/blaze/vert");
|
||||||
pipelineBuilder.withFragmentShader(Identifier.fromNamespaceAndPath("distanthorizons", "fog/blaze/frag"));
|
pipelineBuilder.withFragmentShader("fog/blaze/frag");
|
||||||
|
|
||||||
pipelineBuilder.withSampler("uDhDepthTexture");
|
pipelineBuilder.withSampler("uDhDepthTexture");
|
||||||
|
|
||||||
pipelineBuilder.withUniform("fragUniformBlock", UniformType.UNIFORM_BUFFER);
|
pipelineBuilder.withUniformBuffer("fragUniformBlock");
|
||||||
|
|
||||||
pipelineBuilder.withVertexFormat(BlazePostProcessUtil.createVertexFormat(), VertexFormat.Mode.TRIANGLE_FAN);
|
pipelineBuilder.withVertexFormat(BlazePostProcessUtil.createVertexFormat());
|
||||||
|
pipelineBuilder.withVertexMode(RenderPipelineBuilderWrapper.EDhVertexMode.TRIANGLE_FAN);
|
||||||
}
|
}
|
||||||
this.pipeline = pipelineBuilder.build();
|
this.pipeline = pipelineBuilder.build();
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
|
|||||||
|
|
||||||
|
|
||||||
this.fogColorTextureWrapper.tryCreateOrResize();
|
this.fogColorTextureWrapper.tryCreateOrResize();
|
||||||
|
this.fogDepthTextureWrapper.tryCreateOrResize();
|
||||||
|
|
||||||
{
|
{
|
||||||
int uniformBufferSize = new Std140SizeCalculator()
|
int uniformBufferSize = new Std140SizeCalculator()
|
||||||
@@ -338,7 +338,7 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
|
|||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
this.fogColorTextureWrapper.textureView,
|
this.fogColorTextureWrapper.textureView,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||||
/*depthTexture*/ null,
|
this.fogDepthTextureWrapper.textureView,
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
||||||
{
|
{
|
||||||
renderPass.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureSampler);
|
renderPass.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureSampler);
|
||||||
|
|||||||
+19
-18
@@ -31,16 +31,14 @@ import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
|||||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
import com.mojang.blaze3d.pipeline.BlendFunction;
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import com.mojang.blaze3d.platform.DestFactor;
|
import com.mojang.blaze3d.platform.DestFactor;
|
||||||
import com.mojang.blaze3d.platform.PolygonMode;
|
|
||||||
import com.mojang.blaze3d.platform.SourceFactor;
|
import com.mojang.blaze3d.platform.SourceFactor;
|
||||||
import com.mojang.blaze3d.shaders.UniformType;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
import com.mojang.blaze3d.systems.RenderPass;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
|
||||||
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
||||||
@@ -52,7 +50,6 @@ import com.seibel.distanthorizons.core.util.RenderUtil;
|
|||||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhSsaoRenderer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhSsaoRenderer;
|
||||||
import net.minecraft.resources.Identifier;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
@@ -82,7 +79,9 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
|||||||
|
|
||||||
private GpuBuffer vboGpuBuffer;
|
private GpuBuffer vboGpuBuffer;
|
||||||
|
|
||||||
public BlazeTextureWrapper ssaoColorTextureWrapper = BlazeTextureWrapper.createColor("DhSsaoTexture");
|
private final BlazeTextureWrapper ssaoColorTextureWrapper = BlazeTextureWrapper.createColor("dh_ssao_color_texture");
|
||||||
|
/** We don't want to actually write any depth data, but blaze3D complains if we don't bind a depth texture. */
|
||||||
|
private final BlazeTextureWrapper ssaoDepthTextureWrapper = BlazeTextureWrapper.createDepth("dh_ssao_depth_texture");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -109,24 +108,25 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
|||||||
/*uniforms*/ new String[] { "applyFragUniformBlock" }
|
/*uniforms*/ new String[] { "applyFragUniformBlock" }
|
||||||
);
|
);
|
||||||
|
|
||||||
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
|
RenderPipelineBuilderWrapper pipelineBuilder = new RenderPipelineBuilderWrapper();
|
||||||
{
|
{
|
||||||
pipelineBuilder.withCull(false);
|
pipelineBuilder.withFaceCulling(false);
|
||||||
//pipelineBuilder.withDepthWrite(false);
|
pipelineBuilder.withDepthWrite(false);
|
||||||
//pipelineBuilder.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST);
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.NONE);
|
||||||
//pipelineBuilder.withColorWrite(true);
|
pipelineBuilder.withColorWrite(true);
|
||||||
//pipelineBuilder.withoutBlend();
|
pipelineBuilder.withoutBlend();
|
||||||
pipelineBuilder.withPolygonMode(PolygonMode.FILL);
|
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.FILL);
|
||||||
pipelineBuilder.withLocation(Identifier.parse("distanthorizons:ssao_render"));
|
pipelineBuilder.withName("ssao_render");
|
||||||
|
|
||||||
pipelineBuilder.withVertexShader(Identifier.fromNamespaceAndPath("distanthorizons", "ssao/blaze/vert"));
|
pipelineBuilder.withVertexShader("ssao/blaze/vert");
|
||||||
pipelineBuilder.withFragmentShader(Identifier.fromNamespaceAndPath("distanthorizons", "ssao/blaze/frag"));
|
pipelineBuilder.withFragmentShader("ssao/blaze/frag");
|
||||||
|
|
||||||
pipelineBuilder.withSampler("uDhDepthTexture");
|
pipelineBuilder.withSampler("uDhDepthTexture");
|
||||||
|
|
||||||
pipelineBuilder.withUniform("fragUniformBlock", UniformType.UNIFORM_BUFFER);
|
pipelineBuilder.withUniformBuffer("fragUniformBlock");
|
||||||
|
|
||||||
pipelineBuilder.withVertexFormat(BlazePostProcessUtil.createVertexFormat(), VertexFormat.Mode.TRIANGLE_FAN);
|
pipelineBuilder.withVertexFormat(BlazePostProcessUtil.createVertexFormat());
|
||||||
|
pipelineBuilder.withVertexMode(RenderPipelineBuilderWrapper.EDhVertexMode.TRIANGLE_FAN);
|
||||||
}
|
}
|
||||||
this.pipeline = pipelineBuilder.build();
|
this.pipeline = pipelineBuilder.build();
|
||||||
|
|
||||||
@@ -159,6 +159,7 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
|||||||
|
|
||||||
// textures
|
// textures
|
||||||
this.ssaoColorTextureWrapper.tryCreateOrResize();
|
this.ssaoColorTextureWrapper.tryCreateOrResize();
|
||||||
|
this.ssaoDepthTextureWrapper.tryCreateOrResize();
|
||||||
|
|
||||||
// frag uniforms
|
// frag uniforms
|
||||||
{
|
{
|
||||||
@@ -258,7 +259,7 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
|||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
this.ssaoColorTextureWrapper.textureView,
|
this.ssaoColorTextureWrapper.textureView,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||||
/*depthTexture*/ null,
|
this.ssaoDepthTextureWrapper.textureView,
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
||||||
{
|
{
|
||||||
renderPass.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureSampler);
|
renderPass.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureSampler);
|
||||||
|
|||||||
+20
-14
@@ -40,6 +40,7 @@ import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
|||||||
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhCopyRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhCopyRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
@@ -81,7 +82,10 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
|
|
||||||
private GpuBuffer vboGpuBuffer;
|
private GpuBuffer vboGpuBuffer;
|
||||||
|
|
||||||
public final BlazeTextureWrapper fadeColorTextureWrapper = BlazeTextureWrapper.createColor("DhVanillaFadeTexture");
|
public final BlazeTextureWrapper fadeColorTextureWrapper = BlazeTextureWrapper.createColor("DhVanillaFadeColorTexture");
|
||||||
|
/** We don't want to actually write any depth data, but blaze3D complains if we don't bind a depth texture. */
|
||||||
|
private final BlazeTextureWrapper fadeDepthTextureWrapper = BlazeTextureWrapper.createDepth("DhVanillaFadeDepthTexture");
|
||||||
|
|
||||||
|
|
||||||
public final BlazeTextureViewWrapper mcDepthTextureWrapper = new BlazeTextureViewWrapper();
|
public final BlazeTextureViewWrapper mcDepthTextureWrapper = new BlazeTextureViewWrapper();
|
||||||
public final BlazeTextureViewWrapper mcColorTextureWrapper = new BlazeTextureViewWrapper();
|
public final BlazeTextureViewWrapper mcColorTextureWrapper = new BlazeTextureViewWrapper();
|
||||||
@@ -105,18 +109,18 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
|
RenderPipelineBuilderWrapper pipelineBuilder = new RenderPipelineBuilderWrapper();
|
||||||
{
|
{
|
||||||
pipelineBuilder.withCull(false);
|
pipelineBuilder.withFaceCulling(false);
|
||||||
//pipelineBuilder.withDepthWrite(false);
|
pipelineBuilder.withDepthWrite(false);
|
||||||
//pipelineBuilder.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST);
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.NONE);
|
||||||
//pipelineBuilder.withColorWrite(true);
|
pipelineBuilder.withColorWrite(true);
|
||||||
//pipelineBuilder.withoutBlend();
|
pipelineBuilder.withoutBlend();
|
||||||
pipelineBuilder.withPolygonMode(PolygonMode.FILL);
|
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.FILL);
|
||||||
pipelineBuilder.withLocation(Identifier.parse("distanthorizons:mc_vanilla_fade_render"));
|
pipelineBuilder.withName("vanilla_fade");
|
||||||
|
|
||||||
pipelineBuilder.withVertexShader(Identifier.fromNamespaceAndPath("distanthorizons", "fade/blaze/vert"));
|
pipelineBuilder.withVertexShader("fade/blaze/vert");
|
||||||
pipelineBuilder.withFragmentShader(Identifier.fromNamespaceAndPath("distanthorizons", "fade/blaze/vanilla_fade"));
|
pipelineBuilder.withFragmentShader("fade/blaze/vanilla_fade");
|
||||||
|
|
||||||
pipelineBuilder.withSampler("uMcDepthTexture");
|
pipelineBuilder.withSampler("uMcDepthTexture");
|
||||||
pipelineBuilder.withSampler("uCombinedMcDhColorTexture");
|
pipelineBuilder.withSampler("uCombinedMcDhColorTexture");
|
||||||
@@ -124,9 +128,10 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
pipelineBuilder.withSampler("uDhDepthTexture");
|
pipelineBuilder.withSampler("uDhDepthTexture");
|
||||||
pipelineBuilder.withSampler("uDhColorTexture");
|
pipelineBuilder.withSampler("uDhColorTexture");
|
||||||
|
|
||||||
pipelineBuilder.withUniform("fragUniformBlock", UniformType.UNIFORM_BUFFER);
|
pipelineBuilder.withUniformBuffer("fragUniformBlock");
|
||||||
|
|
||||||
pipelineBuilder.withVertexFormat(BlazePostProcessUtil.createVertexFormat(), VertexFormat.Mode.TRIANGLE_FAN);
|
pipelineBuilder.withVertexFormat(BlazePostProcessUtil.createVertexFormat());
|
||||||
|
pipelineBuilder.withVertexMode(RenderPipelineBuilderWrapper.EDhVertexMode.TRIANGLE_FAN);
|
||||||
}
|
}
|
||||||
this.pipeline = pipelineBuilder.build();
|
this.pipeline = pipelineBuilder.build();
|
||||||
|
|
||||||
@@ -157,6 +162,7 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
|
|
||||||
// textures
|
// textures
|
||||||
this.fadeColorTextureWrapper.tryCreateOrResize();
|
this.fadeColorTextureWrapper.tryCreateOrResize();
|
||||||
|
this.fadeDepthTextureWrapper.tryCreateOrResize();
|
||||||
|
|
||||||
this.mcDepthTextureWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getDepthTexture());
|
this.mcDepthTextureWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getDepthTexture());
|
||||||
this.mcColorTextureWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getColorTexture());
|
this.mcColorTextureWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getColorTexture());
|
||||||
@@ -234,7 +240,7 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
this.fadeColorTextureWrapper.textureView,
|
this.fadeColorTextureWrapper.textureView,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||||
/*depthTexture*/ null,
|
this.fadeDepthTextureWrapper.textureView,
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
||||||
{
|
{
|
||||||
renderPass.bindTexture("uMcDepthTexture", this.mcDepthTextureWrapper.textureView, this.mcDepthTextureWrapper.textureSampler);
|
renderPass.bindTexture("uMcDepthTexture", this.mcDepthTextureWrapper.textureView, this.mcDepthTextureWrapper.textureSampler);
|
||||||
|
|||||||
+1
-1
@@ -101,7 +101,7 @@ public class BlazeDhTestTriangleRenderer implements IDhTestTriangleRenderer
|
|||||||
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.NONE);
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.NONE);
|
||||||
pipelineBuilder.withColorWrite(true);
|
pipelineBuilder.withColorWrite(true);
|
||||||
pipelineBuilder.withoutBlend();
|
pipelineBuilder.withoutBlend();
|
||||||
pipelineBuilder.withName("triangle_test_render");
|
pipelineBuilder.withName("triangle_test");
|
||||||
|
|
||||||
pipelineBuilder.withVertexShader("test/blaze/vert");
|
pipelineBuilder.withVertexShader("test/blaze/vert");
|
||||||
pipelineBuilder.withFragmentShader("test/blaze/frag");
|
pipelineBuilder.withFragmentShader("test/blaze/frag");
|
||||||
|
|||||||
+1
-1
@@ -78,7 +78,7 @@ public class BlazeDhVertexFormatUtil
|
|||||||
BYTE_PAD = VertexFormatElement.register(/*id*/25, /*index*/0, VertexFormatElement.Type.BYTE, false, /*count*/ 1);
|
BYTE_PAD = VertexFormatElement.register(/*id*/25, /*index*/0, VertexFormatElement.Type.BYTE, false, /*count*/ 1);
|
||||||
|
|
||||||
META = VertexFormatElement.register(/*id*/26, /*index*/0, VertexFormatElement.Type.USHORT, false, /*count*/ 1);
|
META = VertexFormatElement.register(/*id*/26, /*index*/0, VertexFormatElement.Type.USHORT, false, /*count*/ 1);
|
||||||
RGBA_UBYTE_COLOR = VertexFormatElement.register(/*id*/27, /*index*/0, VertexFormatElement.Type.UBYTE, false, /*count*/ 4);
|
RGBA_UBYTE_COLOR = VertexFormatElement.register(/*id*/27, /*index*/0, VertexFormatElement.Type.UBYTE, true, /*count*/ 4);
|
||||||
IRIS_MATERIAL = VertexFormatElement.register(/*id*/28, /*index*/0, VertexFormatElement.Type.BYTE, false, /*count*/ 1);
|
IRIS_MATERIAL = VertexFormatElement.register(/*id*/28, /*index*/0, VertexFormatElement.Type.BYTE, false, /*count*/ 1);
|
||||||
IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, VertexFormatElement.Type.BYTE, false, /*count*/ 1);
|
IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, VertexFormatElement.Type.BYTE, false, /*count*/ 1);
|
||||||
|
|
||||||
|
|||||||
+9
-1
@@ -9,9 +9,13 @@ import com.mojang.blaze3d.buffers.GpuBuffer;
|
|||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
|
||||||
public class BlazeUniformUtil
|
public class BlazeUniformUtil
|
||||||
{
|
{
|
||||||
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
||||||
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
||||||
|
|
||||||
@@ -22,7 +26,11 @@ public class BlazeUniformUtil
|
|||||||
if (vboGpuBuffer == null
|
if (vboGpuBuffer == null
|
||||||
|| vboGpuBuffer.size() < size)
|
|| vboGpuBuffer.size() < size)
|
||||||
{
|
{
|
||||||
// GpuBuffer.USAGE_UNIFORM = 128
|
if (vboGpuBuffer != null)
|
||||||
|
{
|
||||||
|
vboGpuBuffer.close();
|
||||||
|
}
|
||||||
|
|
||||||
int usage = GpuBuffer.USAGE_COPY_DST
|
int usage = GpuBuffer.USAGE_COPY_DST
|
||||||
| GpuBuffer.USAGE_VERTEX
|
| GpuBuffer.USAGE_VERTEX
|
||||||
| GpuBuffer.USAGE_UNIFORM;
|
| GpuBuffer.USAGE_UNIFORM;
|
||||||
|
|||||||
+19
-2
@@ -6,6 +6,7 @@ import com.mojang.blaze3d.pipeline.DepthStencilState;
|
|||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import com.mojang.blaze3d.platform.CompareOp;
|
import com.mojang.blaze3d.platform.CompareOp;
|
||||||
import com.mojang.blaze3d.platform.PolygonMode;
|
import com.mojang.blaze3d.platform.PolygonMode;
|
||||||
|
import com.mojang.blaze3d.shaders.UniformType;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ public class RenderPipelineBuilderWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
private BlendFunction blendFunction = null;
|
private BlendFunction blendFunction = null;
|
||||||
public RenderPipelineBuilderWrapper withBlendFunction(BlendFunction blendFunction)
|
public RenderPipelineBuilderWrapper withBlend(BlendFunction blendFunction)
|
||||||
{
|
{
|
||||||
this.blendFunction = blendFunction;
|
this.blendFunction = blendFunction;
|
||||||
return this;
|
return this;
|
||||||
@@ -118,6 +119,18 @@ public class RenderPipelineBuilderWrapper
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RenderPipelineBuilderWrapper withSampler(String name) throws IllegalArgumentException
|
||||||
|
{
|
||||||
|
this.blazePipelineBuilder.withSampler(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RenderPipelineBuilderWrapper withUniformBuffer(String name) throws IllegalArgumentException
|
||||||
|
{
|
||||||
|
this.blazePipelineBuilder.withUniform(name, UniformType.UNIFORM_BUFFER);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
private VertexFormat vertexFormat = null;
|
private VertexFormat vertexFormat = null;
|
||||||
public RenderPipelineBuilderWrapper withVertexFormat(VertexFormat vertexFormat)
|
public RenderPipelineBuilderWrapper withVertexFormat(VertexFormat vertexFormat)
|
||||||
{
|
{
|
||||||
@@ -201,7 +214,7 @@ public class RenderPipelineBuilderWrapper
|
|||||||
case LESS:
|
case LESS:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.blazePipelineBuilder.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST);
|
this.blazepipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.NONE);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -239,6 +252,9 @@ public class RenderPipelineBuilderWrapper
|
|||||||
case TRIANGLES:
|
case TRIANGLES:
|
||||||
blazeVertexMode = VertexFormat.Mode.TRIANGLES;
|
blazeVertexMode = VertexFormat.Mode.TRIANGLES;
|
||||||
break;
|
break;
|
||||||
|
case TRIANGLE_FAN:
|
||||||
|
blazeVertexMode = VertexFormat.Mode.TRIANGLE_FAN;
|
||||||
|
break;
|
||||||
case LINES:
|
case LINES:
|
||||||
blazeVertexMode = VertexFormat.Mode.DEBUG_LINES;
|
blazeVertexMode = VertexFormat.Mode.DEBUG_LINES;
|
||||||
break;
|
break;
|
||||||
@@ -303,6 +319,7 @@ public class RenderPipelineBuilderWrapper
|
|||||||
public enum EDhVertexMode
|
public enum EDhVertexMode
|
||||||
{
|
{
|
||||||
TRIANGLES,
|
TRIANGLES,
|
||||||
|
TRIANGLE_FAN,
|
||||||
LINES;
|
LINES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+22
@@ -13,20 +13,27 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||||||
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.IndexBufferBuilder;
|
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.IndexBufferBuilder;
|
||||||
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodQuadBuilder;
|
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodQuadBuilder;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper;
|
||||||
import org.lwjgl.system.MemoryUtil;
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class BlazeVertexBufferWrapper implements IVertexBufferWrapper
|
public class BlazeVertexBufferWrapper implements IVertexBufferWrapper
|
||||||
{
|
{
|
||||||
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
private static final AbstractDhRenderApiDefinition RENDER_DEF = SingletonInjector.INSTANCE.get(AbstractDhRenderApiDefinition.class);
|
private static final AbstractDhRenderApiDefinition RENDER_DEF = SingletonInjector.INSTANCE.get(AbstractDhRenderApiDefinition.class);
|
||||||
|
|
||||||
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
||||||
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
||||||
|
|
||||||
|
private static final AtomicInteger BUFFER_COUNT_REF = new AtomicInteger(0);
|
||||||
|
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public String getName() { return this.name; }
|
public String getName() { return this.name; }
|
||||||
@@ -111,6 +118,12 @@ public class BlazeVertexBufferWrapper implements IVertexBufferWrapper
|
|||||||
// due to a bug on Mac where it will attempt to render anything allocated in the buffer
|
// due to a bug on Mac where it will attempt to render anything allocated in the buffer
|
||||||
|| oldVertexCount != vertexCount)
|
|| oldVertexCount != vertexCount)
|
||||||
{
|
{
|
||||||
|
if (this.vertexGpuBuffer == null)
|
||||||
|
{
|
||||||
|
BUFFER_COUNT_REF.incrementAndGet();
|
||||||
|
//LOGGER.info("Create, count: ["+BUFFER_COUNT_REF.get()+"]");
|
||||||
|
}
|
||||||
|
|
||||||
if (this.vertexGpuBuffer != null)
|
if (this.vertexGpuBuffer != null)
|
||||||
{
|
{
|
||||||
this.vertexGpuBuffer.close();
|
this.vertexGpuBuffer.close();
|
||||||
@@ -146,6 +159,11 @@ public class BlazeVertexBufferWrapper implements IVertexBufferWrapper
|
|||||||
if (this.indexGpuBuffer == null
|
if (this.indexGpuBuffer == null
|
||||||
|| oldIndexCount != this.indexCount)
|
|| oldIndexCount != this.indexCount)
|
||||||
{
|
{
|
||||||
|
if (this.indexGpuBuffer == null)
|
||||||
|
{
|
||||||
|
BUFFER_COUNT_REF.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.indexGpuBuffer != null)
|
if (this.indexGpuBuffer != null)
|
||||||
{
|
{
|
||||||
this.indexGpuBuffer.close();
|
this.indexGpuBuffer.close();
|
||||||
@@ -180,13 +198,17 @@ public class BlazeVertexBufferWrapper implements IVertexBufferWrapper
|
|||||||
{
|
{
|
||||||
if (this.vertexGpuBuffer != null)
|
if (this.vertexGpuBuffer != null)
|
||||||
{
|
{
|
||||||
|
BUFFER_COUNT_REF.decrementAndGet();
|
||||||
this.vertexGpuBuffer.close();
|
this.vertexGpuBuffer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.indexGpuBuffer != null)
|
if (this.indexGpuBuffer != null)
|
||||||
{
|
{
|
||||||
|
BUFFER_COUNT_REF.decrementAndGet();
|
||||||
this.indexGpuBuffer.close();
|
this.indexGpuBuffer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//LOGGER.info("Close, count: ["+BUFFER_COUNT_REF.get()+"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|||||||
+50
@@ -47,6 +47,11 @@ import com.mojang.blaze3d.textures.GpuSampler;
|
|||||||
public class MixinChunkSectionsToRender
|
public class MixinChunkSectionsToRender
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//===========//
|
||||||
|
// Pre MC 26 //
|
||||||
|
//===========//
|
||||||
|
//regino
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_10
|
#if MC_VER <= MC_1_21_10
|
||||||
// needs to fire at HEAD with a lower than normal order (less than 1000)
|
// needs to fire at HEAD with a lower than normal order (less than 1000)
|
||||||
@@ -74,6 +79,51 @@ public class MixinChunkSectionsToRender
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
#else
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//============//
|
||||||
|
// post MC 26 //
|
||||||
|
//============//
|
||||||
|
//region
|
||||||
|
|
||||||
|
// needs to fire at HEAD with a lower than normal order (less than 1000)
|
||||||
|
// otherwise it will be canceled by Sodium
|
||||||
|
@Inject(at = @At("HEAD"), method = "renderGroup", order = 800)
|
||||||
|
private void renderDeferredLayerHead(ChunkSectionLayerGroup chunkSectionLayerGroup, GpuSampler gpuSampler, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, Minecraft.getInstance().levelRenderer.level);
|
||||||
|
|
||||||
|
|
||||||
|
ClientApi.RENDER_STATE.canRenderOrThrow();
|
||||||
|
|
||||||
|
if (chunkSectionLayerGroup == ChunkSectionLayerGroup.TRANSLUCENT)
|
||||||
|
{
|
||||||
|
ClientApi.INSTANCE.renderDeferredLodsForShaders();
|
||||||
|
}
|
||||||
|
else if (chunkSectionLayerGroup == ChunkSectionLayerGroup.OPAQUE)
|
||||||
|
{
|
||||||
|
ClientApi.INSTANCE.renderFadeTransparent();
|
||||||
|
ClientApi.INSTANCE.renderLods();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(at = @At("RETURN"), method = "renderGroup", order = 800)
|
||||||
|
private void renderDeferredLayerReturn(ChunkSectionLayerGroup chunkSectionLayerGroup, GpuSampler gpuSampler, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
ClientApi.RENDER_STATE.canRenderOrThrow();
|
||||||
|
|
||||||
|
if (chunkSectionLayerGroup == ChunkSectionLayerGroup.TRANSLUCENT)
|
||||||
|
{
|
||||||
|
ClientApi.INSTANCE.renderFadeOpaque();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+80
-6
@@ -47,30 +47,39 @@ import org.joml.Matrix4fc;
|
|||||||
import org.joml.Vector4f;
|
import org.joml.Vector4f;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
#else
|
#elif MC_VER <= MC_1_21_11
|
||||||
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
||||||
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
|
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
import net.minecraft.client.Camera;
|
|
||||||
import net.minecraft.client.DeltaTracker;
|
import net.minecraft.client.DeltaTracker;
|
||||||
import net.minecraft.client.renderer.chunk.ChunkSectionsToRender;
|
import net.minecraft.client.renderer.chunk.ChunkSectionsToRender;
|
||||||
import org.joml.Matrix4f;
|
|
||||||
import org.joml.Matrix4fc;
|
import org.joml.Matrix4fc;
|
||||||
import org.joml.Vector4f;
|
import org.joml.Vector4f;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
#else
|
||||||
|
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
||||||
|
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
|
import net.minecraft.client.DeltaTracker;
|
||||||
|
import net.minecraft.client.renderer.chunk.ChunkSectionsToRender;
|
||||||
|
import org.joml.Matrix4fc;
|
||||||
|
import org.joml.Vector4f;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
import net.minecraft.client.renderer.state.level.CameraRenderState;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
|
||||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.renderer.LevelRenderer;
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
@@ -91,6 +100,13 @@ public class MixinLevelRenderer
|
|||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//===========//
|
||||||
|
// Pre MC 26 //
|
||||||
|
//===========//
|
||||||
|
//region
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
|
||||||
#if MC_VER < MC_1_17_1
|
#if MC_VER < MC_1_17_1
|
||||||
@Inject(at = @At("HEAD"),
|
@Inject(at = @At("HEAD"),
|
||||||
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDD)V",
|
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDD)V",
|
||||||
@@ -128,7 +144,7 @@ public class MixinLevelRenderer
|
|||||||
Vector4f skyColor, boolean thinFog, CallbackInfo callback)
|
Vector4f skyColor, boolean thinFog, CallbackInfo callback)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if MC_VER == MC_1_16_5
|
#if MC_VER <= MC_1_16_5
|
||||||
// get the matrices from the OpenGL fixed pipeline
|
// get the matrices from the OpenGL fixed pipeline
|
||||||
float[] mcProjMatrixRaw = new float[16];
|
float[] mcProjMatrixRaw = new float[16];
|
||||||
GL32.glGetFloatv(GL32.GL_PROJECTION_MATRIX, mcProjMatrixRaw);
|
GL32.glGetFloatv(GL32.GL_PROJECTION_MATRIX, mcProjMatrixRaw);
|
||||||
@@ -190,6 +206,64 @@ public class MixinLevelRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//============//
|
||||||
|
// post MC 26 //
|
||||||
|
//============//
|
||||||
|
//region
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
#else
|
||||||
|
|
||||||
|
@Inject(at = @At("HEAD"), method = "prepareChunkRenders")
|
||||||
|
private void prepareChunkRenders(final Matrix4fc modelViewMatrix, CallbackInfoReturnable<ChunkSectionsToRender> callback)
|
||||||
|
{
|
||||||
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, this.level);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(at = @At("HEAD"), method = "renderLevel")
|
||||||
|
public void renderLevel(
|
||||||
|
final GraphicsResourceAllocator resourceAllocator, final DeltaTracker deltaTracker,
|
||||||
|
final boolean renderBlockOutline, final CameraRenderState camera,
|
||||||
|
final Matrix4fc modelViewMatrix, final GpuBufferSlice terrainFog,
|
||||||
|
final Vector4f fogColor, final boolean shouldRenderSky,
|
||||||
|
final ChunkSectionsToRender chunkSectionsToRender,
|
||||||
|
CallbackInfo callback)
|
||||||
|
{
|
||||||
|
ClientApi.RENDER_STATE.mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrix);
|
||||||
|
ClientApi.RENDER_STATE.mcProjectionMatrix = McObjectConverter.Convert(camera.projectionMatrix);
|
||||||
|
|
||||||
|
ClientApi.RENDER_STATE.partialTickTime = MinecraftRenderWrapper.INSTANCE.getPartialTickTime();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "addMainPass(Lcom/mojang/blaze3d/framegraph/FrameGraphBuilder;Lnet/minecraft/client/renderer/culling/Frustum;Lorg/joml/Matrix4fc;Lcom/mojang/blaze3d/buffers/GpuBufferSlice;ZLnet/minecraft/client/renderer/state/level/LevelRenderState;Lnet/minecraft/client/DeltaTracker;Lnet/minecraft/util/profiling/ProfilerFiller;Lnet/minecraft/client/renderer/chunk/ChunkSectionsToRender;)V",
|
||||||
|
at = @At(
|
||||||
|
value = "RETURN",
|
||||||
|
target = "Lcom/mojang/blaze3d/framegraph/FramePass;executes(Ljava/lang/Runnable;)V",
|
||||||
|
remap = false
|
||||||
|
)
|
||||||
|
)
|
||||||
|
public void addMainPass(
|
||||||
|
CallbackInfo ci)
|
||||||
|
{
|
||||||
|
// only crash during development
|
||||||
|
if (ModInfo.IS_DEV_BUILD)
|
||||||
|
{
|
||||||
|
ClientApi.RENDER_STATE.canRenderOrThrow();
|
||||||
|
}
|
||||||
|
|
||||||
|
ClientApi.INSTANCE.renderLods();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+72
@@ -35,6 +35,7 @@ import net.minecraft.client.DeltaTracker;
|
|||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.renderer.LevelRenderer;
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.state.level.CameraRenderState;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.joml.Matrix4fc;
|
import org.joml.Matrix4fc;
|
||||||
import org.joml.Vector4f;
|
import org.joml.Vector4f;
|
||||||
@@ -77,6 +78,12 @@ public class MixinLevelRenderer
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//===========//
|
||||||
|
// Pre MC 26 //
|
||||||
|
//===========//
|
||||||
|
//region
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
|
||||||
#if MC_VER < MC_1_21_6
|
#if MC_VER < MC_1_21_6
|
||||||
@Inject(at = @At("HEAD"), method = "renderSectionLayer")
|
@Inject(at = @At("HEAD"), method = "renderSectionLayer")
|
||||||
private void renderChunkLayer(RenderType renderType, double x, double y, double z, Matrix4f modelViewMatrix, Matrix4f projectionMatrix, CallbackInfo callback)
|
private void renderChunkLayer(RenderType renderType, double x, double y, double z, Matrix4f modelViewMatrix, Matrix4f projectionMatrix, CallbackInfo callback)
|
||||||
@@ -165,6 +172,71 @@ public class MixinLevelRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//============//
|
||||||
|
// post MC 26 //
|
||||||
|
//============//
|
||||||
|
//region
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
#else
|
||||||
|
|
||||||
|
@Inject(at = @At("HEAD"), method = "prepareChunkRenders")
|
||||||
|
private void prepareChunkRenders(final Matrix4fc modelViewMatrix, CallbackInfoReturnable<ChunkSectionsToRender> callback)
|
||||||
|
{
|
||||||
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, this.level);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(at = @At("HEAD"), method = "renderLevel")
|
||||||
|
public void renderLevel(
|
||||||
|
final GraphicsResourceAllocator resourceAllocator, final DeltaTracker deltaTracker,
|
||||||
|
final boolean renderBlockOutline, final CameraRenderState camera,
|
||||||
|
final Matrix4fc modelViewMatrix, final GpuBufferSlice terrainFog,
|
||||||
|
final Vector4f fogColor, final boolean shouldRenderSky,
|
||||||
|
final ChunkSectionsToRender chunkSectionsToRender,
|
||||||
|
CallbackInfo callback)
|
||||||
|
{
|
||||||
|
ClientApi.RENDER_STATE.mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrix);
|
||||||
|
ClientApi.RENDER_STATE.mcProjectionMatrix = McObjectConverter.Convert(camera.projectionMatrix);
|
||||||
|
|
||||||
|
ClientApi.RENDER_STATE.partialTickTime = MinecraftRenderWrapper.INSTANCE.getPartialTickTime();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "addMainPass(Lcom/mojang/blaze3d/framegraph/FrameGraphBuilder;Lnet/minecraft/client/renderer/culling/Frustum;Lorg/joml/Matrix4fc;Lcom/mojang/blaze3d/buffers/GpuBufferSlice;ZLnet/minecraft/client/renderer/state/level/LevelRenderState;Lnet/minecraft/client/DeltaTracker;Lnet/minecraft/util/profiling/ProfilerFiller;Lnet/minecraft/client/renderer/chunk/ChunkSectionsToRender;)V",
|
||||||
|
at = @At(
|
||||||
|
value = "RETURN",
|
||||||
|
target = "Lcom/mojang/blaze3d/framegraph/FramePass;executes(Ljava/lang/Runnable;)V",
|
||||||
|
remap = false
|
||||||
|
)
|
||||||
|
)
|
||||||
|
public void addMainPass(
|
||||||
|
CallbackInfo ci)
|
||||||
|
{
|
||||||
|
// only crash during development
|
||||||
|
if (ModInfo.IS_DEV_BUILD)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ClientApi.RENDER_STATE.canRenderOrThrow();
|
||||||
|
}
|
||||||
|
catch (IllegalStateException e)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClientApi.INSTANCE.renderLods();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user