Jump to content

Facial Recognition (updated)



I've cracked the code.


Okay, nothing actually that over-dramatic, but still. I managed to figure out something that's been bugging me for a while, and I'm a little excited about it. So while I had a pile of other stuff that I've been working on banked for a post, I'm gonna skip over it for the moment and show off something that I worked out literally yesterday.


Pretty much right from the first point I started at making masks from in-game faces with the COR heads, I've also been poking at the idea of making 'living' faces that could be used with the DMA system. One of the biggest flaws with making equippable parts out of the games' head meshes is that they lose all of the facial animations. That was one of the first things I stumbled across during that abandoned 'detachable head' experiment early in the DCC project, and I've yet to find any reasonable way to add them back in while maintaining the parts' swappability. It just doesn't seem to be something the game's really built to do. When I was cutting the head meshes up into masks, however, it occurred to me that doing things the other way around and making 'mask' versions of the head meshes should be technically feasible. It would lose the capability to swap around faces, as they'd be treated just like the game's regular headparts and thus would be restricted to the single character that they were built for, but having a 'cyborg mask' with working facial animations was enough of a draw to make investigating the idea worthwhile. 


Now, there's two ways to approach this, design-wise. The first is what you could call the 'hardware' solution- physically chopping up the mesh in the same way I did for the masks and subbing that in for the character's existing head model. I've featured my attempts at this route before in this blog, but it never quite worked. While subbing the mesh in was possible, it turned out that having it mismatched with the head's .tri files resulted in a number of the facial animations and morphs going all, to use the technical term, 'wonky'. There didn't seem to be any way to remedy that short of making whole new .tri files for the mask-cut head meshes, which was well outside of what I know how to do, and I also had concerns about how those altered meshes would or wouldn't work with existing face presets. So after a last try around the time I was making the first batch of the Vanilla faces, I pretty much gave up on the idea.


The second route would be the 'software' solution, and was actually the first idea I had for approaching this because it seemed much easier... but then I could never get it to work. Theoretically, all you really need to do to achieve the effect I was looking for was to alter the head's skin texture by erasing everything except the face. Without a texture, the rest of the mesh should be invisible and thus function about the same way visually as the physically cut mask meshes. Problem was that it didn't. I could alter the texture all I wanted, but when I tried applying it to the mesh, the mesh would inexplicably continue to display the unaltered texture on the areas that should've been rendered transparent. I had no idea what was going on there and that last point was particularly weird, so I shied away from it and explored the hardware solution instead. But the other night, and I'm not even sure what exactly prompted this, I started thinking about it again. I'd had to figure out how to make headpart entries in the Creation Kit as part of getting the null heads for the DMA followers I've been messing around with to work, and it occurred to me that I should look at how the use of texture sets and skin swaps on headparts might affect things, especially in light of how I had to use them extensively to get the right skins on the Doll bodies. I also wanted to see how a non-Vanilla skin set like on the COR races worked, so I loaded up an early COR follower mod in the CK and started poking around at it. 


Turns out none of that actually mattered, though. No matter how I tried re-pointing the textures, it kept doing the same thing. So as a last-ditch effort I opened up the character's head model in Nifskope to take a look at things... And remembered all the 'NiAlphaProperty' tags that I had to pull from hair meshes to disable the transparency effects for the stone and brass versions. Surely, I thought, it can't be that easy.




It's that easy. ?‍♂️




Look, I still don't know how a lot of this stuff works, okay? I'm just high-level faking it. 


Lilitha had a bit of an issue as a test subject, though, as her hair's built in a way that makes it basically permanent. But there didn't seem to be any reason the same method wouldn't work on Vanilla faces. So I made dupes of a couple of my old NPC projects, good 'ol 12-16 and an appearance modification of the 'Swimmer' from the north Reach that I made ages ago, and applied it to their head meshes.




Now first off, this initial test clearly shows one of the problems with this method, which is figuring out exactly which parts of the texture need to be erased. This isn't helped much by the fact that the texture isn't mapped on all that evenly, so doing a quick and dirty oval cut-out of the face left me with jaggy edges and way more scalp than I expected, thusly:




But this was more than good enough to test out the concept with, and the details can be fixed later. The next problem is providing a robotic frame for this, as the ones already included in the DMA are set to a slot that would displace this face. But I already had some Crystal Frame heads set to alternate slots from the hardware solution's experiments, so that was a non-issue for now.





The exact logistics of those head frames are going to require more thought, though. Which slot they'll use is one concern; they need to be on one not really used by anything else to avoid them getting displaced at random. I've currently got one on slot 35 and one on 50, but I need to look around and see exactly how much competition those have. Another issue is the design of the frames, especially around the eyes and jaw. These were originally designed for the very non-Vanilla Sextreme faces, and while they happened to fit into the COR faces just fine I found out early on in the Vanilla face project that they were a bit too over-built for them and tended to clip through a lot of the thinner faces or ones with deep-set eyes. I made some changes to the frames which alleviated those issues, but they didn't completely resolve them and I'm leery of making further changes to those models because it'll start to affect how they look without a face attached. Here, however, the face itself is 'permanent' and the frames meant to go with it are not intended to ever have their front sides on display, so I should be able to make more drastic changes without them becoming all that noticeable. Maybe not enough to avoid all potential clipping, but altering the faces themselves is less of an option here, so it'll have to do. I'll also pretty much have to give up on the frame structures inside of the face, for much the same reason. But these are all worthwhile trade-offs to get the animations back.





The eyes are another concern. The lovely orb eyes I made for the Vanilla masks don't really transfer back over, sadly, and due to how the eye meshes incorporate the eyelashes it's not an easy proposition to just sub in the swirl texture I used on those, either. (It would be on the COR eyes where the eyeball and eyelashes are separate parts, but...) I've got plenty of options for Vanilla-type eyes to use, though, especially from the Portal Eyes and Holzfrau's Dwemer set, and even some of the nicer human eye textures. And these have their eye tracking back, the loss of which on the masks was the biggest reason why I ditched them in favor of the omnidirectional orbs in the first place. 





The eyes are a factor in how much of a pain in the ass these are going to be to implement, though. You see, until yesterday my plan for the DMA followers was to give them all the null heads and set their respective Vanilla mask as part of their outfit to build the character. I briefly considered including a copy of the full head model that I'd built the masks from as their default headmeshes, but it seemed like too much new work to learn considering that I've never built a follower for distribution before. But now I've got to basically do just that, which means I'm going to have to figure all that crap out. I probably won't do it for every single follower (and I wasn't planning on making NPCs for every Vanilla mask I've put into the pack anyway), but it's still quite a bit of extra work. I'll also have to figure out how exactly I'm going to handle their hair. The wigs, as-is, don't color match on the non-player characters (and it can be kinda spotty on the player, at that), so I was thinking about doing some character-specific alternate colors like the blonde Shero wig for 12-16 above. But as I'm already planning on leaving them with a 'real' head, I could conceivably include regular hair-part versions of the styles I wanted to use and let the game color them like normal. It's more work, but it would polish things off a bit. Not that the wigs don't work fine in their current state, provided you like brunettes...





But speaking of polishing things off, let's go back to that... Cut line? Erase line? ...Where the edges at. Like I said, for this first test I just plopped an oval down and called it a day, but that clearly isn't something I'd want in a proper release. The ideal would be to get it pretty much in-line with where the edges of the physically cut mask model are, for consistency with those since I don't intend to take them out at this point. (Maybe I'll stick each character's mask into their non-outfit inventory. That'd be fun.) The question was how to see where the edges from that mesh lined up on the texture. As it happens, NifSkope does have some texture mapping editing tools that are mostly way outside of what I want to mess with, but as a part of that display a visual overlay of the vertices on the texture, thus:




With that, it's just a matter of taking an isolated screenshot of the UV mapping window scaled to an even number of pixels, blowing that up to the texture's ratio, copying it in as a new layer over the skin texture, reducing its opacity and adjusting its position to get things to line up as well as possible, using the free select tool to trace the vertices around the outside of the mesh overlay, inverting that selection and erasing all the skin outside of it, making sure the image has a proper alpha layer, and then exporting it to a file that Skyrim can read. Simple, right?




But in the end, you do get something that pretty much works.




It didn't come out quite even, both because tracing those vertices was kind of a pain and because it looks like they're on there a bit lopsided to begin with. Comparing it to the meshlines in NifSkope it's clearly not perfectly matched to them.






But this is definitely a case of the perfect being the enemy of the good the damned enough, and it looks fine as it is. There's some slight jags at certain points, but you have to look close to really see them in-game. 





I should also mention the question of the ear-caps. Keeping the rest of the robotic mask structures wouldn't really work that well, but I would like to retain those given that they're the element that mounts the face to the head frame. The problem is the variance in head widths between individuals and especially between the races. I've been manually adjusting them for each mask, but here I'd need more of a one-size-fits-most solution, along with a different way to implement them. My current thinking is to make slightly thicker caps incorporated into the alternate frame's model, with race-specific versions for humans, elves, and orcs. That should hopefully cover most of the potentials, but I haven't actually tried building that yet to see how it'd work out. This is all still very preliminary and there's plenty of possible stumbling blocks, but it's an infinitely more promising approach than the previous attempts.


I mean, hot damn.






But the most potentially interesting thing about this method isn't actually how I'll be using it for my own characters. It's how it works on any character with an exported FaceGen. Making masks out of personal followers was mentioned in comments before, but using the hardware solution it's a pretty laborious process. With this, once you have the altered texture it's basically three steps in NifSkope.


One, repath the skin texture to the mask-cut texture.




Two, right-click on the head mesh. Go to Node > Attach Property > NiAlphaProperty.




Three, go to the Lighting Shader line under the head mesh in the Block List. Go down to Shader Flags 2 in the Details pane and click 'Double Sided' to prevent the face from being see-through from camera angles behind the head. Do the same with the mouth mesh, if needed.




That's it. That's literally all the modifications you need to make to an NPC, and again this should work on any one with a head model that you can access. (I'm not sure where/how the player's head is stored, though, so I can't make any promises about using it outside of NPCs yet.) Once that file's saved the character will appear with a floating, disembodied face in-game, ready to be equipped with a proper head frame and DMA body. The hair probably shouldn't be messed with, as the game's expecting to see it and might do weird things if it's not there, but considering that a lot of the Vanilla hairs really aren't built with the idea of seeing them from the inside in mind...




...having some way to remove or swap them out in-game would be recommended. Like with the included wig sets! When I stop finding more things to do and get around to actually releasing any of this, that is. 


Speaking of those other things I found to do, I'll get back to those next post. Stay tuned.



(Huarache Lights intensifies)



Update: Gonna tack this onto here instead of making a whole new entry for it, since it's just a straight continuation of what I was talking about above. I mentioned needing to make modified versions of the head frames for this owing to some morphs of the Vanilla head models not really fitting over the existing ones. This was something I was aware of from when I first started working on making my own Vanilla-based masks, but it wasn't until I started looking at making masks from existing NPC's faces that I realized just how bad it could get.




Obviously, that needed to be addressed before I could really do anything with this whole 'live faces' idea, so that was my project for today. And like I stated above, since most of that structure was built to make the frames look good without a face equipped, for this application where the faces would be 'permanent' and the front of the frames will never be seen most of that could get shrunk down or removed. These are just going to reuse the Doll heads' ground models, so the sins that the edits introduce won't be seen.




The only real exception to that is on the Crystal Frame, whose open structure loses the brain casing that obstructs the view of the inside of the face from the back. In that case the Live version doesn't do anywhere near as good of a job of hiding the back of the eyes as the original version did, but it's still something that you generally have to be really looking for from weird camera angles to even notice. Considering that I have yet to run into a face that the modified structures clip through, I'll consider it an acceptable trade-off.




I also implemented the idea I mentioned above regarding the ear-plates, with race-specific versions added onto the models. These are slightly thicker than the ones used on the masks, and hopefully will work with most morphs, but I can't really guarantee it. For instance I could see there being problems on those more 'anime' styled follower faces that some folks like, where the effect is sometimes achieved by making the head wider than normal. But for the Vanilla ranges it ought to be fine. Probably. It's also far enough back that jaw movement doesn't seem to affect the clearance much.





While I was putting these together it did occur to me that there might be an issue with how tetchy Skyrim can get about handling layered transparencies, given how these faces work by making part of the head transparent and the Brain Capsule using a semi-transparent texture, but I'm happy to report that the two seem to be able to co-exist just fine.







This is a definite relief, as having the visible brain effect compromised would've been a major disappointment.


...It does occur to me that I still need to check out how the faces work when viewed through water, though.


But speaking of co-existing, I also took a minute to check out one of the other things that made the idea of Live faces so appealing: Gag compatibility!




Since the Live face is fundamentally just a standard head mesh with only some texture modifications, it'll work perfectly normally with anything that affects the head like this. It should also work just fine with any face-based tattoo overlays or the like. I'm slightly less certain about what will happen in decapitations; the face itself should go flying as if it were a normal head, but what will happen to the underlying mechanical frame is rather in question. Particularly since it's currently using one of the decapitation slots, number 50. 




I picked that one because it has fairly minimal conflicts, with the DD vaginal piercings being the only other thing I know of that uses it, and because some of the other viable slots put it right up against the gags and blindfolds, which I actually cared about. Everything else either has similar conflicts or is just full up. One slot that is fairly free is number 60, but I do have one thing that makes use of it and that item keeps getting mysteriously de-equipped so I'm not exactly trustful of it. That said I might include an alternate set of the frames on 60 for those who have some reason to want 50 free. Changing the slot assignments on all the pieces is a pain, but it's doable. One thing I'm definite on, though, is that I'm only going to make these with the Doll necks. They're mainly intended to be used with the Doll body parts, and that neck's base works fine with robotic torsos, so there doesn't really seem to be any reason to bother with the old large neck pieces.


Given that these faces do require actively modifying the character's FaceGen, though, I was especially curious to see how Paradise Halls' NPC cloning process would handle them. Using PAHE and HSH slaves to make Automatons can be a bit difficult due to some factor in their unique outfit system that makes them highly prone to having their original heads pop back in. That problem wouldn't come into play through this method, but I was unsure if the cloning process would copy over modifications made to the original's head model. So I made a copy of a Bandit and applied the mask effect to their head model, then spawned them into the room I've been doing this testing in, where the various followers made quick work of them:




And then after using the raise-then-paralyze trick to get them into PAHE, it turns out that the modifications to the head model get copied over without any issue. 




'Course, the obvious problem here is that without any DMA parts you're just left with a face creepily floating over an empty neckhole. You'll have to fill that in with one of the Live head frames and the Doll collar...




...Or you could just go ahead and replace everything else, while you're at it.




The only real problem I've run into with all this so far is that I can't think of any way to do all of this dynamically inside of the game, since it requires certain changes to be made to the .nif file for the character's head. So it can only really work on purpose-built NPCs like this, and not just any rando you run into in the wild, sadly. And those NPCs will have that weird floating face thing going unless their outfits are modified to have the DMA parts pre-equipped, which cuts down a bit on the ~~immersion~~, but considering that it took me the better part of a year to figure out how to do this at all I'll take what I can get. Just having some way to put an NPC's living face on an Automaton keeps me happy.


And speaking of, I chose that particular bandit model, one of the Bosmer Bandit Plunderers, for a very specific reason. Her face was on my shortlist for use in making the Vanilla NPC masks, and was actually once of the first ones I checked... and the first one that I found the clipping problems around the eyes on. So I particularly wanted to make sure that the new head frame structures were being cleared properly on her, and was quite pleased to see that everything fits just fine.




And, of course, with accessories:




Quite pleased.








Recommended Comments

  • Create New...