project reality header
Go Back   Project Reality Forums > PR:BF2 Mod Forums > PR:BF2 Community Modding > Modding Tutorials
18 Sep 2024, 00:00:00 (PRT)
Register Developer Blogs Members List Search Quick Links
Modding Tutorials Information and tutorials related to modding BF2.

Reply
 
Thread Tools Display Modes
Old 2013-01-17, 18:42   #1
Rhino
Retired PR Developer
Supporting Member

Rhino's Avatar
Arrow Working With Multi/Sub-Object Materials

Been meaning to write up a tutorial on this for some time as it has significant advantages over the normal method of assigning individual materials to faces which can cause serious errors like duplicate materials on the same object etc, and generally isn't as easy to work with overall.

Basically, this tutorial is about how you, as an exporter (although this tut is also very useful for modellers but not aimed at them) of either weapons, vehicles or staticobjects can assign multiple materials to the same object simply and effectively without having to deal with loads of different individual materials that can get messed up when you assign them or attach other objects with different materials.

For this Tutorial I'm going to be using the French AS 565MB Panther and the Zhi-9 Series.



Before you begin this tutorial you should have some experience with exporting for BF2 and understand how BF2 and 3DsMax materials work.


The Advantages of Multi/Sub-Object Materials

Before I go into any detail on them I would like to just go over the advantages of this system in detail so you can see why you should learn how to use these materials as an exporter
  1. Easy Copying & Switching of Materials between Similar Models
  2. Multiple Materials with the same Names, Helps Massively for Shader Technique Assignment
  3. Unlimited Amount of Materials
  4. Avoiding Cloned Materials

1. Easy Copying & Switching of Materials between Similar Models
With this system, you can make multiple Multi/Sub-Object Materials, which then you can interchange with ease between different models. This as you will see in this tut can make your life much easier as an exporter, and also allow you to view the "_woodland" textures with just one click of a button, rather than changing endless amounts of materials, then having to change them all back to export again.

2. Multiple Materials with the same Names, Helps Massively for Shader Technique Assignment
As I'll demonstrate in this tutorial, no longer will you need to worry about what material do you assign an "Alpha" or "Alpha_Test" to because for some odd reason the exporter doesn't sometimes like you using the "*||Alpha_Test" and ignores the "Alpha_Test" Shader Technique you've tried to apply to that material when it exports it, as now you can call multiple materials, in the same multi/sub-object material, "Alpha_Test"

3. Unlimited Amount of Materials
This is only really sometimes a problem for people working on a very complex object, or more likely a complex set of objects like a weapon series with loads of different components requiring different textures and shader techniques, its easy to run out of the 24 Material Slots you have available to you in the Max Material Window. As you can see in my "Separating 1st and 3rd Person Models/Textures for Handheld Weapons" tut I almost ran out of material slots for the SA80 series, which I made before I started using this system, and had to get rid of some of the materials I was using to help me make the models like the UV helper mat etc, not to mention it became a total cluster f*ck to find which material you needed and very hard to work with.

4. Avoiding Cloned Materials
By using this method, you have to assign each material with a "Material ID". Now this may seem like a slight con over the old system where you don't need to worry about this, but in the long run it pays off as you can see very clearly all the MatIDs your object uses, and with it, avoid any cloned mats. Cloned Materials are bad because not only are they harder to update, but it also means another draw calls, which means more of the players CPU needs to think about how it needs to draw the object, meaning more the CPU can potentially bottleneck, causing FPS lag even thou the GFX card isn't working flat out, simply because the CPU can't get the data the GPU needs to process in time the player wants it on his screen.
This also means that attaching two objects using the same multi/sub-object material to each other is much faster as it doesn't give you that window, asking to match materials to material ids etc, which is the main cause of cloned materials.


Part 1. Multi/Sub-Object Material Setup

Before I go any further, just to give you some background on what I'm working on and done so far is Haute has already done most of the Export work for these choppers, but hasn't set the materials up as Multi/Sub-Objects as he doesn't really know how to use them yet (one of the main reasons I'm writing this tut is for him ) and I've already setup the Zhi-9 with a Multi-Sub-Object Material, but instead of doing this the speedy way that I will for the Zhi-9WA and the Brazilian Pantera, I'm going to setup the French Panthers Multi/Sub-Object Material from scratch.

It should also be noted that there are a few things I still need to fix up with this export scene which I won't be including in this tut and I also still need to make the lods/cols, although will add a bit later on about how to use multi/sub-object mats for cols once I've done them too later on

Anyways here is the geom1, lod0 of the Panther without rotors and the 7 materials circled in red are the ones it currently uses assigned to different faces in the normal way and the green arrow points to the box I'm going to have my Panther Multi/Sub-Object Material

The Materials it currently uses include:
  • Fr_Panther_1p||ColorMapGloss
  • Fr_Panther_3p||ColorMapGloss
  • Fr_Panther_3p||Alpha_Test (although just called "Alpha_Test" currently)
  • Glass||Alpha
  • French_parts||ColorMapGloss
  • French_parts||Alpha (although just called "Alpha" currently)
  • Gauges (temp mat that I need to replace later on)

Now first step is to select the material slot we want to use, hit the "Standard" button (might be labelled differently if you've assigned a different material already to that slot), then select "Multi/Sub-Object" from the list, then a window will pop up afterwards asking you if you want to either Discard the old material, or if you want to include it in your new Multi/Sub-Object Material as one of the sub materials, but in this case, since it was a blank material we no longer want, I'm going to hit discard. If you selected the Keep old mat as sub-mat option then the current mat slot your replacing would become the first mat of the new multi/sub-object mat

Now we have our basic Multi/Sub-Object Material with the default number of 10 sub materials in it, all blank, newly crated, "Standard" materials. Next thing I'm going to do is to name the Multi/Sub-Object Material to "Fr AS 565MB Panther" from "03 - Default" so I and anyone else possibly working on this scene later can easily work out what this material is for.

Now I'm going to name each of my Sub Materials which not only helps me more easily pick them out of the material list, but also they show up in the Material ID selection with these name and for when you can't name the full material because if its an "Alpha" or "Alpha_Test" material, you have to name the full material by that name and not "Name||Alpha" as the exporter doesn't recognise that some reason as you trying to designate the shader technique like it dose for CMG and others.
My Material names are all Prefixed with "FrP", Standing for French Panther, keeping it as short as possible since its only a tiny box you get to fill out and lots of other details you need in there, and the prefix ensures its the correct material your working with when your assigning it to faces though MatIDs and not got the wrong Multi/Sub-Object Material on the model
In all, here are all my mats:
  1. FrP 1p (main 1st person texture sheet)
  2. FrP 3p (main 3rd person texture sheet)
  3. FrP 3p Alpha (main 3rd person texture sheet but with an alpha shader technique)
  4. FrP Glass (Glass texture sheet with alpha shader technique)
  5. FrP MRB (MRB = "Main Rotor Blur", which is a 2D texture of the rotor blurred up when it spins)
  6. FrP TRB (TRB = "Trail Rotor Blur", same as the above but for the Tail Rotor)
  7. Guages (temp mat that I need to replace later on for the 1p gauge textures)
  8. FrP Parts (The extra model parts the French Panther has from the Z-9 series that are added to a new sheet just for the French Panther)
  9. FrP Parts Alpha (Same as the above, but with an alpha shader technique)


Now we have named them all we need to make, or copy over our materials into the Sub Object Materials.

First I'm going into how to make them which is basically the same you would normally do, with the only real difference being that your making it within a material
What we are aiming for is the same, "BF2 BundledMesh" material I have selected in this pic below, That is called "Fr_Panther_1p||ColorMapGloss" and for its colour texture has "fr_the_panther_1p_c.dds" and for its normal texture it has "fr_the_panther_1p_b.dds" assigned to it, with no shadow texture.

So if we go back to our Multi/Sub-Object Material and click on the Materiel ID 1 box, next to "FrP 1p" which currently says "Material #2176 (Standard)" in it, your then dropped into that sub material, which note in the top right under the material boxes, it gives the MatID (1) and the name we have given to this Mat ID of "FrP 1p"

Now to assign a BF2 BundledMesh material to this Sub Material you would do what you would normally do for a normal material, by clicking the "Standard" box on the right then selecting "BF2 BundledMesh" from the list and it will then make you your normal BF2 BundledMesh material in this sub material slot

Then as you normally would, you would name your material to what you want it to be, in this case we want to name it "Fr_Panther_1p||ColorMapGloss" and then assign the colour texture to the "fr_the_panther_1p_c.dds" and the normal texture to "fr_the_panther_1p_b.dds" like so:

Now to navigate around a Multi/Sub-Object Material you have these two buttons in the pic below.

1 is called "Go to Parent" and if you click it, you will move up and out of your current sub material, back to the "Parent" containing all the sub materials, like so. Note, keyboard shortcut for this is the up arrow key:

2 is called "Go Forward to Sibling", which if we go back into our MatID 1 sub material again, and click it it will move us forward to the next Sub Material in the list, in this case, the MatID 2 "FrP 3p". Note, keyboard shortcut for this is the right arrow key, and left arrow key will go backwards instead of forwards:

Now that covers how to make a new material inside a multi/sub-object material and navigating around one, now its a matter of just setting up all the other sub materials.

Since most of our materials are already made up in other slots outside of our multi/sub-object material, we can just copy them into our Multi/Sub-Object Material. There are a few ways this can be done depending on the situation. The first for a normal material slot you need to drag and drop the material you want into the sub slot you want, while having your multi/sub-object material selected. In this case, I want to copy my Fr Panther 3p material into the "FrP 3p", MatID 2 slot like so, which after doing that, asks you if you want to copy the material as an instance or as a copy, in this case, we want to just do a copy as we will delete the old material after we've fully set these up. Note how everything about the material is copied from the materials name, to the type of the material and the texture paths etc, meaning as long as its setup correctly, no more setup is required by us:



Now for the Main/Tail Rotor Blur ("FrP MBR" and "FrP TBR") Materials I don't have a slot material slot for them, but I do have them setup inside my Zhi-9 Multi/Sub-Object material I did before I started this tut, which are circled at the bottom of the pic below:

Ignore that they are "Standard" Materials for the moment, I will go into why they are later on in Part 3. But for now I'm just going to show you how to copy a sub material from one Multi/Sub-Object Material to anouther, in this case, the Main Rotor Blur (MRB) from the Zhi-9 MSO (Mulit/Sub-Object) Material to the French Panther MSO Material. To do this, you just need to simply right click on the material slot box you want to copy, select copy, then switching to the French Panther MSO material, right clicking on the box you want to paste that material into, select paste, and you can either do Instance or Copied, and since all of the choppers in the Zhi-9/Panther series all use the same rotor blur textures, we are going to paste this as an Instance, so any changes we may make to one of them, affect all of them, if we need to make a change at some point. Do the same to the TRB material as well so we end up with the following




Part 2. Material ID Assignment

This might be a bit harder for people to grasp at first from the old system but once you've got the hang of it you won't want to go back as while the initial setup is a bit tiresome, the later rewards are easily worth it

Now anyways, selecting all the parts of your model, I'm just going to do my geom1, lod0 mesh for now, assign your Multi/Sub-Object that you want on to your selecting, in my case, the French Panther MSO Material by hitting the "Assign Material to Section Button" and don't worry, this won't screw up any of your assignments you've done so far (not beyond repair anyways) if your working with an old model you haven't setup with MSO materials from the very start

Now in the case of the Panther, it now looks all screwed up, which it is because we haven't yet assigned the Material IDs to the correct Materials on the mesh which we will do next

Lets first start with fixing the bodies MatIDs by first selecting it, then going into face selection mode then scrolling down the right hand side in the modifier bar until you come to the "Polygon Properties" section, which then you've got a bit about Materials. This is what we are interested in and at the bottom is a drop down box, which if we click it, we can see all the assigned materials to the model.

Now if we select each one in turn from that drop down list, the faces that are assigned to that MatID will be selected and you can easily see what is what:




Now I can tell you that Material 1 is meant to be 2 (Fr Panther 3p), 2 is meant to be 4 (Glass), 3 is meant to be 8 (Fr Panther Parts) and 4 is meant to be 9 (Fr Panther Parts Alpha).
To sort these out we need to do a little bit of musical chairs so I'm first going to Assign 4 to 9 which opens up 2 to go to 4, which then opens up 1 to go to 2, then finally 3 to 8 and we are all done with the correct MatIDs assigned to the correct faces, for this part anyways

In fact we are not quite done yet, for some reason the air filters are assigned to MatID2, where they should be MatID3 since they have little transparent holes in them that only work if the Alpha Material is assigned to them:

So I'm going to select these faces, then going to assign them the current MatID (3) by typing in 3 into the "Set ID:" box like so:

Then if we change that material to show its normal map, we can see its working separately from the main 3p mat:

Now its just a matter of doing the rest of the parts:

Now I know these following parts only use one material, the 3rd person body material and because I know this for sure, I can quickly fix the Material IDs for all of them in one go by first selecting all the objects, then applying a "Material" modifier to all these objects, I can set them all to all use the same material, for all of their faces, in this case, Material 2, then just convert all these objects to Editable Poly afterwards to apply these changes fully and bringing them back into their editable state:



Then going to do the same for the FLIR Camera, other than applying MatID 8 in its case

And now its just a matter of doing the same thing for the 1p model:










Part 3. Transparent Materials

Now this technically has nothing to do with the Multi/Sub-Object Material, you can do this even without using them but since hardly any exporters know about this very useful feature I'm going to include it in this tutorial here.

Basically you can have materials, like glass, that are transparent ingame using the "Alpha" Shader Technique, also transparent in 3DsMax and working perfectly well with the export script.

For this I'm going to use the FrP Glass (MatID 4) Material and make it transparent both in 3DsMax and ingame once its exported using the same material.

To do this, simply change your Material from a "BF2 BundledMesh" Material to a normal "Standard" Material, then expanding the maps tab, check Diffuse Color, click the "None" box next to it, select Bitmap from the list at the top, then pick out your transparent texture you want, then click the "Go to Parent" button to go back up to the list of maps you can pick again, check Opacity and click the box next to it, select bitmap again and then select the texture that has the transparency map in it, in this case, the same texture as before, then for Opacity you want to switch the "Mono Channel Output" from RGB Intensity to Alpha like so, so it uses the textures alpha channel for this map:





When you've done all that, if you click "Go to Parent" so your back on the main material and click the "Show Map in Viewport" button you should now see your windows being transparent
It is very important that the Shader Technique is still the Materials name keep in mind otherwise when its exported, it wont be exported as a transparent texture.

You can also assign a normal map in this manner by putting the "_b.dds" texture into the bump slot under a bitmap. If you try to put a "Normal Bump" material and set that to use the "_b.dds" texture in its place however, like you would for making max render the normal map correctly in a render, the exporter will not recognise that and will not export the path to the normal map.

And here it is exported with the above materials in the editor and you can see the normal map working off the spec reflection of the air filter as well as the transparent glass

This technique is also very useful for Rotor Blur Textures which means that you won't be constantly seeing a massive black plane above your chopper when they are in view



Part 4. Switching Between Different Multi/Sub-Object Materials

Now one of the big advantages with MSO Materials is the ability to quickly switch texture sets between objects without having to change or re-apply loads of individual textures to do the same thing.

When your working with multiple objects of pretty much the same thing, like I am here with this Zhi-9/Panther Chopper Series, its REALLY important to have all the Material IDs match each other between different Multi/Sub-Object Materials. For example if you compare my Zhi-9 and my French Panther Multi/Sub Object Materials, you can see that both have their 1p textures on MatID 1, 3p on 2, 3p Alpha on 3, Glass on 4, MRB on 5, TRB on 6 and Gauges on 7, with the French Panther having a few extra materials for 8 and 9 for its extra bits:

This dose require a bit of forward planning with your materials but isn't hard to do but this essentially means that I can easily interchange the materials between these objects which makes life in the long run, a hell of a lot easier, as I'll now demonstrate with the Rotors.

Here are the Zhi-9's rotors, as you can tell by the Green Rotor Head, its using the Zhi-9 textures, but more imporantly is what you can't see and what is a massive common mistake, like the tail rotor looks excatly the same for both the Zhi-9 and French Panther, which ever texture its using, and the common mistake is for someone to forget to apply the correct material to them, meaning that a load of massive texture sheets are being needlessly loaded ingame, costing the client memory and no one will ever notice (other than perhaps the poor FPS and the CTDs from players running out of memory etc) unless they look deep into the code.

Working with MSO Materials while it is still possible to make this mistake, is harder to because the process, once the MSO Materials and MatIDs are all setup, is so simple its hard to make a mistake.

So basically now I'm going to clone the Zhi-9's rotors, showing you my method of doing this by first selecting both of the rotors like so:

Then going to Tools>Rename Objects:

Uncheck the default "Base Name", check suffix and then in its box put in "--" without the quotes:

This then gives us a barrier between the numbering system max likes to do when cloning its objects so if you now clone them instead of it renaming "lod0" to something like "lod05", it will simply be "lod0--01" like so, also don't forget when you do your copy, do them as a copy:

Then keeping your selection, going back into the rename objects window, check the box for "Remove Last * Digits" and set the number at 4, which will then remove the "--01" etc from the end of your clones leaving you with the following:

Then its just a matter of renaming the roots to the correct export name like so:

And then repairing the Zhi-9 Rotor naming by just removing the last 2 digits off of them like so:

Then hiding the Zhi-9 Rotors we are left with our new Panther Rotors, but they still are using the Zhi-9 textures with the green rotor head etc:

To fix this its a matter of simply selecting the meshes for each lod:

And then applying the French Panthers Multi/Sub-Object Material to the selected objects:

And walla the correct textures are applied without any fuss

This becomes a much bigger factor however when you start working with LODs and other things but generally, is a very useful thing and something you should try and use with MSO Materials as it can save you loads of time, as well as making it harder to make mistakes



Part 5. Adding/Removing Sub Materials

Now that I need to do the Zhi-9WA, and it pretty much uses all the same textures as the Zhi-9, other than it has one extra "Zhi-9WA Parts" texture with all the extra/modified bits on it like the French Panther has for all its extra parts, I need to add that to the Zhi-9 Multi/Sub-Object Material since there is no point in making a clone of it when they all use the same textures, except one extra one which can be left off the normal Zhi-9 by just not assigning that material ID to any of the faces.

Now since this material only has 7 slots currently and all of them are in use, I need to add another one for the Z-9WA parts material. But before I do that I'll go over all the options of managing your sub materials.

Above all your sub materials you've got 3 buttons. "Set Number", "Add" and "Delete"

First going to go into Add, which if you push it, will add another material to the very bottom of the list like so, note the new material 8 at the bottom:

Now the Delete button also dose pretty much what it says on the tin, with it deleting w/e material you have selected. I've added another material (9) below 8 but I want to delete 8. To do this you need to select it, by clicking on the sphere icon with the texture plastered over it if it has a texture set to it, and when its selected it will have a little white box around it like so, once selected, hit delete and it will delete it, leaving 9 and the rest of them in this in this case:

Set Number allows you to set how many materials you want in your multi/sub-object material, quite simply if you press it, then you can set how many materials you want, for this example I'm going to say 20, then it will add blank materials on top of the ones you already have to the bottom of the list like so (btw I deleted mat 9 from above before I added the new ones with set number):


I only want 8 materials however so now if I say set number 8, from the 20, it will delete the last 12 on the list. Be careful however as if you set the number too low, it will delete materials you may want to keep.


And now I'm just going to make my Z-9WA Parts mat in this new mat slot and apply it to the Zhi-9WA


As you can see you can set your Multi/Sub-Object Material to have as many sub materials as you like, effectively meaning you can have unlimited amount of materials where before, you only had 24 slots to work with



Part 6. Cloning Multi/Sub-Object Materials

This is what I would have done to make the French Panthers Multi/Sub-Object Material, with cloning the Zhi-9 one I had already done but I made it from scratch for the purpose of making the previous parts of this tutorials. However now I've done that, for the Brazilian HM-1 Pantera I'm going to clone the French Panther's Multi/Sub-Object Material which should speed things up

To do this, all you need to do is drag your material you want to copy into an empty slot like so, then rename it, and then rename all its MatIDs and then changing all the texture paths that need changing:


Then its simply just a matter of applying this material to the model, as per Part 2:



Part 7. Viewing _Woodland & other Texture Sets

Once you've setup your main Multi/Sub-Object Materials for your object, you can then easily clone that as per Part 6 to make different texture setups for your object for the purpose of viewing them in 3DsMax easily. For this I'm going to setup the Brazilian Panther with a "_woodland" texture set by cloning its MSO Material and then just changing its textures to use any of the new _woodland textures, which in this case are just for the 3p materials and the Brazilian Parts mat, like so:


Then its just a simple matter of applying your new material to your old object like so

NOTE: This should only be used for viewing a texture. Before exporting make 100% sure that you switch back to the normal texture otherwise if you export with the _woodland texture then your loosing the ability to view the normal texture for this object, as otherwise to load a woodland texture it would be looking for, in this case a "br_the_panther_c_woodland_woodland.dds" texture when loading a _woodland map. Its also very important to make sure every component of your object is using the correct material before export, otherwise, if a wheel for example is using the _woodland texture, on a desert map you would be loading the _woodland sheets it uses where they would not be loaded on the map, wasting memory and chances are no one will be able to see a visual difference, but would be costing loads of extra memory etc. So if you use this, use it with care and what what you do.



Part 8. Using Multi/Sub-Object Mats for Collision Mats

Using Multi/Sub-Object Materials for Collision Materials that you apply to your col mesh uses all the same basic principles you should have now learnt from above, and all you need to do is setup a MSO mat with all the col mats you want in it, apply it to your col mesh and setup all your materials though MatIDs, like so:


Rhino is offline
Last edited by Rhino; 2021-06-02 at 00:32..
Reply With Quote
Old 2013-01-18, 07:10   #2
Rhino
Retired PR Developer
Supporting Member

Rhino's Avatar
Default Re: [Export Tutorial] Working with Multi/Sub-Object Materials

Tips:

Wreck / Dummy TIS Textures in Standard Mats
Quote:
Originally Posted by [R-DEV]Rhino View Post
One small quick tip of using the Standard Material in or outside an MSO Material, is if you need to add a wreck or dummy tis texture to what you would normally put into the "Shadow" slot of a normal BF2 BundledMesh Material, you can also add it to a Standard Material by putting it Self-Illumination Slot of a Standard Material and from what I can tell so far (haven't tested it) it will export it like you put the texture in the shadow slot



Exported Code inside the material, which is identical to what it would be from a BF2 BundledMesh material:
Code:
  Shader: BundledMesh.fx
  Technique: Alpha
  Type: 1
   Texture: objects/common/supply/pr_supply_crate/textures/supplycrate03_c.dds
   Texture: Common\Textures\SpecularLUT_pow36.dds
   Texture: objects/common/textures/dummyblack_tis.dds
Rhino is offline
Last edited by [R-DEV]Rhino; 2013-02-13 at 14:38..
Reply With Quote
Old 2013-02-01, 13:33   #3
Rhino
Retired PR Developer
Supporting Member

Rhino's Avatar
Default Re: [Export Tutorial] Working with Multi/Sub-Object Materials

Updated OP with new Part 8. "Using Multi/Sub-Object Mats for Collision Mats"

Rhino is offline Reply With Quote
Old 2013-02-13, 14:37   #4
Rhino
Retired PR Developer
Supporting Member

Rhino's Avatar
Default Re: [Export Tutorial] Working with Multi/Sub-Object Materials

One small quick tip of using the Standard Material in or outside an MSO Material, is if you need to add a wreck or dummy tis texture to what you would normally put into the "Shadow" slot of a normal BF2 BundledMesh Material, you can also add it to a Standard Material by putting it Self-Illumination Slot of a Standard Material and from what I can tell so far (haven't tested it) it will export it like you put the texture in the shadow slot



Exported Code inside the material, which is identical to what it would be from a BF2 BundledMesh material:
Code:
  Shader: BundledMesh.fx
  Technique: Alpha
  Type: 1
   Texture: objects/common/supply/pr_supply_crate/textures/supplycrate03_c.dds
   Texture: Common\Textures\SpecularLUT_pow36.dds
   Texture: objects/common/textures/dummyblack_tis.dds

Rhino is offline Reply With Quote
Reply


Tags
export, materials, multi or subobject, tutorial, working

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 00:32.