This article relates to the game "Half-Life: Alyx". Click here for more information.
This article relates to the workshop tools for "Half-Life: Alyx". Click here for more information.
This article's documentation is for Source 2. Click here for more information.

Half-Life: Alyx Workshop Tools/Modeling/Material Groups

From Valve Developer Community
Jump to navigation Jump to search

This tutorial demonstrates creating a simple model and then adding two material groups. In many locations material groups are referred to as Skins.

Add a render mesh to the model

For this example we are going to create 3 boxes. However, this can easily be substituted with one or more 'RenderMeshFile' nodes which reference externally authored meshes.

Click the Add node button and select the 'RenderPrimitiveBox' node type.

Material Groups-131007422.png

Name this box 'Red'.

Material Groups-131007425.png

When prompted for a bone, simply select 'none'.

Set the Origin of the box to < 20, 0, 5 > using the Node Editor.

Material Groups-131007426.png

Change the material of the box to 'primary_red' by clicking on the Browse (magnifying glass) button under the Material property of the box in the Node Editor

This will open an asset browser, type 'primary red' in the Name Filter, then select the 'primary_red.vmat' and click the Accept button

Material Groups-131007427.png

We now have a single render mesh using a single material. Next we will add two more boxes using two different materials, as this will help better illustrate the material group functionality.

Add additional render meshes using different materials

Create a copy of the 'Red' mesh by right clicking on it and selecting Duplicate.

Material Groups-131007429.png

Rename the new mesh to 'Green' by right clicking on it and selecting Rename.

Material Groups-131007431.png

Change the material of this box to be 'primary_green' by again using Browse button under the Material property in the Node Editor.

Material Groups-131007432.png

Using the Node Editor, set the Origin of this box to < 0, 0, 5 >.

Material Groups-131007434.png

Repeat the above steps to create a new box, this time name the box 'Blue', assign it the 'primary_blue' material, and set its origin to < -20, 0, 5 >.

Material Groups-131007436.png

Click the 'needs compiling' to save and compile your model.

Material Groups-131007437.png

You should now a have a model with a red, green and blue box:

Material Groups-131007438.png

Create a material group

Click the Add node button and select the 'MaterialGroup' node type.

Material Groups-131007439.png

Name this material group 'Reflectivity'.

Material Groups-131007442.png

The material group should now be selected, and the node editor should displaying a list of the 3 materials currently in use in the model.

Each of the original materials in the model has replacement material, currently all of the replacement materials are the same as the original materials.

Material Groups-131007444.png

Pick replacement materials

For each of the original material we want to pick a material to replace it with

Click on the Browse button under the entry for original material 'primary_red.vmat' and select the material 'refelectivity_10.vmat' from the asset browser to replace it

Material Groups-131007447.png

Note that you should see the thumbnail and the path of the replacement material appear under the name of the original material in the Node Editor. However there will be no change in the viewport.

Repeat the process for the 'primary_green.vmat' and 'primary_blue.vmat' replacing them with 'reflectivity_50.vmat' and 'refelectivity_90.vmat'.

Material Groups-131007455.png

Create an additional material group

Create another material group by right clicking on the MaterialGroupList in the Document Outliner and selecting the Add MaterialGroup command from the context menu.

Material Groups-131007456.png

Give this material group a name. For the example we are going select tile materials, so we named the material group 'Tile'.

Material Groups-131007458.png

Use the Node Editor to select different replacement materials for each of the 3 original materials.

The materials selected here are game specific, so they may not be available depending on which game you are running. Simply select any three materials that are different from the ones previously selected for the 'Reflectivity' material group

Material Groups-131007460.png

Preview the material groups

Click 'Needs Compiling' to compile the model.

Material Groups-131007437.png

You should now see the 'Default' as well as the 'Reflectivity' and 'Tile' material groups listed in the Preview Outliner

Material Groups-131007461.png

Double click on the 'Reflectivity' material group in the Preview Outliner to preview it in the 3D viewport.

Material Groups-131007463.png

Double click on the 'Tile' material group in the Preview Outliner to preview it in the 3D viewport.

Material Groups-131007465.png

Note, you can also change the material group being previewed from material group drop-down in the toolbar.

Material Groups-131007466.png

Place the model in Hammer and select a skin

You can now place the model in Hammer a select different skins

Open Hammer from the asset browser.

Material Groups-131007482.png

Create a new document by selecting File > New.

Material Groups-131007483.png

If you have Hammer in the default configuration, the lower right panel should contain an asset browser view.

Select the models tab and type in the name you gave the model into the filter.

Material Groups-131007490.png

Once you have located your model, you can drag and drop from the asset browser into the 3D viewport to place an instance.

Material Groups-131007492.png

With the new instance of the model selected, you can now expand the Render Properties in the Object Properties editor and select one of the material groups from the Skin drop-down.

Material Groups-131007493.png

The selected skin should be visible in the hammer viewport

Material Groups-131007495.png