I’ve run across some code in what I think was nVidia’s GLSL implementation that won’t run on the ATI or 3Dlabs cards we have here (surprise!? ). What it is doing is constructing a 3x3 submatrix from a 4x4 matrix using something along the lines of:
uniform mat4 foo
void main() {
mat3 bar = mat3(foo);
}
I’m not entirely sure this is a legal thing to do. The 1.051 spec only talks about using collections of floats for the matrix constructor or from vec types, but nothing involving matrix types. Am I correct in this read of the spec?
If so, what is an efficient way of constructing a sub matrix out of a larger matrix? Alternatively, efficiently dealing with making the same 4x4 matrix do both point and vector transformations without creating a submatrix. Perhaps creating a new vec4 with the w component set to zero? eg
mat4 foo;
vec4 new_normal = vec4(old_normal.xyz, 0);
new_normal = foo * new_normal;