Skip to content

Commit 89ce6f8

Browse files
committed
fix: lines not 3d rendering through blocks
fixes #389
1 parent 18e8e35 commit 89ce6f8

File tree

5 files changed

+18
-106
lines changed

5 files changed

+18
-106
lines changed

src/main/kotlin/util/render/CustomRenderLayers.kt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ package util.render
33
import com.mojang.blaze3d.pipeline.BlendFunction
44
import com.mojang.blaze3d.pipeline.RenderPipeline
55
import com.mojang.blaze3d.platform.DepthTestFunction
6+
import com.mojang.blaze3d.shaders.UniformType
7+
import com.mojang.blaze3d.vertex.DefaultVertexFormat
68
import com.mojang.blaze3d.vertex.VertexFormat.Mode
79
import java.util.function.Function
810
import net.minecraft.client.renderer.RenderPipelines
9-
import com.mojang.blaze3d.shaders.UniformType
10-
import com.mojang.blaze3d.vertex.DefaultVertexFormat
11+
import net.minecraft.client.renderer.rendertype.LayeringTransform
12+
import net.minecraft.client.renderer.rendertype.OutputTarget
1113
import net.minecraft.client.renderer.rendertype.RenderSetup
1214
import net.minecraft.client.renderer.rendertype.RenderType
1315
import net.minecraft.resources.Identifier
@@ -23,12 +25,6 @@ object CustomRenderPipelines {
2325
.withCull(false)
2426
.withDepthWrite(false)
2527
.build()
26-
val OMNIPRESENT_LINES = RenderPipeline
27-
.builder(RenderPipelines.LINES_SNIPPET)
28-
.withLocation(Firmament.identifier("lines"))
29-
.withDepthWrite(false)
30-
.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
31-
.build()
3228
val COLORED_OMNIPRESENT_QUADS =
3329
RenderPipeline.builder(RenderPipelines.MATRICES_PROJECTION_SNIPPET)// TODO: split this up to support better transparent ordering.
3430
.withLocation(Firmament.identifier("colored_omnipresent_quads"))
@@ -58,6 +54,11 @@ object CustomRenderPipelines {
5854
.withSampler("Sampler3")
5955
.withUniform("Animation", UniformType.UNIFORM_BUFFER)
6056
.build()
57+
val OMNIPRESENT_LINES = RenderPipeline.builder(RenderPipelines.LINES_SNIPPET)
58+
.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
59+
.withLocation(Firmament.identifier("lines"))
60+
.withDepthWrite(false)
61+
.withLocation("pipeline/lines").build()
6162
}
6263

6364
object CustomRenderLayers {
@@ -91,6 +92,14 @@ object CustomRenderLayers {
9192
.createRenderSetup()
9293
)
9394

95+
val LINES_NO_DEPTH = RenderType.create(
96+
"firmament_lines_no_depth",
97+
RenderSetup.builder(CustomRenderPipelines.OMNIPRESENT_LINES)
98+
.setLayeringTransform(LayeringTransform.VIEW_OFFSET_Z_LAYERING)
99+
.setOutputTarget(OutputTarget.ITEM_ENTITY_TARGET)
100+
.createRenderSetup()
101+
)
102+
94103
val TRANSLUCENT_CIRCLE_GUI =
95104
RenderType.create(
96105
"firmament_translucent_circle_gui",

src/main/kotlin/util/render/RenderInWorldContext.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class RenderInWorldContext private constructor(
174174
}
175175

176176
fun line(points: List<Vec3>, color: Int, lineWidth: Float = 10F) {
177-
val buffer = vertexConsumers.getBuffer(RenderTypes.LINES)
177+
val buffer = vertexConsumers.getBuffer(CustomRenderLayers.LINES_NO_DEPTH)
178178

179179
val matrix = matrixStack.last()
180180
var lastNormal: Vector3f? = null

src/main/resources/assets/firmament/shaders/core/rendertype_lines.fsh

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/main/resources/assets/firmament/shaders/core/rendertype_lines.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/main/resources/assets/firmament/shaders/core/rendertype_lines.vsh

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)