Hi,
I am multiplying two matrices in a shader utility function. In fact I'm multiplying quite a few matrices in this utility function to create a model view transformation. Everything works nicely, except for in one case where I have to multiply two matrices in a function. All this function does is take two float4x4s and multiply them together, if I don't do this, if I try to multiply them inline where I have the function the shader shows complete garbage. The matrices I'm multiplying are the post view space and a camera rotation matrix.
Everything works great, when those camera matrix multiplications are in a function. It makes no sense to me. Here are links to my code:
This is the useless function that is required looks like this:
float4x4 matrixProduct4x4(float4x4 m1, float4x4 m2) {
return m1 * m2;
}
Here is where I have to use it:
SRT_CR = matrixProduct4x4(SRT_C, cameraRotationMatrix.y);
SRT_CR = matrixProduct4x4(SRT_CR, cameraRotationMatrix.x);
^^^ This works.
If try this:
SRT_CR = SRT_C * cameraRotationMatrix.y;
SRT_CR = SRT_CR * cameraRotationMatrix.x;
Which is all that function does, I see garbage.
I don't understand what's happening. What is there being a function involved doing? You can see there are lots of other regular matrix multiplications happening without any problem, including other rotations that use the exact same rotation matrix format.
It seems like a Metal bug. Either the bug is that my code is broken and it shouldn't work with the function, or the bug is that it should work without the function.
Edit: I tried to post links to github but it ended up being in moderation, if anyone wants more details maybe I can provide those.
Thank you.