Added point light prototype

This commit is contained in:
Robert 2021-01-26 15:34:35 +01:00
parent 3f6e2c2b6b
commit b3e82ca9df
7 changed files with 144 additions and 33 deletions

View file

@ -1,5 +1,7 @@
#version 330 core
in vec2 oUV;
in vec3 oNormal;
in vec3 oFragPos;
out vec4 FragColor;
@ -9,9 +11,19 @@ uniform sampler2D texture2;
uniform float ambientStrength;
uniform vec3 ambientColor;
uniform vec3 lightPos;
uniform vec3 lightColor;
void main()
{
vec3 ambient = ambientColor * ambientStrength;
vec3 norm = normalize(oNormal);
vec3 lightDir = normalize(lightPos - oFragPos);
FragColor = mix(texture(texture1, oUV), texture(texture2, oUV), 0.2) * vec4(ambient, 1.0);
float diff = max(dot(norm, lightDir), 0.0);
vec3 diffuse = diff * lightColor;
vec4 objColor = mix(texture(texture1, oUV), texture(texture2, oUV), 0.2);
FragColor = vec4(ambient + diffuse, 1.0) * objColor;
}

View file

@ -0,0 +1,10 @@
#version 330 core
uniform vec3 color;
out vec4 FragColor;
void main()
{
FragColor = vec4(color, 1.0);
}

View file

@ -0,0 +1,13 @@
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aUV;
layout (location = 2) in vec3 aNormal;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main()
{
gl_Position = projection * view * model * vec4(aPos, 1.0);
}

View file

@ -1,15 +1,21 @@
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aUV;
layout (location = 2) in vec3 aNormal;
out vec2 oUV;
out vec3 oNormal;
out vec3 oFragPos;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
uniform mat3 normal;
void main()
{
oUV = aUV;
oNormal = normal * aNormal;
gl_Position = projection * view * model * vec4(aPos, 1.0);
oFragPos = vec3(model * vec4(aPos, 1.0));
}