I am looking for a suitable simple example.
Now I had something based on a textbook, but I do not see variations in the middle of the triangles. Each triangle seems to change color, but only in general.
out vec3 vertex_normal;
out vec3 vertex_light_position;
.. in the vertex shader.
with
vertex_normal = normalize(NormalMatrix * in_Normal);
mat3 NormalMatrix = transpose(
inverse(
mat3(
ModelViewMatrix
)
)
);
and on the 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 seems to be a solid color (which only changes as a whole).
I heard that normalization can play a role, but if I normalize () vertex_normal, then the same result.
j riv source
share