is there an efficient way to iterate all elements of a mat3? What I mainly wanted to do is sum up all elements of a matrix and was wondering if there is a better way to do it than just:
float sum = 0.;
for( int i = 0; i < 3; ++i )
{
for( int j = 0; j < 3; ++j )
{
sum += m[i][j];
}
}
Awesome! Thank you very much - This looks somewhat cheaper.
I suppose there isn’t something equivalent for arrays of floats? Although the compiler will probably store these in sets of vec4 anyway? Or do you think a shader compiler will recognize a loop over an array which doesn’t anything more than just summing these elements. This could also be expressed as a set of vec4 dot-products with vec4(1.)…
I would probably need to use vec4[] instead of float[], don’t I? But that seems a bit uncomfortable