30 lines
951 B
GLSL
30 lines
951 B
GLSL
#version 400 core
|
|
layout(location = 0) in vec3 vertex_position; // position
|
|
layout(location = 1) in vec3 vertex_normal; // colour of each vertex point
|
|
layout(location = 2) in vec2 vertex_tex;
|
|
layout(location = 3) in vec4 vertex_colour;
|
|
|
|
out vec2 TexCoord;
|
|
out vec4 VertexColour;
|
|
|
|
// TODO: change c code to match with u_<uniformName>
|
|
// also types really matter for shaders!!
|
|
uniform mat4 matrix;
|
|
uniform mat4 view;
|
|
uniform mat4 proj;
|
|
uniform vec3 u_lightDir;
|
|
uniform float u_lightInfluence; // 0.0 indoors, 1.0 outdoors
|
|
|
|
void main() {
|
|
gl_Position = proj * view * matrix * vec4(vertex_position, 1.0);
|
|
|
|
// max 0.3 so the shadowed side isn't pure black (ambient light)
|
|
float diffuse = max(dot(normalize(vertex_normal), normalize(u_lightDir)), 0.3);
|
|
|
|
float intensity = mix(1.0, diffuse, u_lightInfluence);
|
|
|
|
vec3 lighting = intensity * vertex_colour.rgb;
|
|
|
|
VertexColour = vec4(lighting, vertex_colour.a);
|
|
TexCoord = vertex_tex;
|
|
} |