官术网_书友最值得收藏!

How to do it...

We are going to create our first complex material in Unreal Engine 4! Complex is a word used lightly in this context, as it doesn't have anything to do with the difficulty of creating the asset itself. It's more of a statement: what we are going to be creating from now on are examples that could just as well be real assets in a game studio. 

With that said, the first stop in this journey is going to be the laying down of the foundations of the material. We are going to operate on the material graph by organizing and thinking about how things should be put together. Make sure you have the 03_01_ComplexShader_Start scene open, or any other of your own that you choose, and let's start taking a look at that:

  1. Let's start by creating a new material, so that we can change the appearance of the main model to something more exciting. I've created a new asset, named M_ToyTank, which will be in the following folder: Content / UE4ShadersAndEffects / Assets / Chapter03. You could use that or also create your own!
  2. As the tank has different small parts (the tracks, the barrel, the main body, and so on), chances are that we are going to want to treat those areas differently. To do so, we will need to create masks that fit the selected parts that we want to shade— but before that happens, we need to take a look at how the UVs are laid out. Select SM_ToyTank in the content browser, open the asset editor, and click on the UV button | UV Channel 0. This is what it should look like:
You can export the model from the game engine and alter the UVs in your DCC until you are happy with them. To do this, right-click on the asset within the content browser and select Asset Actions | Export.
  1. There's a small mask that you can use for this example, named T_TankMasks, which you'll be able to find in the same folder as the tank. It's basically an RGB image, which you can see in the following screenshot. Drag that resource into the newly created material, as we'll be using it soon:
  1. Also within the material graph, create two Constant3 nodes, and select whichever color you want under their color selection wheel. Make sure they are different from one another, though!
  2. Next, create a Lerp node. That strange word is short for linear interpolation, and it lets us blend between different assets according to the masks that we connect to the Alpha pin. Connect the red channel of the T_TankMasks asset to that pin of the new node. 
  3. Connect each of the Constant3 vectors to the A and B pins of the Lerp node. 
  1. Create another Lerp node and a different Constant3 vector. Connect the blue channel of our mask into the Alpha of the new Lerp and the new Constant3 vector into the B pin. Finally, connect the output of the previous Lerp into the A slot. Also, make sure to apply the material to the tank in the main scene! The resulting material graph should look something like this:

At this stage, we've managed to differentiate certain areas of the model in our material thanks to using masks. We now need to expand this concept to the Metallic and the Roughness attributes of the material, just so we can also control those independently.

  1. Copy all of the previously created nodes and paste them twice—we'll need one copy to connect to the roughness slot and a different one that will drive the Metallic attribute. 
  1. Replace the Constant3 nodes of the new copies for simple Constant nodes. We don't need an RGB value to specify the Metalness and Roughness properties, so let's tidy that up! The graph should now look something like this:
  1. Assign custom values for the new constant nodes you have created on the Metallic and the Roughness attributes. Remember what we saw in the first chapter: a value of 0 for the roughness slot means that the material has very clear reflections, while a value of 1 means the exact opposite. Similarly, a value of 1 connected to the metallic node means that the material is a metal, while 0 determines that it is not. Let's take a look at the final results!

Finally, think about tidying things up by grouping the different sections of the material graph together. This is done by selecting all the nodes that you want to group and pressing the C key on your keyboard. It keeps things organized, which is very important—especially when working with others or whenever you revisit your own work:

主站蜘蛛池模板: 苍梧县| 贞丰县| 昌邑市| 济宁市| 囊谦县| 富裕县| 山阳县| 大石桥市| 秦安县| 南昌市| 德格县| 汉阴县| 雷州市| 西林县| 乐业县| 通江县| 航空| 将乐县| 武鸣县| 牟定县| 普格县| 柘城县| 云梦县| 平阴县| 五大连池市| 阳新县| 烟台市| 桐柏县| 监利县| 平阳县| 清水县| 章丘市| 西贡区| 南溪县| 盱眙县| 客服| 黄平县| 阜阳市| 吉隆县| 襄城县| 历史|