To obtain constant directional light, I multiplied the view matrix by the light direction vector:
#version 300 es
uniform mat4 u_mvMatrix; // model-view matrix
uniform mat4 u_vMatrix; // view matrix
in vec4 a_position;
in vec3 a_normal;
const vec3 lightDirection = vec3(-1.9, 0.0, -5.0);
...
void main() {
vec3 modelViewNormal = vec3(u_mvMatrix * vec4(a_normal, 0.0));
vec3 lightVector = -(mat3(u_vMatrix) * lightDirection);
float diffuseFactor = max(dot(modelViewNormal, lightVector), 0.0);
...
}
But the diffuseFactor value is the same as when use:
vec3 lightVector = -lightDirection;
In other words, it turns out the same worst picture.
Question: Can anyone please suggest why multiplication by a view matrix does not affect the resulting value diffuseFactor?
Note: The view matrix is created using:
Matrix.setLookAtM(viewMatrix, rmOffset:0, eyeX:0f, eyeY:0f, eyeZ:0f,
centerX:0f, centerY:0f, centerZ:-4f, upX:0f, upY:1f, upZ:0f)
fun getVMatrixAsFloatBuffer(): FloatBuffer = Buffers.floatBuffer(viewMatrix)
GLES20.glUniformMatrix4fv(vMatrixLink, 1, false, view.getVMatrixAsFloatBuffer());
I also checked the correctness of the view matrix using:
gl_Position = u_pMatrix * u_vMatrix * u_mMatrix * a_position;
This is working fine.
Thanks in advance!