Modding:Creating and Exporting Meshes in Blender: Difference between revisions
No edit summary |
No edit summary |
||
(14 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
|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. | |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. | ||
|image=Modding_resources.webp | |image=Modding_resources.webp | ||
}} | }}<div column-width: "60em2;>{{Modding box}}{{Modding sidebar}}[[File:ScreenshotHowToImportIt.webp|thumb|This should show up in your File> Import menu if you have the addon installed correctly.|306x306px]] | ||
<div column-width: "60em2;> | |||
[[File:ScreenshotHowToImportIt.webp|thumb|This should show up in your File> Import menu if you have the addon installed correctly.|306x306px]] | |||
In this tutorial we will assume you are generally knowledgable about how to use 3d software, so this will focus on things specific to Baldur’s Gate 3 exporter made by Norbyte. Remember, there are many general youtube tutorials about how to weight paint and edit meshes in Blender. | In this tutorial we will assume you are generally knowledgable about how to use 3d software, so this will focus on things specific to Baldur’s Gate 3 exporter made by Norbyte. Remember, there are many general youtube tutorials about how to weight paint and edit meshes in Blender. | ||
Line 22: | Line 19: | ||
==Extracting a model to work with== | ==Extracting a model to work with== | ||
[[File:NewBodyBlenderScreenshotImported.webp|thumb|Imported meshes.|187x187px]]Now open your modder’s multitool. Click ‘Search Index’. Filter by .GR2. Search something like HUM_F_ARM_ and browse the in game meshes available to regular size humanlike females. | [[File:NewBodyBlenderScreenshotImported.webp|thumb|Imported meshes.|187x187px]]Now open your modder’s multitool. Click ‘Search Index’. Filter by .GR2. Search something like HUM_F_ARM_ and browse the in game meshes available to regular size humanlike females. | ||
You should at least extract [[Modding:Body Models|HUM_F_NKD_Body_A]] (or whatever nude you are basing your outfit on) to fit your new outfit around. | You should at least extract [[Modding:Body Models|HUM_F_NKD_Body_A]] (or whatever nude you are basing your outfit on) to fit your new outfit around. | ||
Line 50: | Line 47: | ||
==Vertex Paint== | ==Vertex Paint== | ||
[[File:BlenderVertexPaintUnderwearExample.webp|thumb|This underwear has its green vertex paint, which tells it to vanish when a top is equipped.|171x171px]] | [[File:BlenderVertexPaintUnderwearExample.webp|thumb|This underwear has its green vertex paint, which tells it to vanish when a top is equipped.|171x171px]] | ||
Tab into '''Vertex Paint''' mode to look at the naked body. | Tab into '''Vertex Paint''' mode to look at the clothes and (for reference) the naked body. | ||
The game’s armour system works by vertex paint. It uses this, in combination with the .lsx code, to tell it what to hide and what to show. For example, an armour mesh may unload the torso as it will not be shown. The bottom half of a pant leg may not show when boots are equipped. Genitals have their own vertex paint and only load in when nothing with the 'hide genitals' tag is equipped. You can use existing meshes as a reference for this. | The game’s armour system works by vertex paint. It uses this, in combination with the .lsx code, to tell it what to hide and what to show. For example, an armour mesh may unload the torso as it will not be shown. The bottom half of a pant leg may not show when boots are equipped. Genitals have their own vertex paint and only load in when nothing with the 'hide genitals' tag is equipped. You can use existing meshes as a reference for this. | ||
Line 65: | Line 62: | ||
If you intend to use part of an underwear mesh on an outerwear outfit, make sure you paint it black in Vertex Paint or it will hide when it’s not supposed to. | If you intend to use part of an underwear mesh on an outerwear outfit, make sure you paint it black in Vertex Paint or it will hide when it’s not supposed to. | ||
[[File:How2ViewVertyPaint.webp|thumb|How to view Vertex Paint in Object Mode|307x307px]] | [[File:How2ViewVertyPaint.webp|thumb|Blender Attributes: How to view Vertex Paint in Object Mode|307x307px]] | ||
== How to Vertex Paint Sleeves and Pant Legs == | == How to Vertex Paint Sleeves and Pant Legs == | ||
Line 80: | Line 77: | ||
Go into Vertex color and click the little icon on top that makes sure you only paint on selected vertices. | Go into Vertex color and click the little icon on top that makes sure you only paint on selected vertices. | ||
Fill vertex color. | Fill vertex color. (You can use Shift+K to bucket fill vertex paints also) | ||
Remember also you need to have a VertCut material set up in your LSX for Vertcut to take effect. | Remember also you need to have a VertCut material set up in your LSX for Vertcut to take effect. | ||
Line 90: | Line 87: | ||
[https://www.youtube.com/watch?v=NCDGhz3RSr8 See this video] for how to fix meshes that import in with messed up normals and export looking like see through checkerboards. | [https://www.youtube.com/watch?v=NCDGhz3RSr8 See this video] for how to fix meshes that import in with messed up normals and export looking like see through checkerboards. | ||
You can also fix with '''[Edit Mode] Mesh> Clean Up> Merge By Distance''', and then put a solidify modifier at 00.1 thickness. | You can also fix with '''[Edit Mode] Mesh> Clean Up> Merge By Distance''', and then put a solidify modifier at 00.1 thickness. Recalculate Normals> Average Face Area may also help. | ||
Alternately, select all, alt+n to average face area. If any blue lines on the edges appear, select edges, then 'clear sharp' and alt+n average face areas again. | |||
[[File:How2ViewFaceorientationoverlay.webp|thumb|291x291px|How to view face orientation overlay on Blender. Blue is outside, red is inside. Red will be invisible in-game, unless you set up a 2 sided shader in your LSX code later.]] | [[File:How2ViewFaceorientationoverlay.webp|thumb|291x291px|How to view face orientation overlay on Blender. Blue is outside, red is inside. Red will be invisible in-game, unless you set up a 2 sided shader in your LSX code later.]] | ||
==Physics== | ==Physics== | ||
[https://www.nexusmods.com/baldursgate3/articles/311 Here is a tutorial about how to add physics to your mesh by ReallyLazyIcarus.] | |||
Unfortunately physics are not quite at game quality yet at this stage. | Unfortunately physics are not quite at game quality yet at this stage. | ||
Physics are set with red vertex paint. Hot pink vertex paint counterbalances the physics. | Physics are set with red vertex paint. Hot pink and blue vertex paint counterbalances the physics. | ||
If a mesh is 100% weighted to a single bone, adding physics will cause it to crash the game. If you are making a helmet item and therefore need it to be entirely static, weight some of it to the piercing bones as they also do not move. | |||
A mesh cannot be entirely vertex painted red or it will bounce around, it needs some black vertex paint left to keep it in place. | |||
If your mesh is creasing up at the back, you may want to lower the vertex paint to be lower down. | |||
A cloth mesh (Generally named something like HUM_F_CLT_Daisy_Dress_A_Cloth_Mesh and will import in) is the collider mesh, which stops it clipping through things. Sadly you may need to delete it as it can cause your mesh to be exported with errors. | A cloth mesh (Generally named something like HUM_F_CLT_Daisy_Dress_A_Cloth_Mesh and will import in) is the collider mesh, which stops it clipping through things. Sadly you may need to delete it as it can cause your mesh to be exported with errors. | ||
[https:// | Some people have had success pasting the code from in game meshes into their lsx mesh code, specifically clothbuffer values, which caused the physics to be less flappy and enabled the collider mesh to be exported without issues. Which is worth a try if you have a lot of patience and experience with coding. [https://docs.google.com/document/d/1nb_B2uz8Xlakhoa7XNf4IRU8mMisGPZyQEkydlZQdD0/edit?usp=sharing A tutorial can be found for this here.] | ||
[[File:ScreenyExampleOfPhysicsMesh.webp|thumb|134x134px|Example of red vertex paint for Physics. (Daisy Dress Mesh)]] | |||
Some people have also experimented with not exporting the mesh and setting non-skirt parts of the original mesh to use an invisible material, then combining it with their own torso in a roottemplate. | |||
If you learn anything new, add it here! | If you learn anything new, add it here! | ||
== | ==LODs and Load Order== | ||
[https://www.youtube.com/watch?v=5TpdCBxYO1Q Here is a video of Padme’s addons being used.] | [https://www.youtube.com/watch?v=5TpdCBxYO1Q Here is a video of Padme’s addons being used.] | ||
LODs are a way of improving performance on weaker computers by using a lower-quality version of the mesh at farther distances. | |||
Using Padme’s addon tool, click the button to generate LOD and you will have your nice new set of LODs. You may need to edit the LOD0 it’s a new mesh, as it won't know what settings a BG3 mesh should have. | Using Padme’s addon tool, click the button to generate LOD and you will have your nice new set of LODs. You may need to edit the LOD0 it’s a new mesh, as it won't know what settings a BG3 mesh should have. | ||
Line 114: | Line 123: | ||
'''-Lod Distance''' is the distance from which your mesh swaps to the next LOD. For this reason, your highest quality mesh should probably be something like 9-15 metres, your middle ones 15-20, while your last LOD always needs to be set to 0. Or it will vanish from a distance. There are certain cutscenes in Act 3 and elsewhere where your player character is seen from a very long distance, so this is important! | '''-Lod Distance''' is the distance from which your mesh swaps to the next LOD. For this reason, your highest quality mesh should probably be something like 9-15 metres, your middle ones 15-20, while your last LOD always needs to be set to 0. Or it will vanish from a distance. There are certain cutscenes in Act 3 and elsewhere where your player character is seen from a very long distance, so this is important! | ||
'''-Export order.''' Generally all your LOD0 meshes go first, then your LOD1, LOD2, LOD3, assuming you have multiple LOD0 meshes. Look at imported game meshes for reference. If there is not a consistent 1, 2, 3, 4, export order, the mesh will refuse to export. | '''-Export order.''' Generally all your LOD0 meshes go first, then your LOD1, LOD2, LOD3, assuming you have multiple LOD0 meshes. Look at imported game meshes for reference. If there is not a consistent 1, 2, 3, 4, export order, the mesh will refuse to export. | ||
If you get the export order wrong in the code, some meshes may end up with the wrong material assigned to them. | If you get the export order wrong in the code, some meshes may end up with the wrong material assigned to them. | ||
=== '''Using No LODs''' === | |||
If you don’t particularly care about it performing well on bad computers, you can have no LOD meshes and just set your high quality mesh to have a LOD distance of 0. | |||
== Weight Painting == | |||
If you hand edited the weight paints and now your outfit is squiggling, you may need to limit the total amount of vertices affected by the weight. | |||
''Weight Painting Mode> Weights > Limit Total'' | |||
Usually the default '4' will work, but you may wish to try '2' if it persists. | |||
==Exporting== | ==Exporting== | ||
Line 131: | Line 148: | ||
If you parented your mesh to the nude body armature, remember to delete the nude body before exporting it! | If you parented your mesh to the nude body armature, remember to delete the nude body before exporting it! | ||
See here for a [[Modding:Blender Export Settings|list of past and future Blender export settings]]. | |||
[[File:BlenderTtut3.6ExportSettings.webp|thumb|Default export settings for Blender 3.6|445x445px]] | [[File:BlenderTtut3.6ExportSettings.webp|thumb|Default export settings for Blender 3.6|445x445px]] | ||
Line 140: | Line 158: | ||
==Hotloading== | ==Hotloading== | ||
It is not only possible but very recommended to hotload meshes, it enables you to fix them in action. [[Modding:Hotloading|See here for how.]] | It is not only possible but very recommended to hotload meshes, it enables you to fix them in action. [[Modding:Hotloading|See here for how.]] | ||
Although it has to have the same mesh order as the thing you are replacing. | |||
== General Blender tutorials == | == General Blender tutorials == | ||
If you don't understand how to use Blender, start with [https://www.youtube.com/@blenderguru Donut tutorial by BlenderGuru]. | If you don't understand how to use Blender, start | ||
[[Category:Modding guides]] | |||
with [https://www.youtube.com/@blenderguru Donut tutorial by BlenderGuru]. | |||
You may also find [https://www.youtube.com/@TheRoyalSkies/playlists TheRoyalSkies short videos on Blender] to be helpful. | You may also find [https://www.youtube.com/@TheRoyalSkies/playlists TheRoyalSkies short videos on Blender] to be helpful. | ||
Line 153: | Line 175: | ||
[https://www.nexusmods.com/baldursgate3/mods/4310 Volno texture toolbox]- for previewing textures on the mesh. | [https://www.nexusmods.com/baldursgate3/mods/4310 Volno texture toolbox]- for previewing textures on the mesh. | ||
{{Modding navbox}} | |||
[[Category:Armor modding]] | |||
[[Category: |
Latest revision as of 13:29, 15 April 2024
This page is a modding page, and follows its own rules and standards separate from the rest of the wiki. |
bg3.wiki modding |
---|
Modding homepage |
Modding resources - Meshes, Models, Tools, etc. |
Modding guides |
Hair modding |
Head modding |
Item modding - Armours, Outfits, Weapons etc. |
Race/class modding |
In this tutorial we will assume you are generally knowledgable about how to use 3d software, so this will focus on things specific to Baldur’s Gate 3 exporter made by Norbyte. Remember, there are many general youtube tutorials about how to weight paint and edit meshes in Blender.
BG3 Tutorials and Resources[edit | edit source]
Be sure to watch this video tutorial series by Druu using the BG3 Blender plugin and follow along. It is older but still very relevant and helpful.
Setup[edit | edit source]
Check here for a list of tools.
Here we are using Modder's Multitool, Blender 3.6, and Norbyte’s Blender installer. Until the update specifically says it has been updated to work with Blender 4.0, we recommend sticking with Blender 3.6 currently.
Make sure you install it correctly- this video should give you some example of how to install it.
You should also install Padme’s Addon, ‘Create LODs’. You may also find use of the 'Reset Transforms' tools as they are helpful when weight painting a model.
Extracting a model to work with[edit | edit source]
Now open your modder’s multitool. Click ‘Search Index’. Filter by .GR2. Search something like HUM_F_ARM_ and browse the in game meshes available to regular size humanlike females.You should at least extract HUM_F_NKD_Body_A (or whatever nude you are basing your outfit on) to fit your new outfit around.
When you have found a model to your liking, click the extract file/open folder. You should find the mesh in .GR2 and .dae form on your computer. Use the .dae- the Blender importer likes .dae format a lot more than it likes .gr2. You generally cannot import a modded-in mesh without the plugin crashing Blender. Hopefully you are sensible and you save your own work often and can re-export it from there, and have obtained permission to edit all the modded items you want to import anyway.Importing[edit | edit source]
It will be a fairly standard rig with an Armature modifier (see Modifier tab).
Your armatures will import in at 90 degrees. This will cause it to export flat to the floor and follow a naked character around like a weird sad windsock, so you need to fix it.
[Object Mode] Object > Apply> All Transforms on the armature, until the coordinates for its location all read 0, 0, 0. You may need to do the same thing on the meshes as well.
The mesh will import in with 1 or more LODS. These are level of detail meshes, intended to be viewed at a distance so they are lower poly. You only need the best quality one as we are making new LODs later, so delete anything that has LOD in the name.
If your mesh you imported has a skirt, it may have an undetailed boxy thing called a ‘Cloth Mesh’. This has to do with Physics (see below).
Editing Meshes[edit | edit source]
If you wish to combine two meshes for whatever reason, remember that each mesh will have its own name for the UV map and colour maps. You need to rename the UV maps and Colour maps to be the same before you combine them, or one will be absorbed into the other.
The UV map may seem bare when you tab into the UV display, but BG3 meshes have an odd habit of not being on the actual UV square itself, as the UV tiles. So you may need to scroll out quite far to see the full UV. You can drag it back (Snap to Vertex can be useful with this) or keep it there, it usually does not matter.
Depending on what type of mesh you imported, it will not have all the bones- circlets for example may only import in with the head bone.If making a new full body mesh, it is generally a good idea to parent your mesh to a naked body, which does have all the bones, as this can avoid weighting issues.
Remember that genitals are attached later via lsx code and aren't a part of the body mesh.
Vertex Paint[edit | edit source]
Tab into Vertex Paint mode to look at the clothes and (for reference) the naked body.
The game’s armour system works by vertex paint. It uses this, in combination with the .lsx code, to tell it what to hide and what to show. For example, an armour mesh may unload the torso as it will not be shown. The bottom half of a pant leg may not show when boots are equipped. Genitals have their own vertex paint and only load in when nothing with the 'hide genitals' tag is equipped. You can use existing meshes as a reference for this.
Check here for a reference and Hex codes for the vertex paint including physics colours.
Keeping the HUM_F_NKD_Body_A in the scene is useful as reference here. For example, if you set an upper arm to be hidden for some gloves, you may wish to fit it around these seams to ensure there is no gap in the body showing.
You can turn on the vertex paint to look at it in non-Vertex Paint modes by touching the Blender attributes menu.
You can also turn on Flat shading from the same menu, to get a better view of things if you are creating your own vertex paint for outfits.
Generally outfit meshes are black in vertex paint, with some dark green on elements intended to disappear such as the pant legs. You may not need to touch the vertex paint if you are just editing existing outfits!
If you intend to use part of an underwear mesh on an outerwear outfit, make sure you paint it black in Vertex Paint or it will hide when it’s not supposed to.
How to Vertex Paint Sleeves and Pant Legs[edit | edit source]
If you handpaint vertex paint on your own meshes, the mesh will often glitch. You may need to use this method to make it work.
Go into Edit mode.
Select the vertices you want painted.
Shift + D to copy the vertices (right click so they stay in place)
Go into Vertex color and click the little icon on top that makes sure you only paint on selected vertices.
Fill vertex color. (You can use Shift+K to bucket fill vertex paints also)
Remember also you need to have a VertCut material set up in your LSX for Vertcut to take effect.
Fixing meshes that import in wrong[edit | edit source]
Sometimes meshes will import in with broken shading and stuck together, usually on skirt meshes. This is because the verts were too close together and the importer couldn't interpret it. This is often an issue with the normals as well.
See this video for how to fix meshes that import in with messed up normals and export looking like see through checkerboards.
You can also fix with [Edit Mode] Mesh> Clean Up> Merge By Distance, and then put a solidify modifier at 00.1 thickness. Recalculate Normals> Average Face Area may also help.
Alternately, select all, alt+n to average face area. If any blue lines on the edges appear, select edges, then 'clear sharp' and alt+n average face areas again.
Physics[edit | edit source]
Here is a tutorial about how to add physics to your mesh by ReallyLazyIcarus.
Unfortunately physics are not quite at game quality yet at this stage.
Physics are set with red vertex paint. Hot pink and blue vertex paint counterbalances the physics.
If a mesh is 100% weighted to a single bone, adding physics will cause it to crash the game. If you are making a helmet item and therefore need it to be entirely static, weight some of it to the piercing bones as they also do not move.
A mesh cannot be entirely vertex painted red or it will bounce around, it needs some black vertex paint left to keep it in place.
If your mesh is creasing up at the back, you may want to lower the vertex paint to be lower down.
A cloth mesh (Generally named something like HUM_F_CLT_Daisy_Dress_A_Cloth_Mesh and will import in) is the collider mesh, which stops it clipping through things. Sadly you may need to delete it as it can cause your mesh to be exported with errors.
Some people have had success pasting the code from in game meshes into their lsx mesh code, specifically clothbuffer values, which caused the physics to be less flappy and enabled the collider mesh to be exported without issues. Which is worth a try if you have a lot of patience and experience with coding. A tutorial can be found for this here.
Some people have also experimented with not exporting the mesh and setting non-skirt parts of the original mesh to use an invisible material, then combining it with their own torso in a roottemplate.
If you learn anything new, add it here!
LODs and Load Order[edit | edit source]
Here is a video of Padme’s addons being used.
LODs are a way of improving performance on weaker computers by using a lower-quality version of the mesh at farther distances.
Using Padme’s addon tool, click the button to generate LOD and you will have your nice new set of LODs. You may need to edit the LOD0 it’s a new mesh, as it won't know what settings a BG3 mesh should have.
-LOD Level is what level of LOD it is. LOD0 is the best quality, cutscene one. Meshes generally have no more than 4-5 LODS, usually depending on how 'common' an asset it is. (A common peasant shirt will have many LODS, while an armour intended only for the player or important NPC may have only 1 LOD.)
-Lod Distance is the distance from which your mesh swaps to the next LOD. For this reason, your highest quality mesh should probably be something like 9-15 metres, your middle ones 15-20, while your last LOD always needs to be set to 0. Or it will vanish from a distance. There are certain cutscenes in Act 3 and elsewhere where your player character is seen from a very long distance, so this is important!
-Export order. Generally all your LOD0 meshes go first, then your LOD1, LOD2, LOD3, assuming you have multiple LOD0 meshes. Look at imported game meshes for reference. If there is not a consistent 1, 2, 3, 4, export order, the mesh will refuse to export.
If you get the export order wrong in the code, some meshes may end up with the wrong material assigned to them.
Using No LODs[edit | edit source]
If you don’t particularly care about it performing well on bad computers, you can have no LOD meshes and just set your high quality mesh to have a LOD distance of 0.
Weight Painting[edit | edit source]
If you hand edited the weight paints and now your outfit is squiggling, you may need to limit the total amount of vertices affected by the weight.
Weight Painting Mode> Weights > Limit Total
Usually the default '4' will work, but you may wish to try '2' if it persists.
Exporting[edit | edit source]
Remember to set all of your mesh to the same material in Blender, or delete all materials assigned to the mesh before exporting, or some parts of the outfit may not show up in the game.
Default export settings are fine to use. See here for an example.
Remember to save as .GR2 not .gr2 and use that in all your code, the game is very concerned with capitalisation.
Your mesh will export x-mirrored. Meshes import in from the multitool x-mirrored, so they are the right way around now!
If you parented your mesh to the nude body armature, remember to delete the nude body before exporting it! See here for a list of past and future Blender export settings.
Testing in Game[edit | edit source]
It is recommended to test the mesh first by exporting it as a replacer for an existing mesh(even one from a mod you have unpacked) if you are new to modding, as there’s a lot of things that can cause an item to not show up in your code.
For adding the item in game as a seperate item, see here- Coding an Item.
Hotloading[edit | edit source]
It is not only possible but very recommended to hotload meshes, it enables you to fix them in action. See here for how.
Although it has to have the same mesh order as the thing you are replacing.
General Blender tutorials[edit | edit source]
If you don't understand how to use Blender, start with Donut tutorial by BlenderGuru.
You may also find TheRoyalSkies short videos on Blender to be helpful.
Modders Resources[edit | edit source]
Outfit Builder by LazyIcarus- uses shapekeys to edit a mesh to a different body type- useful if you want to make an outfit for different body types.
Volno texture toolbox- for previewing textures on the mesh.