mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 08:27:29 -04:00
shaders: apply tint before texel, particle fog
Applying the tint before the texel, fixes a lot of fog issues that are caused by lighting
This commit is contained in:
parent
a3f09071d6
commit
5ecca7c87e
@ -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) }
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ out vec4 foutColor;
|
||||
#include "minosoft:animation"
|
||||
|
||||
void main() {
|
||||
applyDefaults();
|
||||
applyTint();
|
||||
applyTexel();
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ out vec4 foutColor;
|
||||
#include "minosoft:animation"
|
||||
|
||||
void main() {
|
||||
applyTexel();
|
||||
applyDefaults();
|
||||
applyTint();
|
||||
applyTexel();
|
||||
}
|
||||
|
@ -27,8 +27,9 @@ in vec4 finFlashColor;
|
||||
#include "minosoft:animation"
|
||||
|
||||
void main() {
|
||||
applyTexel();
|
||||
applyDefaults();
|
||||
applyTint();
|
||||
applyTexel();
|
||||
|
||||
foutColor = mix(foutColor, finFlashColor, uFlashProgress);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ out vec4 foutColor;
|
||||
#include "minosoft:animation"
|
||||
|
||||
void main() {
|
||||
applyDefaults();
|
||||
applyTint();
|
||||
applyTexel();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ in vec2 finUV;
|
||||
#include "minosoft:animation"
|
||||
|
||||
void main() {
|
||||
applyTexel();
|
||||
applyDefaults();
|
||||
applyTint();
|
||||
applyTexel();
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ in vec2 finUV;
|
||||
#include "minosoft:animation"
|
||||
|
||||
void main() {
|
||||
applyTexel();
|
||||
applyDefaults();
|
||||
applyTint();
|
||||
applyTexel();
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ out vec4 foutColor;
|
||||
#include "minosoft:animation"
|
||||
|
||||
void main() {
|
||||
applyTexel();
|
||||
applyDefaults();
|
||||
applyTint();
|
||||
applyTexel();
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ vec4 getAnimationTexture() {
|
||||
|
||||
void applyTexel() {
|
||||
vec4 texel = getAnimationTexture();
|
||||
foutColor = texel;
|
||||
foutColor *= texel;
|
||||
|
||||
#ifdef FOG
|
||||
fog_set();
|
||||
|
@ -68,4 +68,9 @@ vec4 getTexture(uint textureId, vec3 uv) {
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void applyDefaults() {
|
||||
foutColor = vec4(1.0f);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ out vec4 foutColor;
|
||||
#include "minosoft:animation"
|
||||
|
||||
void main() {
|
||||
applyTexel();
|
||||
applyDefaults();
|
||||
applyTint();
|
||||
applyTexel();
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ out vec4 foutColor;
|
||||
#include "minosoft:animation"
|
||||
|
||||
void main() {
|
||||
applyTexel();
|
||||
applyDefaults();
|
||||
applyTint();
|
||||
applyTexel();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user