Archived

This topic is now archived and is closed to further replies.

Vertexshader tweening with mesh

This topic is 5641 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I would be so gratefull if anyone could explain to me both in Theory and with Real code on how to do tweening with vertexshader with Meshes. please dont give me that link to that old post that someone wrote ages ago. do i need vertexbuffers when i got meshes?. please, could u explain step by step both theory and code on how to do it?. i would be eternally grateful. / Mr. Funk

Share this post


Link to post
Share on other sites
You sure are asking for a lot. Have you taken a look at the Dolphin sample in the DirectX SDK? There is your sample code. I will be more than happy to answer any specific questions you may have after you have bloodied yourself on that.

Share this post


Link to post
Share on other sites
quote:

I would be so gratefull if anyone could explain to me both in Theory and with Real code on how to do tweening with vertexshader with Meshes.



The DX SDK docs do show how tweening works fairly well. Also, I would download the nVidia effects browser, which contains a few tweening (morphing) vertex shaders with full source.

quote:

please dont give me that link to that old post that someone wrote ages ago.


There should be nothing wrong with a link to a message with the exact answers you seek.

quote:

do i need vertexbuffers when i got meshes?.


Meshes are vertex buffers. If you are using ID3DXMesh, then you are using a vertex buffer and index buffer wrapped by an interface class.

quote:

please, could u explain step by step both theory and code on how to do it?.
i would be eternally grateful.



To quote the DX SDK:

Tweening is performed before lighting and clipping. The resulting vertex position (normal) is computed as follows:
POSITION = POSITION1 * (1.0 - TWEENFACTOR) + POSITION2 * TWEENFACTOR, and likewise for normals.

Inside the vertex shader, it breaks down to taking a source and destination set of coordinates, and interpolating between them using a time factor.

An extremely basic tween shader looks like this:


  
vs.1.0

; v0 = source vertex
; v3 = target vertex
; c0-c3 = world*view*projection transformation
; c4.x = tween factor, c4.y = 1-tween factor

; LERP vertex coordinates
mul r1, v0, c4.x
mad r1, v3, c4.y, r1

; Transform to clip space and output
dp4 oPos.x, r1, c0
dp4 oPos.y, r1, c1
dp4 oPos.z, r1, c2
dp4 oPos.w, r1, c3



Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX

Share this post


Link to post
Share on other sites