开发者

Molehill Shader

开发者 https://www.devze.com 2023-02-20 09:36 出处:网络
I\'m trying to understand molehill and would like to multiple a vertex by two matrices, say: output = theVertex * scaleMatrix * rotationMatrix

I'm trying to understand molehill and would like to multiple a vertex by two matrices, say:

output = theVertex * scaleMatrix * rotationMatrix

Im guessing my vertex shader would look something like:

"m44 vt0, va0, vc0\n" +
"mul op, vt0, vc1\n";

And i would set the matrices with

context3d.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX,开发者_开发技巧 0, scaleMatrix);
context3d.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 1, rotationMatrix);

But its not working. What am i doing wrong?

Im aware that i could multiple the matrix before putting on the shader, but i am trying to understand AGAL.

Cheers


A m44 matrix is 4x4 floats, it takes 4 registers as each register is 128bits (4 floats) so you have to load your rotation matrix into vc4 register:

"m44 vt0, va0, vc0\n" +
"mul op, vt0, vc4\n";

context3d.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 0, scaleMatrix);
context3d.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 4, rotationMatrix);
0

精彩评论

暂无评论...
验证码 换一张
取 消