Face Swapping

Hey Folks! Gradually getting there with the live portraits feature. Getting faces to show in the right part of the UI, as well as getting some variety to them.

The UI portion of it wasn't too hard, though it required some banging around to get it right. For now, the portraits area of the UI is a single texture that covers the lower left of the screen. And that texture is being drawn to by a camera pointed at some off-screen portraits. (This is similar to how the docking and navigation UI displays work.) Probably the hardest part here was getting the camera, render texture, and destination texture sizes right so that I could show multiple faces in a row without too much squashing. (Note: render texture, destination texture, and camera all need the same aspect ratio.)

Once it was showing up in the right place at the right size, it was mostly tedious asset shuffling to get the prefabs organized so I could spawn more as needed.

The face-swapping was a bit more elusive. I briefly worried that I'd have to have a separate spritemesh for each swappable face part style (e.g. one for each of Akiko's face parts, one for each of Jones's), and then use code to swap one spritemesh in for another.

However, Sergi (Anima2D's custodian/maker at Unity) suggested that it should be possible to change the texture on the SpriteMeshInstance's material param block at runtime. So I'm looking into that now. Though, as you can see in the image above, it's not working yet. We just have Jones's all the way down :)

Still, that's one animated Jones portrait for each spawned crew member! And assuming I can get the face swapping to work, I should have separate appearances for each soon. Then, it's off to hook-up AI emotional states to animation states!

Tags: Ostranauts