Skip to content

Commit b82eb41

Browse files
committed
primitive shader delegates, some shader cleanup
1 parent 9ce9b57 commit b82eb41

38 files changed

+345
-90
lines changed

src/main/java/de/bixilon/minosoft/gui/rendering/camera/arm/ArmRenderer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class ArmRenderer(override val context: RenderContext) : Renderer, Drawable {
9797
shader.use()
9898
shader.skinParts = renderer.model?.skinParts ?: 0xFF
9999
shader.texture = renderer.skin?.shaderId ?: context.textures.debugTexture.shaderId
100-
shader.tint = ChatColors.WHITE
100+
shader.tint = ChatColors.WHITE.rgb()
101101

102102
val pivot = Vec3f((if (arm == Arms.RIGHT) 6f else -6f) / 16f, 24 / 16f, 0f)
103103

src/main/java/de/bixilon/minosoft/gui/rendering/camera/arm/ArmShader.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureManager
2424
class ArmShader(override val native: NativeShader) : Shader(), TintedShader, TextureShader {
2525
override var textures: TextureManager by textureManager()
2626
var texture by uniform("uIndexLayerAnimation", 0x00, NativeShader::setUInt)
27-
override var tint by uniform("uTintColor", ChatColors.WHITE) { shader, name, value -> shader.setUInt(name, value.rgb) }
27+
override var tint by uniform("uTintColor", ChatColors.WHITE.rgb())
2828
var skinParts by uniform("uSkinParts", 0xFF, NativeShader::setUInt)
2929
var transform by uniform("uTransform", Mat4f.EMPTY)
3030
}

src/main/java/de/bixilon/minosoft/gui/rendering/chunk/border/WorldBorderShader.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureManager
2424

2525
class WorldBorderShader(
2626
override val native: NativeShader,
27-
) : Shader(), TextureShader, ViewProjectionShader, FogShader, CameraPositionShader, TintedShader {
27+
) : Shader(), TextureShader, ViewProjectionShader, FogShader, CameraPositionShader {
2828
override var textures: TextureManager by textureManager()
2929
override var viewProjectionMatrix: Mat4f by viewProjectionMatrix()
3030
override var cameraPosition: Vec3f by cameraPosition()
3131
override var fog: FogManager by fog()
3232

33-
override var tint by uniform("uTintColor", ChatColors.BLACK)
33+
var tint by uniform("uTintColor", ChatColors.BLACK)
3434

3535
var textureIndexLayer by uniform("uIndexLayerAnimation", 0, NativeShader::setUInt)
3636
var textureOffset by uniform("uTextureOffset", 0.0f)

src/main/java/de/bixilon/minosoft/gui/rendering/entities/feature/SkeletalFeature.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ open class SkeletalFeature(
7272
}
7373

7474
override fun draw() {
75-
var tint = renderer.light.value.rgba()
75+
var tint = renderer.light.value
7676
if (renderer is LivingEntityRenderer<*>) {
7777
tint *= renderer.damage.value
7878
}

src/main/java/de/bixilon/minosoft/gui/rendering/entities/feature/block/BlockFeature.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ open class BlockFeature(
7979
protected open fun draw(mesh: BlockMesh, shader: BlockShader) {
8080
shader.use()
8181
shader.matrix = matrix.unsafe
82-
shader.tint = renderer.light.value.rgba()
82+
shader.tint = renderer.light.value
8383
super.draw(mesh)
8484
}
8585

src/main/java/de/bixilon/minosoft/gui/rendering/entities/feature/block/BlockShader.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ open class BlockShader(
3333
override var cameraPosition: Vec3f by cameraPosition()
3434
override var fog: FogManager by fog()
3535
var matrix: Mat4f by uniform("uMatrix", Mat4f())
36-
override var tint by uniform("uTintColor", ChatColors.WHITE) { shader, name, value -> shader.setUInt(name, value.rgb) }
36+
override var tint by uniform("uTintColor", ChatColors.WHITE.rgb()) { shader, name, value -> shader.setUInt(name, value.rgb) }
3737
}

src/main/java/de/bixilon/minosoft/gui/rendering/entities/feature/block/flashing/FlashingBlockFeature.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import de.bixilon.kmath.vec.vec3.f.Vec3f
1717
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
1818
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
1919
import de.bixilon.minosoft.data.text.formatting.color.RGBAColor
20+
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
2021
import de.bixilon.minosoft.gui.rendering.entities.feature.block.BlockFeature
2122
import de.bixilon.minosoft.gui.rendering.entities.feature.block.BlockMesh
2223
import de.bixilon.minosoft.gui.rendering.entities.feature.block.BlockShader
@@ -29,7 +30,7 @@ open class FlashingBlockFeature(
2930
renderer: EntityRenderer<*>,
3031
state: BlockState?,
3132
scale: Vec3f = DEFAULT_SCALE,
32-
var flashColor: RGBAColor = ChatColors.WHITE,
33+
var flashColor: RGBColor = ChatColors.WHITE.rgb(),
3334
var flashInterval: Float = 0.2f,
3435
var maxFlash: Float = 0.5f
3536
) : BlockFeature(renderer, state, scale) {

src/main/java/de/bixilon/minosoft/gui/rendering/entities/feature/block/flashing/FlashingBlockShader.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Minosoft
3-
* Copyright (C) 2020-2023 Moritz Zwerger
3+
* Copyright (C) 2020-2025 Moritz Zwerger
44
*
55
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
66
*
@@ -20,6 +20,6 @@ import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader
2020
class FlashingBlockShader(
2121
native: NativeShader,
2222
) : BlockShader(native) {
23-
var flashColor by uniform("uFlashColor", ChatColors.WHITE) { shader, name, value -> shader.setUInt(name, value.rgb) }
23+
var flashColor by uniform("uFlashColor", ChatColors.WHITE.rgb())
2424
var flashProgress by uniform("uFlashProgress", 0.0f)
2525
}

src/main/java/de/bixilon/minosoft/gui/rendering/entities/feature/item/ItemFeature.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ open class ItemFeature(
116116
protected open fun draw(mesh: BlockMesh, shader: BlockShader) {
117117
shader.use()
118118
shader.matrix = matrix.unsafe
119-
shader.tint = renderer.light.value.rgba()
119+
shader.tint = renderer.light.value
120120
super.draw(mesh)
121121
}
122122

src/main/java/de/bixilon/minosoft/gui/rendering/entities/feature/text/BillboardTextFeature.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ open class BillboardTextFeature(
103103
val shader = renderer.renderer.features.text.shader
104104
shader.use()
105105
shader.matrix = matrix.unsafe
106-
shader.tint = renderer.light.value.rgba()
106+
shader.tint = renderer.light.value
107107
super.draw(mesh)
108108
}
109109

0 commit comments

Comments
 (0)