Reputation: 1
Using the Molehill with Flash I wish to create a vertiex shader, to have one mesh transform into another, I have seen that it is possible with Flare, However I am unsure if that was using Stage3D, Can anyone give me any pointers in the use of shaders in AGAL as to how this might be done. Thanks
Upvotes: 0
Views: 325
Reputation: 1069
(maybe too late)
a morphing is "simply" a linear interpolation between 2 sets of positions.
assuming you have a first vertexBuffer VA0 representing the origins and a second vertexbuffer VA1 representing your destinations. you can store them in temporary registers:
"mov vt0 va0 \n" +//temp var, will hold the result
"mov vt1 va0 \n" +//start position
"mov vt2 va1 \n" +//destination
then you'll need a T value that you can pass as a constant like this:
context.setProgramConstantsFromVector( Context3DProgramType.VERTEX, id, constant );
if you pass something like
Vector.<Number>([ T, 0,0, 1 ])
with 0<=T<=1 as the constant and put it at id 0, the following code will transform (linearly inpterpolate) the output positions from the starting position to the end position.
//lerp
"sub vt0 vt2 vt1 \n" +
"mul vt0 vt0 vc0.x \n" +
"add vt0 vt0 va1 \n" +
then you need to project VT0 to get the correct output.
Upvotes: 2
Reputation: 18546
The next version of pixel bender should support creating both 3d vertex and fragment shaders. A preview release should be available here
Upvotes: 0