I was looking to access a float4x4 as a flat array (16 floats) but it doesn’t seem to work - is that possible to do in a shader?
e.g.
float4x4 myMatrix;
float fValue = myMatrix[14];
I’ve also tried using an integer index but it only seems to work for one of the values.
This works:
float4 fRow = myMatrix[rowIndex][0];
This doesn’t work:
float fValue = myMatrix[rowIndex][colIndex];
Once i’ve retrieved the row I thought I could access the ‘column’ by using the float4 as 4 floats but I can’t seem to find a way of doing that without having 4 if statements:
Thanks for that but I was looking for a specific value so even if I used that method I would still need to have an ‘IF’ statement to decide which one to use.
Yeah, it’s strange it doesn’t work but I guess the shader assembly language doesn’t support double indexing like that. Unfortunately your other suggestion doesn’t work either
I managed to remove the conditional by multiplying the resulting row with a row from this matrix to isolate the value: