Blender Vertex Color height blend material tutorial - Learn how to blend materials in Evee & Cycles

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to the material blending tutorial for blender and in here we're going to set up a shader that allows you to blend between different materials using vertex painting and a height map so this is exactly the same behavior that you can get in a game engine when you feed it an object and then use vertex colors to blend between different materials on the object so it's actually great to be able to preview that in real time in blender because it really allows you to fine tune the look and feel of your object directly in your modeling application in the tutorial i'm going to give you a brief overview of the shader editor and how to set up your materials set up your notes and then preview it either using ev or cycles in the viewport so let's get started so the first thing that we want to do is actually enable the node wrangler add-on because it makes working in the shader editor much quicker and much easier and it contains a bunch of useful shortcuts so go to edit preferences and navigate to the add-ons category and in here just type in node wrangler and then make sure that this add-on is enabled and has a checkbox in front of it once you have done that um we can actually get started okay so um right now our viewport has the 3d view up here and the animation editor down here so what i'm going to do is i'm just going to move this up and then down here switch this to the shader editor so just click up here and then go to the shader editor and as you can see it shows you the material of the cube that's in your scene so up here you can see slot 1 and then material which means that this object has the material with the name material assigned to it what i'm going to do is i'm actually going to delete the object and then i'm going to add a new plane so shift a to add an object then go to mesh and then go to plane and then what we want to do is subdivide this a little bit so i'm going to go into edit mode and i'm going to go to edge mode and then i'm going to plus press ctrl r to add subdivisions and then i'm going to use my mouse wheel and scroll up until we have 10 cuts and then i'm going to do left mouse button to confirm and right mouse button to confirm again and we're going to do the same thing on the other axis ctrl r scroll your mouse wheel until we have 10 cuts left mouse button right mouse button and now that we have done that we have a nice plane that has a bunch of subdivisions as you can see this thing doesn't have a material applied yet and um what we can do is we can actually create a new material if we wanted to by just pressing on new and now you can see it has created a material called material001 and for now that's fine but let's rename that and let's actually rename that to blend underscore material and then once i do that you can see the name change and you can see the name change up here as well so that's our basic material setup and next we're going to bring in some textures that we're going to use to blend between so before we load quixle bridge to bring a material into blender one thing we need to make sure is that our render engine is set to cycles so go to your render properties and then up here you can change the render engine from ev to cycles so left click on it change it to cycles cycles is a path-traced renderer that supports displacement maps ev is more like a game engine and doesn't support displacement maps by default so if we don't set it to cycles quixl bridge will actually not export your displacement maps and since we need the displacement map to blend between layer 1 and layer 2 of the material we need to make sure to set our render engine to cycles also i like to set the feature set to experimental and i like to set the device to gpu compute which means it's going to use my gpu to render the viewport now that all of that is adjusted you can load the quicksilbridge software so here it is you can download the software from the quiksil website if you don't have it yet and then once you've installed it just go to edit and settings and change the dcc engine to blender quick thing about the ui you can see various different materials what we want to do is we want to actually download a ground texture so let's just type in ground to look for actual ground materials and then you can see i think these two look pretty promising blending between these two materials should be fun so those are the materials we're going to use if you haven't downloaded a material or an asset yet you will see it's being displayed on a gray background so this one i haven't downloaded and this one i haven't downloaded for example if i hover over it i can click on the download icon in the upper right corner and once i do that it will download it once it's downloaded it will show up with a blue checkbox which means it's now in your local library and then you can click the export button to actually export it so what you want to do is you want to hover over the rocky dot material and download it by clicking the download icon in the upper right corner you can see i've already done it so i'm just going to left click and then in here you have the asset info that describes the material you can go to your download settings make sure that albedo displacement normal ao and roughness is enabled uh in the export settings you can specify the texture resolution that's going to be used to export it to blender and the texture format i'm going to set it to 4k and tga and then i want it to export to blender once i'm happy with that i'm just going to click export and then it's going to take a second to actually export to blender and then we can go here and as you can see nothing has really changed and that's because our plane still has the blend material aside now we can switch to the new material by clicking in here and selecting the dry rocky ground material or we can go down here to the material properties tab and switch between blend and the rocky ground material with that let's take a closer look at the shader editor and see what's going on in there so to be able to see the texture in the viewport let's switch to the material preview viewport shading so left click on that to enable it and then you can see we can now see the texture on our object and i also want to turn off the wireframe on the object so select it and then just click here and turn off wireframe or use whatever hotkey you have assigned to it and then down here we have the shader editor so let's take a look at that and the orange boxes are our textures that we have brought in and then essentially what's going on is we're specifying the uv coordinates that are being used here and then here are our different texture maps here are some nodes that do some changes to the texture maps and then here is the principled bsdf shader that gets fed the albedo ambient occlusion roughness and normal maps and then we have the material output that gets fed the displacement information from the displacement map down here now um what we actually want to do is we want to take a look at these nodes and see what they do so the ambient occlusion down here and the albedo map are being multiplied with one another so you can see layer one is the albedo map layer two is the ambient occlusion map and the ambient occlusion map is being blended with the blending mode multiply with a factor of 0.5 so if i change this by left clicking and dragging the mouse you can see that the intensity of the ambient occlusion changes in the viewport so i can go from 0 all the way up to 1. if i hold down shift it becomes more sensitive when moving the mouse if i hold down control it snaps to 0.1 increments we want to make sure to leave this at point 5 for now and then the result of that multiplied node gets fed into the base color slot of the shader the roughness map gets fed directly into the reference slot and the normal map gets fed into a normal map node where you can specify what tangent space to use and you can change the strength of the normal map so if i go down here and i change this to zero you can see the normal map's not being used at all i can change it to 0.25 and then you can see it starts coming in i can change it to 0.75 it becomes more intense i can change it to 1 for its full effect we want to leave that as 1 as well for the best results and then down here is our displacement map um the displacement map gets fed into a separate rgb node which then gets fed into the um displacement node and then here you can specify the intensity of the displacement and the mid level and that get gets then fed into the material output slot now right now we can't see any displacement in the viewport because we are in material preview mode if we change this to rendered mode we should get a little bit of displacement on the object and there you go you can see we're getting some displacement on the object if i turn on my wireframe again you can see the original wireframe is still down here and that's the displacement that we're getting through the shader um now because we do not have enough resolution in our mesh we're actually not getting a ton of displacement yet so what we want to do is we want to select the mesh and then go to modifiers so modifier properties and we're going to add a modifier and we are going to add a subdivide modifier so subdivision surface we're going to set this to simple and we're going to set the viewport levels to 2 which will increase the density of our mesh in the viewport let's actually crank it up to three and then you can see with every change that we make the displacement becomes more and more realistic so right now we have more points to work with so the displacement actually becomes more interesting um to change the scale of the displacement we can use the slider so if we crank it up to let's say one we get like a super intense result which we probably don't want if we change it to 0.5 we get a less intense result and for now i'm just going to leave this at point one the mid level just changes where the midpoint where the displacement map is being applied to is located and um i'm gonna leave that at zero as well so that's the basics for controlling the shader um here we can specify the texture coordinates that are being used and since we do not want to do any changes to the texture coordinates yet i'm not going to get into that but we're still going to leave them in here since we do want to blend between two different materials we need to bring in a second set of textures into blender so let's go back to quixler bridge type in ground up here again and we're going to use the dry mud floor 2x2 meters so download it once it's downloaded click the export button and that will bring it to blender so give it a second to do that and then in here you can see we now can switch between the dry rocky ground and the dry mud floor so if i do that you can see that my shader graph changes and the assignment to the object changes before we move forward let's actually get rid of that subdivision modifier and switch our render engine back to ev because this is a little bit faster and will allow us to see results a little bit quicker so let's change the plane material to the rocky ground material because we've already organized our shader graph in here a little bit better there's also snapping in here by the way so you can turn this on and then you can turn this to like node x and y for example and then once you drag the nodes it will actually snap to the left or to the right or to the top or the bottom so you can also use g to move and then press x to constrain to the x axis y to constrain to the y axis so all your 3d viewport hotkeys work in here as well let's turn snapping back off and let's actually bring in that second set of textures so what we're going to do is we're going to make a duplicate of this shader so select everything but the material output by left clicking and dragging and then left click on the principle bsdf and move it a little bit and then make sure you're hovering over the principle bsdf and press ctrl c to copy and then we want to do control v to paste and it will paste the duplicate of the selected notes in place so ctrl v and here's our duplicate and then i'm going to left click on this and move it down and then you can see here is our second principle bsdf shader now in order to take or in order to have this rendered in the viewport we need to plug it into the material output so let's go in here and let's actually move this down and what we're going to do the first thing we want to do is actually get rid of that displacement so just left click on the displacement input here drag it to the left and just let go of the left mouse button and then we're going to left click on the bsdf of the copy of our shader and drag that into the surface slot so now this shader is being rendered in the viewport now obviously this is using the exact same inputs as the first shader so it's showing you the same image in the viewport so we need to change that to change the texture just click here and then you can see that our texture for this material is called uh omj and we want to switch it to ug40c which is that first material here which is going to be the second material that we brought in so let's click on that and just go through and change all of the textures accordingly so this is the roughness texture so let's change to the roughness texture this is the normal texture let's change to the normal texture this is the displacement texture so let's change to the displacement texture and now you can see we have that second material that's being rendered and then if we actually go here and plug in that first material again it will change what's being rendered in the viewport and if we want to set it to the second material again let's just plug in the second material so that's all it is we just created a duplicate of the shader and we can now switch between the two different materials so in order to blend between the two different shaders that we have here we need to create a mix node so press shift a left mouse button on search and then type in mix and then select the mix shader node and this node allows you to blend between two different inputs and have a factor which specifies the factor that is used for blending the two different inputs so let's go up here and plug in the output of the first shader into the mix shader and let's move it down here and plug in the output of the second shader into the second shader input of the mix shader and then plug the result of the mix shader node into the surface node and then you can see the viewport will update and it's now blending halfway between shader 1 and shader 2. if i set this to 0 it will fully display material 1 if i set it to 1 it will fully display material 2. and here you can see i can just blend between the materials by using the slider now this is all cool but we do want to blend we do want to control the blend using vertex colors so what we're going to do is we're going to bring in a new node so shift a left click on search and then type in vertex color and this gives you a vertex color node and we only want to use one channel to control the blending so we need to separate the vertex colors into the r g and b channel so let's get another note for that left click on search and then type in separate and select separate rgb and then we're going to plug in the color into the image slot and then we're going to plug in the result of the red channel into the factor of the mix shader what that means is we can now control the blending using the red channel of the vertex colors that we paint on the mesh let's actually start painting some vertex colors we can quickly do that by switching to paint mode or vertex paint mode up here and then once you do that you will see the texture change so left click and you can see now the information in the second shader is fully being displayed on the mesh the reason for that is by switching to vertex paint mode we have just added a set of vertex colors to the object if i remove that again it goes back to the original layer now in the shader we have specified that we want to use the red color channel to blend between shader 1 and shader 2 and by adding vertex colors we're flatting everything with white and white is red one green one and blue one and as a result it's fully displaying whatever is in the second slot of the mix shader if i switch to solid viewport mode i can actually show what's going on when painting the controls for painting are pretty easy you can press f and hold down f and use the left mouse button to change the radius and you can use shift f to change the strength you can also use the sliders up here so just however you want to do it i recommend using the keyboard shortcuts because it's a little bit more intuitive up here you can specify the color so what we want to do is switch from hsb to rgb and then bring this down to green 0 and blue 0 because we only want to paint in the red channel and now when we start painting using the left mouse button you can see that we're filling the area with red and the first thing we want to do is actually increase the radius and then fill everything with red and then bring the radius back down and while painting we can hold down control to invert so instead of red it's painting black and if i let go of control it's painting red again if i switch to the rendered viewport mode you can see that once i start painting and then once i hold down control and start painting i'm starting to reveal the second layer or the first layer actually because we are fully looking at the second layer by default and then also i can use shift f to change the strength so if i do that i can get a little bit of a softer blending and in order to see this a little bit better let me actually scroll out switch back to object mode select the light here and then press alt g to center it at the zero zero zero coordinates of our scene and then press g to move it and move it a little bit over here so that we're getting a little bit of a nicer result in the viewport and then we can select the object again and go back to vertex paint mode and then we can start um painting these textures and then depending on the strength like right now the strength is really really small so it takes me a lot of clicks to actually paint in some color information so let me increase that and you can see now this is working a little bit better so these are the basics for vertex painting fairly simple stuff i really like how blender is handling it what we want to do though is we want to use the height information in our displacement map to blend between the two different layers and we also want to be able to specify a blend factor so we want to be able to control how sharp our blending between the two different materials is and in order to do that we need to add some more notes to our shader graph so let's do that next so next we want to add the height map to the blending process and in order to do that we need to add some math notes so shift a and type in math to look for math notes and this one we're going to set to subtract and then we're going to make two copies of this so ctrl c ctrl v move that down ctrl v again move that over here let me select all of them and move them a bit out of the way and then make a copy of that subtract node and set this one to divide and this will all make sense in a little bit and then we also need a mix rgb node so plug that in and then we're going to group all of these so left click and drag to select them and then ctrl g to group and make a note group and let's connect the color out to the group output and then go to node up here and then um change the interface so we want to have three inputs one for the blend mask one for the height map and one for the falloff so type click on plus three times and then the first one is gonna be blend mask and that's gonna be the result of the vertex colors second one is gonna be a height map node and then the third one is just going to be falloff and for the output let's add another one as well and call that one mask because that's the result and let's actually get rid of um this one up here so let's plug that let's remove that let's plug the color into the mask and let's just delete the color output and then all we need to do is um change some settings here and connect these up so um this is just a math that drives the blending that we're gonna set up now so the blend mask is gonna go into this slot but it's also going to go into the first slot down here and then we want to set the value on the subtract node to 1 and the fall off is going to go into the value here and then the height map is just going to go into the value up here and then this result is going to be dragged in here this result is going to be dragged in here this is going to go here this is going to go to the color one looks like that one didn't connect so let's do that again and then what we're going to do is make sure that this is set to 0.735 and let's check all of our notes right now the mixing algorithm is set to mix we want to set this to add and um yeah this is subtract this is divide this is subtract um the value here is one so yeah we should be good on that so let's just go out of the group by pressing this icon up here and then you can see here's our note group with the different inputs and our mask output and um let's make some space here and then what we're going to do is we're going to put the note group before the mix shader um simply because we want um to use the node group to drive the factor so the height or the blend mask is the result of the red channel so let's feed that in and drag that out the height map is actually the displacement texture so let's feed that into the heightmap slot make sure to drag it directly from the texture not from the separate rgb and then the falloff is just a value that we are going to manually set and then another thing we need to do is we need a ramp node so um look for color ramp and what we're going to do is we're going to plug the mask into the color ramp which means it's going to take the output of the mask and it's going to color it from black to white and then we're going to feed that result into the factor of the mix shader and once we do that we should get a result in the viewport and if we now change the falloff value you can see that we can now change the blending from um let's try 0.1 which is pretty harsh or we can try 0.7 which is pretty soft so let's try 0.05 and we can use our vertex colors to blend and we can also change the strength and then we can get some harder and or some softer blending and if you want to change the look of the blend in general you can also play with these um values in the color ramp here so um let's actually switch to falloff to something like 0.5 and then start playing with these values and as you can see it's another way to just like influence the look of the blending if you need to um we could have added this color ramp within the node group so that it's part of the node group and we don't have it exposed but i like having it exposed because it gives you a quick way to just change the values or even just flip the texture so if you want to invert the displacement map you can just invert these values and now it's basically flipping which layer is on top which is sometimes useful so that's why i like to have it exposed so um that's basically it we do have our blending setup um it's pretty cool uh works like in most of the other game engines um that you um can be familiar with like unreal allows you to do setups like this unity allows you to do setups like this and obviously you can get a lot more elaborate with all of this and now that we have the base blending working the next thing that we need to look into is doing our displacement blending as well so just like we did with two different shaders we also need to blend the displacement maps together now before we do that i want to show you some quick tips um and since we activated the node wrangler add-on we can always preview a node in the viewport by ctrl shift left clicking on the node so if i control shift and left click on the displacement node here i can see the result in the viewport if i click on the normal node i can see the result of the normal node in the viewport if i click on the albedo node i can see the albedo map and if i click on the color ramp node i can see the result of the colorant node so that's a quick way to preview things if you want to go back to your original result just delete that viewer node and plug the shader back into the surface material output so let's blend the displacement maps together this is displacement map one so let's move that down here and this is displacement map2 let's move that over as well and then we're going to use a mix rgb because we're blending two color maps together and not two shaders so shift a look for mix rgb and then we're gonna do factor one and factor two and for the factor so for the blending we want to use the result of the color ramp which is um our blend mask if you remember correctly and um then what we're going to do is we're going to plug the result of the color map into the displacement slot and as you can see nothing has really changed and that's because we're still in the ev we're still using the ev render engine so let's switch that back to cycles and we should be getting some displacement yep and we do need more subdivisions on the geometry to get proper displacement so add a subdivision surface modifier and crank up the viewport levels to four and now you can see we're getting some really nice displacement here and we can still modify the falloff value for example we can go in here and paint on our mesh let's crank up the strength and as you can see it's taking quite a bit of time to update now and that's because we're working with um pretty dense geometry because of the subdivision modifier that's on our geo we can also change the scale of the two displacement um after two displacement maps so we can set this 2.2 for example and this one 2.2 and now it's just more intense or you can have different values as well so if you want to have 0.3 for the first layer and less for the second layer you can do that as well and as you can see it's really powerful like this texture is actually really nice and displaces really nicely um one last thing we need to do to get the best quality in the viewport um go to material settings and um then we are gonna go into the displacement slot and then in here um under displacement so in the settings category you want to make sure that displacement is set to displacement and bump that means that you're using both geometry displacement and the normal map if this is set to bump only you can see we're only getting the normal map if it's set to displacement only we're only getting the geometry deformation if we set it to displacement and bump we're getting the information from both passes so this is giving you the best result in the viewport so to tweak the quality of the rendering just a little bit more one thing we can do is go back to object mode and then if we take a closer look you can see we're getting some faceting here on the meshes and that's because our original object is not set to shade smooth so right click on the object and then just turn on shade smooth and once you do that you can see the faceting goes away also let's go to the modifier tab and set the deformation to simple so that we don't lose the definition of the mesh in the corners next thing we want to do is load in a hdri background image so that we are getting some better lighting so switch in the shader editor from object to world and then in here type shift a look for search and bring in an environment texture and nothing has changed yet because we haven't loaded a texture and plugged it into hdri background yet one good resource for hdri images is hdrihaven.com so in here you can download any of these textures and then plug them into your scene so let's do that i'm going to click on open and navigate to the directory where i have downloaded my hdi image into and then select the image that i want to use and then plug that into the color slot of the background node and then once i do that it's going to take a second to calculate and then now you can see it's using the hdii image to light our scene also the hri is now showing up in the background if you don't want that just go to your render properties go to film down here and then set it to transparent and now we can quickly tweak the intensity of the um hdri image so just go in here and if we set this to like a low value like 0.5 or something you can see that the hi image is now not contributing as much to the scene anymore obviously you can still tweak the light so if you select the light in your outliner and then for example reduce the intensity of the light to like 500 and then maybe up the intensity of the hdri image you can kind of like tweak the look of your c i'm going to go back to what i had previously set this to 1000 and 0.25 and then let's also switch back the render engine to eb again so that you can see that the hdi image is influencing the object in here too so just give it a second to change and once it has changed we can now see the hdi image influencing the lighting in ev as well if we set it to zero there's no influence and then the more we um the more we increase the strength the more the hdi images contribute so um pretty easy to control there's also more settings that you can access specifically in ev so over here you can turn on a bunch of post processing like ambient occlusion bloom screen space reflections motion blur all that good stuff um ambient occlusion won't do much right now because we don't have any geometry that can actually influence one another so let's just add a cube and like scale that down and if we now turn on ambient occlusion we're getting a little bit of contact ambi occlusion down here but we need to play with the values so let's maybe increase the factor and also increase the distance and now you can see we're getting something here so basically if you would have more objects in your scene um this would be even more uh visible so let me just exaggerate what's going on but yeah there you go if i get rid of this cube obviously we don't have any ambient occlusion at all let's turn this back off and then one last thing just if you wanted to make the surface look a little bit more interesting what you could do is just switch to select the object and switch to sculpt mode and then turn off symmetry up here and then you can use the same controls as for vertex color painting to like change the shape of your of your plane and make it look a little bit more interesting so all good stuff [Music] let's take a look at one last thing let's go back to object mode now if you want to change the tiling of the textures so let's say you want the first layer to tile twice in comparison to the first layer to the second layer you can go into your node network and then remember here is the texture coordinate node and then here's the mapping node and in the mapping node in the scale you can actually change the scaling of the texture so if you want this to tile twice you can just set this to two two and two and now you can see um it's actually half the resolution than it was before so if we switch this back to one it becomes sharper and then if we switch this to like 0.5 you can see it is now tiling twice and then that's basically how you can control the tiling of the different channels so one and one is the default and then if you reduce the scale then it tiles more if you increase the scale it tiles less and the same is true for the second layer so if you wanted to influence that you could just do it down here set this to like 0.25 and now you can see this is tiling a lot more than the first layer and because these nodes are all set up correctly we can switch back to cycles if we wanted to and we're getting displacement that is respecting the change in the mapping as well so yeah all good stuff that's uh how you can control the tiling and then there's a ton of more things you could do in here um you could have a third layer by just copying that layout and then just adding another mix shader and then mixing that in with the original layers that we had pretty much possibilities are endless here blender's shader editor is really powerful but this is just a basic setup that allows you to do material blending directly in the viewport of blender and you can basically preview your mesh a little bit better by having a setup like this especially if you want to use vertex blending in the game engine so if we export this to unreal this is just a really cool way to preview what it's going to look like in unreal so we're almost at the end of the tutorial now in order for you to not have to set up this whole shader graph from scratch every time you want to create a material you can go to my gumroad and get the source file for this for free and what you're going to do is you're just going to make a new scene and then append the shader from that blender file into that new scene to be able to use it one thing i want to make you guys aware of before we before i show you how to do that is that each of these texture maps that we're using has a color space so you can see down here it says srgb for the albedo map and then none color for everything else so this is important because the file that i'm going to give you um will not include the quiksil textures obviously they belong to qixel and i can't just add them to the tutorial so if you want to use them in unreal you can just make a quick sell account and um download them and use them in unreal if you want to use them for your personal projects you are going to have to end up buying points and purchasing them for yourself but um basically you're going to get a note set up that does not contain any of the textures and when you bring in those textures you have to make sure that the color space is set to the correct setting so everything but albedo needs to be set to none color and then the albedo texture needs to be set to srgb just keep that in mind so srgb for albedo non-color for ao none color for roughness none color for normal non-color for displacement so let's show you how to append the material into your file so this is a brand new blender file and what you're going to do is you're going to click on file append and then you're going to navigate to the directory where you have downloaded the blender file that comes with the tutorial it's called two layer blend and then you just double click on it and then in here you can now see the scene collection or the outliner you can see everything that's in the file and then you just navigate to materials and what you want to do is you want to append the blend shader so double click on that and now that you've done that you can see that we can choose the blend shader over here so let's just do that which will assign the blend shadow to the object and then we can add another screen and switch this to shader editor and i'm going to give you a quick rundown i've spent some time kind of like organizing things a little bit over here you have your uv tiling control where you can change the scale of the tiling and then here are the textures themselves so here you're going to plug in your texture maps by just opening them or adding them and again make sure to set it to the correct color space like i've just talked about and you have to do this for both layers and then you have your ambient occlusion intensity for layer one your normal intensity for layer one your ao intensity for layer two normal intensity for layer two and then the blending setup is here so if you just want to use this part of the shadow you can copy that and bring it into your shader and then we have the displacement amount that you can control down here and then all of that feeds into the material output so pretty simple setup um feel free to use it and i hope it's useful for you thanks for watching and have a good rest of your day
Info
Channel: Simon Fuchs
Views: 132,397
Rating: undefined out of 5
Keywords:
Id: ccciTF5aZP8
Channel Id: undefined
Length: 39min 22sec (2362 seconds)
Published: Wed Jul 22 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.