update 26.2 snapshot 5 -> 7
This commit is contained in:
+9
-10
@@ -29,6 +29,7 @@ import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
|
||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
|
||||
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
||||
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||
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.util.BlazePostProcessUtil;
|
||||
@@ -353,21 +354,19 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
|
||||
|
||||
private void renderFogToTexture()
|
||||
{
|
||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
||||
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||
this::getRenderPassName,
|
||||
this.fogColorTextureWrapper.textureView,
|
||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||
this.fogDepthTextureWrapper.textureView,
|
||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
||||
this.fogColorTextureWrapper,
|
||||
this.fogDepthTextureWrapper))
|
||||
{
|
||||
renderPass.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureSampler);
|
||||
renderPassWrapper.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper);
|
||||
|
||||
renderPass.setUniform("fragUniformBlock", this.fragUniformBuffer);
|
||||
renderPassWrapper.renderPass.setUniform("fragUniformBlock", this.fragUniformBuffer);
|
||||
|
||||
renderPass.setVertexBuffer(0, this.vboGpuBuffer); // vertex buffer can only be "0" lol
|
||||
renderPass.setPipeline(this.pipeline);
|
||||
renderPassWrapper.setVertexBuffer(this.vboGpuBuffer); // vertex buffer can only be "0" lol
|
||||
renderPassWrapper.renderPass.setPipeline(this.pipeline);
|
||||
|
||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 4);
|
||||
renderPassWrapper.draw(/*indexCount*/ 4);
|
||||
}
|
||||
}
|
||||
private String getRenderPassName() { return "distantHorizons:McFogRenderer"; }
|
||||
|
||||
+9
-10
@@ -26,6 +26,7 @@ public class BlazeDhSsaoRenderer {}
|
||||
|
||||
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
||||
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||
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.util.BlazePostProcessUtil;
|
||||
@@ -277,21 +278,19 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
||||
|
||||
private void renderSsaoToTexture()
|
||||
{
|
||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
||||
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||
this::getRenderPassName,
|
||||
this.ssaoColorTextureWrapper.textureView,
|
||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||
this.ssaoDepthTextureWrapper.textureView,
|
||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
||||
this.ssaoColorTextureWrapper,
|
||||
this.ssaoDepthTextureWrapper))
|
||||
{
|
||||
renderPass.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureSampler);
|
||||
renderPassWrapper.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper);
|
||||
|
||||
renderPass.setUniform("fragUniformBlock", this.fragUniformBuffer);
|
||||
renderPassWrapper.renderPass.setUniform("fragUniformBlock", this.fragUniformBuffer);
|
||||
|
||||
renderPass.setVertexBuffer(0, this.vboGpuBuffer); // vertex buffer can only be "0" lol
|
||||
renderPassWrapper.setVertexBuffer(this.vboGpuBuffer);
|
||||
|
||||
renderPass.setPipeline(this.pipeline);
|
||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 4);
|
||||
renderPassWrapper.renderPass.setPipeline(this.pipeline);
|
||||
renderPassWrapper.draw(4);
|
||||
}
|
||||
}
|
||||
private String getRenderPassName() { return "distantHorizons:McSsaoRenderer"; }
|
||||
|
||||
+13
-13
@@ -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.util.BlazePostProcessUtil;
|
||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||
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.BlazeTextureWrapper;
|
||||
@@ -80,6 +81,7 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
||||
|
||||
public static final BlazeVanillaFadeRenderer INSTANCE = new BlazeVanillaFadeRenderer();
|
||||
|
||||
|
||||
private RenderPipeline pipeline;
|
||||
private boolean init = false;
|
||||
|
||||
@@ -240,25 +242,23 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
||||
|
||||
private void renderFadeToTexture()
|
||||
{
|
||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
||||
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||
this::getRenderPassName,
|
||||
this.fadeColorTextureWrapper.textureView,
|
||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||
this.fadeDepthTextureWrapper.textureView,
|
||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
||||
this.fadeColorTextureWrapper,
|
||||
this.fadeDepthTextureWrapper))
|
||||
{
|
||||
renderPass.bindTexture("uMcDepthTexture", this.mcDepthTextureWrapper.textureView, this.mcDepthTextureWrapper.textureSampler);
|
||||
renderPass.bindTexture("uCombinedMcDhColorTexture", this.mcColorTextureWrapper.textureView, this.mcColorTextureWrapper.textureSampler);
|
||||
renderPassWrapper.bindTexture("uMcDepthTexture", this.mcDepthTextureWrapper);
|
||||
renderPassWrapper.bindTexture("uCombinedMcDhColorTexture", this.mcColorTextureWrapper);
|
||||
|
||||
renderPass.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureSampler);
|
||||
renderPass.bindTexture("uDhColorTexture", BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureSampler);
|
||||
renderPassWrapper.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper);
|
||||
renderPassWrapper.bindTexture("uDhColorTexture", BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper);
|
||||
|
||||
renderPass.setUniform("fragUniformBlock", this.fragUniformBuffer);
|
||||
renderPassWrapper.renderPass.setUniform("fragUniformBlock", this.fragUniformBuffer);
|
||||
|
||||
renderPass.setVertexBuffer(0, this.vboGpuBuffer); // vertex buffer can only be "0" lol
|
||||
renderPassWrapper.setVertexBuffer(this.vboGpuBuffer);
|
||||
|
||||
renderPass.setPipeline(this.pipeline);
|
||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 4);
|
||||
renderPassWrapper.renderPass.setPipeline(this.pipeline);
|
||||
renderPassWrapper.draw(/*indexCount*/ 4);
|
||||
}
|
||||
}
|
||||
private String getRenderPassName() { return "distantHorizons:McFadeRenderer"; }
|
||||
|
||||
+9
-9
@@ -35,6 +35,8 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.textures.*;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.BlazeVertexFormatBuilder;
|
||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||
@@ -107,7 +109,7 @@ public class BlazeDhTestTriangleRenderer implements IDhTestTriangleRenderer
|
||||
pipelineBuilder.withVertexShader("test/blaze/vert");
|
||||
pipelineBuilder.withFragmentShader("test/blaze/frag");
|
||||
|
||||
VertexFormat vertexFormat = VertexFormat.builder()
|
||||
VertexFormat vertexFormat = new BlazeVertexFormatBuilder()
|
||||
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
|
||||
.add("vColor", BlazeDhVertexFormatUtil.RGBA_FLOAT_COLOR)
|
||||
.build();
|
||||
@@ -168,16 +170,14 @@ public class BlazeDhTestTriangleRenderer implements IDhTestTriangleRenderer
|
||||
this.mcColorTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getColorTexture());
|
||||
this.mcDepthTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getDepthTexture());
|
||||
|
||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
||||
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||
this::getRenderPassName,
|
||||
this.mcColorTextureViewWrapper.textureView,
|
||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||
this.mcDepthTextureViewWrapper.textureView,
|
||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
||||
this.mcColorTextureViewWrapper,
|
||||
this.mcDepthTextureViewWrapper))
|
||||
{
|
||||
renderPass.setVertexBuffer(0, this.vboGpuBuffer);
|
||||
renderPass.setPipeline(this.pipeline);
|
||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 3);
|
||||
renderPassWrapper.setVertexBuffer(this.vboGpuBuffer);
|
||||
renderPassWrapper.renderPass.setPipeline(this.pipeline);
|
||||
renderPassWrapper.draw(3);
|
||||
}
|
||||
}
|
||||
private String getRenderPassName() { return "distantHorizons:DhTestRenderer"; }
|
||||
|
||||
+19
-2
@@ -4,7 +4,7 @@ package com.seibel.distanthorizons.common.render.blaze.util;
|
||||
public class BlazeDhVertexFormatUtil {}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
@@ -88,7 +88,7 @@ public class BlazeDhVertexFormatUtil
|
||||
IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, VertexFormatElement.Type.BYTE, false, /*count*/ 1);
|
||||
|
||||
FLOAT_XYZ_POS = VertexFormatElement.register(/*id*/30, /*index*/0, VertexFormatElement.Type.FLOAT, false, /*count*/ 3);
|
||||
#else
|
||||
#elif MC_VER <= MC_26_1_2
|
||||
|
||||
SCREEN_POS = VertexFormatElement.register(/*id*/22, /*index*/0, GpuFormat.RG32_FLOAT); // 2 floats
|
||||
RGBA_FLOAT_COLOR = VertexFormatElement.register(/*id*/23, /*index*/0, GpuFormat.RGBA32_FLOAT); // 4 floats
|
||||
@@ -102,6 +102,21 @@ public class BlazeDhVertexFormatUtil
|
||||
IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, GpuFormat.R8_UINT); // 1 byte
|
||||
|
||||
FLOAT_XYZ_POS = VertexFormatElement.register(/*id*/30, /*index*/0, GpuFormat.RGB32_FLOAT); // 3 floats
|
||||
|
||||
#else
|
||||
|
||||
SCREEN_POS = new VertexFormatElement("Screen Pos", Float.BYTES * 2, GpuFormat.RG32_FLOAT);
|
||||
RGBA_FLOAT_COLOR = new VertexFormatElement("RGBA Float Color", Float.BYTES * 4, GpuFormat.RGBA32_FLOAT);
|
||||
|
||||
SHORT_XYZ_POS = new VertexFormatElement("Short XYZ Pos", Short.BYTES * 3, GpuFormat.RGB16_UINT);
|
||||
BYTE_PAD = new VertexFormatElement("Byte Pad", 1, GpuFormat.R8_UINT);
|
||||
|
||||
META = new VertexFormatElement("DH Meta", Short.BYTES, GpuFormat.R16_UINT);
|
||||
RGBA_UBYTE_COLOR = new VertexFormatElement("Rgba Ubyte Color", 4, GpuFormat.RGBA8_UNORM);
|
||||
IRIS_MATERIAL = new VertexFormatElement("Iris Material", 1, GpuFormat.R8_UINT);
|
||||
IRIS_NORMAL = new VertexFormatElement("Iris Normal", 1, GpuFormat.R8_UINT);
|
||||
|
||||
FLOAT_XYZ_POS = new VertexFormatElement("Float XYZ Pos", Float.BYTES * 3, GpuFormat.RGB32_FLOAT);
|
||||
#endif
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -137,5 +152,7 @@ public class BlazeDhVertexFormatUtil
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
+2
-1
@@ -11,6 +11,7 @@ import com.mojang.blaze3d.systems.CommandEncoder;
|
||||
import com.mojang.blaze3d.systems.GpuDevice;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.BlazeVertexFormatBuilder;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
@@ -67,7 +68,7 @@ public class BlazePostProcessUtil
|
||||
|
||||
public static VertexFormat createVertexFormat()
|
||||
{
|
||||
VertexFormat vertexFormat = VertexFormat.builder()
|
||||
VertexFormat vertexFormat = new BlazeVertexFormatBuilder()
|
||||
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
|
||||
.build();
|
||||
return vertexFormat;
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.seibel.distanthorizons.common.render.blaze.wrappers;
|
||||
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||
|
||||
public class BlazeVertexFormatBuilder
|
||||
{
|
||||
private final VertexFormat.Builder builder;
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
//region
|
||||
|
||||
public BlazeVertexFormatBuilder()
|
||||
{
|
||||
#if MC_VER <= MC_26_1_2
|
||||
this.builder = VertexFormat.builder();
|
||||
#else
|
||||
this.builder = VertexFormat.builder(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//==========//
|
||||
// building //
|
||||
//==========//
|
||||
//region
|
||||
|
||||
public BlazeVertexFormatBuilder add(String name, VertexFormatElement element)
|
||||
{
|
||||
#if MC_VER <= MC_26_1_2
|
||||
this.builder.add(name, element);
|
||||
#else
|
||||
this.builder.addAttribute(name, element.format());
|
||||
#endif
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public VertexFormat build() { return this.builder.build(); }
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
package com.seibel.distanthorizons.common.render.blaze.wrappers;
|
||||
|
||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||
import com.mojang.blaze3d.systems.GpuDevice;
|
||||
import com.mojang.blaze3d.systems.RenderPass;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.IDhBlazeTexture;
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalDouble;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
#if MC_VER <= MC_26_1_2
|
||||
#else
|
||||
import com.mojang.blaze3d.IndexType;
|
||||
#endif
|
||||
|
||||
public class RenderPassWrapper implements AutoCloseable
|
||||
{
|
||||
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||
|
||||
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
||||
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
||||
|
||||
|
||||
public final RenderPass renderPass;
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
//region
|
||||
|
||||
public RenderPassWrapper(
|
||||
final Supplier<String> nameGetterFunc,
|
||||
final IDhBlazeTexture colorTexture,
|
||||
final IDhBlazeTexture depthTexture)
|
||||
{
|
||||
#if MC_VER <= MC_26_1_2
|
||||
this.renderPass = COMMAND_ENCODER.createRenderPass(
|
||||
nameGetterFunc,
|
||||
colorTexture.getTextureView(),
|
||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||
depthTexture.getTextureView(),
|
||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty());
|
||||
#else
|
||||
this.renderPass = COMMAND_ENCODER.createRenderPass(
|
||||
nameGetterFunc,
|
||||
colorTexture.getTextureView(),
|
||||
/*clearColor*/ Optional.empty(),
|
||||
depthTexture.getTextureView(),
|
||||
/*clearDepth*/ OptionalDouble.empty());
|
||||
#endif
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//=======//
|
||||
// setup //
|
||||
//=======//
|
||||
//region
|
||||
|
||||
public void bindTexture(
|
||||
final String name,
|
||||
final IDhBlazeTexture textureView)
|
||||
{
|
||||
this.renderPass.bindTexture(
|
||||
name,
|
||||
textureView.getTextureView(),
|
||||
textureView.getTextureSampler());
|
||||
}
|
||||
|
||||
public void setVertexBuffer(GpuBuffer buffer)
|
||||
{
|
||||
#if MC_VER <= MC_26_1_2
|
||||
this.renderPass.setVertexBuffer(/*slot*/0, buffer);
|
||||
#else
|
||||
this.renderPass.setVertexBuffer(/*slot*/0, buffer.slice());
|
||||
#endif
|
||||
}
|
||||
|
||||
public void setIndexBuffer(GpuBuffer buffer)
|
||||
{
|
||||
#if MC_VER <= MC_26_1_2
|
||||
this.renderPass.setIndexBuffer(buffer, VertexFormat.IndexType.INT);
|
||||
#else
|
||||
this.renderPass.setIndexBuffer(buffer, IndexType.INT);
|
||||
#endif
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//===========//
|
||||
// rendering //
|
||||
//===========//
|
||||
//region
|
||||
|
||||
public void draw(int vertexCount)
|
||||
{
|
||||
#if MC_VER <= MC_26_1_2
|
||||
this.renderPass.draw(0, vertexCount);
|
||||
#else
|
||||
this.renderPass.draw(vertexCount, /*instanceCount*/1, /*firstVertex*/0, /*firstInstance*/0);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void drawIndexed(int indexCount)
|
||||
{
|
||||
#if MC_VER <= MC_26_1_2
|
||||
this.renderPass.drawIndexed(
|
||||
/*indexStart*/ 0,
|
||||
/*firstIndex*/0,
|
||||
indexCount,
|
||||
/*instanceCount*/1);
|
||||
#else
|
||||
this.renderPass.drawIndexed(
|
||||
indexCount,
|
||||
/*instanceCount*/1,
|
||||
/*firstVertex*/0,
|
||||
/*vertexOffset*/0,
|
||||
/*firstInstance*/0);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// base overrides //
|
||||
//================//
|
||||
//region
|
||||
|
||||
@Override
|
||||
public void close() { this.renderPass.close(); }
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
+38
@@ -14,8 +14,12 @@ import net.minecraft.resources.Identifier;
|
||||
|
||||
#if MC_VER <= MC_1_21_11
|
||||
import com.mojang.blaze3d.platform.DepthTestFunction;
|
||||
#elif MC_VER <= MC_26_1_2
|
||||
import com.mojang.blaze3d.platform.CompareOp;
|
||||
#else
|
||||
import com.mojang.blaze3d.platform.CompareOp;
|
||||
import com.mojang.blaze3d.GpuFormat;
|
||||
import com.mojang.blaze3d.PrimitiveTopology;
|
||||
#endif
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -262,12 +266,22 @@ public class RenderPipelineBuilderWrapper
|
||||
}
|
||||
this.blazePipelineBuilder.withDepthStencilState(new DepthStencilState(compareOp, this.writeDepth));
|
||||
|
||||
#if MC_VER <= MC_26_1_2
|
||||
this.blazePipelineBuilder.withColorTargetState(
|
||||
new ColorTargetState(
|
||||
Optional.ofNullable(this.blendFunction),
|
||||
this.writeColor ? ColorTargetState.WRITE_ALL : ColorTargetState.WRITE_NONE
|
||||
)
|
||||
);
|
||||
#else
|
||||
this.blazePipelineBuilder.withColorTargetState(
|
||||
new ColorTargetState(
|
||||
Optional.ofNullable(this.blendFunction),
|
||||
GpuFormat.RGBA8_UNORM,
|
||||
this.writeColor ? ColorTargetState.WRITE_ALL : ColorTargetState.WRITE_NONE
|
||||
)
|
||||
);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -275,6 +289,7 @@ public class RenderPipelineBuilderWrapper
|
||||
|
||||
// vertex format
|
||||
{
|
||||
#if MC_VER <= MC_26_1_2
|
||||
VertexFormat.Mode blazeVertexMode;
|
||||
switch (this.vertexMode)
|
||||
{
|
||||
@@ -293,6 +308,29 @@ public class RenderPipelineBuilderWrapper
|
||||
}
|
||||
|
||||
this.blazePipelineBuilder.withVertexFormat(vertexFormat, blazeVertexMode);
|
||||
#else
|
||||
|
||||
PrimitiveTopology primitiveTopology;
|
||||
switch (this.vertexMode)
|
||||
{
|
||||
case TRIANGLES:
|
||||
primitiveTopology = PrimitiveTopology.TRIANGLES;
|
||||
break;
|
||||
case TRIANGLE_FAN:
|
||||
primitiveTopology = PrimitiveTopology.TRIANGLE_FAN;
|
||||
break;
|
||||
case LINES:
|
||||
primitiveTopology = PrimitiveTopology.DEBUG_LINES;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnsupportedOperationException("No PrimitiveTopology defined for type ["+this.vertexMode+"].");
|
||||
}
|
||||
|
||||
this.blazePipelineBuilder.withVertexBinding(0, vertexFormat);
|
||||
this.blazePipelineBuilder.withPrimitiveTopology(primitiveTopology);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-3
@@ -14,7 +14,7 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
|
||||
import java.util.OptionalDouble;
|
||||
|
||||
public class BlazeTextureViewWrapper
|
||||
public class BlazeTextureViewWrapper implements IDhBlazeTexture
|
||||
{
|
||||
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||
|
||||
@@ -22,8 +22,11 @@ public class BlazeTextureViewWrapper
|
||||
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
||||
|
||||
|
||||
public GpuTextureView textureView = null;
|
||||
public GpuSampler textureSampler = null;
|
||||
private GpuTextureView textureView = null;
|
||||
public GpuTextureView getTextureView() { return this.textureView; }
|
||||
|
||||
private GpuSampler textureSampler = null;
|
||||
public GpuSampler getTextureSampler() { return this.textureSampler; }
|
||||
|
||||
|
||||
|
||||
|
||||
+20
-3
@@ -22,9 +22,10 @@ import com.mojang.blaze3d.textures.*;
|
||||
|
||||
#else
|
||||
import com.mojang.blaze3d.GpuFormat;
|
||||
import org.joml.Vector4f;
|
||||
#endif
|
||||
|
||||
public class BlazeTextureWrapper
|
||||
public class BlazeTextureWrapper implements IDhBlazeTexture
|
||||
{
|
||||
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||
|
||||
@@ -42,8 +43,13 @@ public class BlazeTextureWrapper
|
||||
#endif
|
||||
|
||||
public GpuTexture texture = null;
|
||||
public GpuTextureView textureView = null;
|
||||
public GpuSampler textureSampler = null;
|
||||
|
||||
private GpuTextureView textureView = null;
|
||||
public GpuTextureView getTextureView() { return this.textureView; }
|
||||
|
||||
private GpuSampler textureSampler = null;
|
||||
public GpuSampler getTextureSampler() { return this.textureSampler; }
|
||||
|
||||
|
||||
private int width = -1;
|
||||
private int height = -1;
|
||||
@@ -185,7 +191,18 @@ public class BlazeTextureWrapper
|
||||
{
|
||||
if (this.texture != null)
|
||||
{
|
||||
#if MC_VER <= MC_26_1_2
|
||||
COMMAND_ENCODER.clearColorTexture(this.texture, clearArgbColor);
|
||||
#else
|
||||
Vector4f clearColor = new Vector4f(
|
||||
// color values should be between 0.0 and 1.0
|
||||
ColorUtil.getRed(clearArgbColor) / 255.0f,
|
||||
ColorUtil.getGreen(clearArgbColor) / 255.0f,
|
||||
ColorUtil.getBlue(clearArgbColor) / 255.0f,
|
||||
ColorUtil.getAlpha(clearArgbColor) / 255.0f
|
||||
);
|
||||
COMMAND_ENCODER.clearColorTexture(this.texture, clearColor);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.seibel.distanthorizons.common.render.blaze.wrappers.texture;
|
||||
|
||||
import com.mojang.blaze3d.textures.GpuSampler;
|
||||
import com.mojang.blaze3d.textures.GpuTextureView;
|
||||
|
||||
public interface IDhBlazeTexture
|
||||
{
|
||||
|
||||
GpuTextureView getTextureView();
|
||||
GpuSampler getTextureSampler();
|
||||
|
||||
}
|
||||
+6
-2
@@ -157,8 +157,10 @@ public class MinecraftGLWrapper
|
||||
GL32.glEnable(GL32.GL_BLEND);
|
||||
#if MC_VER <= MC_1_12_2
|
||||
GlStateManager.enableBlend();
|
||||
#else
|
||||
#elif MC_VER <= MC_26_1_2
|
||||
GlStateManager._enableBlend();
|
||||
#else
|
||||
GlStateManager._enableBlend(0);
|
||||
#endif
|
||||
}
|
||||
/** @see GL32#GL_BLEND */
|
||||
@@ -167,8 +169,10 @@ public class MinecraftGLWrapper
|
||||
GL32.glDisable(GL32.GL_BLEND);
|
||||
#if MC_VER <= MC_1_12_2
|
||||
GlStateManager.disableBlend();
|
||||
#elif MC_VER <= MC_26_1_2
|
||||
GlStateManager._disableBlend();
|
||||
#else
|
||||
GlStateManager._disableBlend();
|
||||
GlStateManager._disableBlend(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -456,8 +456,8 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
.backendName();
|
||||
boolean isVulkan = backendName.equalsIgnoreCase("Vulkan");
|
||||
this.renderApi = isVulkan ? EDhRenderApi.VULKAN : EDhRenderApi.OPEN_GL;
|
||||
return this.renderApi;
|
||||
#endif
|
||||
return this.renderApi;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user