[SOLVED] Is it possible to merge vertices in realtime in BGE?

I’m creating some characters for the Blender Game Engine and I plan to add shape keys for facial animation. Of course, I don’t want to save information for the character’s entire body when I only plan to morph the head. For now I’ve decided to separate the mesh where the neck and shoulders are ‘submerged’ beneath the clothing as that’s a good way of hiding the separation. However, some characters may be shirtless, animals, or otherwise difficult to create a hidden seam for.

As I don’t want to design all of my characters to wear thick neckbraces to hide the seams, I was wondering if there’s a possible way to merge a head model with shapekeys to the rest of the body in realtime, given the vertices share the same position. Does anyone know of such a solution, and if so is the performance reasonable in BGE?

This is not necessary.

The GPU renders each single polygon separately. They do not share a vertex. The vertices just get the same position in space. This way it looks like they are connected. Within Blender it acts like it is a single vertex. This is just a comfort function for you as user.

If you do your animations, meshes and vertex groups right, you should never see a gap.

In your case, ensure the meshes receive the same deformation. E.g. when you shape key the head, do not deform the borders of he mesh (the neck). The other way around: when you deform the border of the mesh, you need to deform the other mesh too, by playing an according animation. As this is pretty inefficient, I recommend the first method (exclude borders).

Or rig the face.
Shape keys are great, but they don’t mix well with other systems.
Just add some bones for the muscles of the face and animate normally.

It is possible to change the normal shading of a poly in the game engine to make two adjacent polys more smoothly match, but that won’t work on a rigged or shapekeyed mesh.

If it is about smooth shading you can check this method: Smooth shading over different objects

Ah yes, excluding the ‘seam’ should be no problem. I suppose I just assumed that a split edge would appear as it does while working on the meshes (and because I deal with this in other engines frequently). I certainly intend for all armature and morph deformation to be identical along the seam vertices. Thanks for correcting my misperception, Monster.

Unfortunately, some of the shape keys will be rather complex, rendering a rig-only solution impractical. I’m certainly not against driving the shape keys with a rig, but bones-only is off the table for now.

UPDATE: Just tried it on a very basic mesh and I’m definitely seeing the seam. I think there may be a slight misunderstanding as to what I’m referring to. Of course the faces appear to be connected as in there is no gap you can see through, but the edge is still split/hard. The reason I want to combine the vertices is to continue the smoothing seamlessly across the border rather than seeing the break. Also, as Smoking_mirror mentioned, modifying the normal shading manually may not provide the same results during deformation.

I guess I’ll have to do some further investigation on the matter and possibly make some design sacrifices. Here are some shots of what I’m experiencing and a simple .blend to demonstrate it:

Ah, Monster, I only just caught your post right after I wrote that lengthy comment- thanks for clarifying and giving the link. The method you suggest seems practical, although I’m not sure exactly how I should set the shared faces as invisible. I just applied a material that is meant to be invisible to that area, but I get the same result with or without shape keys. I’m guessing this simply means there’s a better way.

As that thread you linked to is from the 2.4 era, I’m not entirely sure what the proper option would be now after looking around a bit. Maybe I’ll find it in the morning- I’ll keep you posted.

UPDATE: So, it turns out the invisible material actually works without armature deformation or shape keys (ie. it’s useless). So I started fiddling around with the settings and as soon as I turned off invisibility, it works! Super weird, I know. It turns out that the first Material you assign trumps the second even if you switch the order afterwards. It may not be the most appropriate solution to the issue and it’s certainly very strange, but it works nonetheless. Here’s the .blend so you can see that it actually works.

Although it’s not the cleanest solution, I’m still marking the thread as solved. Feel free to add any other discoveries you make in the meantime.