UE4 Intro To Materials - Page 7


Index



Metallic Mask


  1. In our Metallic and Roughness, we don’t have to use a single number. We can use a gray scale mask so that each pixel can project number between 0 (black) and 1 (white). Lets look at masks in materials on metallic. Open the Content Browser and select the Textures folder:
Create new sprite with button

  1. Press the Import button and go to the folder Files Neede For Walkthrough and select CircleMask_D.tga.
Create new sprite with button

  1. Rename the file and add T_ in front of the new file to end up with T_CircleMask_D. Go to the Materials Folder and create a new Material called M_Metallic.
Create new sprite with button

  1. Open the Material and add a Texture Sample node and selected the new texture we just created T_CircleMask_D.
Create new sprite with button

  1. Add a Constant 3 node and select a strong color. I picked a very bright green.
Create new sprite with button

  1. Lets add these two nodes together. Put an Add node and hook the texture up with the Constant 3. The addition will keep the white white, but make the black the green that was created. Connect the output of the addition mode to the Base Color node and look at the result on the sphere:
Create new sprite with button

  1. Add a constant node set to 0 and plug it into the Roughness pin. Connect the Texture Sample to the Metalic node. Now every where it is white it will be reflective and every where it is black it will not. You can see the result on the sphere.
Create new sprite with button

  1. Go into the game and move the camnera to Room 3. Change to Place mode and select the Basic menu items. Drag a Cube into the game window. Name the cube Reflecting Cube and move it to the Room 3 folder.
Create new sprite with button

  1. Assign the material we just created. Go to World Outliner | Lighting | Sphere Reflection Capture volume and make sure the Influence Radius is set to 2000 and center it on the level.
Create new sprite with button

  1. You might find some black reflections. Go to Skylight and change Mobility to Static
Create new sprite with button

  1. Run the game and go around the cube to look at the reflections.
Create new sprite with button

  1. Now what if we wanted the opposite? What if want the green dot to be reflective and the rest of the surface be matte? We could go to photoshop and invert the image, but we can do this in the material. Open the M_Metallic and add a OneMinus node:
Create new sprite with button

  1. Connect the output of the Texture Sample to the 1-x node and put that output in Metallic. Select the cube to preview and now you can see that it only reflects inside the green dots.
Create new sprite with button

  1. To see what the 1-X node does, right click and select Start Previewing Node. See how it just inverts the image:
Create new sprite with button

  1. Go into the game and play it and look at the cube. The metallic effect is now reversed:
Create new sprite with button

Opacity Mask


  1. We have only dealt with opaque materials. We can also have holes cut in the materials with transulcency. There are two types of approaches. The faster in terms of performance is an opacity mask. This means that a pixel can be completely transparent. But there are no partial transparencies. The pixel is opaque or is clear. Lets take a look. Create a new Material in the Materials folder and call it M_OpacityMask.
Create new sprite with button

  1. Double click the new Material and add a Texture Sample node. Add the T_CircleMask_D texture and you should see:
Create new sprite with button
  1. Connect the output of the Texture Sample node and connect it to the Opacity Mask mode. This does nothing and it is grayed out. We will fix this shortly.
Create new sprite with button

  1. Add a Constant 3 vector and pick a nice bright color. I picked orange:
Create new sprite with button

  1. Now the Opacity mask is supposed to be clear where there is an alpha (black pixel) and opaque where white. Right now we just have a solid Orange surface.
Create new sprite with button

  1. There are different blend modes available in the shaders. To read more about it go to this section in their manual. Now select the Blend Mode drop down menu and pick Masked:
Create new sprite with button

  1. Now switch to a cube and you will see that the black areas of the map cut into the cube.
Create new sprite with button

  1. Now go to the game and press the alt button and drag another copy of the cube. Assign the M_OpacityMastk material.
Create new sprite with button

</div> </div>


  1. You might have noticed that there is no inside of the box. The entire inside is clear. Why is that? In 3-D modelling the light is only reflected where normals are placed. Typically in closed surfaces like cubes there are only normals on one side. Double click the cube static mesh (in the World Outliner) and click on Normals. You should see green lines pointing outwards:
Create new sprite with button

  1. In the Details panel of your Material there is a Two Sided radio button. This allows you to let the material know that you want to project light on both sides of each face of the object. Look how much better it looks!
Create new sprite with button

  1. Check out the box in game. Now it looks more like we expect it to. Next up lets make a mask with semi translucent surfaces.
Create new sprite with button



<- Previous   Home    Continue ->