Modding:Hair Mod Mesh Setup: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(44 intermediate revisions by one other user not shown)
Line 1: Line 1:
<div class="nomobile" column-width: "60em2;>
{{PageSeo
{| class="nomobile" style="text-align:center; margin: auto; border:1px solid #785000; font-size:83%; background-color:#1B1B1B; width: 60;" ;
|title=Modding Resources
|- style="font-weight:bold; background-color:#281C14; color:#c27736; border:0px none;"
|description=This page is a hub for everything related to Modding Baldur's Gate 3. Check out the following guides to learn how to mod BG3.
| colspan="2" |
|image=Modding_resources.webp
[[File:bgwiii.png|30px|link=Template:NavWiki]] [[BG3Wiki:Community|Community]] • [[Guide:Guides|Guides]] • [[Modding: Modding resources|Modding]]
}}{{Modding box}}{{Modding sidebar}}
|-
| style="background-color:#28201B; color:#c27736; width: 15%;" |[[:Category:Modding|Modding guides]]
| style="text-align:left; padding:0 4px;" |<div class="navcat" ;>
<categorytree hideprefix="1" hideroot="1" mode="pages">Modding guides</categorytree>
</div>
|-
| style="background-color:#28201B; color:#c27736; width: 15%;" |[[Modding:Modding resources|Modding resources]]
| style="text-align:left; padding:0 4px;" |<div class="navcat" ;>
<categorytree hideprefix="1" hideroot="1" mode="pages">Modding resources</categorytree>
</div>
|}</div><div class="noexcerpt navigation-not-searchable" style="text-align:center"><span class="nodesktop"> [[Modding:Index|Modding index]] </span></div>So, you wanna make a hair mod for Baldur’s Gate 3. How do you do that, though? This guide will show you how.


=== Essential Tools ===
Welcome to the mesh creation portion of making a hair mod. For an overview of all the steps, see [[Modding:Creating Hair Mods]].
First off, get yourself these tools.


* [https://www.blender.org/download/lts/3-6/ Blender] (version 3.6 recommended)
<div class="noexcerpt navigation-not-searchable" style="text-align:center"><span class="nodesktop"> [[Modding:Index|Modding index]] </span></div>So, you wanna make a mesh for a hair mod for Baldur’s Gate 3. How do you do that, though? This guide will show you how.
* [https://github.com/Norbyte/lslib Lslib] by Norbyte
* [https://github.com/ShinyHobo/BG3-Modders-Multitool BG3 Multi-Tool] by ShinyHobo
* [https://github.com/Norbyte/dos2de_collada_exporter Collada/GR2 import/export Blender plugin] by Norbyte


Because we’ll be using Blender to make the mesh for our hair mod, we recommend at least having a cursory knowledge of how to use Blender before attempting to follow this guide. If you don’t have that, we recommend [https://youtube.com/playlist?list=PLjEaoINr3zgEPv5y--4MKpciLaoQYZB1Z&si=GqdmSXxoU6_-RorW Blender Guru’s Donut tutorial series]. But any tutorial that teaches you the basics of how to move around, shape the mesh, create objects, etc, should be fine.
Because we’ll be using Blender to make the mesh for our hair mod, we recommend at least having a cursory knowledge of how to use Blender before attempting to follow this guide. If you don’t have that, we recommend [https://youtube.com/playlist?list=PLjEaoINr3zgEPv5y--4MKpciLaoQYZB1Z&si=GqdmSXxoU6_-RorW Blender Guru’s Donut tutorial series]. But any tutorial that teaches you the basics of how to move around, shape the mesh, create objects, etc, should be fine.


Open up your Multitool and [https://bg3.wiki/wiki/Modding:Unpacking_and_converting_files unpack the Models.pak game files]. This should contain all of the vanilla hair models we are going to use.
Open up your Multitool and [https://bg3.wiki/wiki/Modding:Unpacking_and_converting_files unpack the Models.pak game files], if you have hard drive space for it. Otherwise, you can just [https://bg3.wiki/wiki/Modding:Unpacking_and_converting_files#Unpacking_Process index it]. This should contain all of the vanilla hair models we are going to use.


Open Blender 3.6 and [https://github.com/Norbyte/dos2de_collada_exporter install the Collada/GR2 exporter plugin]. This will allow you to import and export .GR2s, which is the file type BG3 uses for its models.
Open Blender 3.6 and [https://github.com/Norbyte/dos2de_collada_exporter install the Collada/GR2 exporter plugin]. This will allow you to import and export .GR2s, which is the file type BG3 uses for its models.


=== Loading A Mesh ===
We recommend creating a project folder to hold your various hair mod files.
Let’s load a hair mesh into Blender! Go to the [[Modding:Hair Meshes]] page and pick a mesh that you like. Take note of the Asset Name—that’s what it’s called in the game files. Open the Multitool and search the index for this Asset Name. It should have a .GR2 extension, e.g.  Hair_GTY_F_GithyankiCut_Short_A_Spring.GR2. Once you find it, copy it to a project folder to make it easier to find. Then go into Blender, go to File, and Import the .GR2.
 
===Loading a Mesh===
Let’s load a hair mesh into Blender! Go to the [[Modding:Hair Meshes]] page and pick a mesh that you like. Take note of the Asset Name—that’s what it’s called in the game files. Open the Multitool and search the index for this Asset Name. It should have a .GR2 extension, e.g.  Hair_GTY_F_GithyankiCut_Short_A_Spring.GR2. Once you find it, copy it to your project folder to make it easier to find. Then go into Blender, go to File, and Import the .GR2.


Here is an [https://youtu.be/yQSqRF7dLB8?si=dbmIX2UpsK5XtDFR example video of installing the plugin and importing a GR2].
Here is an [https://youtu.be/yQSqRF7dLB8?si=dbmIX2UpsK5XtDFR example video of installing the plugin and importing a GR2].
Line 43: Line 30:
If you’re not really sure what you’re looking at, BG3’s hair models are composed of pieces called “hair cards” that are essentially just long strips of mesh, or planes, with a hair texture applied. This is a (comparatively) low-poly way of making hair.
If you’re not really sure what you’re looking at, BG3’s hair models are composed of pieces called “hair cards” that are essentially just long strips of mesh, or planes, with a hair texture applied. This is a (comparatively) low-poly way of making hair.


If you want to see how the hair looks on a head, you can import a head model into Blender too using the exact same method you used for the hair. Just make sure the race of the [[Modding:Head Models|Head Model]] you choose matches the hair you’re working with—so if you’re editing HAIR_HUM_F_Afro_Long_A, choose a human or humanlike head.
If you want to see how the hair looks on a head, you can import a head model into Blender too, using the exact same method you used for the hair. Just make sure the race of the [[Modding:Head Models|Head Model]] you choose matches the hair you’re working with—so if you’re editing HAIR_HUM_F_Afro_Long_A, choose a human or humanlike head.


=== Editing the Mesh in Blender ===
=== Editing the Mesh in Blender===
Now comes the fun part—playing with the hair in Blender. Make it longer or shorter, remove some parts, add some parts. There’s a lot you can do even without making any custom hair parts from scratch, so get creative!
Now comes the fun part—playing with the hair in Blender. Make it longer or shorter, remove some parts, add some parts. There’s a lot you can do even without making any custom hair parts from scratch, so get creative!


==== Mesh Editing FAQ ====
=== Mesh Editing FAQ ===
Here are some common issues you might run into while editing the hair in Blender:
Here are some common issues you might run into while editing the hair in Blender:


Line 57: Line 44:
'''Is there an easier way to select an entire part of the hair (such as a ponytail) without manually selecting each vertex? It’s hard for me to do this when the hair gets close to the scalp.''' Yes! Use the Box or Circle select tool to select as much of the ponytail as you can. Then, to get those pesky roots without grabbing other parts of the hair, press CTRL + +, and continue pressing those keys to Select More of the parts you already have selected.
'''Is there an easier way to select an entire part of the hair (such as a ponytail) without manually selecting each vertex? It’s hard for me to do this when the hair gets close to the scalp.''' Yes! Use the Box or Circle select tool to select as much of the ponytail as you can. Then, to get those pesky roots without grabbing other parts of the hair, press CTRL + +, and continue pressing those keys to Select More of the parts you already have selected.


'''Can I add custom highlights/greying to my hair if I don’t like the vanilla ones?''' Yes! This is done using Vertex Paint. See [[Modding:Custom Hair Highlights|this tutorial]] for more details. The tutorial should work the same way for adding greying—just paint with a red color instead of a blue one.
'''Can I add custom highlights to my hair if I don’t like the vanilla ones?''' Yes! This is done using Vertex Paint. See [[Modding:Custom Hair Highlights|this tutorial]] for more details.
 
'''Can I adjust the UVs/the parts of the texture that my hair cards use?''' Yes! See [https://docs.google.com/document/d/1Kv9P01LZIXtP-U0KqOH7_P5lu9lyzJPbbUpYX2ASbMY/edit?usp=sharing this tutorial] for more details.
 
'''Can I add physics to my hair?''' Yes, as long as you use one of the vanilla physics skeletons/armatures (so a skeleton from a vanilla hair with physics), as we can't make custom skeletons for hairs at this time. You'll need to weight your hair to the armature so the hair will move with the skeleton. You'll also need the SkeletonResource of the vanilla hair you're using. Then plug the SkeletonResource into this line in your _merged.lsf.lsx file.<syntaxhighlight lang="xml">
<attribute id="SkeletonResource" type="FixedString" value="SKELETONRESOURCEHERE" />
</syntaxhighlight>To find the SkeletonResource of vanilla hairs, check out these pages. [[Modding:Hair Meshes]] and [https://docs.google.com/spreadsheets/d/16cQUxQ7FrGVmIPy5929qae4cCQls4ZWuBX_w08zvv5M/edit#gid=0 BG3 Hair Reference Spreadsheet].
 
'''None of the vanilla hairs seem to have the part I want. Can I make my own custom hair for BG3?''' Yes! WIP tutorial here: [[Modding:Creating Custom Hair with Hair Tool|Creating Custom Hair with Hair Tool]]
 
====Autosnapping Weights====
Padme has [https://youtu.be/siC6fak9zDM?si=vFQBBiLNV79kUVkt&t=298 a great video here] that explains how to use a vanilla mesh to transfer weights to your new hair. It's recommended to find the vanilla hair that looks most similar to your hair, and use that.
 
====Non-Autosnapping Weights====
[[File:CrunchyHairExample.png|thumb|An example of hair "crunching" caused by autosnap not working well.]]
If your hair is crunching really badly with autosnap, you might want to re-weight it to be non-autosnap. How do you do that? It's fairly simple: wipe out all of the existing vertex groups on your hair. Create a new vertex group and name it Head_M (mind the capitalization). Select all in edit mode and assign your hair mesh to that vertex group. If your hair is shorter than the character's shoulders, you're done! If it's longer and you want it to move somewhat with the upper body, create another vertex group called Chest_M, and use the gradient tool in Weight Paint mode to weight from the bottom up. Test in game and adjust as necessary. Those two vertex groups are probably all you need for non-autosnapping. Make sure when you're setting up the files later that you turn off autosnapping in there, too, otherwise your hair won't behave properly. Remember that turning off autosnap means you have to manually refit the hair for every body type that you want it to be available for... which is a pain.
 
===Exporting the Mesh===
If using the GR2 plugin, you want to first make sure you have your export order set up, which you can find in the Object Properties tab:
[[File:Exportorder.webp|none|frame]]
 
Set the LOD Level and LOD Distance to 0. For the first part of your mesh set the export order to 1. Increase the export order number for every part you have. So part 1 is Export Order 1, part 2 is Export Order 2, etc... Blender will throw an error if you don't have these in order.
 
Once you have all that set up, if you haven't already sometime in your process, select the armature and all your meshes, and apply transforms with Ctrl + A > Apply Transforms.
 
Now you can export the mesh(es). These are the export settings to use when exporting with the GR2 plugin:
[[File:Gr2export.webp|thumb|none]]
 
The settings below this cutoff remain as they are by default. If you don't apply transforms, turn back on the Convert to Y-Up.
 
=== Conforming with LSLib===
After exporting the mesh from Blender, there's one more step you need to follow: conforming to a vanilla skeleton with LSLib. Why? We're not totally sure, but we do know that hair gets very wacky in game if you don't do this.
 
Export your mesh from Blender as a .dae file, then load up LSLib. Make sure your settings are the same in all of the red highlighted areas (note some of them may not be selectable until you Import a file). The pink highlighted path should be the path to your .dae file, and the orange highlighted path should be the same, only with the file extension changed to .GR2 (uppercase!)
[[File:LSLibConformExample.png|none|frame]]
The green highlighted path should lead to a vanilla hair that you want to conform to. In general, pick a hair that's a similar overall shape to your hair. Whatever that hair is called, you need to rename your hair in the Object Data Properties in Blender to match the same name--otherwise, LSLib will throw an error when you try to conform.
 
For example: If the vanilla mesh you are conforming to is HAIR_GTY_F_GithyankiCut_Short_A_Spring, then the name you need to change your hair to is HAIR_GTY_F_GithyankiCut_Short_A_Spring_Mesh.
[[File:ChangeODPNameExample.png|none|frame]]
Change the name highlighted in red to the name of the vanilla mesh. Do this for all of your hair parts (it's okay if Blender automatically appends numbers to the end). Re-export, load into LSLib as .dae, and it should now let you conform to the same vanilla mesh, as it now has matching object property names.


'''None of the vanilla hairs seem to have the part I want. Can I make my own custom hair for BG3?''' Tutorial for this coming soon(TM)!
Done with editing the mesh in Blender? Follow [[Guide:Hair Mod File Setup|this tutorial]] to set up the files for inclusion into the game!


Done with editing the mesh in Blender? Follow this tutorial to set up the files for inclusion into the game! [[Guide:Hair Creation]]
{{Modding navbox}}
[[Category:Hair modding]]

Latest revision as of 23:15, 29 July 2024

Welcome to the mesh creation portion of making a hair mod. For an overview of all the steps, see Modding:Creating Hair Mods.

So, you wanna make a mesh for a hair mod for Baldur’s Gate 3. How do you do that, though? This guide will show you how.

Because we’ll be using Blender to make the mesh for our hair mod, we recommend at least having a cursory knowledge of how to use Blender before attempting to follow this guide. If you don’t have that, we recommend Blender Guru’s Donut tutorial series. But any tutorial that teaches you the basics of how to move around, shape the mesh, create objects, etc, should be fine.

Open up your Multitool and unpack the Models.pak game files, if you have hard drive space for it. Otherwise, you can just index it. This should contain all of the vanilla hair models we are going to use.

Open Blender 3.6 and install the Collada/GR2 exporter plugin. This will allow you to import and export .GR2s, which is the file type BG3 uses for its models.

We recommend creating a project folder to hold your various hair mod files.

Loading a Mesh[edit | edit source]

Let’s load a hair mesh into Blender! Go to the Modding:Hair Meshes page and pick a mesh that you like. Take note of the Asset Name—that’s what it’s called in the game files. Open the Multitool and search the index for this Asset Name. It should have a .GR2 extension, e.g. Hair_GTY_F_GithyankiCut_Short_A_Spring.GR2. Once you find it, copy it to your project folder to make it easier to find. Then go into Blender, go to File, and Import the .GR2.

Here is an example video of installing the plugin and importing a GR2.

623px-Blender gr2 addon 02.webp

You should now see your mesh in Blender! But it looks all white… we should fix that and make it look closer to what it’s going to look like in-game.

To visualize the texture in Blender, follow this tutorial.

Once finished, your hair should now display a texture in Blender.

If you’re not really sure what you’re looking at, BG3’s hair models are composed of pieces called “hair cards” that are essentially just long strips of mesh, or planes, with a hair texture applied. This is a (comparatively) low-poly way of making hair.

If you want to see how the hair looks on a head, you can import a head model into Blender too, using the exact same method you used for the hair. Just make sure the race of the Head Model you choose matches the hair you’re working with—so if you’re editing HAIR_HUM_F_Afro_Long_A, choose a human or humanlike head.

Editing the Mesh in Blender[edit | edit source]

Now comes the fun part—playing with the hair in Blender. Make it longer or shorter, remove some parts, add some parts. There’s a lot you can do even without making any custom hair parts from scratch, so get creative!

Mesh Editing FAQ[edit | edit source]

Here are some common issues you might run into while editing the hair in Blender:

Will there be issues if I import a second (or more) vanilla hair mesh to add parts of it to my hair? You can definitely do this, and it’s a great way to make a hairstyle look unique. However, make sure all of your meshes are parented to one armature. If your hair meshes use the same material (same hair texture), we recommend combining them for simplicity once you’re done.

My hair is stretching weirdly, or even appearing on the floor in game. You need to apply transforms on the hair mesh and armature using CTRL + A > All Transforms.

Is there an easier way to select an entire part of the hair (such as a ponytail) without manually selecting each vertex? It’s hard for me to do this when the hair gets close to the scalp. Yes! Use the Box or Circle select tool to select as much of the ponytail as you can. Then, to get those pesky roots without grabbing other parts of the hair, press CTRL + +, and continue pressing those keys to Select More of the parts you already have selected.

Can I add custom highlights to my hair if I don’t like the vanilla ones? Yes! This is done using Vertex Paint. See this tutorial for more details.

Can I adjust the UVs/the parts of the texture that my hair cards use? Yes! See this tutorial for more details.

Can I add physics to my hair? Yes, as long as you use one of the vanilla physics skeletons/armatures (so a skeleton from a vanilla hair with physics), as we can't make custom skeletons for hairs at this time. You'll need to weight your hair to the armature so the hair will move with the skeleton. You'll also need the SkeletonResource of the vanilla hair you're using. Then plug the SkeletonResource into this line in your _merged.lsf.lsx file.
<attribute id="SkeletonResource" type="FixedString" value="SKELETONRESOURCEHERE" />
To find the SkeletonResource of vanilla hairs, check out these pages. Modding:Hair Meshes and BG3 Hair Reference Spreadsheet.

None of the vanilla hairs seem to have the part I want. Can I make my own custom hair for BG3? Yes! WIP tutorial here: Creating Custom Hair with Hair Tool

Autosnapping Weights[edit | edit source]

Padme has a great video here that explains how to use a vanilla mesh to transfer weights to your new hair. It's recommended to find the vanilla hair that looks most similar to your hair, and use that.

Non-Autosnapping Weights[edit | edit source]

An example of hair "crunching" caused by autosnap not working well.

If your hair is crunching really badly with autosnap, you might want to re-weight it to be non-autosnap. How do you do that? It's fairly simple: wipe out all of the existing vertex groups on your hair. Create a new vertex group and name it Head_M (mind the capitalization). Select all in edit mode and assign your hair mesh to that vertex group. If your hair is shorter than the character's shoulders, you're done! If it's longer and you want it to move somewhat with the upper body, create another vertex group called Chest_M, and use the gradient tool in Weight Paint mode to weight from the bottom up. Test in game and adjust as necessary. Those two vertex groups are probably all you need for non-autosnapping. Make sure when you're setting up the files later that you turn off autosnapping in there, too, otherwise your hair won't behave properly. Remember that turning off autosnap means you have to manually refit the hair for every body type that you want it to be available for... which is a pain.

Exporting the Mesh[edit | edit source]

If using the GR2 plugin, you want to first make sure you have your export order set up, which you can find in the Object Properties tab:

Exportorder.webp

Set the LOD Level and LOD Distance to 0. For the first part of your mesh set the export order to 1. Increase the export order number for every part you have. So part 1 is Export Order 1, part 2 is Export Order 2, etc... Blender will throw an error if you don't have these in order.

Once you have all that set up, if you haven't already sometime in your process, select the armature and all your meshes, and apply transforms with Ctrl + A > Apply Transforms.

Now you can export the mesh(es). These are the export settings to use when exporting with the GR2 plugin:

Gr2export.webp

The settings below this cutoff remain as they are by default. If you don't apply transforms, turn back on the Convert to Y-Up.

Conforming with LSLib[edit | edit source]

After exporting the mesh from Blender, there's one more step you need to follow: conforming to a vanilla skeleton with LSLib. Why? We're not totally sure, but we do know that hair gets very wacky in game if you don't do this.

Export your mesh from Blender as a .dae file, then load up LSLib. Make sure your settings are the same in all of the red highlighted areas (note some of them may not be selectable until you Import a file). The pink highlighted path should be the path to your .dae file, and the orange highlighted path should be the same, only with the file extension changed to .GR2 (uppercase!)

LSLibConformExample.png

The green highlighted path should lead to a vanilla hair that you want to conform to. In general, pick a hair that's a similar overall shape to your hair. Whatever that hair is called, you need to rename your hair in the Object Data Properties in Blender to match the same name--otherwise, LSLib will throw an error when you try to conform.

For example: If the vanilla mesh you are conforming to is HAIR_GTY_F_GithyankiCut_Short_A_Spring, then the name you need to change your hair to is HAIR_GTY_F_GithyankiCut_Short_A_Spring_Mesh.

ChangeODPNameExample.png

Change the name highlighted in red to the name of the vanilla mesh. Do this for all of your hair parts (it's okay if Blender automatically appends numbers to the end). Re-export, load into LSLib as .dae, and it should now let you conform to the same vanilla mesh, as it now has matching object property names.

Done with editing the mesh in Blender? Follow this tutorial to set up the files for inclusion into the game!