Add code
This commit is contained in:
38 files changed
+2150
No files matched your search
@@ -0,0 +1,29 @@
|
||||
#version 330 core
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec3 normal;
|
||||
in vec3 fragPosWorld;
|
||||
|
||||
uniform vec3 uColor;
|
||||
|
||||
vec3 lightColor = vec3(1.0f, 1.0f, 1.0f);
|
||||
|
||||
vec3 lightPos = vec3(-100.0f, 50.0f, 100.0f);
|
||||
|
||||
void main()
|
||||
{
|
||||
// Ambient
|
||||
float ambientStrength = 0.5;
|
||||
vec3 ambient = ambientStrength * lightColor;
|
||||
|
||||
// Diffuse
|
||||
vec3 norm = normalize(normal);
|
||||
vec3 lightDir = normalize(lightPos - fragPosWorld);
|
||||
float diff = max(dot(norm, lightDir), 0.0);
|
||||
vec3 diffuse = diff * lightColor;
|
||||
|
||||
|
||||
vec3 result = (ambient + diffuse) * uColor;
|
||||
FragColor = vec4(result, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#version 330 core
|
||||
|
||||
layout (location = 0) in vec3 inPos;
|
||||
layout (location = 1) in vec3 inNormal;
|
||||
|
||||
uniform mat4 uModel;
|
||||
uniform mat4 uView;
|
||||
uniform mat4 uProjection;
|
||||
|
||||
out vec3 normal;
|
||||
out vec3 fragPosWorld;
|
||||
|
||||
void main()
|
||||
{
|
||||
fragPosWorld = vec3(uModel * vec4(inPos, 1.0));
|
||||
normal = vec3(uModel * vec4(inNormal, 0.0));
|
||||
|
||||
gl_Position = uProjection * uView * uModel * vec4(inPos, 1.0f);
|
||||
}
|
||||
Reference in new issue
Block a user