AGAL: m44 instead of Matrix3D.append()

314 Views Asked by At

How to move such computation:

var a : Matrix3D = ...
var b : Matrix3D = ...
a.append( b );

within shader?

My current approach:

setProgramConstantsFromMatrix( VERTEX, 0, a, true );
setProgramConstantsFromMatrix( VERTEX, 4, b, true );


"mov vt0, vc0\n" + 
"mov vt1, vc1\n" + 
"mov vt2, vc2\n" + 
"mov vt3, vc3\n" + 
"m44 vt4, vc4, vt0\n"

produce wrong results into vt4. What am I doing wrong?

1

There are 1 best solutions below

4
On

In the shader you don't need to assign vt1, 2 and 3. The shader will 'know' it is being sent a matrix and automatically load the following 3 registers (4 registers in total) with the required details. Loading them yourself might be causing the unpredictable results.
Also note that the order you apply matrix3D multiplications matters. In AS3 there is also the prepend method, which puts the matrix3D parameter on the right hand side of the multiplication. The append method puts the matrix3D parameter on the left hand side of the multiplication. You may, then, need to reverse the order in which you apply the m44. ie; you could set vt1 to b and then multiply (m44) by a.