diff options
| author | Patrick Schönberger | 2021-01-20 12:30:16 +0100 |
|---|---|---|
| committer | Patrick Schönberger | 2021-01-20 12:30:16 +0100 |
| commit | 3482c97d66930004d823462c19efb57a8fc1e5de (patch) | |
| tree | 26718d6dbfd7d33fab2bbb2a1f91e01df63773e5 /shaders | |
| parent | d231a4a0d3eca45bb1129f8fa5f9d093f3eff480 (diff) | |
| download | subsurface_scattering-3482c97d66930004d823462c19efb57a8fc1e5de.tar.gz subsurface_scattering-3482c97d66930004d823462c19efb57a8fc1e5de.zip | |
Code Refactoring
Diffstat (limited to 'shaders')
| -rw-r--r-- | shaders/frag.glsl | 25 | ||||
| -rw-r--r-- | shaders/vert.glsl | 18 |
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 |
