billboard text: light

This commit is contained in:
Moritz Zwerger 2023-11-06 16:46:17 +01:00
parent 5eecbe89b7
commit a73fc2a43c
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 7 additions and 7 deletions

View File

@ -106,6 +106,7 @@ open class BillboardTextFeature(
val shader = renderer.renderer.features.text.shader
shader.use()
shader.matrix = matrix
shader.tint = renderer.light.value
mesh.draw()
}

View File

@ -15,23 +15,23 @@ package de.bixilon.minosoft.gui.rendering.entities.feature.text
import de.bixilon.kotlinglm.mat4x4.Mat4
import de.bixilon.kotlinglm.vec3.Vec3
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
import de.bixilon.minosoft.gui.rendering.camera.FogManager
import de.bixilon.minosoft.gui.rendering.light.LightmapBuffer
import de.bixilon.minosoft.gui.rendering.shader.Shader
import de.bixilon.minosoft.gui.rendering.shader.types.FogShader
import de.bixilon.minosoft.gui.rendering.shader.types.LightShader
import de.bixilon.minosoft.gui.rendering.shader.types.TextureShader
import de.bixilon.minosoft.gui.rendering.shader.types.TintedShader
import de.bixilon.minosoft.gui.rendering.shader.types.ViewProjectionShader
import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureManager
class BillboardTextShader(
override val native: NativeShader,
) : Shader(), TextureShader, LightShader, ViewProjectionShader, FogShader {
) : Shader(), TextureShader, ViewProjectionShader, FogShader, TintedShader {
override var textures: TextureManager by textureManager()
override val lightmap: LightmapBuffer by lightmap()
override var viewProjectionMatrix: Mat4 by viewProjectionMatrix()
override var cameraPosition: Vec3 by cameraPosition()
override var fog: FogManager by fog()
var matrix: Mat4 by uniform("uMatrix", Mat4())
override var tint by uniform("uTintColor", ChatColors.WHITE) { shader, name, value -> shader.setUInt(name, value.rgb) }
}

View File

@ -20,6 +20,7 @@ layout (location = 3) in float vinTint;
uniform mat4 uViewProjectionMatrix;
uniform mat4 uMatrix;
uniform uint uTintColor;
flat out uint finTextureIndex;
@ -29,14 +30,12 @@ out vec3 finFragmentPosition;
out vec4 finTintColor;
#include "minosoft:color"
#include "minosoft:light"
void main() {
vec4 position = uMatrix * vec4(vinPosition, 0.0f, 1.0f);
gl_Position = uViewProjectionMatrix * position;
finTintColor = getRGBAColor(floatBitsToUint(vinTint)); // * getLight(lightTint >> 24u); // TODO
finTintColor = getRGBAColor(floatBitsToUint(vinTint)) * getRGBColor(uTintColor);
finFragmentPosition = position.xyz;
uint indexLayerAnimation = floatBitsToUint(vinIndexLayerAnimation);