HLSL instancing problem

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: HLSL instancing problem

Post by Mel »

No, none of them will bring you anywhere. wordlViewInverse is the view matrix, multiplied by the world matrix, and that, made inverse.

Code: Select all

 
matrix4 worldViewInverse;
worldViewInverse = viewMatrix*worldMatrix;
worldViewInverse.makeInverse();
 
http://www.cs.uaf.edu/2007/spring/cs481 ... rices.html

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... :D) 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.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
kevinsbro
Posts: 51
Joined: Fri Nov 05, 2010 8:18 pm

Re: HLSL instancing problem

Post by kevinsbro »

Thank you so much for your help! I don't think there's any easy way around the problem, but I tried
Post Reply