|
5 | 5 | import com.mojang.blaze3d.pipeline.BlendFunction; |
6 | 6 | import com.mojang.blaze3d.pipeline.RenderPipeline; |
7 | 7 | import com.mojang.blaze3d.pipeline.RenderTarget; |
8 | | -import com.mojang.blaze3d.platform.DepthTestFunction; |
9 | | -import com.mojang.blaze3d.platform.LogicOp; |
10 | 8 | import com.mojang.blaze3d.systems.RenderPass; |
11 | 9 | import com.mojang.blaze3d.systems.RenderSystem; |
12 | 10 | import com.mojang.blaze3d.textures.GpuTextureView; |
13 | 11 | import com.mojang.blaze3d.vertex.*; |
| 12 | +import net.irisshaders.iris.api.v0.IrisApi; |
| 13 | +import net.irisshaders.iris.api.v0.IrisProgram; |
14 | 14 | import net.minecraft.client.Minecraft; |
15 | 15 | import net.minecraft.client.renderer.DynamicUniforms; |
16 | 16 | import net.minecraft.client.renderer.RenderPipelines; |
|
22 | 22 | import org.joml.Matrix4fStack; |
23 | 23 | import org.joml.Vector3f; |
24 | 24 | import org.joml.Vector4f; |
| 25 | +import org.lwjgl.opengl.GL11; |
25 | 26 | import pro.mikey.xray.XRay; |
26 | 27 |
|
27 | 28 | import java.io.Closeable; |
28 | 29 | import java.util.*; |
29 | 30 |
|
30 | 31 | public class OutlineRender { |
31 | | - public static boolean requestedRefresh = false; |
32 | 32 |
|
33 | 33 | private static final RenderSystem.AutoStorageIndexBuffer indices = RenderSystem.getSequentialBuffer(VertexFormat.Mode.LINES); |
34 | 34 | private static final Map<ChunkPos, VBOHolder> vertexBuffers = new HashMap<>(); |
35 | 35 |
|
36 | 36 | private static final Set<ChunkPos> chunksToRefresh = Collections.synchronizedSet(new HashSet<>()); |
37 | 37 |
|
38 | | - public static RenderPipeline LINES_NO_DEPTH = RenderPipeline.builder(RenderPipelines.MATRICES_FOG_SNIPPET, RenderPipelines.GLOBALS_SNIPPET) |
39 | | - .withLocation(XRay.id("pipeline/xray_lines")) |
40 | | - .withVertexShader("core/rendertype_lines") |
41 | | - .withFragmentShader(ResourceLocation.fromNamespaceAndPath(XRay.MOD_ID, "frag/constant_color")) |
42 | | - .withBlend(BlendFunction.TRANSLUCENT) |
43 | | - .withCull(false) |
44 | | - .withVertexFormat(DefaultVertexFormat.POSITION_COLOR_NORMAL, VertexFormat.Mode.LINES) |
45 | | - .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST) |
46 | | - .withColorLogic(LogicOp.NONE) |
47 | | - .build(); |
| 38 | + public static RenderPipeline LINES_NO_DEPTH = RenderPipeline.builder(RenderPipelines.MATRICES_FOG_SNIPPET, RenderPipelines.GLOBALS_SNIPPET) |
| 39 | + .withLocation(ResourceLocation.fromNamespaceAndPath(XRay.MOD_ID, "pipeline/lines_2")) |
| 40 | + .withVertexShader("core/rendertype_lines") |
| 41 | + .withFragmentShader(ResourceLocation.fromNamespaceAndPath(XRay.MOD_ID, "frag/constant_color")) |
| 42 | + .withBlend(BlendFunction.TRANSLUCENT) |
| 43 | + .withCull(false) |
| 44 | + .withVertexFormat(DefaultVertexFormat.POSITION_COLOR_NORMAL, VertexFormat.Mode.LINES) |
| 45 | + .build(); |
48 | 46 |
|
49 | 47 | public static void renderBlocks(PoseStack poseStack) { |
50 | 48 | if (!ScanController.INSTANCE.isXRayActive() || Minecraft.getInstance().player == null) { |
@@ -139,13 +137,18 @@ public static void renderBlocks(PoseStack poseStack) { |
139 | 137 | .createCommandEncoder() |
140 | 138 | .createRenderPass(() -> "xray", colorTextureView, OptionalInt.empty(), depthTextureView, OptionalDouble.empty())) { |
141 | 139 |
|
| 140 | + GL11.glDisable(GL11.GL_DEPTH_TEST); |
| 141 | + |
142 | 142 | renderPass.setPipeline(LINES_NO_DEPTH); |
143 | 143 | RenderSystem.bindDefaultUniforms(renderPass); |
144 | 144 | renderPass.setVertexBuffer(0, holder.vertexBuffer); |
145 | 145 | renderPass.setIndexBuffer(gpuBuffer, indices.type()); |
146 | 146 | renderPass.setUniform("DynamicTransforms", gpubufferslice[0]); |
147 | 147 | renderPass.setPipeline(LINES_NO_DEPTH); |
148 | 148 | renderPass.drawIndexed(0, 0, holder.indexCount, 1); |
| 149 | + |
| 150 | + // Re-enable depth test after drawing |
| 151 | + GL11.glEnable(GL11.GL_DEPTH_TEST); |
149 | 152 | } |
150 | 153 | } |
151 | 154 | } |
|
0 commit comments