actionscript-3stage3dagal

AGAL HELP: in 2D texture, 2D rendering, how to use agal to comput vertex by x,y offset from program constant


I hope someone could shred some light on my agal question:

I have a 64x64 fixed size texture. The uv and vertex are fixed as well.

Now I need to move it in a 2D stage.

The current way I’m using is to compute and upload a new vertex every time drawing triangles from this texture.

I’ve found VertexBuffer3D.uploadFromByteArray takes significant time to process.

I believe there must be smarter ways to do this in agal.

Can I pass the x, y offset in constant registers for Vertex Shade, and compute the vertex size in agal?

If this is possible, how can I do it?


Solution

  • Upload your geometry once and then multiply each vertex by your Model-View-Perspective matrix in the vertex shader. The matrix can be passed to the vertex shader in the constant register (beware that one 4x4 matrix takes 4 constant registers). Here`s a nice example of this.