38 lines
684 B
GLSL
38 lines
684 B
GLSL
#type vertex
|
|
#version 410 core
|
|
|
|
layout(location = 0) in vec3 v_position;
|
|
layout(location = 1) in vec3 v_normal;
|
|
|
|
out vec3 normal;
|
|
|
|
uniform mat4 u_viewMatrix;
|
|
uniform mat4 u_worldMatrix;
|
|
|
|
void main()
|
|
{
|
|
vec3 positon = v_position / 256.0;
|
|
|
|
gl_Position = u_viewMatrix * u_worldMatrix * vec4(positon,1.0);
|
|
normal = v_normal;
|
|
}
|
|
|
|
#type fragment
|
|
#version 410 core
|
|
|
|
layout(location = 0) out vec4 fragColor;
|
|
layout(location = 1) out int objectID;
|
|
|
|
in vec3 normal;
|
|
|
|
uniform int u_objectID;
|
|
|
|
void main()
|
|
{
|
|
float light = clamp(dot(normal, normalize(vec3(1,7,3))), 0.1, 1.0);
|
|
|
|
fragColor = vec4(light, light, light, 1.0);
|
|
//fragColor = vec4(1, 1, 1, 1.0);
|
|
objectID = u_objectID;
|
|
}
|