Skip to content Skip to sidebar Skip to footer

Multiplication By A View Matrix Does Not Affect The Resulting Value In Opengl Es 2.0/3.0

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_vMatr

Solution 1:

The view matrix

Matrix.setLookAtM(viewMatrix, 0, 0f, 0f, 4f, 0.0f, 0f, 0f, 0f, 1.0f, 0.0f)

does not affect the viewing directing, because the upper left 3x3 of the view matrix is the Identity matrix.

Hence the operation

vec3 lightVector = -(mat3(u_vMatrix) * lightDirection);

multiplies the vector lightDirection by the identity matrix and doesn't change the vector at all.

Use different a point of view, to see the effect of the view matrix. For Instance:

Matrix.setLookAtM(viewMatrix, 0f, 0f, 2.8f, 2.8f, 0.0f, 0f, 0f, 0f, 1.0f, 0.0f)

Post a Comment for "Multiplication By A View Matrix Does Not Affect The Resulting Value In Opengl Es 2.0/3.0"