Blender 2.8 Tutorial - Procedural Carbon Fiber Shader - Part 1 (Cycles & Eevee Compatible)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Perfect i literally searched one 5 min ago

👍︎︎ 2 👤︎︎ u/NlHlL0 📅︎︎ Apr 25 2020 🗫︎ replies
Captions
Oh [Music] hey this is Chris plush from CG masters and this is a free lecture from our upcoming course the blender encyclopedia this is an all-in-one type course with more than 50 hours of training for the latest version of blender including step-by-step projects like this one on creating a fully procedural carbon-fiber shader so check the description for more info on the course and I hope you like this tutorial in this step-by-step project we're gonna build a carbon-fiber shader this consists of a metallic weave pattern and a brushed metal look to it and this tutorial will be step by step but is probably more on the advanced side so it would help if you had at least basic experience with nodes before attempting this and like with many textures there's likely other methods of creating this one but I haven't seen any that used the correct weave pattern or any that didn't just use image textures so I wanted to make one procedurally so we can customize it more this shader will be best applied to anything UV unwrapped so for this tutorial you can use any model that's unwrapped including any of the default mesh objects here like the monkey head or plane and to keep things simple what I'm gonna do is use a plane while we're building this so let me press a to select everything press X to delete it and then I'll press shift an a and I'll add in a mesh plane now let's add in a material for this so let's go over to the material properties here I'll click on new and we'll rename this to carbon fiber now let's split the window by clicking on the top right corner there and dragging left and then we'll go into the header menu here and we'll switch this to the shader editor and we press the end key to get rid of the right side toolbar and zoom in on what we've got so far now we don't need to do much with the principal node for now except we'll crank the metallic value up to 1 now our main goal is to create this weave pattern here so this is our aim we have a clear weave pattern and each fiber is brighter in the center and darker on the ends so we can use this as height information for a normal map now you can see we've got some fibers going sideways and some going up and down and note how all fibers going in the same direction follow a sort of zigzag pattern so that's our first step we'll make a black and white zigzag mask to use to mix both directions of fibers together and notice how the pattern goes four rows up before starting over we'll keep that in mind alright now for this we'll start off with checker textures so let me pan that over there and I'll press shift an a and from the texture menu we'll add in a checker texture and with that selected let me press ctrl + T and it gives us a mapping and texture coordinate node now make sure to enable node Wrangler in your add-ons in order for hotkeys like that to work we go over no Wrangler earlier in this section all right so now let's go over to the 3d view press and go into material preview and let's get rid of these gridlines they're intersecting the plane and kind of annoying me so I'm going to go up into the viewport overlays here and I'll check off floor and the axes there that's better all right so now let's get a preview of our checker pattern by holding ctrl shift and left clicking on the checker texture and now let's change the scale here to 10 so that we can see more checkers and that's actually important too because we do some calculations based on scale later so you should definitely set the scale to 10 as well now let me press numpad 7 for top view now our goal is to take a checker texture like this and we want to move each row sideways a little bit so that the squares overlap that will give us the zig-zag pattern in the end and in order to do that we'll need four different offset values because like I mentioned there are four unique rows in the weave pattern before the pattern starts over so we need to move each one of those four rows a different amount so that there's a perfect overlap so we'll start by creating something that gives us four rows that have four different values so let's change the X scale on the mapping node here to zero and that's going to stretch those checkers out infinitely on the x axis so that they just appear to be straight horizontal bands and let's change color number two here to black and we'll change color number one we'll just crank that up so that it's a pure white it was a little bit dim all right so now we essentially have two different rows with two different values but we need four so what we'll do is use this here as a mask and we'll fit other checker bands inside and you'll see what I mean in a second so let me select the checker texture I'll press shift and D and we'll duplicate this twice and let's connect the mapping node to each vector socket of each of those checker textures now in each checker band right here we want to fit to all their bands so we need bands that are half the size so what we're going to do is take these two checker textures and we're going to double the scale value which will make them half the size so I'll type in 20 there and 20 for this one as well you can see we're previewing this checker texture still and when we change that to 20 those bands now become half the size so these two smaller bands here fit in one of the larger bands of the mask that we're going to use so that's perfect so we have to check textures here each with two different colors which means we have four bands available to us between the two notes so let's make them all different values and we're gonna need to do that in perfect quarter increments too since there's four bands so we'll start off at the top here and we'll make sure that color is a perfect white or a perfect value of one then the next color down we'll bring that down a quarter so I'll click and drag over all the RGB channels and type in point 75 then we'll go down to this one and we'll click and drag over RGB and type in point five and then finally for the last color will type in point twenty five now what can mix these two together using our original mask right here so let me zoom out a bit select them and move them over and give us more space to work with and let's combine these together so I'll hold ctrl shift and right click and drag between them and it will connect them using a mixed note and let's mix these two together using the color from this checker texture as the mixing factor and I'll hold ctrl shift and left click on that for a preview and there we go so what's happening is we're taking this checker texture right here and using it as a mask where the white areas are gonna show the bottom checker texture and the black areas are gonna show the top one so that in the end is going to show us four different bands so so far so good so now that we have these four different bands we can use those values as an offset for another checker texture and that's gonna give us the zigzag pattern now before we move on let me switch the texture coordinates here to UV this texture is definitely the kind that's gonna work better with UV coordinates so let me connect that to the mapping node there and now let's move on so we're gonna need some extra space in here so let me drag this window over a little bit and I'll drag this over a little let me zoom out I'll select all those nodes and move them over and now let's select this middle checker texture here I'll press shift + D to duplicate it and drag it over there just in the middle of nowhere now for this let's make the bottom color black and we're gonna leave the scale at 20 as well to make sure it aligns with the checker bands perfectly so let's preview this I'll hold ctrl shift and left-click on it now in order to offset these checkers will need to use a mapping node so let me shifting a and from the input menu here nope factor menu yep there it is okay from the vector menu add in a mapping node and we'll connect the vector output to the vector input there and it turns black now because we need some kind of texture coordinates for this and we're going to use UV texture coordinates as well so let me zoom out and where's it so the texture coordinate node is over here so I'll click on the UV output there drag it all the way over to the vector input of the mapping node all right and let's also change the Y scale value to zero so that we start off with vertical bands here and now we can just offset each row and get our zig-zag pattern and that's where the mapping node comes into play look what happens when I hold shift click on location there and then drag it you can see it offsets the texture but it's just using one value to offset things resulting in the entire texture offsetting that's where those four bands with the four different values come into play but we can't just plug this mix node into the location value there that's going to offset things on every axis when we just want to offset on the x-axis so let me press shift and a and from the converter menu here I'll add in a combined XYZ node so this is basically just like a blank vector node right now and we can change values for every axis here so let's plug the mixed node into the x value there and we'll plug the vector output into location input of the mapping node now it looks like a regular checker texture again so what happened well take a look at what happens when when we change the value of these bands you can see it is actually offsetting each row so that's perfect it's actually working however it looks like it's offsetting it twice as much as we wanted to so let's simply divide these values by two and we can do that with a math node so let me press shift an a and from the converter menu I'll add in a math node and sneak it over that line right there so that it connects let's switch this to divide and we'll divide those values by two and there we go so now it's looking more like a zig-zag pattern we could have probably also divided all these color values over here by two to achieve the same thing and avoid using another node but adding that divide node in seems easier plus now in the end we can actually turn this back to one if we want a simpler checker pattern we've instead so that adds to the customization alright so that was all actually the trickiest part it gets a little bit easier from here so the next thing we'll do is make these fibers rectangular so let's go over to this mapping node here and we'll change the X scale to 0.5 and that is perfect now the next step is to create a gradient that we can use for a normal map so it looks like the bands are rounded and bumping out a little and for that we'll use a Voronoi texture so let me press shift an a and from the texture menu I'll add in a Voronoi texture and we'll just put it right below the checker texture there let's move these things aside we're gonna need some extra space over here now there are a few ways to create the gradient there's even a gradient texture but the Voronoi texture perfectly aligns with the checker texture in terms of scale meaning when both textures have the same exact scale value they're the same exact size and perfectly aligned with each other so that's why I picked the Voronoi texture because I know that the gradient we create from this is going to perfectly align with the checker texture that we see in the zig zag pattern here so we should end up with a perfect gradient in each one of these fibers so now let's start turning this into a gradient let me hold ctrl shift and left click on that to get a preview of the distance output now you might be wondering how we turn this into a gradient and it's actually pretty easy first we'll change the dimensions here to 2d instead of 3d and now we'll turn randomness down to zero and we'll change the scale value to match the checkered texture so I'll type in 20 there now you can see this is perfectly aligned with how the checkered texture looked like originally so when we give it the same mapping coordinates by plugging that back to output into this vector input boom so with the y scale value here being zero it stretched the Voronoi pattern vertically producing vertical bands in fact let me cut off the offset right there so we can see those vertical bands and this is what it looks like without the offset so just like we were able to stretch Checker's into vertical bands we're able to stretch this as well but we ended up with gradients instead since it's a different texture then when we apply that offset again we get a perfect base pattern to use for the weave now let me zoom in on one of these gradients we can actually get a somewhat smoother gradient by changing the f1 in here to smooth f1 and if I switch back and forth you can see the difference it's slight but it does give it a slightly more rounded look to it and all right we're actually doing pretty good now we're done the horizontal bands for the weave but now we need to create vertical bands which is going to be pretty easy because we already have everything made all right let me zoom out a bit and let me select that checkered texture I'll press G and move it up and out of the way and let's Center that know a little bit better and let's go down to the end over here I'll select the texture coordinate node and I'll move that down they're out of the way now all these nodes in there are what we're gonna duplicate and create vertical bands with now before we duplicate these let's line these nodes up a little bit better just so it looks a little nicer so let me select just these nodes right there and I can press shift and the equals key and it lines them all up horizontally that works with vertical bands as well for example if I have vertical bands offset a little bit like that and I select them all I can press shift and equals and it aligns them nice and neat for me all right so now let me select all of those nodes and I'll press shift and deed to duplicate and I'll move them straight down to right there now we need to reconnect the texture coordinates here so I'll connect UV from there to the mapping node here and let me press ctrl + space to fullscreen this and I'll connect UV mapping to that mapping node as well I'll press ctrl in space to get out of full screen and let's get a preview of this entire bottom chain here so I'll hold ctrl shift and left-click on the Voronoi texture there now it looks the same so far because we didn't make any changes so to switch the direction of the bands we simply just need to switch all the X and y values for example the X scale is 0.5 and the Y value is 0 so let's just switch X to be 0 and Y to be 0.5 and now we need to switch this to go into the Y socket there and disconnect the X and then finally over here we need to make the x value 1 and the Y value 0 and there we go vertical bands so now that we have both directions of banding we can now use this mask up here to come them together alright so now to mix these together we'll hold ctrl shift and right click on that and drag it up to there and it combines them with a mix node and let's get a preview of this so far I'll hold ctrl shift and left click on it right now it's mixing them both 50/50 so we need a mix factor and that's where the checkered texture mass comes into play so let's connect the color value there to the factor value there and boom there we go there's our weave pattern sweet so again with masks what's happening is the lighter areas here or the white areas are showing the bottom texture which is the vertical bands and the black areas are showing the top texture which are the horizontal bands so when you mix them together with that mask you get a perfect weave pattern of gradients alright now before we work on the normal map let's work on the colors for the bands now for carbon-fibre it's usually too greyish values one darker than the other so let me select this mix RGB node I'll press shift + D to duplicate it and move it up a little bit now let's change color number one here I'm going to click on the RGB fields there I'll change this to point zero zero eight to be our darker gray value and let's change the bottom color here to be point zero three to be our lighter gray and now let's preview this I'll hold ctrl shift and left click on that and right now it's just giving us a perfect 50/50 combo of those colors so we're gonna need to mix them using a mask and we'll use the checker texture mask we made here so I'll plug that color value in as the mixing factor and there we go alright so this is looking good but now let's say I wanted to add some shadowing to the weave for that we can simply multiply the weave pattern over this so let me hold ctrl shift and I'll right click on that and drag it up to that and that'll again mix them with a mix node here and we'll just switch the mixing type here to multiply and I'll increase the factor up to one there now you can see that adds in the weave pattern shadowing on top of our colors for the weave then we can adjust the shadowing using this slider here too so that's good for customizing when we've mindset a little bit lower to 0.85 just for a hint to those shadows that's looking pretty good alright so now I think we're ready to plug this in to the principle node as the base color so let me connect that color to the base color the principled node and a hold control shift and left-click on that to plug that back into the material output and there we go let's check it out it's looking pretty good so far alright so now let's work on the normal map which includes the bands bumping out a little as well as a brushed metal effect on them and we already have the gradients to use for the bands bumping out right here so let's plug this into a bump node to convert it to a normal map so let me press shift an a and from the vector menu yeah we'll add in a bump node drop it right there and for the height value here we're gonna use this wave pattern so I'll plug that color value in as the height value and Alex connect that normal value to the normal value of the principal node and that'll hold control shift and left-click on the principal node to plug that back in alright so it's doing something but it's definitely a little extreme right now so let me turn the strength value down to point two and that's a little bit better but I do feel like it's a little bit too sharp in the middle there's too sharp of a transition there should be more rounded off and I think this is because there's too much contrast in the height map what that we're plugging in so what we can do is we can decrease the range of the height map by lowering the distance value right here so let me lower that down to 0.4 and that looks a lot better that's a lot more rounded off now and we're actually almost done with this now we just need to add in that brushed metal effect on the bands and then give it a clear coat layer we're gonna use noise textures for the brush metal so let's add one in me zoom out and we'll go over where we're gonna go let's go down here let me press shift and a and from the texture menu I'll add in a noise texture and we'll want to use the same UV coordinates for that as well so let's connect the UV coordinates from there over there but I kind of don't want the lines to be intersecting any more nodes anymore so what I'll do is press shift and a and from the layout menu I'll add in a reroute node and I'll plug it in right there now what we can do is click on UV drag that to the reroute node to connect it and now we can connect that reroute node over to the vector socket of the noise texture there there we go so that just helps us organize the layout of all the nodes and the connections and let's add a mapping node for this too to help us out with the scale so let me press shift an a and from the vector menu we'll add in a mapping node and drag it over that line until highlights and then just drop it right there until it connects now let's preview the noise so I'll hold ctrl shift and left click on that to preview it and the noise pattern is way too big so let's change the scale here up to 10 that's got to be too small but let's just use the mapping node now to really dial this in so let me start by changing the Y scale up to 30 and that'll squash it and then we'll change the X scale up to point or down to 0.2 to stretch it out now it's almost looking good but I'm seeing a hint of banding I guess you could call it I'm seeing a darker band of noise there and then a lighter band in the middle and then a darker one there it's faint but I'd rather not have any kind of repeating pattern like that so let's turn the distortion value for the noise up to five and that randomizes it enough that you don't notice any detectable pattern so this is looking like a pretty decent brushed metal effect now now because we have bands going in two directions we'll need the brushed metal effect in two directions as well so let me select both of these and I'm gonna duplicate them and move them down and let's connect UV coordinates to this mapping node as well so I'll click on that reroute node connect it to the vector socket at the top of the mapping node and let's preview this by holding ctrl shift and left clicking on it now we can change the direction of the noise again by just swapping x and y values so let me type in 30 for the x value and point two for the Y value and there we go so now let's mix these two directions together by holding ctrl shift right clicking on that and dragging it up to that and it's going to combine them with a mix node right now it's mixing them 50/50 so we're gonna need to use our original weave pattern mask up here in order to mix the two directions of brushed metal together so let's click on that color output of that checker texture up there drag it down to the mix factor of our mix node there and there we go perfect and as you can see this can also be used for things like making a wooden floor for example there's actually quite a few uses for this kind of mask setup now all that's left to do for this is to mix it in with the band gradients so our band gradients are up here I think yeah right there so we're gonna mix these two together so that we get a better more rich normalmap out of it with a brushed metal effect so let me move the bump map over there I'll select this mix node there press shift and deed to duplicate it and drag it over that line so they connect and now let me connect to this color to the bottom socket there now let's get a preview of this I'll hold ctrl shift and left click on it to preview it and you can see how it's mixing them together but I want them to multiply or I want to the bottom to multiply on top of the gradients so let me switch this to multiply and strike the factor all the way up to 1 and you can see how they're combining now so that's gonna be the new height map that we're converting into a normal map so let's see how that looks in the end I'll hold ctrl shift and left-click on the principle node to plug that back in though the brushed metal effect is obviously a little extreme but we can use the factor value here to turn the brushed metal effect up or down so that's great for customizing I'm gonna turn mine real low 2.03 just for a subtle effect and I think that looks great now the texture is almost complete I just want to add a polished clear coat layer on top of this so let's go over to the principle node and I'll turn clear coat up to 0.5 I also want to get a better preview of this it's not looking that great on just a flat plane with this kind of background so let me first go up into the viewport shading menu here I'll switch the background to the one with the blue sky and the Sun there I think that looks a little bit cooler gives it a little bit of blue - which looks nice and thus I'm reflecting off of the normal map looks really good alright now let's get rid of this plane by pressing X and deleting it and then I'll press shift and a and I'll add in a mesh monkey head we're gonna add the carbon fiber material to this right here now I want it to be more high resolution so to add in a subsurf modifier at level 3 with a hot key you can simply press ctrl + 3 on the number row and now let me right-click and then choose shade smooth for this then we'll go up into the material menu here and give it the carbon fiber material all right now obviously the pattern came out a little bit too big on the monkey head so what I'm gonna do now is add in a master scale control that we can use to change the scale of everything in the node tree so let's go all the way back to the beginning of node tree here now in order to create that master scale control for everything will add in an initial mapping node next to the UV output right here so at the texture coordinate node selected let me press shift and W for the node Wrangler menu and from the add reroutes menu here select two linked outputs that's going to create this extra reroute node but separate the original node away from all of those lines so now we can add in other nodes in the middle of that so that's we're gonna add another mapping node so let me press shift an a and from the vector menu I'll add in a mapping node and drag it over that line there so now we can use these scale values down here to control the texture size of every texture that's connected to it but instead of having to change all three of these values individually we can use a single value node so let me press shift and a and from the input menu I'll add in a value node now let's connect this to the scale value there now this value affects the scale of every texture along the node tree as you can see very cool now after testing it out I found a scale of 25 for this is likely a better and more true-to-life default scale for this texture but since we scale things down now we'll need to make some adjustments because for example you can see the normal map is a little extreme again at this scale so we're gonna need to change that now the first thing we'll do is fix this camera clipping issue over here so we can zoom in a little closer so let me press the end key for the right side toolbar go over to the View tab there now let's change clip start and 2.01 there we go now we can zoom in a little bit closer let's zoom in on one of these bands here now let's go over to the brushed metal mixture here this it yeah this is it let me turn that down to zero so we can work with just the Bands first and you can see how the middle of the bands are really sharp again so let's turn the distance value of the bump node down again I'll turn it down real low this time two point zero two and that smooths out that band real nice and now let's get the brush metal effect back in there so let me turn this up to scribe point zero five about point two zero four all right think that looks pretty good alright and that is actually that's it I think we're done ending kind of snuck up on me there yeah we are done our carbon-fiber shader and it is looking pretty darn sweet so with this shader you can customize the scale of the carbon fiber pattern you can customize the colors the shadowing which you can find right here you can make it a little bit brighter or add some more shadowing to make it darker a little bit more a little grungy or looking like that which is pretty cool you can adjust the brushed metal effect which is cool you can have none or you can have it extreme it's very customizable and very cool and before I also mention the possibility of making a regular checker pattern weave as well and it's quite easy so let me show you how to do that real fast so in order to make things square again instead of rectangular we can change this scale from 0.5 to 1 and we'll change this scale from 0.5 to 1 as well and then we just need to change these divide values back to 1 and there we go now we have a regular square checker pattern but it still has the correct normal Maps and the correct direction for the weaves all right let me undo that and yeah that is it ladies and gentlemen so that's actually going to do it for this step-by-step project this was a lot of fun to make and it used quite a few nodes so I hope you learned a lot from this and enjoyed it too and I'll see you in the next lecture [Music]
Info
Channel: CG Masters
Views: 55,385
Rating: 4.9848914 out of 5
Keywords: 3d, 3d art, blender, modeling, 3d modeling, texturing, texture, animating, animation, rendering, compositing, cycles, pbr, raytracing, cg, cg masters, tutorial, tutorials, training, learn, how to, blender 2.8, blender 2.9
Id: 1qh2J4oQzy0
Channel Id: undefined
Length: 26min 16sec (1576 seconds)
Published: Fri Apr 24 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.