Weird bodypart rendering if a node has reserved name
Tested with Better Clothes 1.1.
Take a look on a screenshot (Screenshot_20170717_145609.png). PC on this screenshot wears "common_shirt_05".
If you open an attached NIF file, you will see that NIF file has a two nodes: a NiNode with a "Chest" name and a NiTriShape with "Tri Chest" name (look at NifSkope.png).
As result, when OpenMW searches for node for Chest bodypart, it treats the whole shirt ("Chest" NiNode instead of only "Tri Chest" NiTriShape) as a Chest node.
This NIF file can be fixed by renaming the "Chest" NiNode.
An original engine does not have this issue. It seems the engine uses only NiTriShape nodes as bodypart meshes.
There's a bit of history to this one. Originally, OpenMW would only accept NiTriShapes named 'Tri <part>'. Then, to fix bug #1088, we added a check for NiTriShapes named '<part>'. Finally, with the port to OSG there was no longer an easy way to distinguish TriShapes from other nodes so the condition just became 'any node named Tri <part> or <part>'. (A TriShape usually translates to a MatrixTransform with a child Geometry, but after optimizations are run it might look different; also, skinned or morphed meshes will use different nodes).
Just an idea, maybe in this case the vanilla engine ignores the 'Chest' node because it was optimized away? Maybe you could try adding a NiMaterialProperty or a texture to that node to see if it's used then.
#4 Updated by Andrei Kortunov 9 months ago
One last thought, who knows if the preceding 'tri ' has any meaning at all, maybe they just check for '<part>' anywhere in the string.
I tried to rename "Tri Chest" to "Tri2 Chest" in this NIF. Morrowind in this case failed to find any chest part for this file.
In order to create the equivalent of a "TriShape" we have to create several different nodes, some of which may be removed by optimization later. Usually, there will be a MatrixTransform node that creates the transform offset with a Geometry child to do the rendering. If the transform is the identity and is not updated by any keyframes, the optimizer will turn the MatrixTransform into a Group. If the Group is then empty (i.e. it has no StateSet), it may be removed entirely and replaced by just the Geometry.
If we add a tag to all of these nodes that says 'this is part of a TriShape' then that may prevent the optimizations from working at all (since the optimizer would think the tag is something important that must be retained).
In any case, adding such a tag seems wrong; the conversion process from NIF to OSG is supposed to produce something that's not reliant on NIF terminology in order to use it. And since we already support the native OSG format, that one should be (and is, until now) usable for bodyparts, as well, without having to call things 'TriShapes'.
As a second best solution, maybe we can search for a Drawable with the given name, then go up until we find the first node that contains a StateSet. Under the assumption that all body parts actually have a StateSet (i.e. not just a blank untextured model), that should work.
Note: Drawables are not currently given a name, would have to add that e.g. here:
Similarly, we could also look for any node with the given name and then check if it has a 'Geometry' child to make sure that it's (probably) a 'TriShape'. That won't work for geomorphed (e.g. heads) or skinned meshes, though, since they use additional nodes in between. Maybe a combination of both approaches is best?
- Status changed from Closed to Confirmed
- % Done changed from 100 to 0
Looks like solution applied in commit 3fc86342061bab0c30bed6821f66933fef546930 breaks bodypart texturing (take a look at attached screenshot).
Only breaks when shaders are enabled. I can think of a fix but I need to test first that it won't impact performance negatively. Solution has been reverted for now.
Anyway it looks like there was still another issue with overlapping clothes, see screenshot. Bug in the mod or another (unrelated?) bug in OpenMW?