-
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
e631e53
commit bd560d9
Showing
8 changed files
with
346 additions
and
113 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,33 +1,7 @@ | ||
#version 330 core | ||
out vec4 FragColor; | ||
|
||
in vec3 Normal; | ||
in vec3 FragPos; | ||
|
||
uniform vec3 lightPos; | ||
uniform vec3 viewPos; | ||
uniform vec3 lightColor; | ||
uniform vec3 objectColor; | ||
|
||
void main() | ||
{ | ||
// 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); | ||
} | ||
FragColor = vec4(1.0); // set alle 4 vector values to 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,18 +1,11 @@ | ||
#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() | ||
{ | ||
FragPos = vec3(model * vec4(aPos, 1.0)); | ||
Normal = mat3(transpose(inverse(model))) * aNormal; | ||
|
||
gl_Position = projection * view * vec4(FragPos, 1.0); | ||
gl_Position = projection * view * model * vec4(aPos, 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#version 330 core | ||
out vec4 FragColor; | ||
|
||
struct Material { | ||
vec3 ambient; | ||
vec3 diffuse; | ||
vec3 specular; | ||
float shininess; | ||
}; | ||
|
||
struct Light { | ||
vec3 position; | ||
|
||
vec3 ambient; | ||
vec3 diffuse; | ||
vec3 specular; | ||
}; | ||
|
||
in vec3 FragPos; | ||
in vec3 Normal; | ||
|
||
uniform vec3 viewPos; | ||
uniform Material material; | ||
uniform Light light; | ||
|
||
void main() | ||
{ | ||
// ambient | ||
vec3 ambient = light.ambient * material.ambient; | ||
|
||
// diffuse | ||
vec3 norm = normalize(Normal); | ||
vec3 lightDir = normalize(light.position - FragPos); | ||
float diff = max(dot(norm, lightDir), 0.0); | ||
vec3 diffuse = light.diffuse * (diff * material.diffuse); | ||
|
||
// specular | ||
vec3 viewDir = normalize(viewPos - FragPos); | ||
vec3 reflectDir = reflect(-lightDir, norm); | ||
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess); | ||
vec3 specular = light.specular * (spec * material.specular); | ||
|
||
vec3 result = ambient + diffuse + specular; | ||
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 |
---|---|---|
@@ -0,0 +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() | ||
{ | ||
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
Oops, something went wrong.