Away3d AGAL Vertex animation

Ok, so I’m on a mission to create some sweet ass AGAL powered vertex animation that will integrate with the Away3d library. I’ve started a conversation on the away3d forum, but thought I’d create a blog post to help people understand exactly what I’m trying to achieve.

One thing to note is that I’m not trying to create a static vertex animation, the whole point of this is to come up with a dynamic vertex animations via AGAL. Also worth noting that while the same effect can be create by calculating vertex position in AS3 with the CPU and then uploading to the GPU, this is not the desired approach, as the upload process is quite costly.

I’m not sure the best way to approach this. So my first thought was to create a custom material and pass, and then bake the vertex animation AGAL into the custom passes getVertexCode method. This actually worked out exactly as planned (see below)

Get Adobe Flash player

You can download the source files for this here

So this is cool, but the issue arises when trying to combine this effect with some of the more complex materials that are built into away3d. For example I’d like to apply this effect to a standard TextureMaterial with a normalMethod and EnvMapMethod…

Sp my next thought was to create a custom method and try to apply the AGAL with this. The issue with this approach is that the AGAL is inserted in the incorrect location. for example if I use a ColorMaterial and set = true, I can see the output AGAL looks like this:

mov vt0, va0
m44 op, vt0, vc0

Ideally my custom AGAL needs to be injected on the second line.

mov vt0, va0
// Want custom AGAL to go here
m44 op, vt0, vc0

However when I apply my custom method my custom AGAL is inserted underneath the ColorMaterial AGAL.

mov vt0, va0
m44 op, vt0, vc0
// Custom AGAL is getting inserted here

It seems to me that a custom method would be the best way to make custom AGAL vertex shaders because it would make it easier to apply to any material, however I’m a little stumped how to get around this issue.

1 Comment

  1. Peter, thank you so much!


  1. Away3d AGAL Vertex animation (Part 2) | Pete Shand - [...] part 1 of this post (Which can be viewed here) I discussed various approaches to creating a AGAL vertex shader …

Submit a Comment

Your email address will not be published. Required fields are marked *