Issue Matrix multiplication in Directx vs OpenGL.

This worked in DirectX & OpenGL platform. But it repeat the same calculate every vertex, which is not efficient.

float4x4 matWVP = mul(World, mul(View, Proj));
o.position = mul(i.position, matWVP);

But when i precalculate on CPU and pass into GPU, the rendering become weird.


o.position = mul(i.position, WVP);

Pass the WVP in rather than doing the calc in the shader.

I think that OpenGL and DX use different multiplaction order, that is to say one multiples a matrix by column, the other by row, switching the multiplication order may help??

1 Like

try transposing on the shader though im not to confident that is the problem.

WVP = transpose(WVP);
o.position = mul(i.position,WVP);

Does sound similar to a problem i had here.

1 Like

Thanks for reply! it’s work, i did some research on it. I found this.

1 Like