My First Weapon - Material/Proxy Setup

Overview

Continuing on from Part 3 of this tutorial, this article will guide you through the basics for setting up materials for the render mesh and proxy, as well as proxy mesh creation.

Material Setup

It's about time we did something about this "Replace Me" texture! In order to fix this we need to create a material for our weapon.

Material Creation

Inside Max, press M on your keyboard to open the Material Editor, just like in Sandbox. It will look something like by default.

Fill in the name of material "newgun" and then click on the Standard button.

A new dialog will open, select Multi/Sub-Object from the list. This will create a new multi-material setup.

If you chose to "Keep old material as sub-material" when prompted, your material should now look something like .

We know (for now) that we're going to want 2 sub-materials, one for the render mesh and one for the proxy. Click on , set it to 2 and click OK.

The other 8 sub-materials should now disappear and you're just left with two: "newgun (Standard)" and "None".

Material Assignment

With the weapon selected in the viewport, click on the Assign Material To Selection button:

You should notice the weapon now go grey. This is because the color is grey in the material (you can see the color to the right of the material name: newgun ( Standard ).

Lets change that to something nicer by clicking on the grey box and change it to blue. The weapon should update in the viewport as you change the color. Click OK when you're done:

Material ID Setup

If you have a look at the weapon now, you may notice something strange happening. Some faces of the model are black!

This is because when the object is created, the faces are given incremented ID numbers. So when we apply a multi-material with 2 sub-materials, faces 1, 3, 5, 7, etc receive the first material ID and faces 2, 4, 6, 8, etc receive the second material ID.

It's a simple fix however! All we need to do is go into Element Mode (shortcut key: 5), drag the mouse across the object to select every Element and then set the Set ID value down to '1':

Now all faces are using the first (1) sub-material which is our blue colored material which we're going to use for our render mesh.

Material Shader

Because we created this material from the default settings, we need to adjust it slightly. Click on the newgun ( Standard ) button in the Material Editor, this will open up that sub-material.

Let's rename it to something a bit more specific about our weapon, such as metal. Lastly we need to change the Shader type, so click on the dropdown list which says "Blinn" and change it to Crytek Shader.

Proxy Setup

For our third person weapon we need a proxy so that it works correctly in the physical world, when dropped, when players collide with it, etc.

Now that we're making full use of our first material, lets start getting ready to setup our second material which will be for our proxy.

First create a new box shape, something big enough to encompass the entire weapon, try 100cm(l) x 6cm(w) x 8cm(h). Now center it in the scene to 0,0,0 coordinates:

Obviously it doesn't quite fit the weapon so let's convert it to an Editable Poly and move the faces so that it covers the weapon:

Now we can't see the weapon any longer but that's okay, we're going to setup our Proxy material to have some opacity to it which will make it easier to work with.

Proxy Material Setup

Open up the Material Editor again and click on the second sub-material and select Standard so that it's like our #1 render mesh sub-material:

This will create a new material which we need to modify slightly in order for it to work as our Proxy material:

  1. Change the name of the material to "Proxy" (not a requirement, can be called anything).
  2. Change the Shader type to Crytek Shader.
  3. Change the ambient or diffuse (they're linked) color to red (not a requirement, can be any color).
  4. Check the Opacity checkbox and set the value to '15' (not a requirement, but helps see the weapon inside the proxy).
  5. When you do step 2 this option will appear. Check the Physicalize checkbox and select Physical Proxy (NoDraw) from the dropdown list.

When you're done with that we want to go up one level in our material tree. We're currently in our #2 sub-material, we want to go up one level to our "newgun" material, consider that the "parent" of the two children materials.

Now with our Proxy mesh still selected, assign the newgun material to it. You'll notice the same issue with the random material assignment is there:

As earlier, go ahead and select the entire object in Element Mode and then change the Set ID value to '2', which is our Proxy sub-material:

Proxy Assignment

Now that our Proxy mesh and material is all setup correctly we now simply have to setup the hierarchy.

If you still have it open, for now you can close the Material Editor and come out of Element Mode by selecting the button again (it's good practice to deselect all the faces/elements before doing so).

Rename the Proxy to "$proxy_newgun_tp" by double-clicking on it in the left pane list. This isn't a requirement but it can help isolate issues during asset building if there's a problem with the proxy, you'll know by name which proxy has a fault.

To set the hierarchy, activate the Select and Link function from the toolbar. Left click and drag the Proxy node onto the newgun_tp node and it will then become a child node of the newgun_tp parent node.

Re-Export

Now that we've made all these changes since our last export in the first article, go ahead and save/re-export the weapon.

This will update the existing newgun_tp.cgf file with new information about the proxy and materials.