After covering the basics of the Material Editor, textures vs materials and importing your custom textures into UDK, you are now ready to create your first material. Following tutorial will guide you through to creating your first material by using the imported textures from this previous tutorial.
The Tutorial Covers:
- Creating New Material
- Using Imported Textures (Diffuse, Specular and Normal maps)
- Set up textures and create your first material
- Saving Your Material and Package
Creating New Material
Open up Content Browser.
Let's create a new material in already existing package. The package we started in previous tutorial when we imported all of our textures into it.
Select the Package: In Content Browser and in Packages Panel, find and select the package. Selecting this ahead of time will make the Material creation a bit faster.
In Content Browser, Click on New button:
Use drop down menu to select Material:
In Content Browser preview window panel, in the gray area between icons, Right Click and choose New Material.
New option box will pop up. The Package will be set for you because we selected it in the Package Panel first.
Setting Up Package/Group/Name:
Package: the name of the package you are saving the new material into.
The package should be already set because we selected it in previous step. If you don't have it set then use the drop down menu to select which package you want to save your materials into.
If you do not have an existing package, then simply enter a new name of the package you want to save the Material into. Defining a new package name will create a .UPK package file.
Grouping: is a way of organizing your materials. I will create a new Group called Materials.
Name: name of the material. I use MAT_ prefix to name the materials. Example: MAT_BrickWall
Factory option is what you are currently trying to create. You should see Material set in this box.
Click OK. New material will be created and Material Editor will open.
Back in the Content Browser, you will see a new Group created called Materials and in the Preview Window Panel you will see a blank new material with the assigned name.
Now, anytime you need to access the Material Editor for that material, simply double click on the Material from the Content Browser.
Let's set up a material so you can use it in the level. Open the Material Editor (if it isn't opened already). This material is a blank slate. We need to have our diffuse, specular and normal map in the working area. For this, we need a TextureSample expression.
There are two methods of using a texture sample.
Texture Sample - First Method
Step 1: Go to Content Browser and find the package where you imported your textures are and navigate into that group.
Step 2: Select the diffuse map:
Step 3: Back in Material Editor, in the Main Expression Graph Area, Hold T and Left Mouse Click to insert a Texture Sample node. The texture that you had selected in the Content Browser will be used in the TextureSample.
- Hold T + Left Mouse Click = Insert TextureSample
You will see the TextureSample display a preview texture within the node. In the properties menu of the TextureSample, you'll see the Texture slot being used.
Texture Sample - Second Method
Step 1: In Material Editor go to Material Expressions Panel and type in Texture. Left Click and Drag the TextureSample from the Material Expression to the working area:
Another way is to Right Click to access Material Expression Menu and choose Texture --> Texture Sample:
Click on Image for Larger View
Step 2: In Material Editor, select the Texture Sample Node and in the Properties Menu, we need to look for texture we want to plug into the Texture slot. This is if you didn't have the texture selected first:
Click on Image for Larger View
Step 3: Go to Content Browser, filter by Textures and select the diffuse map:
Step 4: Back in Material Editor, Left Click on the green arrow 'Use selected object in the Content Browser' to use the selected texture from the Content Browser:
Texture is being used in the Texture Sample:
Select and Delete
If you need to delete any material expressions from the working area, here is how.
Left Click on the expressions to select it and delete by hitting Delete key.
- Left Mouse = Select material expression (node)
- Delete = Removes selected material node
You can also Marquee Select All of them by Ctrl + Alt and Left Mouse Click and Drag, then hit Delete.
- Ctrl + Alt and Left Mouse Click + Drag = Marquee Selection
Diffuse, Specular and Normal Map
We have our diffuse as a TextureSample. Insert the normal and the specular textures as TextureSamples using two methods above.
I prefer selecting the Texture first in the Content Browser then back in Material Editor, press T + Left Click in the working area to place a TextureSample expression with the selected Texture assigned to it.
Connecting and Working with Expressions
We have all the material expressions inserted into the working area and now we need to organize them and connect them to Main Material.
- Hold Ctrl + Left Mouse Click + Drag = Move/Reposition Expressions (nodes)
- Hold Ctrl + Left Mouse Click = Add to a Selection or Remove From a Selection
- Left Click and Hold + Drag from the output box (black box) and drag the wire to any expression's input. This will connect the Material Expression node to another node.
- Hold Alt and Left Click on the input/output, this will break the connection.
In the Preview Window you can see the changes taking place as you connect expressions.
We want to connect Diffuse TextureSample to Diffuse input of the Main Material Preview.
Connect all three texture into their respective input slots of the Main PreviewMaterial:
- Diffuse texture to Diffuse input slot.
- Specular texture to Specular input slot.
- Normal texture to Normal input slot.
Save Your Material and Package
To use this material in your level or to see any changes of this material already in the environment you need to save it. Click on the Check Icon 'Apply Changes to Original Material and its Use in the World'.
You can now use this material on your geometry or Static Meshes in the level.
This is the most basic set up for a custom material using imported textures.