this blog from:
can someone confirm following calculation, please? :)
in normal android opengl shader the computation:
mat4 a;vec3 p;vec3 pos = (a * vec4(p,1.0)).xyz;
would be calculated like this:
pos.x = a0 * p.x + a1 * p.y + a2 * p.z + a3 * 1.0;pos.y = a4 * p.x + a5 * p.y + a6 * p.z + a7 * 1.0;pos.z = a8 * p.x + a9 * p.y + a10 * p.z + a11 * 1.0;
is this correct? or did I miss something? every help is highly appreciated.
answer1:
Ok actually I've found a reliable source:
vec3 v, u;mat3 m;
And
u = m * v;
is equivalent to
u.x = m[0].x * v.x + m[1].x * v.y + m[2].x * v.z;u.y = m[0].y * v.x + m[1].y * v.y + m[2].y * v.z;u.z = m[0].z * v.x + m[1].z * v.y + m[2].z * v.z;
Therefore
vec3 v, u;mat4 m;
And
u = (mat * vec4(v,1.0)).xyz
should be equivalent to
u.x = m[0].x * v.x + m[1].x * v.y + m[2].x * v.z + m[3].x * 1;u.y = m[0].y * v.x + m[1].y * v.y + m[2].y * v.z + m[3].y * 1;u.z = m[0].z * v.x + m[1].z * v.y + m[2].z * v.z + m[3].z * 1;
Please correct me if I'm wrong though.