Added super simple lighting to shaders.

master
Martin Felis 2020-10-31 22:37:26 +01:00
parent 6dd7d27777
commit 1ef48039b5
2 changed files with 8 additions and 1 deletions

View File

@ -2,8 +2,11 @@
out vec4 fragColor; out vec4 fragColor;
smooth in vec4 ioFragColor; smooth in vec4 ioFragColor;
in vec3 ioNormal;
in vec2 ioUV;
void main() void main()
{ {
fragColor = ioFragColor; float diff = max(dot(ioNormal, vec3(1., 1., 1.)), 0.3);
fragColor = ioFragColor * diff;
} }

View File

@ -10,9 +10,13 @@ uniform mat4 uViewMatrix;
uniform mat4 uProjectionMatrix; uniform mat4 uProjectionMatrix;
smooth out vec4 ioFragColor; smooth out vec4 ioFragColor;
out vec3 ioNormal;
out vec2 ioUV;
void main() void main()
{ {
ioFragColor = inColor; ioFragColor = inColor;
ioNormal = inNormal;
ioUV = inUV;
gl_Position = (uProjectionMatrix * uViewMatrix * uModelMatrix * inCoord); gl_Position = (uProjectionMatrix * uViewMatrix * uModelMatrix * inCoord);
} }