aboutsummaryrefslogtreecommitdiff
path: root/mons_exe/embed/shaders/basic_lit.frag.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'mons_exe/embed/shaders/basic_lit.frag.glsl')
-rw-r--r--mons_exe/embed/shaders/basic_lit.frag.glsl27
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;
+}