UE4 Intro To Materials - Page 14


Index



  1. Animation

Part 7 - A Practical Master Material

Now lets make a Material that is flexible to handle many different situations and can be used as a Material instance for most scenarios. This is a Material that you can keep using for the rest of the course. It can be expanded on to include even more nodes on your own.


A Practical Master Material


  1. Create a new Material and call it M_Base_Master. Add a Texture Sample Parameter 2D node to it so we can customize the texture. Call this node Base Texture.
Create new sprite with button

  1. Assign T_CobbleStone_Rough_D to the texture and change its group from None to Diffuse
Create new sprite with button

  1. Add a Vector Parameter node and pick a base color, Name it Base Color. Set the Group to Diffuse. Feed the color and texture into a Multiply node. Add a Static Switch Parameter node:
Create new sprite with button

  1. Name the Switch Use Texture?. Change the group to Diffuse. Feed the output of the color to the False input the the output of the Multiply into the True input. Feed the switch output into the Base Color in the main node.
Create new sprite with button

  1. Keep the default for the switch at true but you can see what this node does when we switch between true and false.
Create new sprite with button

  1. Add a comment to best explain the node. This allows us to use either a solid color or a texture or a texture multiplied by a color. Remember if you multiply by white it leaves the texture alone (any number times 1 stays the same). Lets change the default color to white (1, 1, 1) as well:
Create new sprite with button

  1. Lets give the user the ability to customize UV’s and not just be stuck with the default 1,1 setting. Add another Static Switch Parameter and call it Adjust UV Coordinates? and change the Group in the Details panel to UV. Also, drop a Texture Coordionate Node and leave its default 1,1 setting:
Create new sprite with button

  1. Add two Scalar Parameter nodes called UScalar and VScalar. Set their group to UV. Set their defaults both to 1. Combine them in an Append node:
Create new sprite with button

  1. Hook the output of the Texture Coordinate node to the False pin of the switch. Add a Multiply node sending the output of the Append into the B input and the output of the Texture Coordinate to the A output. Send the output of the Multiply node to the True input of the Switch Parameter node. Send the output of the Switch to the UVs input on the texture node:
Create new sprite with button

  1. Add a comment to the UV section and clean up your graph which should look like:
Create new sprite with button

  1. Lets create the nodes for the Metallic input. Add a Static Switch Parameter and call it Use Metallic Texture? and add the group Metallic. Add a Scalar Parameter node call it Metallic Scalar and add it to the group Metallic. Send the output of this node to the False pin in the Switch. Add a Texture Sample Parameter 2D, call it Metallic Mask and assign a base texture to it (I picked one of my clouds). Assign it to Group Metallic. Set the default mask to what you think the most likely setting will be (which could be false). Connect the output of the Switch to the Metallic pin:
Create new sprite with button

  1. Add a comment then copy and paste the entire group and place it below as we will use this for roughness which will be similar:
Create new sprite with button

  1. Change the names altering Metallic to Roughness. Change all the groups to Roughness. Connect the output to the Roughness input.
Create new sprite with button

  1. You node graph should look like:
Create new sprite with button

  1. The Emissive will be a bit different. Add another Static Switch Parameter node, call it Use Emissive Mask?. Add a Texture Sample Parameter 2D node called Emissive Mask, assign the cloud texture and add a Scalar Parameter node set to 3 called Emissive Scalar. Set all of their groups to Emissive.
Create new sprite with button

  1. Add a Vector Parameter node called Emissive Color and set it group to Emissive. Add a Multiply node. Add a Scalar Parameter and call it Emissive Strength defaulting to 3. Set its group to Emissive:
Create new sprite with button

  1. Connect the output of the Emissive Mask to the True pin on the Use Emissive Mask? switch. Connect a 0 Constant node into the False pin of the Emissive Switch. Send the output of the switch to a new Multiply node.
Create new sprite with button

  1. Multiply the output of the Multiply node to the ouput of the Switch node. Send the output of this new Multiply to the Emissive Color pin:
Create new sprite with button

  1. Add a comment and Your graph should look like:
Create new sprite with button

  1. Now lets get to the trickiest part of our graph the Material normal. Add a Texture Sample Parameter 2D and call it Normal Texture and assign it to the Normal Group. In my case UE4 automatically picked the same filename using the _N suffix. Add a Static Switch Parameter and call it Use Normal Map? and assign it to the Normal group. Now add a Constant Vector 3 to the node tree and assign it 0,0,1 (or blue). This is the orthoganal normal for a plane and will add no bumps or lighting changes. Send this into the False input of the Switch. Send the output of the Normal Texture to the True pin of the Switch.
Create new sprite with button

  1. Add a comment and connect the output to the Normal pin and it should look like:
Create new sprite with button

  1. And the entire node graph should look like this. Press the Apply button. On the next page we will go into the game and give this a go!
Create new sprite with button



<- Previous   Home    Continue ->