UE4 Intro To Materials - Page 5


Index



Roughness and Metallic Constants


  1. Double click the Material to go back to the editor and right click in the menu and type Constant or press the 1 key on the keyboard and left click:
Create new sprite with button

  1. We will first adjust the roughness of the surface. This affects the reflectivity of the surface. 0 roughness is not rough and the surface is very reflective (mirror, metal) and 1 is completely rough and light gets scattered and diffused. For more information go to UE4’s manual
Create new sprite with button

  1. Connect this single float value vector node to the Roughness pin in the main node:
Create new sprite with button

  1. With that constant selected adjust the roughness to 1 which makes it completely non reflective and very diffuse:
Create new sprite with button

  1. Repeat this and add another Vector node and connect it to Metallic. We will leave the default value of 0 as we want it to have no reflectivity (1 would be maximum reflectivity).
Create new sprite with button

  1. Apply this material and Save it. Go into the game and run it and we have completed our first material in UE4!
Create new sprite with button

Material Instance Diffuse


  1. Materials can be pretty expensive in Unreal. We can’t have too many of them per level. There is a technique where we can get a lot of variety but not use completely different Materials. If you can use the same Material but different values we can use the same Structural Model. What we do is we change the nodes to editable values and we allow instances to be made differently. Lets rebuild the carpet Material to allow for instances as we want multiple different types of carpets and shapes in the game.

    Go to the Materials folder and press Add New. Add another Material and name it M_OfficeCarpet_Master. The _Master indicates that this material is going to be used in instances which I will show you shortly.
Create new sprite with button

  1. Lets add our diffuse color map. But this time we want to expose it as a parameter. This can be done in two ways. First, right click and select Texture Sample. On this node right click and select Convert to Parameter:
Create new sprite with button

  1. Or you can do it in one step by right clicking and selecting Texture Sample Parameter 2D:
Create new sprite with button

  1. Name this node Diffuse Texture Map and in the Details panel add a new Group and call it Diffuse. Select the T_OfficeCarpet_BC texture:
Create new sprite with button

  1. Now do the same thing by adding a Constant Vector 3. Right click and and select Convert to Parameter (or you could just add a Vector Parameter):
Create new sprite with button

  1. Call this parameter Diffuse Color and add the Diffuse Group in the Details panel:
Create new sprite with button

  1. Double click the Diffuse Color and pick the default color for your carpet (you can select white or 1,1,1 if you want to keep the original and not multiply). Add a Multiply node and connect the pins so that the Texture is Multiplied by the Color Tint and hooked into the Base Color node. Press the Apply button on the top menu.
Create new sprite with button

  1. Before we finish the rest of this material lets see why this is different. Lets move into the Materials folder and right click on the M_OfficeCarpet_Master and select Create Material Instance:
Create new sprite with button

  1. Name it MI_OfficeCarpet_Blue. Now repeat this by right clicking on the M_OfficeCarpet_Master and select Create Material Instance and name this one MI_OfficeCarpet_Red:
Create new sprite with button

  1. Double click MI_OfficeCarpet_Blue and take a look at the screen. The Nodes are gone and you just see a giant material with a Details panel to the right. I just see the parameters that I have exposed organized into the groups we created:
Create new sprite with button

  1. If we want to edit anything we need to click the radio box next to the parameter we want to change. Lets change the diffuse color so select the box and double click the color bar to get the color picker. Select a shade of blue:
Create new sprite with button

  1. Repeat the same for MI_OfficeCarpet_Red but select a red color:
Create new sprite with button
  1. Now would be a good time to go back to the Content Browser in the Materials folder and select Save All. This will save all of our work. Scroll the camera over to Room 2 in the level.
Create new sprite with button

  1. OK, now lets add three carpets to the room. Drag and drop Import | SM_Carpet_2,Import | SM_Carpet_3 and Import | SM_Carpet_4 in the Static Meshes folder and select the appropriate import settings:
Create new sprite with button

  1. Drag the three carpets in the room. Position them into ground so they stick out the amount you would like.
Create new sprite with button

  1. Lets assign the materials. Drag and drop the three material instances on the three carpets in any order you like.
Create new sprite with button

  1. Run the game and now you have three material instances running with the same Master material. Now please be aware that any changes you make to the master will be reflected in the Instances. These are children to the Master material. If you like you can even make instances of instances but the parent child relationship with the master will still hold.
Create new sprite with button



<- Previous   Home    Continue ->