treesummaryrefslogcommitdiff
path: root/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'shaders')
-rw-r--r--shaders/frag.glsl25
-rw-r--r--shaders/vert.glsl18
2 files changed, 43 insertions, 0 deletions
diff --git a/shaders/frag.glsl b/shaders/frag.glsl
new file mode 100644
index 0000000..a92699c
--- /dev/null
+++ b/shaders/frag.glsl
@@ -0,0 +1,25 @@
+#version 330 core
+
+in vec3 FragPos;
+in vec3 Normal;
+
+out vec4 FragColor;
+
+uniform vec3 objectColor;
+uniform vec3 lightColor;
+uniform vec3 lightPos;
+
+void main()
+{
+ vec3 norm = normalize(Normal);
+ vec3 lightDir = normalize(lightPos - FragPos);
+
+ float diff = max(dot(norm, lightDir), 0.0);
+ vec3 diffuse = diff * lightColor;
+
+ float ambientStrength = 0.1;
+ vec3 ambient = ambientStrength * lightColor;
+
+ vec3 result = (ambient + diffuse) * objectColor;
+ FragColor = vec4(result, 1.0f);
+} \ No newline at end of file
diff --git a/shaders/vert.glsl b/shaders/vert.glsl
new file mode 100644
index 0000000..fc3721a
--- /dev/null
+++ b/shaders/vert.glsl
@@ -0,0 +1,18 @@
+#version 330 core
+
+layout (location = 0) in vec3 pos;
+layout (location = 1) in vec3 normal;
+
+out vec3 FragPos;
+out vec3 Normal;
+
+uniform mat4 model;
+uniform mat4 view;
+uniform mat4 projection;
+
+void main()
+{
+ gl_Position = projection * view * model * vec4(pos, 1.0);
+ FragPos = vec3(model * vec4(pos, 1));
+ Normal = normal;
+} \ No newline at end of file