Procedural Bricks with Blender 2.9 - Blender Shader Node Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to another procedural texturing tutorial in this one we're going to be tackling this procedural brick setup where we have some various rotation some random color a little bit of rake lines and some cracks and also the ability to put in an image the background to create this brick variation we are working in blender 2.9 today and just before we get started make sure that you have got the node wrangler add-on enabled this is going to save you a lot of time i've got my procedural texturing workspace setup here i have a 3d viewport i'll be working on a plane today i have an image uv editor underneath and my shader workspace the setup for this material is quite simple we're going to be using a uv map because we want to be able to push this texture around on a wall after this add a converter vector math set this up to scale and this is going to give you the control of how many bricks we're going to be able to see we're going to be adding a converter separate xyz basically what we need to do is we need every other row to be offset from one another so if you have re-rows of bricks like this you want your bricks to sort of span the gap of every other row if i was to just take a another vector map here set to modulo and bricks three times wider than they are high generally so i'm gonna go three in x and one in y you can see that all of these bricks have the same point where they divide in between the same mortar lines what we want is for every other row to be shifted one direction or other the easiest way to do this is to take our y here so this is going up and if we want every other row so we're going to take a math node set to modulo modulate it two and then i'm just going to say less than one what this has done is it's given us a mask for every alternate row and then i can add this to my x coordinates if i take a modulo in the x i set this to three right this is the width of our bricks you can see that each brick starts in the same place but if i were to add this new row mask to that then we're getting some offset now we're only offsetting by a unit of one at the moment if our bricks were too wide then this would be perfect this would be halfway but because we're working at three you can see that we need this less than to be increased this is outputting zeros and ones i'm going to increase this to be outputting 1.5 and you can see as i change this it's offsetting any row which is white so what we need to do we're not actually going to be using this math node modulo we're going to be using a vector map i'm going to add a converter back to math and rather than just plugging this in we obviously only want this to go into our x so i'm going to plug it in like this and we're going to take our original y put that into the y back this has given us a essentially a uv space per brick and what i'm going to do is i'm going to pull this vector out i'm going to duplicate our combination set this to three and one so this is our brick size right this vector here so having it like this is going to let us use it in other regions next thing i want to do we've got the uv per brick going to create a random valley pop right now so wherever we have a modulo and we're outputting this kind of whole tile shape in whatever texture you're making what you can do is you can essentially take the same inputs so this is the reason we've got this here ctrl shift d on this modulo and i can set this to be snap now you can see that we have snapped values in the same locations as our uvs supposed to take a texture white noise and plug that onto there then we're getting a random color per tile and this is 4d so we have a seed value we're going to be tackling rotating the bricks in the axis that we look at them right so this is kind of a stylized decision but we're going to be rotating them clockwise or anti-clockwise so in real life a brick in a wall is not going to rotate in this direction it's only going to be rotating sort of out of the wall or into the wall but we're doing these kind of stylized bricks and i think it looks quite good so what i'm going to do is i'm going to center the uv space here i'm going to add a vector math subtract what i need to do is i need to subtract half of the size of the brick because we might want to change the size of the bricks later i'm going to add another vector math in here set to scale and set this to be 0.5 that's going to plug in there so now whatever size we make our bricks we always have a central position on here we are then going to take a vector vector rotate and we're going to change the axis from axis angle to z axis i know you can play with the center here but for what we want to do with the size of the bricks we did want to center this so i'm just going to be leaving the center as zero and the angle we're gonna take the value and plug it in there right now what's happening is it's rotating by between 0 and 1 radians so 360 degrees is 2 pi radians which is around about 6.3 what we can say is that if we have between 0 and 1 then this is around about a 6 of a circle maximum rotation and it's rotating clockwise because they're all above zero we want things to rotate only slightly and also both left and right we're gonna add a converter map range to this value from zero to one is gonna become from minus point one to point one so it's only very subtle what we actually want but you can see as i change that seed value we're getting some brick rotation you can always make this more extreme i'm also going to want a slider to say that we don't want any randomness or we want some amount of the randomness so i'm going to add a color mix rgb leave this as mixed we're going to plug our map range into the bottom of it and we're going to set the first value to be black so now with our factor at 1 this is fully random and at zero everything goes back to being straight we're going to take our rotated brick collectors here and we're going to actually create the brakes for us to do this we're going to add a converter back to math set that to absolute so this is giving us a nice even space what absolute does is it ignores the sign so if something isn't negative it just pretends that it's positive what we can then do is add another vector math gonna set this to be subtract i'm gonna plug the brick size the half size of that brick size it's gonna go into the first socket of our vector map here and the absolute goes into the bottom so what this has done is it's basically said on each axis it's going to add a separate xyz so on each axis where it reaches the outside of the brick we have a zero value there so i have my x and my y i would like to add a converter math node take my x and my y and plug them both in set this to smooth minimum and now you can see we've got a bit of a brick shape and this smooth minimum basically means that we can round the corners of the bricks if i just turn off this randomness see that we have some control there obviously not for every pattern of bricks but for some you may want to round off the corners of your bricks first to control the mortar size i'm going to add a color mix rgb and i'm going to set this to color burn then we want to make sure we have a flat top on our bricks so i'm going to add another one set this to be color dodge make sure that the second color for this one is white and this is going to give us that control over the depth of that profile there last thing for us to do on this is just to make sure that we have a mask that we can use for changing the material on the mortar i'm going to add a converter math to this to be greater than any time that it's zero we've got mortar any time it's one we get brick so i'm just going to load up a picture really quick here this diagram shows a few different bricklaying patterns we have this one currently where we have our bricks where every other row is offset by half a bricks width however you get a lot of patterns like this where we have a row here that is end on these are called headers and you can have them every other row or a number of rows spaced apart you would always have an odd number of bricks in between them though so it would either be like one row in between or three or five and we want to have that control here so at the moment we've only got every other brick row being half offset we want to basically say that every fourth if you have three in between or sixth if you have five in between is going to be half width breaks so the brick size we're gonna need to be able to input something here so that's another reason that we need this combined xyz for us to control one and three or one in five or whatever we need to do the same thing that we did here right modulo and then less than in this case we were using it to create every other if i do ctrl shift d on here if i were to say every five and you can see that we've got four spaced here we always need this to be an even number so that we have an odd number of bricks in between so i'm just going to make sure that we have a controller for that so i'm going to add a value node here this is going to be our header spacing i'm then going to add a math node set the snap i'm snapping at 2 so every time this reaches 2 see we have 2 there and then four and six and so on the bricks in the black area they need to be three wide which is our existing brick scale and the bricks in the other areas in the white areas these need to be 1.5 which is the header width for us to do this very simply just add a color mix rgb this factor goes into the first one and we're going to add two values here so using these mixed nodes as number mixes that's another option that you have so i'm going to set this up like this so in the white sections which are our headers put 1.5 in the bottom and we can put 3 in the top which is our existing brick width so just plug that straight on up into our brick size now it's going to view this modulo we're getting this control to be able to basically shift the bricks however you can also see that we've got overlapping multi-lines and we don't want that we want where we have the narrow headers here we want these to be offset by half the width of a header this multiply is what controls the position of all of these bricks right but we want it to be 1.5 for these ones and we only want it to be 0.75 because we're going for half for us to do this we're just going to take a math node here so to divide plug this into the top so we're dividing this by two plugging that into there and then bam that's exactly what we need we've got none of our multi lines overlapping each other nice and simple when we get below two every row becomes a header and that's not what we want what we want is for this to become no headers so we need whenever this snaps to zero we need this output here instead of it being white we need it to just be zero so i'm just going to add another mix in here when this snaps to zero i want this to be zero and then any time it's above zero we're going to pick the second color which is our mask so below two we've got all of our normal width and then above you see we're starting to add these headers great so that is the layout for our bricks we can just quickly add some color here don't add a mix rgb this is going to be the factor this multi mask and the first socket is our mortar so i'm going to go for a slightly darker gray and the second one is our brick color i'm going to go something like that what's going to go into cycles here because we're gonna start doing displacement add a modifier subdiv simple adaptive you can control how much viewport dicing you have here by default this is set to eight pixels however if your computer can handle it you can drop this down to one or two just to make sure that you've got that really sharp crisp edge in our material as well we just need to go to options settings change from bump only to displacement and bump at the moment we are looking through a viewer which essentially makes this shadeless i would like to have some shadow on it so i'm going to go plug this into the principal bsdf i can press alt and right click to get a quick connection which is a node wrangler feature darkness at the moment so i'm just going to change from the scene world to one of the studio lights i'm going to use this one that i got off hdri haven also because it's brick wall i'm going to rotate this into standing and i'm just going to rotate the world a little bit so we've got some shadows in the right place to add displacement we go vector displacement take the profile depth into the height we're going to take the displacement into the displacement there so for this i'm going to make the mid level to be one which is the front face of the brick and i'm going to reduce the scale to 0.02 let's just play with a few settings really quickly here so my multi-line is obviously much too wide i'm just going to reduce those a little bit and i also want to have some of that random rotation with this set to 0.2 much too high so i'm just going to reduce that to 0.1 and i'm going to pull this down a little bit we're starting to get a few little bits of shadow coming down here but we also want to have bricks that are sort of rotating out this way for us to get that we need to add another gradient to our displacement very easy for us to do so we've got our vector rotation here which is giving us a uv space right take a separate xyz i'm going to drop down here we're just going to take the x value here so what this is going to let us do is essentially rotate out of the wall we need this rotation to be random we don't want every brick to be rotated further out on the right hand side let me show you what that would look like the color makes rgb set this to be add and we're just going to plug our x into the bottom up here into our principled view and you can see that every brick rotates the same direction the same amount obviously doesn't look so good however we do have a white noise texture here and we also have a color output from this white noise texture so if i add a converter separate rgb you can see that the value socket is the same as the red channel from this separate rgb and we've already used the value i want a different white noise if i take the green or the blue you can see that we have different noise patterns here if we have a random value between zero and one we need that to be between a negative and a positive so if i just take the we're gonna do with the blue channel just to keep our noodles neat gonna take a math node and we're gonna subtract 0.5 so we've gone from having a range of zero to one to a range of negative 0.5 to positive point five and we can then multiply this by that x gradient so this is giving us different rotations for different breaks we have a look at this you can see that we now have some bricks that are rotating out this way and others which are rotating out that way we also have this slider which is gonna let us control that one thing that you will notice is that if we zoom in here that displacement is also affecting the motor and we don't want it to we just want it to affect the brake so we need to use our mortar mask here right so if i were to just plug the motor mask straight into the factor then it does fix it but we no longer have control over the amount of that rotation so for us to add that control we're going to add a mix node here mix rgb plug the multiply that we had into the bottom set color one to be black and now you can see that we have this factor controlling the amount of rotation we want to do some more interesting things with the color quite simple for us to do we can just take another mix here and this is going to control the brick color not the more color that's still its own thing just going to drag the brick color into socket one here i'm going to take the color from the white noise and plug it into here an easy way for us to do this while not having to zoom in ctrl shift right click with node wrangler enabled it's going to give you this like blue connector and this is going to let us choose from color into color 2. we don't want this to be mixed we want it to be multiply and this is just giving us very easily a little bit of variation across the bricks here after this multiply we're going to add a mix right and we're going to pick a kind of a brighter color for these other bricks you often see this where a building has a repair in the wall and the bricks that have been used kind of don't match the context that's basically what we're doing here and also i'm just going to remove the shine from these bricks on that principled node where we put the bricks depends on this factor on this mixed node if i was to take a noise texture and if i just use uv coordinates if i put this to a greater lens that we have either or then i plug that into the mix you can see that we're not restricting the noise temperature to be like per brick for us to do this we are going to have to use this snap the snap is giving us an individual unique coordinate per brick and then plug this instead into this texture then see that we need to reduce the scale so now i can play with this uh this greater than here if you go even smaller might set this to be 4d we would also want this output to stop if it's new repair you're not going to have these displacement variations and you're also not going to have the rotational variations which is this mix i want an output of zero on both of these wherever we have this output if i just add a subtract here to plug this into the bottom this great then goes into the bottom and we're subtracting it from one that's basically going to invert that we can take this and plug it into the random rotation and i can plug it into this random displacement so now if i go back to this principle you can see that we've got sort of straight bricks where it's been repaired versus the jaunty bricks everywhere else you also change the value in the subtract node and that's going to give you some variation as well something that i'm noticing is that on the bricks that are going in we have this issue where you have a brick that's rotated in past the edge of the concrete basically i'm going to add a little bit onto here just to make sure that we are not cutting in here i also want to fine-tune this profile shape one around it basically one way that we can do this is with a an rgb curve or the quickest easiest way for us to do it on this profile i'm going to add a another mix rgb and i'm going to send it to the soft light white in the second color i'm going to set that factor to be one so now you can see that we're getting a nice graceful round on that corner we're just going to dress the surface up a little bit a lot of times you see bricks that have a rake pattern on the front face this is nice and easy for us to do we're not going to do it with displacement we're going to do it with a bump map so we're going to unhide the rest of that principled node this back to rotate i'm going to take the output from here into a wave texture if i zoom in here we want it to be in the y axis at the moment we have it evenly going like this we're just going to put a color dodge on here color dodge set this to white it's going to let us cinch in that edge we can also add a little bit of variation here so i'm going to increase the distortion for what we want around about three i'm going to set the detail scale up to something like that this is just giving us a natural rake pattern tracking across the surface we only want this pattern to be on the front face this is very easy again to do basically we take the soft light here we can just take this as a mix factor put this in here put the rake lines into the place where it's one and if i set the color one to be white then it fades off so all of these will be the same depth let's just group these together ctrl j i'm gonna call these rake lines which i'm just going to take a vector bump plug these into the height take this into the normal of our principal node nice that's looking pretty good drop this right down to like point 1.1 and i'm going to increase the scale of this that's just giving us a little bit of extra detail on the surface i'm also going to add some cracks as if these brakes have been weathered so once again we're going to be taking the vector output from our rotation and we're just going to be plugging this straight into a texture voronoi texture right so from here into a voronoi and we're going to be changing this from f1 to distance to edge if i just reduce the scale as well so straight away what we see is we have a repeated pattern every brick is identical so i'd like to be able to take a random value and offset each foreign temperature per brick a different amount obviously we have a random value right here so i'm going to take a converter vector math plug this on here as an add and take the green channel up into that vector input so it's slightly better but you can see that we still have largely the same i'm actually going to change this over to 2d as well so that we get a more even spacing we're using uv maps so we don't need the z anyway just to increase the random distance that these are being pushed at the moment it's between 0 and 1. obviously i have brexit three across i'm just going to multiply this by an arbitrarily large number we want to distribute it a little bit better not every break needs to be completely cracked up if we take our random value here take this multiply node ctrl shift d set this to be greater than and now we have a random value per brick giving us a random distribution so i'm gonna just mix these up to white i can then also make sure that our cracks are a little bit narrower with a color dodge also set to white as you can see this is uh essentially cinching in the edge of those cracks we've got these really straight lines an easy way for us to do this is taking another mix rgb put this onto the vector set it from mix to be linear light and then we're going to take a texture and noise texture again just taking this from the same factor that we're using for the voronoi plug that into the bottom here gonna set the scale of this down to about one right just match the voronoi that's usually a good rule we're going to increase the detail on here slightly uh four or three should be fine and then we can play with the linear light to give us a little bit of control there now i also want to have a little bit more interruption on these cracks so i might just start by going slightly smaller on this foreign texture just to space it out a little bit i'm going to take a converted color ramp take the factor output here this is going to give us a good bit of control and choose exactly where we want to put these i'm just going to take this set it to screen take the color you could think of screen as being the inverse of multiply so when you multiply something by zero and one everywhere that you are multiplying by zero becomes zero right whereas with screen everything that you screen by one becomes one and zeros are ignored it takes both inputs inverts them multiplies them together and then inverts it to the output we can use it here to break up some of these cracks a little bit we don't want the crack map to end up with loads of dark spots because this is going to be displaced inward and so i'm just going to select all of these ctrl j we name this to be cracks how do we combine this with our existing height map because we've got it as being white with black cracks we can just take a mix rgb set it to multiply and take our screen output into the bottom here now you can see that we've got all of these cracks they're really wide at the moment so i'm going to also increase this color dodge i'm just holding shift there while i click on that and i'm going to reduce this multiply just to make sure those cracks aren't super deep one thing that i want to avoid is these rake lines that are on the surface the rake lines were made when the brick was made they shouldn't be in these cracks if we have a look at these i basically need to make wherever there is a crack to be white so i'm going to take a converter map look at how it cracks here and if i say anywhere that is less than one this is where there is a crack below the surface and now i need to make these areas to be white on this map we've just seen how to do that with the screen so we're gonna add another one color mix rgb set this to screen plug this in set that to be one now you can see that we do not have any of the break lines inside you might want to just reduce this slightly to give it the illusion that those brake lines are actually cutting into the surface i'm just going to tighten up those cracks again i think perhaps i would not like to have cracks on the new bricks again for us to do this we just need to take wherever it's black i think is where the cracks are i need to make sure that anywhere that there is a white brick on our color output here i need to make sure that is also white on this great event so we could use screen or a different tactic is to use an add node so anywhere that you have white and one and y on the other you're going to end up with two but in terms of our mix that doesn't matter because we're just using as a mix factor and mix factors only consider something that is between zero and one so you can see that now we have this whole area where the pattern was that is now completely clear of cracks what we're going to do now really quickly is we're just going to map a texture onto here i have the blender icon here i'm just going to drag that in so we've got our blender icon mapped on here i need this to be a mask between 0 and 1 so greater than zero there we go this is giving us just the blender logo being the white region and once again we're going to take the same idea of subtracting from one that's going to give us the inverted mask for the displacement items that need it in the opposite direction so first of all let's just increase the scale of our texture i'm going to add a value here because we're going to plug this into a couple of things like that in here set this to 50 for now we need this to just like how we did with the noise texture follow the actual bricks plug that down here this snap value goes from 0 to 50. it's taking this scale value into a cap first to reverse that we need to take this snap change it to divide if i zoom out here shift alt right click give me the blue one so we're going from value into vector so you can see if we view this one this is being remapped to that zero to one range we have our blender icon perfectly mapped i am actually just going to make it slightly smaller it's going to add a vector mapping node i just want this to be a little bit more kind of centered with bricks around and i'm going to change the interpolation here from repeated to extend so that we get black on the edges i'll show you something actually if i go into ev here right in the material preview you might have seen this happen where you have a tile texture and you've got these pixel lines these show up in the render these are not okay what you've got to do is you've got to change it from linear on your image any other one gets rid of those i always go for cubic because i feel like it's the most accurate one that is uh probably a little bit cheaper than smart if you're working with the eevee obviously for this where you've got displacement you can't but other things that is how you get around that issue of having the pixel lines we want to have a look at our color output here and instead of using the noise texture as the factor we're going to use blender and instead of using the noise texture to control this y rotation we're going to take the subtract from here into the factor there so there you go that's on that y rotation section as well now we're taking the greater than and we're plugging that into yeah this is the crack section we don't want any cracks on the new bricks i'm also going to put it into this mix here and that comes from this subtract so that's controlling how much z rotation hammer rotation in this direction on the wall that you have so let's look back at our principle node now we have these kind of cracked bricks all of the red ones that have random rotation these are in the background and we have our blender logo quickly modeled in new bricks so you want to change the resolution of this that is just on this one original scale set this to be five or something you get this at a 200 and you'll get this let me show you an issue when we set this to 200 the scale of the bricks it's just totally out of whack right the displacement we need to fix it this is our displacement node here and this is our scale so again shift alt right click over to the displacement layer and we are going to the scale we need not the scale directly but we need the reciprocal which is something divided by the scale just a math note change it to divide and i'm going to change this to 0.2 or something right so it looks good from up close when we have this really high scale we set this to 5 you can see that this is still in proportion to our brick scale perfect that's exactly what we want last thing if you wanted to make this kind of zoom in zoom out effect that is just changing the scale by the frame rate so if i do shift right click that's going to create a reroute here go input value look that in here could have just used that original scale but i just want to keep it separate so change this to hashtag frame if i play you can see that this increases and the scale as the frame increases a little bit too fast for me so divide by five a little bit laggy because it's working in cycles right now but you can see that that's sort of resolving nicely there divide this by three instead go over to evie blender logo made in bricks before we finish i just wanted to mention this chord me and sharon from just 3d things we both run the aarondale the xyz discord link for that in the description we've got a lot of really great shader artists and procedural modelers in here we focus on proceduralism even when i'm recording this gabe is streaming right now looks like he's doing some vector displacement he got live streams we've got two a week plus a guest potentially each week as well so that's me and sharon over the weekend we also have the blender royale run by stephen scott that's on a monday evening and then we also have weekly challenges like this just generally people a lot of people we just passed 500 members so that's really cool uh if you want any help with procedural stuff it's a really great place to ask people and get some feedback on your work as well link to the discord down in the description i've gone ahead and cleaned up this note tree a little bit give it some re-roots make it a little bit more readable with frames and colors starting to get into being a complex shader if you want to check against the high-res version of the notes then you can look down the description there'll be a screenshot there if you would like this file in its entirety i have uploaded it to patreon for patreon followers i feel like it's better to make your own things in terms of learning but if you want it it's that that's it for me today i hope you enjoyed it hope you learned something and i'll catch you next time
Info
Channel: Erindale
Views: 52,631
Rating: undefined out of 5
Keywords: blender, shader nodes, shading, beginner, procedural, material, nodes, shader editor, introduction, tutorial, eevee displacement map, eevee displacement node, blender pbr tutorial, blender pbr textures, blender pbr textures free, pbr textures in blender 2.9, vfx school online, blender tutorial, blender eevee, blender enviornment, blender easy, blender easy tutorial, blender cycles, intro to blender, blender 3d, b3d, learn, free, concept art, parametric, computational, design, brick, wall, 2.8
Id: XW-DrBQ-u1o
Channel Id: undefined
Length: 25min 41sec (1541 seconds)
Published: Fri Sep 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.