View Full Version : Lighting effect problem with normal matrix

10-29-2010, 02:46 AM

I have some problems on using the following code:

var normalMatrix = mvMatrix.inverse();
normalMatrix = normalMatrix.transpose();
gl.uniformMatrix4fv(shaderProgram.nMatrixUniform, false, new Float32Array(normalMatrix.flatten()));

If I do not use these three statement to transform the normal, my objects with lighting effect work properly in Google Chrome. However, Firefox fails to show it.

If I use these three statement, I can see the object in Chrome and Firefox but I have to update the light direction and position and I take much time to update it because I have to test different parameter until the light can reflect on the object. After I see the light reflect to the object, I find that the lighting result is not the same as before using these three statement.

I want to know are these three statement must exist in my coding? And how to use these three statement. I want to have the same lighting result after I use these three statement.