-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbf91ab
commit 83c2782
Showing
4 changed files
with
72 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,33 @@ | ||
#version 330 core | ||
out vec4 FragColor; | ||
|
||
uniform vec4 inputColor; | ||
in vec3 Normal; | ||
in vec3 FragPos; | ||
|
||
uniform vec3 lightPos; | ||
uniform vec3 viewPos; | ||
uniform vec3 lightColor; | ||
uniform vec3 objectColor; | ||
|
||
void main() | ||
{ | ||
FragColor = inputColor; // set alle 4 vector values to 1.0 | ||
} | ||
// ambient | ||
float ambientStrength = 0.1; | ||
vec3 ambient = ambientStrength * lightColor; | ||
|
||
// diffuse | ||
vec3 norm = normalize(Normal); | ||
vec3 lightDir = normalize(lightPos - FragPos); | ||
float diff = max(dot(norm, lightDir), 0.0); | ||
vec3 diffuse = diff * lightColor; | ||
|
||
// specular | ||
float specularStrength = 0.5; | ||
vec3 viewDir = normalize(viewPos - FragPos); | ||
vec3 reflectDir = reflect(-lightDir, norm); | ||
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 32); | ||
vec3 specular = specularStrength * spec * lightColor; | ||
|
||
vec3 result = (ambient + diffuse + specular) * objectColor; | ||
FragColor = vec4(result, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
#version 330 core | ||
layout (location = 0) in vec3 aPos; | ||
layout (location = 1) in vec3 aNormal; | ||
|
||
out vec3 FragPos; | ||
out vec3 Normal; | ||
|
||
uniform mat4 model; | ||
uniform mat4 view; | ||
uniform mat4 projection; | ||
|
||
void main() | ||
{ | ||
gl_Position = projection * view * model * vec4(aPos, 1.0); | ||
FragPos = vec3(model * vec4(aPos, 1.0)); | ||
Normal = mat3(transpose(inverse(model))) * aNormal; | ||
|
||
gl_Position = projection * view * vec4(FragPos, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters