Intro to Materials: Material Instancing | 08 | v4.0 Tutorial Series | Unreal Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
♪♪♪ Zak Parrish: Greetings and welcome back. In this video, we are going to take a look at material instancing, which is a very powerful and useful feature when working with materials in UE4. First, what is material instancing? Instancing is where you take a single parent material and you make copies of it that have variations. Here is the copy, which would be referred to as a child or an instance. You can call it either one. Here is another one. Here is another child. Why is this useful? It is useful for a lot of reasons. For instance, let's say your parent material is the perfect basic metal. Your children that you create from that material will start off with all of the features that made this a perfect metal. Then, you can turn them into specific variations such as copper, or aluminum, or aluminium if you are from that part of the world. Essentially, what you are doing is starting off with the exact same properties and you are making changes to them. These properties are going to be referred to as parameters. A parameter is just a value that can change once you instance off a material. Let's go ahead and take a look inside of UE4. I will admit I was going to make an instance out of this material we were creating in the previous videos, but it is complex enough I feel I would just scare people. We won't actually do that. We are going to make something much simpler. For starters, let's begin in the Content Browser. Notice I am in the Materials folder. Right-click and select Material to create a new material. I am going to call this, "Parent". You might want to call yours something a bit more descriptive; maybe put your name on it. We will call it Parent. Let's start off by defining Parent. The first thing you are always going to do is create a parent material just like any other regular material. However, what makes this different from the materials we have made before is that we are going to parameters instead of regular constant values. For example, one of the first things I showed you how to do when creating a material is to create a 3 vector. I held down the 3 key and left-clicked. We can double-click on its color swatch and assign any color we like. Plug that into Base Color. That is fine; this would work. The problem is that this is a constant value and can never change. Once this Material is compiled, that is it. I want to make a quick note about compiling as well. I will jump back to my chalkboard. One of the more important things about instancing is when it comes to compiling, only your parent material is actually compiled. Essentially, the children are free. They don't actually cost anything in terms of compiling. It does speed things up a bit in terms of performance. Let's jump back over to UE4. We are not going to use a constant value this time. Instead, we are going to create a vector parameter. Right-click, type and select, "Vector Parameter". The first thing you will notice when you create a vector parameter is it wants you to give it a name. That is what we are going to do. We are going to call this, "Base Color". We will plug the output right into Base Color. Let's give it a default value. Double-click inside Base Color. We will make this a very pale gray for starters. It essentially looks white when you look at it. The difference between these nodes is when we instance this off, we will have access to this Base Color node and we can make changes. I want to get just a little bit fancy straight away because I think it will help you understand more of how things work in terms of material instancing. We are going to bring in a texture. I am going to go back to the Content Browser and click on the Textures folder. Let's grab something that is kind of metal-like. We have T_Base_Metal_D and T_Base_Metal_N. Let's grab both of these. Select both of the base metal textures. I can select them both by holding CTRL and clicking on the second one. I can drag them together into my Material and you will see they both appear. This is how I was adding textures before. Technically, this works but the problem is these are not parameters. These would be constant and they would always remain the same for our object. It is not entirely useful. I am going to delete both Texture Samples. I wanted to show you there is a difference to adding those textures in. With T_Base_Metal_D selected in the Content Browser, right-click in the Material Editor and type, "Parameter". Here is our list of parameters. You will see TextureSampleParameter2D. Click on that. This is asking for a name. You will see the base name it gives is really long and not particularly useful. Let's call this "Base Color Texture". I would like to rename this Base Color node because we are calling this Base Color Texture. I can rename it in the Details panel by clicking on the Parameter Name property. We are going to call this "Base Color Tint". We have Base Color Tint and Base Color Texture. All we are going to do is multiply them together. Drag a wire off of Base Color Tint and type, "Multiply". Press Enter. Drag a wire off of Base Color Texture and plug it into B of the Multiply. Plug the result of the Multiply into Base Color. Already, we have a much more interesting material than we had a moment ago. Now, we want the ability to control Metallic as well. Drag a wire off of Metallic and type, "ScalarParameter". You can just type "Scalar" and press Enter. We will call this "Metallic". I want to show how this value is different. Normally I would call it Metallic, just to point that out, but I am going to call it "Metallic Z" just to show you that it is different than the actual Metallic value. We will call it Metallic Z, which is probably a really terrible cover band. If that really is a cover band, I am just kidding. I have never heard of that cover band, just to make sure everybody understands that. Let's use Roughness as well. Drag a wire off Roughness, type and select, "ScalarParameter". Let's call this "MyRoughness". We know it is a custom value. Call this "Custom Roughness". That is better. That is cleaner and makes more sense. Let's use "Custom Metallic" as well. That is all much more concise. Now, we need to bring in our Normal map. In the Content Browser, click on T_BaseMetal_N. Right-click in the Material Graph, type "Parameter" and select TextureSampleParameter2D. We will call this "Normal Texture". We will plug the Normal Texutre into Normal on the Parent node. We have all of these parameters plugged into our surface. That is working well. Is there anything else I want to do? I think this is probably enough for getting people warmed up. Let's go ahead and click Apply. Click Save. Then, we can close the Material Editor entirely. Let's go back to the Materials folder in the Content Browser. At the very bottom, we will see Parent. I am not going to apply Parent to the surface. Instead, I am going to right-click on Parent and select Create Material Instance. The instance was created down at the bottom. You will notice it is called Parent_Instance. Let's right-click and select Rename. For our purposes, we will call this "Instance _1". That will appear at the very top because of alphabetical order. Select the object in the viewport and drag Instance_1 onto Element 0 to apply this to our surface. Here is what we get by default. Let me point something out. Notice the thumbnails between a regular material and a material instance. You will see the material instance has a slightly darker green border. That is just something to point out. If I double-click on this material instance, I get the Material Instance Editor. This is a bit different than the actual Material Editor. You have a toolbar, you have a Details panel, you have some Instance Parents to show you who your parent material is, and then you have a great big preview. The important thing to show off here is in the Parameter Groups, you will see all of those parameters you have created. Here are our Texture Parameter Values. Here are our Scalar Parameter Values, or our single numbers. Then, here are our Vector Parameter Values. Now, let's go ahead and make a few edits. I will leave the preview nice and big for now. Let's start off by saying we want to change the Base Color Tint. All we need to do is check the checkbox next to the property. This basically says we would like to override this with our own color. Click and start sliding around to choose a different color. We get instantaneous feedback. I will pull Alpha up. It won't make any changes as far as we are concerned; I just feel better about it being up. You see the feedback is very fast. We can click OK. If I slide the Material Instance Editor off to the side, watch this. Watch in the viewport as I change values. We get instant feedback in the viewport as well. This is a very handy way to work. In fact, it is so handy that our artists will quickly put together their materials with some parameters in place. Then, they will make an instance of that material and use the instance to tweak values in a scene. This allows you to get something perfected very quickly with this real-time feedback. We will choose this pale shade of blue. Go over to the Scalar Parameter Values in the Details panel. Let me slide this bar over. Select Custom Metallic and slide it up towards 1.0. You can see the surface now looks very metallic. We can tweak the Custom Roughness value as well. Now we start to get a very metal-like surface. Let's go ahead and set Metallic all the way to 1.0 so it is a true metal. We can also replace textures as well. Go down to the Textures folder. Let's say we want to turn this into a brick surface. You will notice I made those Texture Parameter Values. We can check Base Color Texture and Normal Texture. Checking those boxes means we want to be able to override what is already there. Drag T_Bricks_D onto the Base Color Texture. Drag the T_Bricks_N on top of the Normal Texture. We are already done. Now we have brick. It probably makes more sense now to change the color. The nice thing is that we can start making multiple copies of this material. Go back to the Materials folder. Scroll up to our Instance_1. Right-click Instance_1 and choose Create Copy. We will call this "Instance_2". In the viewport, I am going to hold down Alt and right-click to drag and push back a little bit. Slide the object to the side. Hold down Alt, and drag out a second copy. I am going to move the Material Instance Editor out of the way. Select the second copy, apply Instance_2 to Element 0. I just want to show this to you. If I double-click on Instance_2, notice we have two (2) panels now. Here is Instance_1 and Instance_2. They can both be entirely different things. Again, I am using my screen space as best as I can. This is one more reason why it is nice to have two (2) monitors if you can manage. Let's take Instance_2 and expand its Texture Parameters. Let's use some different textures. Instead of brick, let's say we want this one to actually look like copper. Drag T_Metal_Copper onto the Base Color Texture. Drag T_Metal_Copper_N onto the Normal map. Leave Base Color Texture unchecked. Suddenly, this looks just like copper. Let's go back to Instance_1. Select the Base Color Tint. We are going to pull the actual color value down really low so it is just using a little bit of that color. Then, we will uncheck the Metallic value. We won't override the Metallic value anymore. Now it is just a non-metal. Select the Custom Roughness and make that pretty high, about 8. Now as you can see, we have two (2) very different materials but they both come from the same parent. Only that parent material would actually be compiled if this were a game. Both of these very different materials would essentially be free. There is only one more thing I want to show off. Right now you will notice our Parameter Groups are just called Texture Parameter Values and Scalar Parameter Values. They are not particularly useful. The last thing I would like to do is go into the Materials folder and open up Parent one more time. I want to show you on each one of these parameters, you have a Group you can edit as well. Select Base Color Tint and set its Group Value. We are going to type a value and call this "Color Adjustment". Then for Custom Metallic, let's call this "Surface Definition". To drive home this is a physically-based system, let's call this "Physical Surface". This is where we define the physical surface. I can click on Roughness, and you will notice this is also a drop down menu. I can reassign any of the groups I have typed in here very quickly. Let's set this to Physical Surface. Select the Base Color Texture, and call this Group "Texture Overrides". Select the Texture Normal map and assign this to Texture Overrides as well. Click Apply. Click Save. If I go back into the Material Instance Editor, take a look at my new Parameter Groups. We have Color Adjustment, which has my Base Color Tint. We have Physical Surface, which has Metallic and Roughness. We have Texture Overrides, where you can see my Base Color Texture and my Normal Texture. It is a really nice way to keep things organized. That is a look at creating material instances and controlling them in UE4. That is going to wrap things up for this video. Thanks a lot. ♪♪♪ ♪♪♪
Info
Channel: Unreal Engine
Views: 135,452
Rating: undefined out of 5
Keywords: Unreal, UE4, Unreal Engine, Materials, Instance, Unreal Engine 4, game development
Id: sx0BlzGkahw
Channel Id: undefined
Length: 16min 57sec (1017 seconds)
Published: Wed Mar 19 2014
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.