Aller au contenu

Photo

Tutorial: Custom Scalp Tattoos


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
DarthParametric

DarthParametric
  • Members
  • 1 409 messages
I got a PM asking how to make scalp tattoos, so I thought I should post the info on the forum in case anyone else is interested.

The vanilla game comes with a variety of face tattoos for all races, and there are various threads discussing the process by which you can make your own custom ones. This is a fairly straightforward process, and there are a number of custom face tattoo mods floating around. However, these face tattoos don’t extend onto the scalp, which is problematic for those wanting bald characters with either scalp or full head tattoos. The reason is because the face is a separate mesh from the scalp/hair, as you can see here:

Posted Image

What this means is that full head tattoos require a two-part texture, one for the face and one for the scalp. That’s not necessarily a problem in principle, but it’s made difficult by two factors. The first is the inconsistent polygon flow and UV mapping of the two different meshes, and the second is the fact that the game is not set up to utilise tattoo masks for the scalp as it is for the face. What this boils down to is that you need to make a custom diffuse texture for your tattoo and make a custom scalp model so that the default one isn’t overridden.

The first step is to locate and extract the appropriate model files for the scalp of interest. There are two sets of files we need, MMH and PHY files, named as follows:

XX_har_blda_Y.mmh and XX_har_blda_Y.phy

Where XX =

df (Dwarf female)
dm (Dwarf male)
ef (Elf female)
em (Elf male)
hf (Human female)
hm (Human male)
qm (Qunari male)

and Y =

0 (highest LOD)
2 (mid LOD)
3 (lowest LOD)

So for a given race and gender there are 6 files, 3 x MMH and 3 x PHY. For this example I’ll be using a Human male. The required files in this case are:

hm_har_blda_0.mmh
hm_har_blda_2.mmh
hm_har_blda_3.mmh
hm_har_blda_0.phy
hm_har_blda_2.phy
hm_har_blda_3.phy

You can find these files inside <install directory>\packages\core\data\modelhierarchies.erf which you can open either via the standalone ErfEditor.exe or the Toolset. Select the required files, then right click and choose Extract Resource. In the pop-up folder browser, choose somewhere to save them and click OK.

In addition, we also need to extract the textures and MAO files. Fortunately, scalp meshes for all races and sexes share a common texture set, meaning you only need to extract this one set of files regardless of which race and gender the tattoo is for. The first are the MAO files. They are located in <install directory>\packages\core\data\materialobjects.erf, the files required being pn_har_bld.mao, pn_har_bld_l2.mao and pn_har_bld_l3.mao. For textures, we only require the diffuse, as the vanilla normal, specular and tint maps can be utilised as-is. Find and extract pn_har_blda_0d.dds in <install directory>\packages\core\textures\high\texturepack.erf. You will also see the LOD2 and LOD3 diffuse textures, pn_har_blda_0dl2.dds and pn_har_blda_0dl3.dds, but we don’t need those.

You now have all the base game files you need. However, you’ll also want to download these UV maps to use as guides for your custom textures:

Posted Image Posted Image

A particular point to note here is that models in Bioware games have traditionally always had pretty ropey UV maps, and the models in DA are no exception. The scalp mesh UV map has a couple of issues which will impact custom tattoo textures, as illustrated here:

Posted Image

You can see there are two areas of concern. The first (and the biggest problem area) is the first few rows of polygons along the forehead. The UVs for this area are stretched, meaning that any image in this area will end up compressed when applied to the mesh. Conversely, the area at the back of the head has compressed UVs (although only mildly so), meaning an image in this area will end up being stretched when applied to the mesh. There are also varying levels of UV stretching and compression for the polys between these two areas. These issues will need to be compensated for, especially if you are trying to produce very precise geometric designs. The scalp mesh really needs to be remapped, or ideally a new mesh made from scratch to match the face mesh’s polygon flow. This is something I may possibly address myself at some point in the (distant) future if I have time, but don’t hold your breath. In the meantime, expect a lot of trial and error tweaking to get your texture looking the way you want it in-game.

Open pn_har_blda_0d.dds in your image editor of choice, such as Photoshop or the like. Change the resolution to 1024x1024. Create a new layer above it and paste the UV map. Change the opacity to around 30% so it’s superimposed over the texture and can act as a guide. Now create a new layer and add your tattoo artwork. Once you are satisfied, save a master version (PSD or the like), then hide or delete the UV map layer, flatten the image and save the texture as a new DDS file. You’ll need to give it a custom name, but you’ll want to stick to the existing naming convention to make your life easier in the Toolset. An example of something suitable is pn_har_bldat1_0d.dds. Once that is done, reduce the resolution to 512x512 and save it out as the LOD2 version (e.g. pn_har_bldat1_0dl2.dds) and then reduce it to 256x256 and save out the LOD3 version (e.g. pn_har_bldat1_0dl3.dds). Here’s a very quick and dirty example I whipped up:

Posted Image

I will add at this point that if you are conversant with a 3D modelling app such as Max etc. that you will considerably reduce the amount of time tweaking the texture takes by loading a suitable head model and seeing how various changes look on-the-fly (as I have done for these example shots). While this is in no way mandatory, testing exclusively via the Toolset is a significantly more fiddly and time consuming approach.

Now that we have suitable textures, it’s time to make some custom MAOs. Open the LOD0 file pn_har_bld.mao in your text editor of choice (the free Notepad++ is worth considering). You’ll see a whole lot of info using XML syntax. There are 2 lines we need to edit, and 2 we need to delete. The two that need editing are MaterialObject Name and mml_tDiffuse. For the first, simply change the value to match the first part of your custom texture name (e.g. PN_HAR_BLDT1) and for the second, change it to your texture’s full filename (e.g. pn_har_bldat1_0d.dds). Next, completely delete the two lines labelled mml_tBrowStubble and mml_tBrowStubbleNormal. Now save it as a new file using the name you used for MaterialObject Name (e.g. pn_har_bldt1.mao). Now open pn_har_bld_l2.mao. You’ll see that there are fewer lines this time, however the lines we need to edit remain the same (with the exception that there is no mml_tBrowStubbleNormal). Edit them as before, but with the addition of the LOD2 suffix (e.g. PN_HAR_BLDT1_L2 and pn_har_bldat1_0dl2.dds). Save it as a new file with an appropriate filename (e.g. pn_har_bldt1_l2.mao). Rinse and repeat for the pn_har_bld_l3.mao with the appropriate LOD3 suffixes (e.g. PN_HAR_BLDT1_L3, pn_har_bldat1_0dl3.dds, pn_har_bldt1_l3.mao). Note: you will see a line called mml_tTattooMask. This is because hair MAOs are based on the same source material used for faces. Just ignore it.

The final step is to produce the custom model files. We are not touching the physical mesh, we are just creating a new set of associated files (controlling animations, collision, etc) that reference that mesh, essentially creating, as far as the game is concerned, a whole new model. Open the LOD0 MMH file (e.g. hm_har_blda_0.mmh) in either the standalone GffEditor.exe or the Toolset. Right click and choose Expand All. There are a couple of lines we need to edit. The first is right at the top – MMH_NAME. Double click on the filename in the Value column to the right in order to edit it. Change it to the same custom filename you used for your textures and MAOs (e.g. hm_har_bldat1_0.mmh). Now scroll right down to the bottom and look for the line MMH_MATERIAL_OBJECT. Change the value to that of your LOD0 MAO (e.g. pn_har_bldt1). Save it using the same filename that you used earlier (e.g. hm_har_bldat1_0.mmh). Now do the same for the LOD2 and LOD3 MMHs, using the appropriate LOD suffixes (e.g. hm_har_bldat1_2.mmh, pn_har_bldt1_l2, hm_har_bldat1_3.mmh, pn_har_bldt1_l3). Now do the same for the PHY files, although here you only need to change the values for MMH_NAME at the top of each file, using the appropriate MMH filenames from the files you just saved. Note: hair models don’t actually need PHY files, but it is a good practice to get into in case you are ever making custom models that do require them.

You should now have everything you need to try a test in the Toolset. Before loading the Toolset, you’ll need to copy across all your files to the Override folder so it can find them. Go to My Documents\BioWare\Dragon Age\packages\core\override\ and create a new folder with an appropriate name (e.g. Custom Scalp Tattoo). The name isn’t important, it just helps keeps things a bit tidier. Once that is done, load the Toolset. Go to File->New->Morph to open up the head morph editor. In the drop-down menu on the toolbar, choose the appropriate base model for the race and sex of your custom scalp (in this case, HM_UHM_BASa_0 for Human male). Change to tab 02, Part Selection, and look for section 2, Parts. You’ll see item 5 is the hair mesh. Select that and click on the button to open the file browser. Find your custom scalp model (see why we stuck to naming conventions?) and click OK. Assuming everything went smoothly, you should now see your tattoo:

Posted Image

If things didn’t go smoothly, make sure that you have all the necessary files in the Override folder and that all the filenames referenced in the MAOs and MMH/PHYs match the actual filenames. I’ll include the tutorial sample files below, so if you have problems download those and compare them to your own.

Now that you have your tattoo finalised and working, you are ready to get it into the game. You have two options here. The first is to make a custom head preset that you can load in the Character Creator. This has been covered elsewhere, so I won’t go over it here in detail, but the basic process is to create a morph to your taste in the Toolset and then export it as a MOP. Then edit chargenmorphcfg.xml and add the name of your MOP to the appropriate race and gender’s preset list (the <heads> section), remembering that there can only be one copy of chargenmorphcfg.xml in the Override (so if you have a mod like “Pineappletree's Vibrant Colors” then edit the one that came with it). You should then be able to choose your custom preset in the Character Creator. The second option is to add your custom scalp to the hair model list in chargenmorphcfg.xml, which will make it selectable in the Character Creator just like any other hairstyle. Be aware however that this option is really only useful for tattoos that are confined to the scalp mesh. If you want to have a full head tattoo you are far better off making a custom head preset that utilises a custom face diffuse texture. The reason for this is that you can’t add additional face textures or additional face tattoo masks to the Character Creator, only replace existing ones.

Either way, once you have chosen the option you prefer, load up the game and see how it looks. Here’s the sample scalp tattoo from earlier as a head preset in the Character Creator, along with a two part face/scalp tattoo you might recognise that will be making an appearance in a certain upcoming mod:

Posted Image

For those interested, I have put together the files I used for the above example. You can grab them here: http://social.biowar...ect/2639/#files

Modifié par DarthParametric, 29 avril 2010 - 11:02 .


#2
princecorg

princecorg
  • Members
  • 67 messages
That's quite funny as i have been working on something similar myself. Great tutorial.

http://social.biowar...m/project/2619/

#3
DhammaWings

DhammaWings
  • Members
  • 125 messages
Excellent tutorial! Well written and well presented.

#4
DarthParametric

DarthParametric
  • Members
  • 1 409 messages
As a further note, it is possible to add custom scalp meshes to the Character Creator as additional hair choices rather than exporting whole head presets. This is a practical route if your design doesn’t extend past the boundaries of the scalp mesh (i.e. not onto the face). If this is the case, you have two options.

The first (and probably best) option is to follow the previous example using a custom diffuse map and just append your custom mesh to chargenmorphcfg.xml in the <hairs> section, under the appropriate race/gender. It is then selectable using the hair slider. One revision I would add however (and this applies to the original guide as well) would be to make a custom tint map. Extract and open pn_har_blda_0t.dds. You’ll see that the RGB channels are black and only the Alpha channel has any greyscale information. This is because the tint system uses the 4th channel (i.e. Alpha) exclusively for skin tints. Previously we left this tint map alone, however this will result in your design being tinted along with the skin. This may prove an issue when using some darker skin tints, especially in combination with light tattoo colours. The solution is to edit the Alpha channel and overlay your design in black. This will stop your design being tinted. See below for an example of what I mean. Once you have made you custom tint map (and the LOD2 and 3 copies), you’ll need to add them to your MAO files. Look for the "mml_tTintMask" line (for some reason there are 2 lines in the LOD0 MAO - not sure why exactly).

The second option is to set up your design to function in the same way as any other hair mesh. That is, the colour of the design is selectable in the Character Creator via tints in the same way as normal hair. This time we want to revert back to the default diffuse texture (pn_har_blda_0d.dds, etc.), so edit your MAOs appropriately. As before, this option requires a custom tint map. This time as well as editing the Alpha channel to stop your design being affected by skin tints, you’ll have to add your design to the RGB channels to allow it to receive hair tints. Here’s a quick and dirty example I whipped up:

Posted Image

And a few of the subsequent results in the Character Creator using different hair colours:

Posted Image

The problem with this approach is that the results are a bit limited using the default tints because of the restricted colour palette (black, white, brown, grey pretty much). The other problem is that beards use the same tint as the hair, meaning that if you made some custom tints any character that had a beard might end up with some bizarre results. Overall I wouldn’t recommend this option, but it is possible – you may just need to do a lot of experimenting to set up a tint map that gives a pleasing result. As far as getting the design into the Character Creator, follow the same route as before, editing the MAOs and adding the hair meshes to chargenmorphcfg.xml.

On the subject of chargenmorphcfg.xml, something I didn’t mention before is a better solution to conflicting versions of the file that doesn’t involve manual editing. There is a tool made by Terra_Ex called CharGenMorph Compiler. This will search the Override folder for multiple instances of chargenmorphcfg.xml and merge them together into a single file. This is great for both end users and modders. For anyone publicly releasing a mod that alters chargenmorphcfg.xml, I would highly recommend you provide instructions and a link to this tool for your end users. All you need to do is include a vanilla copy of chargenmorphcfg.xml appended with your changes and it can be merged into whatever the end user already has when they run CharGenMorph Compiler.

As before, you can grab the example files here - http://social.biowar...ect/2639/#files

Modifié par DarthParametric, 03 mai 2010 - 06:38 .


#5
Beeto

Beeto
  • Members
  • 13 messages
This is a great tutorial. Wish I would have found it before I figured out how to do it on my own. It would have cut down on alot of trial and error.

There are some differences in our methods. I use DATool by Adinos http://social.bioware.com/project/41/ to get the model files needed. It allows you to view the models with their default textures and extract them. You can also apply a new texture and extract it with .mao files that reference the new texture.

I make mine selectable in the CC and they work fine in the toolset as well. I edit pn_har_blda_0t.dds in the same manner, except that I don't edit the alpha channel. I've never had a problem with the color of the tattoo being affected by the skintone. I think the major difference is in what I do with the .mao file.

First, there are 2 entries in the .mao file, "tBrowStubble" and "tBrowStubbleNormal". These 2 entries are not needed, delete them.
Second, like what was mentioned earlier, there are 2 tTintMask entries. Through trial and error, I found that the second one is the important one. Though editing both of them probably wouldn't hurt, all that is necessary is to edit the second tTintMask entry so that it references your new pn_har_blda_0t.dds file. Then you can add it to your chargen as a selectable hairstyle and your good to go.

Modifié par Beeto, 05 février 2011 - 11:57 .