1

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?

Slaus
  • 2,086
  • 4
  • 26
  • 41
  • Well, when you use a.append( b ); you get new matrix. And when you use m44 you get a vector. There should be a vector as source1. http://help.adobe.com/en_US/as3/dev/WSd6a006f2eb1dc31e-310b95831324724ec56-8000.html – nikitablack Jan 29 '14 at 08:12
  • Indeed, it seems like Volgogradetzzz is right. About a third of the way down this page... http://www.adobe.com/devnet/flashplayer/articles/what-is-agal.html there's a chart. Check the m44 description and it says it takes a matrix and a 4 component vector (a component is an x, y, z or w). It can't multiply two matrices. – moosefetcher Jan 29 '14 at 12:56

1 Answers1

0

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.

moosefetcher
  • 1,841
  • 2
  • 23
  • 39
  • The reason (probably) for moving matrix A into tmp registers is because AGAL won't allow multiplication of two constants. – Varnius Jan 28 '14 at 10:13
  • I know. I was talking about a different issue; whether he needs to pass the FOLLOWING 3 vc registers to vt registers. Thinking about it, I am not so sure. But it may still be worth reversing the order in which he applies the multiplication. – moosefetcher Jan 28 '14 at 10:30
  • Tried both: leaving just "mov vt0, vc0" and swapping vc4 and vt0: didn't helped. – Slaus Jan 28 '14 at 21:37
  • Check Volgogradetzz's comment above. It looks like you can't multiply 2 matrices with m44. If you can find an online reference to the calculations required to append one matrix3D to another, you might be able to perform those calculations in your shader on a component-by-component basis, ending up with 4 new registers loaded with the 16 numbers in a matrix3D. – moosefetcher Jan 29 '14 at 13:14