daily update
This commit is contained in:
28
basic-lighting/shaders/fscolors.glsl
Normal file
28
basic-lighting/shaders/fscolors.glsl
Normal file
@@ -0,0 +1,28 @@
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
in vec3 FragPos;
|
||||
in vec3 Normal;
|
||||
|
||||
uniform vec3 viewPos;
|
||||
uniform vec3 lightPos;
|
||||
uniform vec3 objectColor;
|
||||
uniform vec3 lightColor;
|
||||
|
||||
void main() {
|
||||
float ambientStrength = 0.1;
|
||||
float specularStrength = 0.9;
|
||||
vec3 ambient = ambientStrength * lightColor;
|
||||
|
||||
vec3 norm = normalize(Normal);
|
||||
vec3 lightDir = normalize(lightPos - FragPos);
|
||||
float diff = max(dot(norm, lightDir), 0.0);
|
||||
vec3 diffuse = diff * lightColor;
|
||||
|
||||
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);
|
||||
}
|
||||
5
basic-lighting/shaders/fslightCube.glsl
Normal file
5
basic-lighting/shaders/fslightCube.glsl
Normal file
@@ -0,0 +1,5 @@
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
void main() {
|
||||
FragColor = vec4(1.0);
|
||||
}
|
||||
17
basic-lighting/shaders/vscolors.glsl
Normal file
17
basic-lighting/shaders/vscolors.glsl
Normal file
@@ -0,0 +1,17 @@
|
||||
#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 * model * vec4(aPos, 1.0);
|
||||
|
||||
}
|
||||
10
basic-lighting/shaders/vslightCube.glsl
Normal file
10
basic-lighting/shaders/vslightCube.glsl
Normal file
@@ -0,0 +1,10 @@
|
||||
#version 330 core
|
||||
layout(location = 0) in vec3 aPos;
|
||||
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
void main() {
|
||||
gl_Position = projection * view * model * vec4(aPos, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user