Interkarma / daggerfall-unity

Open source recreation of Daggerfall in the Unity engine
http://www.dfworkshop.net
MIT License
2.66k stars 326 forks source link

Option to set depth for head layer #2657

Open probably-jodzie opened 2 months ago

probably-jodzie commented 2 months ago

Would it be possible to have an in-game setting to change the depth for the head sprites? And I suppose also the same for helmets

Alternatively, make it possible to set the depth for sprites in an xml file

KABoissonneault commented 2 months ago

Can you document here why you want the head specifically? Edit it into the original post to make it easier to read the issue.

Basically, what are you attempting to do, what issues are you hitting, why adding this feature would help. When it comes to making changes, it's best for us if we fix the larger problem, rather than address the specific roadblocks of the moment. Engineers might think of a better solution, and we might find something that helps more people. Knowing your intentions helps, overall.

From what my understanding, the entire paperdoll system could use a depth system, rather than force users to put gaps in their sprites. If we're going to fix heads, we might wanna think this through

probably-jodzie commented 2 months ago

Its to fix this:

image

If the modder wanted to have unique head sprites where the hair laid on top of the body, it wont work cuz the head sprites are underneath armour

KABoissonneault commented 2 months ago

After offline discussion and some investigation on my end, I've determined the following.

The current PaperdollRenderer has these categories of paperdoll parts to render:

These are listed from "back" to "front", as drawing something last will make it be on top of what was previously drawn. "Cloak Interior" tries to draw the interior sprite of your Cloak 2 (or Cloak 1 if the player only has one cloak). "Body" draws the naked headless body first, draws the underwear headless body if Player Nudity is disabled, then draws the head. "Items" draws all the equipped items in "draw order" (a property of each item).

By this design, all heads are always drawn before all items, and therefore are behind all clothing and armor, but always above the body. Long hair on the left side looks "behind" the shoulder if the shoulder is clothed, and "in front" if the shoulder is naked.

image image

Pretty sure this inconsistency is a classic issue. It does not require modded graphics to observe.

After my investigation, I've determined three approaches to fix this issue: 1a. Let mods specify the entire head as above most items, but below helmets and cloak exteriors 1b. Make all heads render above most items, but below helmets and cloak exteriors

  1. Let mods provide a second texture associated with the head that renders above items

The first solution has the issue of extra complexity when it comes to sorting equipment, but I think it's not that bad. Version A is opt-in for mods that want to fix this, while Version B always fixes the inconsistency without mods, with the drawback that some clothes or armor might be more covered with some faces. The second solution allows mods to have both parts that go behind and parts that go in front. It does require extra work from modders, to split their textures in two. I also think this approach might be more flexible for solving similar problems in the future. This solution is consistent with how classic handles cloaks, with an interior part underneath the body, and an exterior part above the body.

For solution two, the render order might look more like:

(We don't have to do the hand thing yet, it's just an idea for future proofing)

With this, modders would simply have to provide an extra texture with an annotation on the name (ex: FACE14l0_Front.jpg), and if available, DFU would pick it up and render it.

In addition, having a "_Helmet" variant for faces could be useful, as modders could make the face bald in order to avoid clipping through any helmet.

Anyway, some ideas for whoever wants to tackle this. I'd rather not do 1a, as I feel it's not fully flexible and requires special casing all future similar problems, but it's also the easier and least controversial solution, so I'll take whatever someone manages to achieve.

probably-jodzie commented 1 month ago

Untitled

New tall boots and a loincloth. At this point I dont know. Let the modder set the depth they want in an xml file?

probably-jodzie commented 1 month ago

Capture

It seems different leg items have different depths. Skirts have a depth of 35 while loincloths have a depth of 10, but it should not be 35 as well since it needs to go over, not under?

KABoissonneault commented 1 month ago

I'd rather not touch this value in DFU, it can probably be changed through code by either changing the base loincloth/long skirt, or by creating new item variants that have different draw orders. But that's not terribly accessible to artists. I could conceive of a way for graphics mods to give their own texture a custom draw order though, probably in the XML file used for texture replacements