aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-09-07 14:44:43 +0200
committerLinnea Gräf <nea@nea.moe>2024-09-07 14:44:43 +0200
commit26461deda4dc8695dacedefe50d976eb5e3d7714 (patch)
treec079a8c2330df05037f944d6d7068b9ea39ebc24 /src/main/kotlin/util
parent9cdc30e024fac9fe04eeeccb15dfd46f4aa648cb (diff)
downloadfirmament-26461deda4dc8695dacedefe50d976eb5e3d7714.tar.gz
firmament-26461deda4dc8695dacedefe50d976eb5e3d7714.tar.bz2
firmament-26461deda4dc8695dacedefe50d976eb5e3d7714.zip
Add shader loading functionality
[no changelog]
Diffstat (limited to 'src/main/kotlin/util')
-rw-r--r--src/main/kotlin/util/render/FirmamentShaders.kt23
-rw-r--r--src/main/kotlin/util/render/RenderInWorldContext.kt4
2 files changed, 25 insertions, 2 deletions
diff --git a/src/main/kotlin/util/render/FirmamentShaders.kt b/src/main/kotlin/util/render/FirmamentShaders.kt
new file mode 100644
index 0000000..1094bc2
--- /dev/null
+++ b/src/main/kotlin/util/render/FirmamentShaders.kt
@@ -0,0 +1,23 @@
+package moe.nea.firmament.util.render
+
+import net.minecraft.client.gl.ShaderProgram
+import net.minecraft.client.render.RenderPhase
+import net.minecraft.client.render.VertexFormats
+import moe.nea.firmament.annotations.Subscribe
+import moe.nea.firmament.events.RegisterCustomShadersEvent
+
+object FirmamentShaders {
+
+
+ private lateinit var _LINES: ShaderProgram
+ val LINES = RenderPhase.ShaderProgram({ _LINES })
+
+ @Subscribe
+ fun registerCustomShaders(event: RegisterCustomShadersEvent) {
+ event.register(
+ "firmament_rendertype_lines",
+ VertexFormats.LINES,
+ { _LINES = it },
+ )
+ }
+}
diff --git a/src/main/kotlin/util/render/RenderInWorldContext.kt b/src/main/kotlin/util/render/RenderInWorldContext.kt
index 775e8f3..75f2fad 100644
--- a/src/main/kotlin/util/render/RenderInWorldContext.kt
+++ b/src/main/kotlin/util/render/RenderInWorldContext.kt
@@ -56,7 +56,7 @@ class RenderInWorldContext private constructor(
false, false, // do we need translucent? i dont think so
RenderLayer.MultiPhaseParameters.builder()
.depthTest(RenderPhase.ALWAYS_DEPTH_TEST)
- .program(RenderPhase.LINES_PROGRAM)
+ .program(FirmamentShaders.LINES)
.build(false)
)
}
@@ -172,7 +172,7 @@ class RenderInWorldContext private constructor(
points.zipWithNext().forEach { (a, b) ->
val normal = Vector3f(b.x.toFloat(), b.y.toFloat(), b.z.toFloat())
.sub(a.x.toFloat(), a.y.toFloat(), a.z.toFloat())
- .normalize()
+// .normalize()
val lastNormal0 = lastNormal ?: normal
lastNormal = normal
buffer.vertex(matrix.positionMatrix, a.x.toFloat(), a.y.toFloat(), a.z.toFloat())