Complete model morphing
I'm not sure if i should post this here or in the programming forums, but here goes :
I havent played many recent games, so i havent seen anything like this with my own eyes YET, but, is it possible today to make one model (not a character, just a prop maybe) completely morph into another model in real time inside a game engine ?
For example, a statue of a woman (like those found in the temples) morph into another statue, this time a statue of a demon, as you look at it through the eyes of your player character.
In older games there were all kinds of stretching and squishing of models, but no complete change into model of a different topology.
It is possible, isn't particularly hard to do either, but there's a catch: you need to define the mapping between the vertices of the source and target models.
3D modeler programs usually solve this by enforcing that the models be copies of the same base model, but can have adjusted vertex positions. This way there's an intuitive mapping (vertex in source -> vertex in target) between the vertices.
3D modeler programs usually solve this by enforcing that the models be copies of the same base model, but can have adjusted vertex positions. This way there's an intuitive mapping (vertex in source -> vertex in target) between the vertices.
You could try to think of it as not a transformation between two models, but a direct switch between two models that look exactly the same, and the second gradually move into the second actual one. You could also have 3 models. The original, the new one and one that does the transform.
The only way to 'morph' is with the same vert count. So the new model will need to be made from the same mesh as the old one. (no way around this AFAIK, it is how it is done in films as well, but they have the aid of animated displacement maps)
There are other practical considerations, as well- how about UV's? If the morphing is extreme, the texture will have serious stretching, you will also need to morph UV's- what as these UV's morph, what happens to their underlying maps? You may need to not morph the UV's, but have two different sets, and LERP between the textures if they are different.
Finally and important, morph targets work linearly. If one statue goes from arms crossed to arms above head, it will not work- the verts will move in a linear fashion, intersect, turn inside out, etc.
Your best bet for this is, for example going from a woman status in prayer, to a warrior statue with arms raised, is to model each (from the same start mesh!!!) in a T or biker pose. Skin them up and deform them into their statue pose with Bones (you can rotate and translate, do not scale though). At this point, if you are making a high-res model, you can make it in the statue pose. Also, the UV's can be different, but they will both need to be passed into the shader. Create a blendshape from one model to another IN THE BIND POSE. You'll also need to save out the animation from the one model's pose into the other model's pose.
Then to blend from one to the other, at the start you would have:
Blendshape weight: 0
Animation Time: 0
Texture LERPing (both need to be sampled): 0 (first texture only)
at the middle:
Blendshape weight:.5, it would be halfway deformed between the two
Animation Time: .5, it would be halfway through the pose-to-pose animation
Texture LERPing: .5 (this won't look perfect, it will be a bit blurry and indistinct right now, but it won't have errors)
At the end: (obvious enough so I won't list)
To do a complete statue/character morph, you will need at least the first two (blendshape and skeletal animation) and the last if they have unique textures.
There are other practical considerations, as well- how about UV's? If the morphing is extreme, the texture will have serious stretching, you will also need to morph UV's- what as these UV's morph, what happens to their underlying maps? You may need to not morph the UV's, but have two different sets, and LERP between the textures if they are different.
Finally and important, morph targets work linearly. If one statue goes from arms crossed to arms above head, it will not work- the verts will move in a linear fashion, intersect, turn inside out, etc.
Your best bet for this is, for example going from a woman status in prayer, to a warrior statue with arms raised, is to model each (from the same start mesh!!!) in a T or biker pose. Skin them up and deform them into their statue pose with Bones (you can rotate and translate, do not scale though). At this point, if you are making a high-res model, you can make it in the statue pose. Also, the UV's can be different, but they will both need to be passed into the shader. Create a blendshape from one model to another IN THE BIND POSE. You'll also need to save out the animation from the one model's pose into the other model's pose.
Then to blend from one to the other, at the start you would have:
Blendshape weight: 0
Animation Time: 0
Texture LERPing (both need to be sampled): 0 (first texture only)
at the middle:
Blendshape weight:.5, it would be halfway deformed between the two
Animation Time: .5, it would be halfway through the pose-to-pose animation
Texture LERPing: .5 (this won't look perfect, it will be a bit blurry and indistinct right now, but it won't have errors)
At the end: (obvious enough so I won't list)
To do a complete statue/character morph, you will need at least the first two (blendshape and skeletal animation) and the last if they have unique textures.
-------------www.robg3d.com
Thanks, ahem, Professor. :)
I dont know what i was thinking, asking such an obvious question.
However, i have another one.
Lets say i have a 3D platformer and a model of a little devil. For simplicity lets say he is very high-poly and single mesh. And that you could upgrade him in several ways during the game, without ever changing number of vertices.
You could upgrade his body (small-medium-buff), his wings (small-medium-large), or his horns (small-medium-large).
But, what about mixed upgrades ? If i have a mesh with medium wings and another mesh with small horns - is there a cheat to combine them right in the engine to get a single mesh with the qualities of both parents ? Because just with having 3 upgrades with 3 stages each - number of combinations is already 27. And what if more upgrades or more stages are required ?
Or is it inevitable to cut off different parts ?
I dont know what i was thinking, asking such an obvious question.
However, i have another one.
Lets say i have a 3D platformer and a model of a little devil. For simplicity lets say he is very high-poly and single mesh. And that you could upgrade him in several ways during the game, without ever changing number of vertices.
You could upgrade his body (small-medium-buff), his wings (small-medium-large), or his horns (small-medium-large).
But, what about mixed upgrades ? If i have a mesh with medium wings and another mesh with small horns - is there a cheat to combine them right in the engine to get a single mesh with the qualities of both parents ? Because just with having 3 upgrades with 3 stages each - number of combinations is already 27. And what if more upgrades or more stages are required ?
Or is it inevitable to cut off different parts ?
Quote: Original post by Karnot
Or is it inevitable to cut off different parts ?
Thats definatly the easiest option, and the one most games use. For you to be able to morph individual parts means you must be able to know which verts specifically out of your big vert array are part of the wings, which are part of the horns and which are nothing so you can then know which verts to morph. The hardest part will actually be defining which verts are for which bit. How do you know vert 738 is part of the wings or horns? Maybe its what bone ID its linked to if you've got skinning, maybe you hand write them down or any number of other possible ways. Surely its less trouble to just keep track of 1 or 2 achor points where you can attach your horns/wing meshs.
Morphing your parts around would be pretty cool, and just think of all the RPG's and car games that let you change body size or wheel arch height. They all do mesh morphing. So its most definatly possible. Its just alot of effort to get setup. If you have a good way of defining your vert sets for each part, then scaling, roating or morphing them into some other formation actually seems like the easier bit.
Edit: Of course that is all assuming the the same number of verts alone with what everyone above said. If your morphing between different poses and vert numbers then its gets real tricky, however different wing sizes with the same set of verts just spread out a bit shouldn't be too hard at all.
[Edited by - pto on July 8, 2008 9:18:54 AM]
If you did want to have a go at mesh morphing there is a tutorial at NeHe. It relies on the models having the same number of vertices but i think there would be ways to make it work with different number of vertices. You could merge two vertices into one or split one into two, but that would probably require a lot of coding.
[Window Detective] - Windows UI spy utility for programmers
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement