diff options
author | 2025-02-07 11:27:18 -0500 | |
---|---|---|
committer | 2025-02-07 11:27:18 -0500 | |
commit | 4da7be39827ea5888ef9c97b1aadf61b0d76347c (patch) | |
tree | 15d0ff8f8bcb0e871efb1b2e65c2bc8d07b17565 /mons_exe/embed/shaders/basic_lit.frag.glsl |
initial commit (lol)
Diffstat (limited to 'mons_exe/embed/shaders/basic_lit.frag.glsl')
-rw-r--r-- | mons_exe/embed/shaders/basic_lit.frag.glsl | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/mons_exe/embed/shaders/basic_lit.frag.glsl b/mons_exe/embed/shaders/basic_lit.frag.glsl new file mode 100644 index 0000000..467174c --- /dev/null +++ b/mons_exe/embed/shaders/basic_lit.frag.glsl @@ -0,0 +1,27 @@ +#version 460 core +out vec4 FragColor; + +in vec3 Normal; +in vec2 TexCoord; +in vec3 FragPos; +in mat3 TBN; + +uniform float ambient_strength; +uniform sampler2D base_texture; +uniform sampler2D normal_texture; + +uniform vec4 light_color; +uniform vec3 light_position; + +void main() { + vec4 base_color = texture(base_texture, TexCoord); + vec3 normal = texture(normal_texture, TexCoord).rgb; + normal = normal * 2.0 - 1.0; + normal = normalize(TBN * normal); + vec3 light_direction = normalize(light_position - FragPos); + float diff = max(dot(normal, light_direction), 0.0); + vec4 diffuse_color = diff * light_color; + vec4 ambient_color = ambient_strength * light_color; + + FragColor = (ambient_color + diffuse_color) * base_color; +} |