aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util/render
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-07-28 19:52:18 +0200
committerLinnea Gräf <nea@nea.moe>2025-07-28 19:52:18 +0200
commit80d97bb0de46b1b0cefd8a5bd1ba22105ee08a50 (patch)
treef4f361e7397d0f743429bff824664b09ab4a0748 /src/main/kotlin/util/render
parent32e1b1176b4230e3e76145c1fec7f13f705cb6a7 (diff)
downloadFirmament-80d97bb0de46b1b0cefd8a5bd1ba22105ee08a50.tar.gz
Firmament-80d97bb0de46b1b0cefd8a5bd1ba22105ee08a50.tar.bz2
Firmament-80d97bb0de46b1b0cefd8a5bd1ba22105ee08a50.zip
feat: update to new moulconfig version
Diffstat (limited to 'src/main/kotlin/util/render')
-rw-r--r--src/main/kotlin/util/render/FacingThePlayerContext.kt17
-rw-r--r--src/main/kotlin/util/render/RenderCircleProgress.kt35
-rw-r--r--src/main/kotlin/util/render/RenderInWorldContext.kt9
3 files changed, 28 insertions, 33 deletions
diff --git a/src/main/kotlin/util/render/FacingThePlayerContext.kt b/src/main/kotlin/util/render/FacingThePlayerContext.kt
index 0e5788a..76270c5 100644
--- a/src/main/kotlin/util/render/FacingThePlayerContext.kt
+++ b/src/main/kotlin/util/render/FacingThePlayerContext.kt
@@ -1,7 +1,6 @@
package moe.nea.firmament.util.render
-import io.github.notenoughupdates.moulconfig.platform.next
import org.joml.Matrix4f
import util.render.CustomRenderLayers
import net.minecraft.client.font.TextRenderer
@@ -41,14 +40,14 @@ class FacingThePlayerContext(val worldContext: RenderInWorldContext) {
worldContext.vertexConsumers.getBuffer(RenderLayer.getTextBackgroundSeeThrough())
val matrix4f = worldContext.matrixStack.peek().positionMatrix
vertexConsumer.vertex(matrix4f, -1.0f, -1.0f, 0.0f).color(background)
- .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE).next()
+ .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
vertexConsumer.vertex(matrix4f, -1.0f, MC.font.fontHeight.toFloat(), 0.0f).color(background)
- .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE).next()
+ .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
vertexConsumer.vertex(matrix4f, width.toFloat(), MC.font.fontHeight.toFloat(), 0.0f)
.color(background)
- .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE).next()
+ .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
vertexConsumer.vertex(matrix4f, width.toFloat(), -1.0f, 0.0f).color(background)
- .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE).next()
+ .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
worldContext.matrixStack.translate(0F, 0F, 0.01F)
MC.font.draw(
@@ -79,16 +78,16 @@ class FacingThePlayerContext(val worldContext: RenderInWorldContext) {
val matrix4f: Matrix4f = worldContext.matrixStack.peek().positionMatrix
buf.vertex(matrix4f, -hw, -hh, 0F)
.color(-1)
- .texture(u1, v1).next()
+ .texture(u1, v1)
buf.vertex(matrix4f, -hw, +hh, 0F)
.color(-1)
- .texture(u1, v2).next()
+ .texture(u1, v2)
buf.vertex(matrix4f, +hw, +hh, 0F)
.color(-1)
- .texture(u2, v2).next()
+ .texture(u2, v2)
buf.vertex(matrix4f, +hw, -hh, 0F)
.color(-1)
- .texture(u2, v1).next()
+ .texture(u2, v1)
worldContext.vertexConsumers.draw()
}
diff --git a/src/main/kotlin/util/render/RenderCircleProgress.kt b/src/main/kotlin/util/render/RenderCircleProgress.kt
index 2c875f8..efd99fe 100644
--- a/src/main/kotlin/util/render/RenderCircleProgress.kt
+++ b/src/main/kotlin/util/render/RenderCircleProgress.kt
@@ -1,9 +1,6 @@
package moe.nea.firmament.util.render
-import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.VertexFormat
-import io.github.notenoughupdates.moulconfig.platform.next
-import java.util.OptionalInt
import org.joml.Matrix3x2f
import util.render.CustomRenderLayers
import net.minecraft.client.gui.DrawContext
@@ -14,6 +11,7 @@ import net.minecraft.util.Identifier
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.collections.nonNegligibleSubSectionsAlignedWith
import moe.nea.firmament.util.math.Projections
+import moe.nea.firmament.util.mc.CustomRenderPassHelper
object RenderCircleProgress {
@@ -27,7 +25,7 @@ object RenderCircleProgress {
angleRadians: ClosedFloatingPointRange<Float>,
color: Int = -1,
innerCutoutRadius: Float = 0F
- ) {
+ ) { // TODO: this is fixed by adding a special gui element renderer
val sections = angleRadians.nonNegligibleSubSectionsAlignedWith((τ / 8f).toFloat())
.zipWithNext().toList()
BufferAllocator(layer.vertexFormat.vertexSize * sections.size * 3).use { allocator ->
@@ -45,38 +43,37 @@ object RenderCircleProgress {
.vertex(matrix, secondPoint.x, secondPoint.y, 0F)
.texture(lerp(u1, u2, ilerp(secondPoint.x)), lerp(v1, v2, ilerp(secondPoint.y)))
.color(color)
- .next()
+
bufferBuilder
.vertex(matrix, firstPoint.x, firstPoint.y, 0F)
.texture(lerp(u1, u2, ilerp(firstPoint.x)), lerp(v1, v2, ilerp(firstPoint.y)))
.color(color)
- .next()
+
bufferBuilder
.vertex(matrix, 0F, 0F, 0F)
.texture(lerp(u1, u2, ilerp(0F)), lerp(v1, v2, ilerp(0F)))
.color(color)
- .next()
+
}
bufferBuilder.end().use { buffer ->
- // TODO: write a better utility to pass uniforms :sob: ill even take a mixin at this point
if (innerCutoutRadius <= 0) {
layer.draw(buffer)
return
}
- val vertexBuffer = layer.vertexFormat.uploadImmediateVertexBuffer(buffer.buffer)
- val indexBufferConstructor = RenderSystem.getSequentialBuffer(VertexFormat.DrawMode.TRIANGLES)
- val indexBuffer = indexBufferConstructor.getIndexBuffer(buffer.drawParameters.indexCount)
- RenderSystem.getDevice().createCommandEncoder().createRenderPass(
- { "Firmament Circle Renderer" },
- MC.instance.framebuffer.colorAttachmentView,
- OptionalInt.empty(),
+ CustomRenderPassHelper(
+ { "RenderCircleProgress" },
+ VertexFormat.DrawMode.TRIANGLES,
+ layer.vertexFormat,
+ MC.instance.framebuffer,
+ false,
).use { renderPass ->
+ renderPass.uploadVertices(buffer)
renderPass.setPipeline(layer.pipeline)
-// renderPass.setUniform("InnerCutoutRadius", innerCutoutRadius)
- renderPass.setIndexBuffer(indexBuffer, indexBufferConstructor.indexType)
- renderPass.setVertexBuffer(0, vertexBuffer)
- renderPass.drawIndexed(0, 0, buffer.drawParameters.indexCount, 1)
+ renderPass.setUniform("InnerCutoutRadius", 4) {
+ it.putFloat(innerCutoutRadius)
+ }
+ renderPass.draw()
}
}
}
diff --git a/src/main/kotlin/util/render/RenderInWorldContext.kt b/src/main/kotlin/util/render/RenderInWorldContext.kt
index 29a387b..1077060 100644
--- a/src/main/kotlin/util/render/RenderInWorldContext.kt
+++ b/src/main/kotlin/util/render/RenderInWorldContext.kt
@@ -1,7 +1,6 @@
package moe.nea.firmament.util.render
import com.mojang.blaze3d.systems.RenderSystem
-import io.github.notenoughupdates.moulconfig.platform.next
import java.lang.Math.pow
import org.joml.Matrix4f
import org.joml.Vector3f
@@ -146,11 +145,11 @@ class RenderInWorldContext private constructor(
buffer.vertex(matrix.positionMatrix, a.x.toFloat(), a.y.toFloat(), a.z.toFloat())
.color(-1)
.normal(matrix, lastNormal0.x, lastNormal0.y, lastNormal0.z)
- .next()
+
buffer.vertex(matrix.positionMatrix, b.x.toFloat(), b.y.toFloat(), b.z.toFloat())
.color(-1)
.normal(matrix, normal.x, normal.y, normal.z)
- .next()
+
}
}
@@ -173,11 +172,11 @@ class RenderInWorldContext private constructor(
buf.vertex(matrix.positionMatrix, i, j, k)
.normal(matrix, normal.x, normal.y, normal.z)
.color(-1)
- .next()
+
buf.vertex(matrix.positionMatrix, x, y, z)
.normal(matrix, normal.x, normal.y, normal.z)
.color(-1)
- .next()
+
}