add icon shader
This commit is contained in:
parent
e70efe55fa
commit
e8fd3617c5
3 changed files with 70 additions and 6 deletions
29
src/shaders/icon.fs
Normal file
29
src/shaders/icon.fs
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue