#type vertex #version 410 core layout(location = 0) in vec3 v_position; layout(location = 1) in vec3 v_normal; layout(location = 2) in vec2 v_UV; out vec3 normal; out vec2 uv; uniform mat4 u_viewMatrix; uniform mat4 u_worldMatrix; void main() { uv = v_UV; normal = mat3(u_worldMatrix) * v_normal; // transform normals into world space gl_Position = u_viewMatrix * u_worldMatrix * vec4(v_position, 1.0); } #type fragment #version 410 core layout(location = 0) out vec4 fragColor; layout(location = 1) out int objectID; in vec3 normal; in vec2 uv; uniform sampler2D u_Texture; uniform int u_objectID; void main() { vec3 lightDir = normalize(vec3(1.0, 7.0, 3.0)) * 0.2f + 0.8f; float light = clamp(dot(normalize(normal), lightDir), 0.1, 1.0); vec4 texColor = texture(u_Texture, uv); fragColor = vec4(texColor.rgb * light, texColor.a); // fragColor = vec4(uv.r, uv.g, 0, 1); objectID = u_objectID; }