diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/entities/feature/text/BillboardTextShader.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/entities/feature/text/BillboardTextShader.kt index 175a5ef8f..1461e0910 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/entities/feature/text/BillboardTextShader.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/entities/feature/text/BillboardTextShader.kt @@ -33,5 +33,6 @@ class BillboardTextShader( 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) } } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/ParticleShader.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/ParticleShader.kt index 4380c58cc..e8497bf21 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/ParticleShader.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/ParticleShader.kt @@ -1,6 +1,6 @@ /* * Minosoft - * Copyright (C) 2020-2023 Moritz Zwerger + * Copyright (C) 2020-2024 Moritz Zwerger * * 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. * @@ -15,22 +15,23 @@ package de.bixilon.minosoft.gui.rendering.particle import de.bixilon.kotlinglm.mat4x4.Mat4 import de.bixilon.kotlinglm.vec3.Vec3 +import de.bixilon.minosoft.gui.rendering.camera.fog.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.AnimatedShader -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.ViewProjectionShader +import de.bixilon.minosoft.gui.rendering.shader.types.* import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader import de.bixilon.minosoft.gui.rendering.system.base.shader.ShaderUniforms import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureManager class ParticleShader( override val native: NativeShader, -) : Shader(), TextureShader, AnimatedShader, LightShader, ViewProjectionShader { +) : Shader(), TextureShader, AnimatedShader, LightShader, ViewProjectionShader, FogShader { override var textures: TextureManager by textureManager() override val lightmap: LightmapBuffer by lightmap() override var viewProjectionMatrix: Mat4 by viewProjectionMatrix() + override var fog: FogManager by fog() + override var cameraPosition: Vec3 by cameraPosition() + var cameraRight by uniform(ShaderUniforms.CAMERA_RIGHT, Vec3(), NativeShader::setVec3) var cameraUp by uniform(ShaderUniforms.CAMERA_UP, Vec3(), NativeShader::setVec3) } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/system/opengl/OpenGLNativeShader.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/system/opengl/OpenGLNativeShader.kt index 3c454d557..61fa58987 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/system/opengl/OpenGLNativeShader.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/system/opengl/OpenGLNativeShader.kt @@ -69,7 +69,7 @@ class OpenGLNativeShader( glCompileShader(program) if (glGetShaderi(program, GL_COMPILE_STATUS) == GL_FALSE) { - throw ShaderLoadingException("Can not load shader: $file\n:" + glGetShaderInfoLog(program), glsl) + throw ShaderLoadingException("Can not load shader: $file:\n" + glGetShaderInfoLog(program), glsl) } return program @@ -129,7 +129,7 @@ class OpenGLNativeShader( val location = uniformLocations.getOrPut(uniformName) { val location = glGetUniformLocation(handler, uniformName) if (location < 0) { - throw IllegalArgumentException("No uniform named $uniformName in $this") + throw IllegalArgumentException("No uniform named $uniformName in $this, maybe you use something that has been optimized out? Check your shader code!") } return@getOrPut location } diff --git a/src/main/resources/assets/minosoft/rendering/shader/chunk/chunk.fsh b/src/main/resources/assets/minosoft/rendering/shader/chunk/chunk.fsh index 5efaf2b41..90882ac87 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/chunk/chunk.fsh +++ b/src/main/resources/assets/minosoft/rendering/shader/chunk/chunk.fsh @@ -25,6 +25,7 @@ out vec4 foutColor; #include "minosoft:animation" void main() { + applyDefaults(); applyTint(); applyTexel(); } diff --git a/src/main/resources/assets/minosoft/rendering/shader/entities/features/block/block.fsh b/src/main/resources/assets/minosoft/rendering/shader/entities/features/block/block.fsh index d5e3fd624..4ea8273eb 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/entities/features/block/block.fsh +++ b/src/main/resources/assets/minosoft/rendering/shader/entities/features/block/block.fsh @@ -24,6 +24,7 @@ out vec4 foutColor; #include "minosoft:animation" void main() { - applyTexel(); + applyDefaults(); applyTint(); + applyTexel(); } diff --git a/src/main/resources/assets/minosoft/rendering/shader/entities/features/block/flashing/flashing.fsh b/src/main/resources/assets/minosoft/rendering/shader/entities/features/block/flashing/flashing.fsh index 8db4fb62b..51e290361 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/entities/features/block/flashing/flashing.fsh +++ b/src/main/resources/assets/minosoft/rendering/shader/entities/features/block/flashing/flashing.fsh @@ -27,8 +27,9 @@ in vec4 finFlashColor; #include "minosoft:animation" void main() { - applyTexel(); + applyDefaults(); applyTint(); + applyTexel(); foutColor = mix(foutColor, finFlashColor, uFlashProgress); } diff --git a/src/main/resources/assets/minosoft/rendering/shader/entities/features/text/text.fsh b/src/main/resources/assets/minosoft/rendering/shader/entities/features/text/text.fsh index 0dd95e038..6be2292a6 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/entities/features/text/text.fsh +++ b/src/main/resources/assets/minosoft/rendering/shader/entities/features/text/text.fsh @@ -25,6 +25,7 @@ out vec4 foutColor; #include "minosoft:animation" void main() { + applyDefaults(); applyTint(); applyTexel(); } diff --git a/src/main/resources/assets/minosoft/rendering/shader/entities/player/arm/arm.fsh b/src/main/resources/assets/minosoft/rendering/shader/entities/player/arm/arm.fsh index f1e288234..6b78cf1dc 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/entities/player/arm/arm.fsh +++ b/src/main/resources/assets/minosoft/rendering/shader/entities/player/arm/arm.fsh @@ -29,8 +29,9 @@ flat in uint finAllowTransparency; void main() { if (finTintColor.a == 0.0f) discard; - applyTexel(); + applyDefaults(); applyTint(); + applyTexel(); if (finAllowTransparency > 0u) { if (foutColor.a < 0.5f) discard; } diff --git a/src/main/resources/assets/minosoft/rendering/shader/entities/player/player.fsh b/src/main/resources/assets/minosoft/rendering/shader/entities/player/player.fsh index f1e288234..6b78cf1dc 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/entities/player/player.fsh +++ b/src/main/resources/assets/minosoft/rendering/shader/entities/player/player.fsh @@ -29,8 +29,9 @@ flat in uint finAllowTransparency; void main() { if (finTintColor.a == 0.0f) discard; - applyTexel(); + applyDefaults(); applyTint(); + applyTexel(); if (finAllowTransparency > 0u) { if (foutColor.a < 0.5f) discard; } diff --git a/src/main/resources/assets/minosoft/rendering/shader/generic/texture/texture.fsh b/src/main/resources/assets/minosoft/rendering/shader/generic/texture/texture.fsh index 3f97dc3d8..d8d24e479 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/generic/texture/texture.fsh +++ b/src/main/resources/assets/minosoft/rendering/shader/generic/texture/texture.fsh @@ -23,6 +23,7 @@ in vec2 finUV; #include "minosoft:animation" void main() { - applyTexel(); + applyDefaults(); applyTint(); + applyTexel(); } diff --git a/src/main/resources/assets/minosoft/rendering/shader/generic/texture_2d/texture_2d.fsh b/src/main/resources/assets/minosoft/rendering/shader/generic/texture_2d/texture_2d.fsh index f8b883eef..e3aaad543 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/generic/texture_2d/texture_2d.fsh +++ b/src/main/resources/assets/minosoft/rendering/shader/generic/texture_2d/texture_2d.fsh @@ -24,6 +24,7 @@ in vec2 finUV; #include "minosoft:animation" void main() { - applyTexel(); + applyDefaults(); applyTint(); + applyTexel(); } diff --git a/src/main/resources/assets/minosoft/rendering/shader/gui/gui.fsh b/src/main/resources/assets/minosoft/rendering/shader/gui/gui.fsh index 9a63fd199..848ca1f84 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/gui/gui.fsh +++ b/src/main/resources/assets/minosoft/rendering/shader/gui/gui.fsh @@ -23,6 +23,7 @@ out vec4 foutColor; #include "minosoft:animation" void main() { - applyTexel(); + applyDefaults(); applyTint(); + applyTexel(); } diff --git a/src/main/resources/assets/minosoft/rendering/shader/includes/animation.glsl b/src/main/resources/assets/minosoft/rendering/shader/includes/animation.glsl index c4ffc04c4..59e3e78de 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/includes/animation.glsl +++ b/src/main/resources/assets/minosoft/rendering/shader/includes/animation.glsl @@ -78,7 +78,7 @@ vec4 getAnimationTexture() { void applyTexel() { vec4 texel = getAnimationTexture(); - foutColor = texel; + foutColor *= texel; #ifdef FOG fog_set(); diff --git a/src/main/resources/assets/minosoft/rendering/shader/includes/texture.glsl b/src/main/resources/assets/minosoft/rendering/shader/includes/texture.glsl index 8c4679fad..f4b031ec3 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/includes/texture.glsl +++ b/src/main/resources/assets/minosoft/rendering/shader/includes/texture.glsl @@ -68,4 +68,9 @@ vec4 getTexture(uint textureId, vec3 uv) { #endif #endif } + +void applyDefaults() { + foutColor = vec4(1.0f); +} + #endif diff --git a/src/main/resources/assets/minosoft/rendering/shader/particle/particle.fsh b/src/main/resources/assets/minosoft/rendering/shader/particle/particle.fsh index 3fa1f471c..8711e0ef8 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/particle/particle.fsh +++ b/src/main/resources/assets/minosoft/rendering/shader/particle/particle.fsh @@ -18,9 +18,11 @@ out vec4 foutColor; #include "minosoft:tint" #include "minosoft:texture" #include "minosoft:alpha" +#include "minosoft:fog" #include "minosoft:animation" void main() { - applyTexel(); + applyDefaults(); applyTint(); + applyTexel(); } diff --git a/src/main/resources/assets/minosoft/rendering/shader/skeletal/lightmap/lightmap.fsh b/src/main/resources/assets/minosoft/rendering/shader/skeletal/lightmap/lightmap.fsh index f1f76fad3..1ea4f77b2 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/skeletal/lightmap/lightmap.fsh +++ b/src/main/resources/assets/minosoft/rendering/shader/skeletal/lightmap/lightmap.fsh @@ -24,6 +24,7 @@ out vec4 foutColor; #include "minosoft:animation" void main() { - applyTexel(); + applyDefaults(); applyTint(); + applyTexel(); } diff --git a/src/main/resources/assets/minosoft/rendering/shader/skeletal/normal/normal.fsh b/src/main/resources/assets/minosoft/rendering/shader/skeletal/normal/normal.fsh index f187f8070..90882ac87 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/skeletal/normal/normal.fsh +++ b/src/main/resources/assets/minosoft/rendering/shader/skeletal/normal/normal.fsh @@ -25,6 +25,7 @@ out vec4 foutColor; #include "minosoft:animation" void main() { - applyTexel(); + applyDefaults(); applyTint(); + applyTexel(); }