Code: Select all
matrix4 worldViewInverse;
worldViewInverse = viewMatrix*worldMatrix;
worldViewInverse.makeInverse();
OpenGL has this gl_normalMatrix already calculated, but in DX you have to provide it yourself. But you can't leave out the inverse and transpose calculations of the world*view product. It all must be done together, that is, multiply view*world matrix (irrlicht reverse order of matrix multiplication... ) And this matrix must be inverted, and the inverted matrix then must be transposed. Though that maybe an OpenGL issue, as they use column major matrices, and in HLSL matrices are Row Major, so, the transposed matrix may not be actually needed.
If it works well without transposing the matrix, you can leave it out. But you have to make the inverse of the matrix of the RESULT of the view*world matrix.