add icon shader

This commit is contained in:
Jeeves 2025-06-03 00:20:44 -06:00
parent e70efe55fa
commit e8fd3617c5
3 changed files with 70 additions and 6 deletions

29
src/shaders/icon.fs Normal file
View file

@ -0,0 +1,29 @@
#version 330
in vec2 fragTexCoord;
in vec4 fragColor;
uniform sampler2D texture0;
uniform sampler2D textureNormal;
uniform vec3 lightDir;
uniform vec4 lightColor;
uniform vec4 ambientColor;
uniform vec3 falloff = vec3(0.01, 2.4, 20);
out vec4 finalColor;
void main() {
float d = length(lightDir);
vec3 n = normalize(texture(textureNormal, fragTexCoord).xyz);
vec3 l = normalize(lightDir);
vec3 diffuse = lightColor.rgb * lightColor.a * max(dot(n, l), 0.0);
vec3 ambient = ambientColor.rgb * ambientColor.a;
float attenuation = 1.0 / (falloff.x + falloff.y * d + falloff.z * d * d);
vec3 intensity = ambient + diffuse * attenuation;
vec3 final = diffuse.rgb * intensity;
finalColor = vec4(final, texture(texture0, fragTexCoord).a * 0.93);
}