I'm looking for a proper simple example.
Right now I had something based on a tutorial but I don't see variations in the middle of the triangles. It appears each triangle changes color but only in whole.
out vec3 vertex_normal;
out vec3 vertex_light_position;
.. on the vertex shader.
with
vertex_normal = normalize(NormalMatrix * in_Normal);
// old gl_NormalMatrix: "transpose of the inverse of the upper
// leftmost 3x3 of gl_ModelViewMatrix"
mat3 NormalMatrix = transpose(
inverse(
mat3(
ModelViewMatrix
)
)
);
and on fragment shader:
float diffuse_value = MAX(dot(vertex_normal, vertex_light_position), 0.0);
gl_FragColor = out_Color * diffuse_value
But as I said, each triangle appears to be a solid color (that changes only in whole).
I heard that normalization may play a role but if I normalize() vertex_normal it's same result.