diff --git a/build.gradle.kts b/build.gradle.kts index a8fcf84..d2e8c77 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ plugins { allprojects { group = "org.enginehub.worldeditcui" - version = "${rootProject.libs.versions.minecraft.get()}+04+SNAPSHOT" + version = "${rootProject.libs.versions.minecraft.get()}+01+SNAPSHOT" repositories { mavenCentral { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7d91234..ada706b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,11 +3,11 @@ format = { version = "1.1" } [versions] indra = "3.1.3" -minecraft = "26.2" -fabricLoader = "0.19.3" -fabricApi = "0.156.0+26.2" +minecraft = "26.3" +fabricLoader = "0.19.5" +fabricApi = "0.161.0+26.3" modmenu = "20.0.0-beta.2" -iris = "1.11.2+26.2-fabric" +iris = "1.11.6+26.3-fabric" viafabricplus = "4.5.1" vineflower = "1.11.2" cuiProtocol = "4.0.3" @@ -40,13 +40,13 @@ spotless = { id = "com.diffplug.spotless", version = "6.25.0" } versions = { id = "com.github.ben-manes.versions", version = "0.51.0" } [libraries.cuiProtocol-common] -module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-common-mc26.2" +module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-common-mc26.3" version.ref = "cuiProtocol" [libraries.cuiProtocol-fabric] -module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-fabric-mc26.2" +module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-fabric-mc26.3" version.ref = "cuiProtocol" [libraries.cuiProtocol-neoforge] -module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-neoforge-mc26.2" +module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-neoforge-mc26.3" version.ref = "cuiProtocol" diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/event/listeners/CUIListenerWorldRender.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/event/listeners/CUIListenerWorldRender.java index cf216ea..6c5d7ce 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/event/listeners/CUIListenerWorldRender.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/event/listeners/CUIListenerWorldRender.java @@ -9,9 +9,11 @@ */ package org.enginehub.worldeditcui.event.listeners; -import com.mojang.blaze3d.buffers.GpuBufferSlice; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.renderpearl.api.buffers.GpuBufferSlice; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.SubmitNodeCollector; import net.minecraft.client.renderer.fog.FogRenderer; import net.minecraft.util.profiling.Profiler; import net.minecraft.util.profiling.ProfilerFiller; @@ -19,8 +21,6 @@ import org.enginehub.worldeditcui.render.PipelineProvider; import org.enginehub.worldeditcui.render.RenderSink; import org.enginehub.worldeditcui.util.Vector3; -import org.joml.Matrix4fStack; - import java.util.HashSet; import java.util.List; import java.util.Set; @@ -93,7 +93,7 @@ private void invalidatePipeline() { this.sink = null; } - public void onRender(final float partialTicks) { + public void onRender(final float partialTicks, final SubmitNodeCollector collector, final PoseStack poseStack) { try { final RenderSink sink = this.providePipeline(); if (this.activePipeline != null && !this.activePipeline.shouldRender()) @@ -103,28 +103,33 @@ public void onRender(final float partialTicks) { } final ProfilerFiller profiler = Profiler.get(); profiler.push("worldeditcui"); - this.ctx.init( - new Vector3(this.minecraft.gameRenderer.mainCamera().position()), - partialTicks, - sink, - this.controller.getConfiguration().isHideObstructedLines() - ); final GpuBufferSlice fogStart = RenderSystem.getShaderFog(); - RenderSystem.setShaderFog(this.minecraft.gameRenderer.fogRenderer.getBuffer(FogRenderer.FogMode.NONE)); - final Matrix4fStack poseStack = RenderSystem.getModelViewStack(); - poseStack.pushMatrix(); - + boolean posePushed = false; try { + this.ctx.init( + new Vector3(this.minecraft.gameRenderer.mainCamera().position()), + partialTicks, + sink, + this.controller.getConfiguration().isHideObstructedLines(), + poseStack + ); + this.ctx.beginFrame(collector, poseStack); + RenderSystem.setShaderFog(this.minecraft.gameRenderer.fogRenderer.getBuffer(FogRenderer.FogMode.NONE)); + poseStack.pushPose(); + posePushed = true; this.controller.renderSelections(this.ctx); this.sink.flush(); } catch (final Exception e) { this.controller.getDebugger().error("Error while attempting to render WorldEdit CUI", e); this.invalidatePipeline(); + } finally { + if (posePushed) { + poseStack.popPose(); + } + RenderSystem.setShaderFog(fogStart); + this.ctx.reset(); + profiler.pop(); } - - poseStack.popMatrix(); - RenderSystem.setShaderFog(fogStart); - profiler.pop(); } catch (final Exception ex) { this.controller.getDebugger().error("Failed while preparing state for WorldEdit CUI", ex); diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/event/listeners/CUIRenderContext.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/event/listeners/CUIRenderContext.java index 9e05b73..bddbfd5 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/event/listeners/CUIRenderContext.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/event/listeners/CUIRenderContext.java @@ -9,13 +9,13 @@ */ package org.enginehub.worldeditcui.event.listeners; -import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.SubmitNodeCollector; import org.enginehub.worldeditcui.config.Colour; import org.enginehub.worldeditcui.render.LineStyle; import org.enginehub.worldeditcui.render.RenderSink; import org.enginehub.worldeditcui.render.RenderStyle; import org.enginehub.worldeditcui.util.Vector3; -import org.joml.Matrix4fStack; import java.util.function.Consumer; @@ -28,17 +28,14 @@ public final class CUIRenderContext implements RenderSink { private float dt; private RenderSink delegateSink; private boolean hideObstructedLines; + private PoseStack poseStack; public Vector3 cameraPos() { return this.cameraPos; } - public Matrix4fStack matrixStack() { - return RenderSystem.getModelViewStack(); - } - - public void applyMatrices() { - // RenderSystem.applyModelViewMatrix(); + public PoseStack poseStack() { + return this.poseStack; } public float dt() { @@ -55,11 +52,12 @@ public void withCameraAt(final Vector3 pos, final Consumer act } } - void init(final Vector3 cameraPos, final float dt, final RenderSink sink, final boolean hideObstructedLines) { + void init(final Vector3 cameraPos, final float dt, final RenderSink sink, final boolean hideObstructedLines, final PoseStack poseStack) { this.cameraPos = cameraPos; this.dt = dt; this.delegateSink = sink; this.hideObstructedLines = hideObstructedLines; + this.poseStack = poseStack; } /** @@ -69,10 +67,16 @@ void reset() { this.cameraPos = null; this.delegateSink = null; this.hideObstructedLines = false; + this.poseStack = null; } // RenderSink delegation + @Override + public void beginFrame(final SubmitNodeCollector collector, final PoseStack poseStack) { + this.delegateSink.beginFrame(collector, poseStack); + } + @Override public CUIRenderContext color(final float r, final float g, final float b, final float alpha) { this.delegateSink.color(r, g, b, alpha); diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/fabric/FabricModWorldEditCUI.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/fabric/FabricModWorldEditCUI.java index 2cf0679..bf05003 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/fabric/FabricModWorldEditCUI.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/fabric/FabricModWorldEditCUI.java @@ -9,7 +9,7 @@ */ package org.enginehub.worldeditcui.fabric; -import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.platform.InputConstants; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; @@ -34,7 +34,6 @@ import org.enginehub.worldeditcui.protocol.CUIPacketHandler; import org.enginehub.worldeditcui.render.PipelineProvider; import org.enginehub.worldeditcui.render.VanillaPipelineProvider; -import org.lwjgl.glfw.GLFW; import org.spongepowered.asm.mixin.MixinEnvironment; import java.util.List; @@ -53,9 +52,9 @@ public final class FabricModWorldEditCUI implements ModInitializer { private static final KeyMapping.Category KEYBIND_CATEGORY_WECUI = new KeyMapping.Category(Identifier.fromNamespaceAndPath(MOD_ID, "general")); - private final KeyMapping keyBindToggleUI = key("toggle", GLFW.GLFW_KEY_UNKNOWN); - private final KeyMapping keyBindClearSel = key("clear", GLFW.GLFW_KEY_UNKNOWN); - private final KeyMapping keyBindChunkBorder = key("chunk", GLFW.GLFW_KEY_UNKNOWN); + private final KeyMapping keyBindToggleUI = key("toggle", InputConstants.UNKNOWN.getValue()); + private final KeyMapping keyBindClearSel = key("clear", InputConstants.UNKNOWN.getValue()); + private final KeyMapping keyBindChunkBorder = key("chunk", InputConstants.UNKNOWN.getValue()); private static final List RENDER_PIPELINES = List.of( new VanillaPipelineProvider() @@ -104,15 +103,7 @@ public void onInitialize() { this.onEndExtraction(ctx); }); LevelRenderEvents.END_MAIN.register(ctx -> { - try { - RenderSystem.getModelViewStack().pushMatrix(); - RenderSystem.getModelViewStack().mul(ctx.poseStack().last().pose()); - // RenderSystem.applyModelViewMatrix(); - this.onPostRenderEntities(ctx); - } finally { - RenderSystem.getModelViewStack().popMatrix(); - // RenderSystem.applyModelViewMatrix(); - } + this.onPostRenderEntities(ctx); }); } @@ -191,7 +182,7 @@ private void onEndExtraction(final LevelExtractionContext ctx) { public void onPostRenderEntities(final LevelRenderContext ctx) { if (this.visible) { - this.worldRenderListener.onRender(lastPartialTicks); + this.worldRenderListener.onRender(lastPartialTicks, ctx.submitNodeCollector(), ctx.poseStack()); } } diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/BatchedRenderSink.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/BatchedRenderSink.java index 1836daa..f3c86d2 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/BatchedRenderSink.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/BatchedRenderSink.java @@ -9,13 +9,16 @@ */ package org.enginehub.worldeditcui.render; -import com.mojang.blaze3d.PrimitiveTopology; -import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.blaze3d.vertex.VertexFormat; -import net.minecraft.client.renderer.StagedVertexBuffer; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.renderpearl.api.vertex.VertexFormat; +import net.minecraft.client.renderer.SubmitNodeCollector; +import net.minecraft.client.renderer.rendertype.RenderType; import org.jetbrains.annotations.Nullable; import org.joml.Vector3f; +import java.util.ArrayList; +import java.util.List; + public final class BatchedRenderSink implements RenderSink { private enum Primitive { LINE_LOOP, @@ -24,12 +27,12 @@ private enum Primitive { } private final TypeFactory types; + private @Nullable SubmitNodeCollector collector; + private @Nullable PoseStack poseStack; private @Nullable VariantSet currentVariants; private @Nullable RenderTarget activeTarget; private @Nullable Primitive activePrimitive; - private final StagedVertexBuffer vertexBuffer = new StagedVertexBuffer(() -> "WorldEditCUI", 1536); - private @Nullable StagedVertexBuffer.Draw draw; - private @Nullable VertexConsumer builder; + private @Nullable List vertices; private boolean active; private float r = -1f; private float g; @@ -48,6 +51,12 @@ public BatchedRenderSink(final TypeFactory types) { this.types = types; } + @Override + public void beginFrame(final SubmitNodeCollector collector, final PoseStack poseStack) { + this.collector = collector; + this.poseStack = poseStack; + } + @Override public RenderSink color(final float r, final float g, final float b, final float alpha) { this.r = r; @@ -72,7 +81,7 @@ public RenderSink vertex(final double x, final double y, final double z) { if (this.r == -1f) { throw new IllegalStateException("No colour has been set!"); } - if (!this.active || this.activeTarget == null || this.builder == null) { + if (!this.active || this.activeTarget == null || this.vertices == null) { throw new IllegalStateException("Tried to draw when not active"); } @@ -110,15 +119,15 @@ public RenderSink vertex(final double x, final double y, final double z) { } private void addVertex(final double x, final double y, final double z, @Nullable final Vector3f normal) { - if (this.builder == null) { - throw new IllegalStateException("No active builder"); - } - this.builder.addVertex((float) x, (float) y, (float) z) - .setColor(this.r, this.g, this.b, this.a) - .setLineWidth(this.currentLineWidth); - if (normal != null) { - this.builder.setNormal(normal.x(), normal.y(), normal.z()); + if (this.vertices == null) { + throw new IllegalStateException("No active vertex list"); } + this.vertices.add(new Vertex( + (float) x, (float) y, (float) z, + this.r, this.g, this.b, this.a, + this.currentLineWidth, + normal == null ? null : new Vector3f(normal) + )); } private Vector3f computeNormal(final double x0, final double y0, final double z0, final double x1, final double y1, final double z1) { @@ -176,29 +185,23 @@ public RenderSink endQuads() { @Override public void flush() { - if (this.builder == null || this.activeTarget == null) { + if (this.vertices == null || this.activeTarget == null) { return; } if (this.active) { throw new IllegalStateException("Tried to flush while still active"); } - this.vertexBuffer.upload(); - try { - final StagedVertexBuffer.Draw draw = this.draw; - if (draw == null) { - throw new IllegalStateException("No active draw"); - } - final StagedVertexBuffer.ExecuteInfo executeInfo = this.vertexBuffer.getExecuteInfo(draw); - if (executeInfo != null) { - this.activeTarget.draw(executeInfo); + if (!this.vertices.isEmpty()) { + final SubmitNodeCollector collector = this.collector; + final PoseStack poseStack = this.poseStack; + if (collector == null || poseStack == null) { + throw new IllegalStateException("Render sink was not prepared for this frame"); } - } finally { - this.vertexBuffer.endFrame(); - this.draw = null; - this.builder = null; - this.activeTarget = null; - this.activePrimitive = null; + this.activeTarget.draw(collector, poseStack, List.copyOf(this.vertices)); } + this.vertices = null; + this.activeTarget = null; + this.activePrimitive = null; } private void end(final RenderTarget target, final Primitive primitive) { @@ -219,9 +222,8 @@ private void transitionState(final RenderTarget target, final Primitive primitiv this.flush(); } if (this.activeTarget == null) { - this.draw = this.vertexBuffer.appendDraw(target.format(), target.primitiveTopology()); - this.builder = this.vertexBuffer.getVertexBuilder(this.draw); this.activeTarget = target; + this.vertices = new ArrayList<>(); } this.activePrimitive = primitive; this.active = true; @@ -241,38 +243,46 @@ private RenderTarget activeTargetOrThrow() { return this.activeTarget; } - @FunctionalInterface - public interface MeshDrawer { - void draw(StagedVertexBuffer.ExecuteInfo executeInfo); - } + private record Vertex( + float x, + float y, + float z, + float red, + float green, + float blue, + float alpha, + float lineWidth, + @Nullable Vector3f normal + ) {} public static final class RenderTarget { - private final PrimitiveTopology primitiveTopology; - private final VertexFormat format; private final boolean hasNormals; - private final MeshDrawer drawer; + private final RenderType renderType; - public RenderTarget(final PrimitiveTopology primitiveTopology, final VertexFormat format, final MeshDrawer drawer) { - this.primitiveTopology = primitiveTopology; - this.format = format; + public RenderTarget(final RenderType renderType, final VertexFormat format) { + this.renderType = renderType; this.hasNormals = format.contains("Normal"); - this.drawer = drawer; - } - - PrimitiveTopology primitiveTopology() { - return this.primitiveTopology; - } - - VertexFormat format() { - return this.format; } boolean hasNormals() { return this.hasNormals; } - void draw(final StagedVertexBuffer.ExecuteInfo executeInfo) { - this.drawer.draw(executeInfo); + void draw( + final SubmitNodeCollector collector, + final PoseStack poseStack, + final List vertices + ) { + collector.submitCustomGeometry(poseStack, this.renderType, (pose, consumer) -> { + for (final Vertex vertex : vertices) { + consumer.addVertex(pose, vertex.x(), vertex.y(), vertex.z()) + .setColor(vertex.red(), vertex.green(), vertex.blue(), vertex.alpha()) + .setLineWidth(vertex.lineWidth()); + if (this.hasNormals() && vertex.normal() != null) { + consumer.setNormal(pose, vertex.normal().x(), vertex.normal().y(), vertex.normal().z()); + } + } + }); } } diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/IrisPipelineIntegration.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/IrisPipelineIntegration.java index d019604..41e5837 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/IrisPipelineIntegration.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/IrisPipelineIntegration.java @@ -9,7 +9,7 @@ */ package org.enginehub.worldeditcui.render; -import com.mojang.blaze3d.pipeline.RenderPipeline; +import com.mojang.renderpearl.api.pipeline.RenderPipeline; import net.irisshaders.iris.api.v0.IrisApi; import net.irisshaders.iris.api.v0.IrisProgram; diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/RenderSink.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/RenderSink.java index a86902b..d1e5922 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/RenderSink.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/RenderSink.java @@ -9,6 +9,8 @@ */ package org.enginehub.worldeditcui.render; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.SubmitNodeCollector; import org.enginehub.worldeditcui.config.Colour; /** @@ -65,6 +67,14 @@ default RenderSink color(final LineStyle style, final float tint) { */ RenderSink vertex(double x, double y, double z); + /** + * Called when a frame is initialised for collecting. + * + * @param collector The collector + * @param poseStack The pose stack + */ + void beginFrame(SubmitNodeCollector collector, PoseStack poseStack); + /** * Begin drawing a line loop. * diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/RenderStyle.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/RenderStyle.java index 5cf1e56..91f95f5 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/RenderStyle.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/RenderStyle.java @@ -9,7 +9,7 @@ */ package org.enginehub.worldeditcui.render; -import com.mojang.blaze3d.platform.CompareOp; +import com.mojang.renderpearl.api.pipeline.CompareOp; import org.enginehub.worldeditcui.config.Colour; /** diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/VanillaPipelineProvider.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/VanillaPipelineProvider.java index 1038428..5e72e9b 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/VanillaPipelineProvider.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/VanillaPipelineProvider.java @@ -9,16 +9,18 @@ */ package org.enginehub.worldeditcui.render; -import com.mojang.blaze3d.PrimitiveTopology; -import com.mojang.blaze3d.pipeline.BlendFunction; -import com.mojang.blaze3d.pipeline.ColorTargetState; -import com.mojang.blaze3d.pipeline.DepthStencilState; -import com.mojang.blaze3d.pipeline.RenderPipeline; -import com.mojang.blaze3d.platform.CompareOp; +import com.mojang.renderpearl.api.pipeline.BlendFunction; +import com.mojang.renderpearl.api.pipeline.ColorTargetState; +import com.mojang.renderpearl.api.pipeline.CompareOp; +import com.mojang.renderpearl.api.pipeline.DepthStencilState; +import com.mojang.renderpearl.api.pipeline.PrimitiveTopology; +import com.mojang.renderpearl.api.pipeline.RenderPipeline; +import com.mojang.renderpearl.api.pipeline.ShaderType; +import com.mojang.renderpearl.api.vertex.VertexFormat; import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.VertexFormat; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.client.renderer.oit.OitPipelineSet; import net.minecraft.client.renderer.rendertype.RenderSetup; import net.minecraft.client.renderer.rendertype.RenderType; import net.minecraft.resources.Identifier; @@ -26,6 +28,7 @@ import java.util.EnumMap; import java.util.Locale; import java.util.Map; +import java.util.function.Consumer; public final class VanillaPipelineProvider implements PipelineProvider { @@ -48,8 +51,8 @@ private DefaultTypeFactory() {} private static RenderPipeline.Snippet createSnippet(final RenderPipeline base, final VertexFormat vertexFormat, final PrimitiveTopology primitiveTopology) { final RenderPipeline.Builder builder = RenderPipeline.builder() - .withVertexShader(base.getVertexShader()) - .withFragmentShader(base.getFragmentShader()) + .withVertexShader(base.getShaders().get(ShaderType.VERTEX)) + .withFragmentShader(base.getShaders().get(ShaderType.FRAGMENT)) .withColorTargetState(new ColorTargetState(BlendFunction.TRANSLUCENT)) .withCull(false) .withVertexBinding(0, vertexFormat) @@ -59,6 +62,20 @@ private static RenderPipeline.Snippet createSnippet(final RenderPipeline base, f return builder.buildSnippet(); } + private static OitPipelineSet createOitPipelines( + final String name, + final RenderPipeline.Snippet snippet, + final CompareOp depthTest + ) { + final Consumer applyDepthTest = + builder -> builder.withDepthStencilState(new DepthStencilState(depthTest, false)); + return OitPipelineSet.builder(name, RenderPipeline.builder(snippet)) + .withDepthBoundsModifier(applyDepthTest) + .withTransmittanceModifier(applyDepthTest) + .withAccumulateModifier(applyDepthTest) + .build(); + } + @Override public BatchedRenderSink.VariantSet forStyle(final RenderStyle.RenderType renderType) { final BatchedRenderSink.VariantSet variants = VARIANTS.get(renderType); @@ -91,14 +108,19 @@ private static BatchedRenderSink.RenderTarget createQuadsTarget(final String idS if (IRIS_LOADED) { IrisPipelineIntegration.registerQuads(pipeline); } + final OitPipelineSet oitPipelines = createOitPipelines( + "wecui_quads_" + idSuffix, + RenderPipelines.OIT_DEBUG_FILLED_SNIPPET, + depthTest + ); final RenderSetup setup = RenderSetup.builder(pipeline) + .setOitPipelines(oitPipelines) .sortOnUpload() .createRenderSetup(); final RenderType renderType = RenderType.create("wecui_quads_" + idSuffix, setup); return new BatchedRenderSink.RenderTarget( - PrimitiveTopology.QUADS, - DefaultVertexFormat.POSITION_COLOR, - executeInfo -> renderType.prepare().drawFromBuffer(executeInfo) + renderType, + DefaultVertexFormat.POSITION_COLOR ); } @@ -110,12 +132,18 @@ private static BatchedRenderSink.RenderTarget createLinesTarget(final String idS if (IRIS_LOADED) { IrisPipelineIntegration.registerLines(pipeline); } - final RenderSetup setup = RenderSetup.builder(pipeline).createRenderSetup(); + final OitPipelineSet oitPipelines = createOitPipelines( + "wecui_lines_" + idSuffix, + RenderPipelines.OIT_LINES_SNIPPET, + depthTest + ); + final RenderSetup setup = RenderSetup.builder(pipeline) + .setOitPipelines(oitPipelines) + .createRenderSetup(); final RenderType renderType = RenderType.create("wecui_lines_" + idSuffix, setup); return new BatchedRenderSink.RenderTarget( - PrimitiveTopology.LINES, - DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH, - executeInfo -> renderType.prepare().drawFromBuffer(executeInfo) + renderType, + DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH ); } } diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/shapes/RenderChunkBoundary.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/shapes/RenderChunkBoundary.java index 0216a67..bc04b54 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/shapes/RenderChunkBoundary.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/shapes/RenderChunkBoundary.java @@ -51,9 +51,8 @@ public void render(final CUIRenderContext ctx) this.grid.setPosition(new Vector3(xBase - OFFSET, yMin, zBase - 16 - OFFSET), new Vector3(xBase + 16 + OFFSET, yMax, zBase + OFFSET)); ctx.flush(); - ctx.matrixStack().pushMatrix(); - ctx.matrixStack().translate(0.0f, (float) -ctx.cameraPos().getY(), 0.0f); - ctx.applyMatrices(); + ctx.poseStack().pushPose(); + ctx.poseStack().translate(0.0f, (float) -ctx.cameraPos().getY(), 0.0f); ctx.withCameraAt(Vector3.ZERO, this.grid::render); @@ -65,8 +64,7 @@ public void render(final CUIRenderContext ctx) } ctx.flush(); - ctx.matrixStack().popMatrix(); - ctx.applyMatrices(); + ctx.poseStack().popPose(); } private void renderChunkBorder(final CUIRenderContext ctx, final double yMin, final double yMax, final double xBase, final double zBase) diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/shapes/RenderEllipsoid.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/shapes/RenderEllipsoid.java index 999e65a..7daa422 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/shapes/RenderEllipsoid.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/shapes/RenderEllipsoid.java @@ -49,9 +49,8 @@ public RenderEllipsoid(RenderStyle style, PointCube centre, Vector3 radii) public void render(CUIRenderContext ctx) { ctx.flush(); - ctx.matrixStack().pushMatrix(); - ctx.matrixStack().translate((float) (this.centreX - ctx.cameraPos().getX()), (float) (this.centreY - ctx.cameraPos().getY()), (float) (this.centreZ - ctx.cameraPos().getZ())); - ctx.applyMatrices(); + ctx.poseStack().pushPose(); + ctx.poseStack().translate((float) (this.centreX - ctx.cameraPos().getX()), (float) (this.centreY - ctx.cameraPos().getY()), (float) (this.centreZ - ctx.cameraPos().getZ())); for (LineStyle line : this.style.getLines()) { @@ -65,8 +64,7 @@ public void render(CUIRenderContext ctx) } ctx.flush(); - ctx.matrixStack().popMatrix(); - ctx.applyMatrices(); + ctx.poseStack().popPose(); } protected void drawXZPlane(final CUIRenderContext ctx) diff --git a/worldeditcui-fabric/src/main/resources/fabric.mod.json b/worldeditcui-fabric/src/main/resources/fabric.mod.json index e84d5bf..01c9273 100644 --- a/worldeditcui-fabric/src/main/resources/fabric.mod.json +++ b/worldeditcui-fabric/src/main/resources/fabric.mod.json @@ -54,9 +54,9 @@ "fabric-rendering-v1": ">=1.5.0", "fabric-lifecycle-events-v1": "^4.0.0", "fabric-screen-api-v1": ">=1.0.9", - "fabric-resource-loader-v0": ">=0.4.17", + "fabric-resource-loader-v1": "*", "fabric-transitive-access-wideners-v1": "*", - "minecraft": ">=26.2" + "minecraft": ">=26.3" }, "suggests": { "iris": ">=1.11.0",