I my code I am currently working on, I have to transform a vector in my fragment shader to another coordinate space (simliar to the transformation between the cameras space and the lights space with shadow mapping), do some calculations in this coordinate space, and transform it back.
Since the results were not satisfying, and I was searching for the cause, in the end I checked if I just transform a vector, and then transform it back with the inverse of the transformation matrix it is equal to the original vector.
Something like this:
vec4 transformedVec4 = transformMat4 * originalVec4;
vec4 ReTransformedVec4 = inverse(transformMat4) * transformedVec4;
if(transformedVec4 == ReTransformedVec4)
{
//some code to display if equal
}
I was really surprised to see, that my code never enters the if-statement.
Does anybody know where this comes from? Is it simply the floating point precision, that causes the results to be unequal?