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.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.RenderPassWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
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;
|
||||||
@@ -353,21 +354,19 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
|
|||||||
|
|
||||||
private void renderFogToTexture()
|
private void renderFogToTexture()
|
||||||
{
|
{
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
this.fogColorTextureWrapper.textureView,
|
this.fogColorTextureWrapper,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
this.fogDepthTextureWrapper))
|
||||||
this.fogDepthTextureWrapper.textureView,
|
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
|
||||||
{
|
{
|
||||||
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); // vertex buffer can only be "0" lol
|
||||||
renderPass.setPipeline(this.pipeline);
|
renderPassWrapper.renderPass.setPipeline(this.pipeline);
|
||||||
|
|
||||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 4);
|
renderPassWrapper.draw(/*indexCount*/ 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String getRenderPassName() { return "distantHorizons:McFogRenderer"; }
|
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.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.RenderPassWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
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;
|
||||||
@@ -277,21 +278,19 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
|||||||
|
|
||||||
private void renderSsaoToTexture()
|
private void renderSsaoToTexture()
|
||||||
{
|
{
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
this.ssaoColorTextureWrapper.textureView,
|
this.ssaoColorTextureWrapper,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
this.ssaoDepthTextureWrapper))
|
||||||
this.ssaoDepthTextureWrapper.textureView,
|
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
|
||||||
{
|
{
|
||||||
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);
|
renderPassWrapper.renderPass.setPipeline(this.pipeline);
|
||||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 4);
|
renderPassWrapper.draw(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String getRenderPassName() { return "distantHorizons:McSsaoRenderer"; }
|
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.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.RenderPassWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
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;
|
||||||
@@ -80,6 +81,7 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
|
|
||||||
public static final BlazeVanillaFadeRenderer INSTANCE = new BlazeVanillaFadeRenderer();
|
public static final BlazeVanillaFadeRenderer INSTANCE = new BlazeVanillaFadeRenderer();
|
||||||
|
|
||||||
|
|
||||||
private RenderPipeline pipeline;
|
private RenderPipeline pipeline;
|
||||||
private boolean init = false;
|
private boolean init = false;
|
||||||
|
|
||||||
@@ -240,25 +242,23 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
|
|
||||||
private void renderFadeToTexture()
|
private void renderFadeToTexture()
|
||||||
{
|
{
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
this.fadeColorTextureWrapper.textureView,
|
this.fadeColorTextureWrapper,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
this.fadeDepthTextureWrapper))
|
||||||
this.fadeDepthTextureWrapper.textureView,
|
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
|
||||||
{
|
{
|
||||||
renderPass.bindTexture("uMcDepthTexture", this.mcDepthTextureWrapper.textureView, this.mcDepthTextureWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uMcDepthTexture", this.mcDepthTextureWrapper);
|
||||||
renderPass.bindTexture("uCombinedMcDhColorTexture", this.mcColorTextureWrapper.textureView, this.mcColorTextureWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uCombinedMcDhColorTexture", this.mcColorTextureWrapper);
|
||||||
|
|
||||||
renderPass.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper);
|
||||||
renderPass.bindTexture("uDhColorTexture", BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureSampler);
|
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);
|
renderPassWrapper.renderPass.setPipeline(this.pipeline);
|
||||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 4);
|
renderPassWrapper.draw(/*indexCount*/ 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String getRenderPassName() { return "distantHorizons:McFadeRenderer"; }
|
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.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.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.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.wrappers.minecraft.MinecraftRenderWrapper;
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
@@ -107,7 +109,7 @@ public class BlazeDhTestTriangleRenderer implements IDhTestTriangleRenderer
|
|||||||
pipelineBuilder.withVertexShader("test/blaze/vert");
|
pipelineBuilder.withVertexShader("test/blaze/vert");
|
||||||
pipelineBuilder.withFragmentShader("test/blaze/frag");
|
pipelineBuilder.withFragmentShader("test/blaze/frag");
|
||||||
|
|
||||||
VertexFormat vertexFormat = VertexFormat.builder()
|
VertexFormat vertexFormat = new BlazeVertexFormatBuilder()
|
||||||
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
|
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
|
||||||
.add("vColor", BlazeDhVertexFormatUtil.RGBA_FLOAT_COLOR)
|
.add("vColor", BlazeDhVertexFormatUtil.RGBA_FLOAT_COLOR)
|
||||||
.build();
|
.build();
|
||||||
@@ -168,16 +170,14 @@ public class BlazeDhTestTriangleRenderer implements IDhTestTriangleRenderer
|
|||||||
this.mcColorTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getColorTexture());
|
this.mcColorTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getColorTexture());
|
||||||
this.mcDepthTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getDepthTexture());
|
this.mcDepthTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getDepthTexture());
|
||||||
|
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
this.mcColorTextureViewWrapper.textureView,
|
this.mcColorTextureViewWrapper,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
this.mcDepthTextureViewWrapper))
|
||||||
this.mcDepthTextureViewWrapper.textureView,
|
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
|
||||||
{
|
{
|
||||||
renderPass.setVertexBuffer(0, this.vboGpuBuffer);
|
renderPassWrapper.setVertexBuffer(this.vboGpuBuffer);
|
||||||
renderPass.setPipeline(this.pipeline);
|
renderPassWrapper.renderPass.setPipeline(this.pipeline);
|
||||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 3);
|
renderPassWrapper.draw(3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String getRenderPassName() { return "distantHorizons:DhTestRenderer"; }
|
private String getRenderPassName() { return "distantHorizons:DhTestRenderer"; }
|
||||||
|
|||||||
+19
-2
@@ -4,7 +4,7 @@ package com.seibel.distanthorizons.common.render.blaze.util;
|
|||||||
public class BlazeDhVertexFormatUtil {}
|
public class BlazeDhVertexFormatUtil {}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
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);
|
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);
|
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
|
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
|
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
|
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
|
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
|
#endif
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -137,5 +152,7 @@ public class BlazeDhVertexFormatUtil
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
+2
-1
@@ -11,6 +11,7 @@ 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.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.BlazeVertexFormatBuilder;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
@@ -67,7 +68,7 @@ public class BlazePostProcessUtil
|
|||||||
|
|
||||||
public static VertexFormat createVertexFormat()
|
public static VertexFormat createVertexFormat()
|
||||||
{
|
{
|
||||||
VertexFormat vertexFormat = VertexFormat.builder()
|
VertexFormat vertexFormat = new BlazeVertexFormatBuilder()
|
||||||
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
|
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
|
||||||
.build();
|
.build();
|
||||||
return vertexFormat;
|
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
|
#if MC_VER <= MC_1_21_11
|
||||||
import com.mojang.blaze3d.platform.DepthTestFunction;
|
import com.mojang.blaze3d.platform.DepthTestFunction;
|
||||||
|
#elif MC_VER <= MC_26_1_2
|
||||||
|
import com.mojang.blaze3d.platform.CompareOp;
|
||||||
#else
|
#else
|
||||||
import com.mojang.blaze3d.platform.CompareOp;
|
import com.mojang.blaze3d.platform.CompareOp;
|
||||||
|
import com.mojang.blaze3d.GpuFormat;
|
||||||
|
import com.mojang.blaze3d.PrimitiveTopology;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -262,12 +266,22 @@ public class RenderPipelineBuilderWrapper
|
|||||||
}
|
}
|
||||||
this.blazePipelineBuilder.withDepthStencilState(new DepthStencilState(compareOp, this.writeDepth));
|
this.blazePipelineBuilder.withDepthStencilState(new DepthStencilState(compareOp, this.writeDepth));
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
this.blazePipelineBuilder.withColorTargetState(
|
this.blazePipelineBuilder.withColorTargetState(
|
||||||
new ColorTargetState(
|
new ColorTargetState(
|
||||||
Optional.ofNullable(this.blendFunction),
|
Optional.ofNullable(this.blendFunction),
|
||||||
this.writeColor ? ColorTargetState.WRITE_ALL : ColorTargetState.WRITE_NONE
|
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
|
#endif
|
||||||
}
|
}
|
||||||
@@ -275,6 +289,7 @@ public class RenderPipelineBuilderWrapper
|
|||||||
|
|
||||||
// vertex format
|
// vertex format
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
VertexFormat.Mode blazeVertexMode;
|
VertexFormat.Mode blazeVertexMode;
|
||||||
switch (this.vertexMode)
|
switch (this.vertexMode)
|
||||||
{
|
{
|
||||||
@@ -293,6 +308,29 @@ public class RenderPipelineBuilderWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.blazePipelineBuilder.withVertexFormat(vertexFormat, blazeVertexMode);
|
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;
|
import java.util.OptionalDouble;
|
||||||
|
|
||||||
public class BlazeTextureViewWrapper
|
public class BlazeTextureViewWrapper implements IDhBlazeTexture
|
||||||
{
|
{
|
||||||
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
@@ -22,8 +22,11 @@ public class BlazeTextureViewWrapper
|
|||||||
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
||||||
|
|
||||||
|
|
||||||
public GpuTextureView textureView = null;
|
private GpuTextureView textureView = null;
|
||||||
public GpuSampler textureSampler = 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
|
#else
|
||||||
import com.mojang.blaze3d.GpuFormat;
|
import com.mojang.blaze3d.GpuFormat;
|
||||||
|
import org.joml.Vector4f;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public class BlazeTextureWrapper
|
public class BlazeTextureWrapper implements IDhBlazeTexture
|
||||||
{
|
{
|
||||||
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
@@ -42,8 +43,13 @@ public class BlazeTextureWrapper
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
public GpuTexture texture = null;
|
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 width = -1;
|
||||||
private int height = -1;
|
private int height = -1;
|
||||||
@@ -185,7 +191,18 @@ public class BlazeTextureWrapper
|
|||||||
{
|
{
|
||||||
if (this.texture != null)
|
if (this.texture != null)
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
COMMAND_ENCODER.clearColorTexture(this.texture, clearArgbColor);
|
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);
|
GL32.glEnable(GL32.GL_BLEND);
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
GlStateManager._enableBlend();
|
GlStateManager._enableBlend();
|
||||||
|
#else
|
||||||
|
GlStateManager._enableBlend(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/** @see GL32#GL_BLEND */
|
/** @see GL32#GL_BLEND */
|
||||||
@@ -167,8 +169,10 @@ public class MinecraftGLWrapper
|
|||||||
GL32.glDisable(GL32.GL_BLEND);
|
GL32.glDisable(GL32.GL_BLEND);
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
|
#elif MC_VER <= MC_26_1_2
|
||||||
|
GlStateManager._disableBlend();
|
||||||
#else
|
#else
|
||||||
GlStateManager._disableBlend();
|
GlStateManager._disableBlend(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -456,8 +456,8 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
.backendName();
|
.backendName();
|
||||||
boolean isVulkan = backendName.equalsIgnoreCase("Vulkan");
|
boolean isVulkan = backendName.equalsIgnoreCase("Vulkan");
|
||||||
this.renderApi = isVulkan ? EDhRenderApi.VULKAN : EDhRenderApi.OPEN_GL;
|
this.renderApi = isVulkan ? EDhRenderApi.VULKAN : EDhRenderApi.OPEN_GL;
|
||||||
return this.renderApi;
|
|
||||||
#endif
|
#endif
|
||||||
|
return this.renderApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
Submodule coreSubProjects updated: 51b52a7d2a...9465512491
@@ -1,9 +1,10 @@
|
|||||||
# 26.2.0 version
|
# 26.2.0 version
|
||||||
java_version=25
|
java_version=25
|
||||||
minecraft_version=26.2-snapshot-5
|
minecraft_version=26.2-snapshot-7
|
||||||
parchment_version=1.21:2024.07.28
|
parchment_version=1.21:2024.07.28
|
||||||
# version range should be used instead of individual versions due to how NeoForge handles version loading
|
# version range should be used instead of individual versions due to how NeoForge handles version loading
|
||||||
compatible_minecraft_versions=["26.2.0","26.2-alpha.5"]
|
# TODO this isn't currently a version range for fabric, it's just 2 versions
|
||||||
|
compatible_minecraft_versions=["26.2.0","26.2-alpha.7"]
|
||||||
accessWidenerVersion=26_1
|
accessWidenerVersion=26_1
|
||||||
builds_for=fabric
|
builds_for=fabric
|
||||||
#,neoforge
|
#,neoforge
|
||||||
@@ -17,7 +18,7 @@ lwjgl_version=3.4.1
|
|||||||
|
|
||||||
# Fabric loader
|
# Fabric loader
|
||||||
fabric_loader_version=0.18.5
|
fabric_loader_version=0.18.5
|
||||||
fabric_api_version=0.147.1+26.2
|
fabric_api_version=0.149.0+26.2
|
||||||
modmenu_version=
|
modmenu_version=
|
||||||
starlight_version_fabric=
|
starlight_version_fabric=
|
||||||
phosphor_version_fabric=
|
phosphor_version_fabric=
|
||||||
|
|||||||
Reference in New Issue
Block a user