Mesh "morphing"

hello niddastrasse,

it´s cold outside and i´m playing around with 3d models-
i want to “morph” one model into another.

the “vertexbuffer” -> “mesh”-nodes are not built for this, are they?

i connected an (fast) lfo/togedge to the “do write vertex buffer”/“do create mesh” -pins, and the framerate stays above 40fps, but the whole thing doesn´t run smooth at all…

btw: i´ve encountered this problem when i modified the coordinates (of a single model), too.

gruss, florian
(sorry, messy patch, völlig unpostable at the moment)

hallo flo.

if you’re a bit into shader-programming with hlsl you can do some nice morphing:

*create a vertex buffer, that contains several position-data. that are several positions for each vertex, between which you want to morph. store the several coordinates for each vertex for example in the texturecoordinates(3d) or specular color(if you don’t need that)
*write an effect, that has as many value-parameters as you have different positions for each vertex. these are the weights for your different positions
*transform each position with your world-transform-matrix (Transform)
*your final position is the sum of the several weighted positions you have (the weights are your value-params that you can control easily within your patch)

this way you should be able to have hardware-rendered realtime morphing, that performs smoothly. creating a mesh each frame is expensive, since all the vertex-data has to be send down to the graphics card each frame (the bus may be the bottleneck). of course the possibilities are restricted, since a vertex-buffer can not have unlimited data. (1 position, 2 colors, 1 normal, 8 texturecoordinates - that are the fields you can use to input positions, since they are float3 or float4).

maybe somebody feels like he/she wants to write a tutorial on that; i am very sorry, but i’m pretty short in time at the moment. definitely it’s an issue that could be of interest to many users. ?!

gruesse nach koelle, michel.

hi michel,

i´ve tried to follow your explanation, and started editing the template.fx shader.
assuming i want to morph between 2 objects:

write an effect, that has as many value-parameters as you have different positions for each vertex. these are the weights for your different positions

i added this to “PARAMETERS”

// Vertexes for morphing
float3 vertex1In = { 0, 0, 0 };
float3 vertex2In = { 0, 0, 0 };

// control params for morphing
float vertex1val = { 0 };
float vertex2val = { 0 };

now:

transform each position with your world-transform-matrix (Transform)

guess the calculation takes place in the vertex shader part of the effect?
i´ve copynpasted some lines from the template patch…

struct MORPH_OUTPUT
{
float4 Pos : POSITION;
};

MORPH_OUTPUT MORPH ( float4 Pos : POSITION)
{
//inititalize all fields of output struct with 0
MORPH_OUTPUT Out = (MORPH_OUTPUT)0;

Pos = mul(Pos, tWVP);

// CALCULATE FINAL POSITION ???

Out.Pos = Pos;
return Out;
}

your final position is the sum of the several weighted positions you have (the weights are your value-params that you can control easily within your patch)

mhm, i don´t get that-
why do i need a parameterfor EACH of the 2 states? if it´s for “blending” the two models, i would need only one (kind of of a “percentage”)?

(i´ve attached the fx-file).

gruss, florian

p.s. michel - haste meine email zum bücherthema gekriegt?

the file (sorry, didin´t work the first time)

a tutorial would be really nice!!

hallo flo.

sorry. the effect you uploaded was so full, i did not want to read all that. so i wrote a simple sample scetch. the effect is so basic, that you should understand everything. also the patch is very much self-explaining, i think.

questions? problems? post!

gruesse, michel.

p.s. vielen dank fuerdeine schnelle antwort wegen den buechern. ich muss noch mutti kontaktieren, was den slicecount anbelangt;-) und melde mich alsdann sobald.

good morning.

what i forgot to mention:
of course your 2 models you want to morph must have the same count of vertices and identical indexbuffers. which can be a challenge.

and the same patch as .rar, if you encounter problems with my zipper.

… no text …

hui, thanks a lot.

i thought i had to feed the two vertexes directly into 2 different pins of the shader…
now i see what you meant…

of course your 2 models you want to morph must have the same count of vertices and identical indexbuffers. which can be a challenge.

i expected that. i´ll just try how resampling the second spread looks. otherwise it´s up to the modelling department ;)

grüssle, florian

p.s. alaf yourself, michel!
don´t mess with karneval!

hi flo.
of course we’re excited about the output of your modelling department and would very much appreciate a post.

maybe a nice mesh will motivate me or somebody else to write a more elaborated tutorial.

what about teapot vs. elephant?
or the cathedral of cologne vs. kommerzbank frankfurt…

helau. michel

… and here comes the dirty version:

Hi volks!

I can hardly follow what you wrote about morping in this topic! From your writings I conclude that there already exists a patch for morphing objects. Is it meant to be public accessable? If yes can u tell me where to download it?

And I have yet another question quite relative to this topic: Is it possible to substract (add) one objekt from another?

cheers Pez

Based on the discussion here, somebody seems to have already built a module for morphing meshes, but I’ll be darned if I can find it… So I wrote my own. It’s really quite easy (thank you, VVVV!).

You can find a link to my MorphMesh module on my user page:

http://vvvv.org/tiki-index.php?page=UserPagekcrosley

Enjoy,
Keith

it was so nice your samplepatch but I have some questions…
how you modeled the cubes, because I couldn’t optimize the numbers
of verticies for the models, eventhough I translated some verticies
in maya, just it was functioned with translating or scaling entire Models.
I want to know what kind of software did you use for modeling…
Or is there some functions in Maya to optimize the number of verticies?

thanks…