summaryrefslogtreecommitdiff
path: root/resources/shader.frag
diff options
context:
space:
mode:
Diffstat (limited to 'resources/shader.frag')
-rw-r--r--resources/shader.frag17
1 files changed, 16 insertions, 1 deletions
diff --git a/resources/shader.frag b/resources/shader.frag
index f81277d..0b81464 100644
--- a/resources/shader.frag
+++ b/resources/shader.frag
@@ -2,10 +2,25 @@
// Ouput data
in vec2 UV;
+in vec3 FragmentPos;
+in vec3 Normal;
out vec3 color;
uniform sampler2D textureSampler;
void main() {
- color = texture(textureSampler, UV).rgb;
+ vec3 light_color_ambient = vec3(0.4, 0.6, 0.9);
+ vec3 light_color_diffuse = vec3(0.8, 1.0, 1.0);
+
+ vec3 lightpos = vec3(16, 26, 32);
+
+ float ambient_strength = 0.3;
+ vec3 ambient = ambient_strength * light_color_ambient;
+
+ vec3 norm = normalize(Normal);
+ vec3 light_dir = normalize(lightpos - FragmentPos);
+
+ float diff = max(dot(norm, light_dir), 0.0);
+ vec3 diffuse = diff * light_color_diffuse;
+ color = (ambient + diffuse) * texture(textureSampler, UV).rgb;
}