Fire with Shader Nodes, The Procedural Way || Blender 2.92

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Applause] so in this one i'll explain how to make this fire shader right here that works on a flat plane but you can also use it for volumetrics or an array of plans to fake a volumetric effect for those of you who don't want to go through the trouble of making this yourself or you just want it set up in a nice clean way you can grab these shaders for a few bucks over on gumroad as well as some of my other stuff like my glitch pack that will go up in price soon once i update it i have a bunch of free wallpapers over there too all right enough ads let's get started so for this one i'm in blender 2.91 and we're going to start off by just going into the shading tab right here because most of this is going to be using nodes and i don't really need to see any of the camera or the lights or anything so i'm just going to hide those for now and it's also worth mentioning that i'm using node wrangler add-on for this so if you want to use that go to edit preferences and under add-ons just type in node wrangler and make sure that this is checked right here it's a built-in by default you just have to enable it so to get started i'm just going to add in a plane and i'm going to rotate it on the x by 90 degrees right there and then i'm going to control a to apply the rotation and i'm just going to zoom in on that and just look at it straight on like this and add a new material and i'm going to get rid of this principled setup and instead i'm going to add in a mix shader and the two shaders that we're going to use for this are the transparent shader and i'll just plug that into the first one and the emission shader and i'll plug that into a second slot right there and the factor right here is basically just saying um when it's zero it's choosing the first shader and when it's one it's choosing the second you can see right now that when it's set to be using the transparent shader this isn't transparent and that's because we're using ev right now and so we have to turn transparency on for shaders so over here in this window you can just hit n to open the side panel and go to options and change blend mode from opaque to alpha blend and now you can see it's working also i'm also going to turn the shadow mode from opaque to none because fire doesn't have a shadow um you can also access these settings when you have your object selected there's this material properties right here and you can access the settings over here it has the same options so most of what we're going to be doing is altering this factor right here um to switch between transparent and the emissive shader so i'm just going to add in a gradient texture and you can plug that directly into the factor and you can already see um right here is transparent and over here is opaque so i'm just going to change this from linear to spherical so we get this like circular gradient but we want it to be in the middle so i'm going to click on the gradient and hit control t and with the node wrangler install it'll add the texture coordinate and mapping i'm just going to control x on the mapping to get rid of that and we're going to switch this from generated texture coordinate to the object right here and you can see it'll move to the middle now and that's because object just uses the origin point as like the zero spot and by default the origin point is in the middle of the plane if we go into edit mode and move it around um that doesn't move the origin point so you can see this is just a cross section of a sphere right now and if you want to like move the origin point without actually selecting it and moving it you can just go into edit mode and shift this up and down all right so next i am going to add in a vector math node right here i'm just going to change this to scale and that way we can change the size of this if we want to by default it's just going to reach the edges right here and we're basically just going to like use this for the texture coordinate for all of the other textures we're adding in that way when we scale it all of them change scale first thing i'm going to do is start distorting this so i'm going to add in a noise texture if you saw my last tutorial it was actually about making node groups that do this for you a lot easier more easily so i'm going to do this part pretty quickly if you want a more in-depth explanation of why i'm doing what i'm doing just watch the last video i'll link it up above over here so i'm going to add in a noise texture and another vector math node right here you can just leave that set to add we're going to plug the scale into the first one noise into the second one we're going to take the scale right here and use that for the vector which is just the object texture coordinate then i'm going to add in a math node and i'm going to duplicate that and add a second one so the first one we're going to change to subtract by 0.5 this is basically just changing the midpoint of this texture from 0.5 to zero um that way when we change the second one to multiply this doesn't shift around too much if this is set to zero you'll see it it shifts around and then i'm going to add in a combine xyz and i'm just going to switch this to z because we only want it to be distorting on the z-axis right here so the multiply you can use for the distortion strength now so i'm just going to turn that to something like 1.5 and i'm also going to change the scale to 3 the detail just all the way down and that's it for now you can see this is already distorting quite a bit but i don't necessarily want it to be distorting on the bottom so much so we'll get to that but for now i am going to show you how to animate this texture we're just going to add in another vector math node and if we use the add and change the z value right here you can see it's moving the noise texture up and down and it's already like starting to have like a decent fire animation and this add node right here is basically like using a mapping node and just changing the z location it'll it actually does like the exact same thing it's just it gives you fewer options so it's a little neater that's why i like to use it and then i'm going to show you how to animate this what we are going to use is i'm just going to use a value node for this and i'm gonna type in hash and frame and that's basically just going to give you the value of the frame you're on so you can see we're on frame one and when i change this it changes that so you hit play and this will just start moving that way you don't have to like insert keyframes and stuff and so we can just plug this directly into here and hit play and it just moves all over the place so this is way too fast and it's also moving on the x y and z and we only want it on the z so first i'll separate that with a combine xyz you can plug that in here and you just want to plug this just into the z it's hard to tell because it's going really fast still so to slow it down you just add a math node right here and you want to change this to divide and basically the higher this value the slower it'll go so i'll just set it something pretty high and this is positive right now and it's going down instead of up so we can just make this negative so i'll make it negative 30 and you can see it's going up now and if you want this to get faster just make this like a i guess a value closer to zero so i'll just make this like negative 15 for now to make this a little neater i'm actually going to group some of these nodes like i did in my previous video so just select all of these right here from the combine xyz to the add and you can just hit ctrl g and this will group them all together so when you exit with tab this is what we're looking at right now and if you want more options on the outside you can come in with tab and hit n and go up to node right here and it'll give you more options so we don't need two vectors because you know these are using the same vector so i'm just going to plug this one into here delete the first one and so we have the z right here that's i'll just name that to z translate and plug the next one into the multiply and that's going to be our strength i'm also going to change this from 3d to 40 so we have this w value it kind of like randomizes the texture a little and i'm just gonna grab all of these also so we can change those from the outside and then i'm going to exit and if you want you can rename all of these things when you're out here just uh go to the item tab i'll just name this distortion for now for the name the label and this field right here too and now you can just control everything from the outside and everything looks a lot neater also don't forget to save i'll save mine right now next we're going to change which part of the circle we're actually going to distort and which parts are unchanged so to do that i am actually going to grab a separate xyz make sure we plug in the object texture coordinate and if we ctrl shift click on this we can preview these so we're going to use the z coordinates for this one basically what we're going to do is plug this into our strength field right here and it's going to control how much it's distorting so usually when you see black that's a value of zero and when you see white that's a value of one but in this case zero is right here and you can't really tell by looking but the further you go down we're getting to getting into negative values and in the same way the further we go up we're getting into numbers that are higher than one so we need to add in a clamp node and basically what that is doing is making all negative values go to the minimum value right here and the same with the max so this only goes from zero to one now which is what we want so i'll just plug that into strength right here and then we'll preview it and you can see that's already basically doing what we want and you can see if i just hover over this and hit m that'll mute it so it's like not working you can see that when i'm not clamping it the middle is not distorting but it starts distorting the more you go downward and that's because of the negative values that i was talking about so you need this clamp node right here or else it's not really going to work the way you want it to and also i want it to distort a little lower so to do that i'm just going to add in another vector math node right here this is basically just moving this texture up and down with the z value right here so that's how we can alter how much is being distorted so when we preview this again you can choose like where you want it to to be distorting like that so that looks pretty good and if you want this to be stronger like more distortion instead of maxing out at one because before it was set to 1.5 right there you can either change this maximum value or what i like to do instead is add another math node and set that to multiply and you can just use this for your for your strength value so i'm going to reset that to 1.5 and that's what we have right now i'm also going to add more distortion like a second layer of distortion by just copying this duplicating it and putting it right after i did this in my previous video also and once again so this is not distorting the bottom we can just plug this in to the z strength for the second one and that'll fix up the bottom so this one i have set to a scale of three the second one i'm going to set to a scale of one and if you want these to be more pointy instead of blobby you can just like turn the distortion of one of these up if you turn it up too high it starts to look not really like fire anymore so i think one or lower looks pretty good i'm just going to set mine to 0.5 and then you can also plug in the z translate for both of them so they're both animated and i think that just adds a little more complexity to the shape of the fire if this looks too rigid like going up you can also animate the w value to get some some more randomness in there but if you do that i recommend creating a second divide node right here so you can set a different value so let's see when i plug this in and for this i'm just going to remove the translate so we can see just exactly how fast only the w is moving and that's moving pretty fast so i think negative 50 is is enough and then we can just plug the translate back in and don't forget to save so this isn't necessary but it adds a little randomness and i like that so if you don't like how circular this is you want it to be like taller fire i'll show you how to change that right now basically what we're going to do is change the shape of our gradient texture right here this circle to do that i'm going to add in a curve specifically the vector curve right here i'm just going to plug in our scale node right here directly into the vector and we're just going to replace that for now so we only see the circle so with this node we can distort our texture but on you know specifically the x y and z coordinates like separately so yeah you can click on these little dots here and move them around either by clicking or dragging but when you click and drag you don't like see it update in real time so i like to click on it and then use these so you can actually see what it's doing so you can see this is like squashing on the x-axis this one will be on the y so it's like towards and away from you it's it's harder to visualize because we're just using a plane for this and to reset this um you can just select it hover over it and hit backspace and that'll reset everything what we want to affect is the z right here so you can see when i select one of these and move it up and down it's actually like elongating it we're gonna make this more egg shaped so to do that i'm gonna click in the center i'm just going to change this back to 0 so it's dead center and i'm just going to update the top point right here i'm just going to pull it down on the y axis and you can see it's pulling it up and making this more egg shaped and if this is going off your plane you can just turn the scale down so i'm going to turn this down a little lower so you can make this whatever whatever shape you want um if you go too far to the point where this is like flattening out it's just going to go up kind of like infinitely tall so i'm only gonna change this very slightly and if you think the bottom is too round you can also select the bottom point right here and just uh you know pull that inward like that be subtle with it so i'm gonna do it like that and then we can plug the distortion back in to see what that is looking like now and i'll just hit play you can see it's distorting the bottom quite a bit so once again if you want to change where it's distorting you just want to update this value right here to something a little smaller you can see if i turn it down too much it's not distorting at all so you can just slide that along until you get something that you like i think around 0.65 is looking good for me and if you don't like how much space is at the bottom once again you can move the origin point so um the easiest way to do that is to select your plane go into edit mode and then lift this up i don't want to do that though i kind of like everything being in the center so i'm just going to make this smaller and then if you wanted it to be you know bigger you just make your plane bigger scale it up okay next i'm going to talk about color so basically to color it we're just going to change the color of the emission right here so you can see if we just change the color field it's it's changing the color you can also change the strength i'm going to turn mine up to 5. when you're using ev it'll add some bloom for you as long as you have bloom turned on right here but we don't want this to be one solid color we want it to be the color of fire which is a few different colors so basically what i'm going to do is um plug the gradient texture right here into the color you can see it's already a little more interesting but it's just black and white it's just using black and white values so i'm gonna throw a color ramp in here and then we can change the the colors of the flags in here and add whatever colors we want so for the outside which is black right now i'm just going to change that to something like a red color like that and then i'm going to add a second one in the middle or third one i guess and i'm gonna change that to um closer to yellow and instead of using linear right here i'm gonna change this to b spline and it's gonna just make it a little smoother i think it looks better that way and then you can just move these flags around until you get something that you like so if we pull this in you can see it's like creating this like red band on the outside so i want to keep it subtle and only pull it in like very slightly and i'm also going to change this white right here to yellow but i'm going to make it pretty pale like maybe like point around point two i think is okay and you can just like mess with these until you get values that you like so i think this looks pretty good something like that and if you want this to be smoother right now it's like kind of sharp on the outside you can also add in another color ramp um just hit backspace to reset it put it right here and you can change this from uh like linear to ease and and it'll make a little it'll make it a little smoother for you but i'm just going to keep mine set to linear for now which is what it is by default when you don't put anything in here all right so this is what we have right now and i think that's looking pretty good but if you want to go the extra mile you can add some sparks in here so i'm going to show you how to do that really quick it's actually not too hard so to do that i'm actually going to add in another mix shader right after our first one right here so i'm going to add in a mix shader and basically this factor now is switching between um this shader right here like the one we were working with before and the second one will be whatever we put here so i'm going to put another emission plug that in and i'm just going to turn this back to zero for now and for the spark texture i'm just going to use a voronoi texture and plug the distance into the factor make sure you plug the texture coordinate into the vector it's all the way back here shift and right click to add a reroute new node to add this like reroute over here to make it a little cleaner and i think this is inverted right now so we just have to switch these shader slots right here and this is starting to look a little better but i want these to be smaller so i'm going to add in a map range node and i'm just going to turn the from max down to something smaller like .1 and you can see we just have a bunch of little dots now but when we hit play they're not moving and also they're like all over the place we don't really need sparks below our fire we want it just where the fire is so telling the sparks where to be is actually not too hard we're going to add in a mix rgb and we're just gonna plug it in over here so right now the map range is plugged into color one and you can see uh when we change this to white all the way um that'll just be transparent so i'm going to do that for color 1 also and we're going to plug a mask into the factor right here and for that we're just going to reuse this gradient texture so we're just going to reuse this gradient texture and we want to plug in our texture coordinate into the vector so it's the right size and all that and we're just going to plug the factor of the gradient into the factor of the mix rgb i also want to turn the strength of this up to something like 10 so it's a little higher you can see now that there are only sparks inside our fire so this is working so far it's masking it it's just we want the sparks to go higher than our fire too so you know how we changed the shape of our sphere before we're just going to do that again and since we duplicated it we can just preview with a control shift click we can just alter this a little more by like pulling this top point down to make it taller like that now when we preview it you see that it's actually going up a little more but it's still not animating so we have to do that next so to do that is also pretty easy we can do it the same way that we animated our noise textures before except we're going to animate our voronoi texture with a vector math node set to add and we're just going to animate the z value like that so we want this to go down also so we can just plug in one of these nodes down here but before we do that we just have to add in a combine xyz and make sure to only plug it into the z value like that this is getting a little messy so if you need to add reroute nodes you can do that with shift and right click drag and then you can just move these little things around with uh g when they're selected so you can see that's looking pretty good now actually and if you want this to have its own dedicated speed you just need to make a different uh divide node and just you know you could set it up over here and then just like plug the frame value up over into it so it has its own dedicated speed now and i think this is looking pretty good but i want them to like wave around a little more and just be a little more random looking and so to do that we can actually just reuse this distortion node that we made i'm just going to duplicate that and drag it um before this ad right here so we're distorting the texture and right now it's looking a little wonky because it's trying to distort it on the z axis but i want it to go side to side like this and that would be the x-axis so if you tab in here and change stuff around it's going to change these other three or these other two because they're all linked right now you can see that they're all linked because there's this three right here that means we have three nodes um and they're all linked so if you want this to not change the other values when you edit stuff inside you just have to click this button right here and that'll make it single user you can see it says .001 now that means when we go inside here and change things around it's not going to affect our other nodes so basically what i'm doing now is just coming in here and switching all of the z's to x's so it only distorts on the x-axis so we just have to change it in that spot and also right here and if you want to keep this neat you can hit n change this from z to x just to keep it consistent like that now when we change the strength you can see it's pushing it on the x but i want this to be a little smaller i'm going to set it to something like 0.5 and now we can look at the strength and that's looking all right you can see now it looks like they're kind of wavy and if you want the texture to to change so that this isn't always wavy in the same spot in particular you can animate the w or like the translate so i'll just do that with this node right here negative 50 so this should be slower and i'll just plug that into the x translate right there and now it'll animate that that texture too don't forget to save i think this is looking pretty cool and once again if you don't like where the sparks are coming from or going you you just have to change this right here so if you wanted to be flatter bring this in a little more like that or if you want this to not go off the edge you just want to move this up a little more like that and they'll they'll just fade out after a while i'm just going to scale this a little so you can see this goes up pretty high now all right so i mean that's pretty much it that's this is all we've done it might look like a tangled mess but when you separate each component it's actually not that bad and if you really wanted to you could make this like easily editable by just like grouping everything like this ctrl g and now this is what everything looks like you just want to you know go in here and make sure you're plugging all of the inputs in that you want to change so we could plug in like the scale and stuff like that i'm not going to go through making like a dedicated group for this but if you wanted to make it easily reusable i would recommend doing that so because we built this using like 3d textures like our spherical gradient is like a cross section of a sphere this can actually work with volumetrics but another like less expensive way than doing volumetrics is coming in here and adding an array modifier and we can just change this from relative to constant and we want this to be going on the y axis right here so i'm going to change this to like 0.1 and you can see it's uh it's starting to add planes right here and i'm just going to add a few more of those so i'm just going to add like five of those and then i'm going to duplicate this with shift d change this count to two and then i'm just going to change the the y value of the second one to negative 0.5 it's basically just mirroring what we had before so you can see now we have this like cross section um and it's kind of making our fire look like it's using volumetrics and if you want this to be neater you can add more planes in here and just make them closer together but just know that when you do that it'll be a little more taxing on your computer and this is a lot more like performant than using volumetrics you can actually play in real time um i have my frame rate set to 24 frames per second and it's actually the correct frame rate which is pretty cool and the illusion only like starts to break when you get at like a very shallow angle like this but even something like that is is pretty good it still looks decent oh yeah another thing is you might want to change the the color of your sparks to be like a pale yellow or orange or something like that and if you want there to not be so many or them to be smaller uh make this value a little smaller to like .05 or something like that and you can see they're they're smaller and there are a few of fewer of them it's also worth noting that this works in cycles and when you do use cycles it'll actually emit light which is pretty cool so i actually figured out the problem here in cycles obviously an eevee it works fine but in cycles if you're getting this problem you just need to go to your light paths it's under render properties right here yeah you basically just want to turn the transparency samples up until that problem goes away so i actually figured this out by asking for help over on aarondale's discord server any username proud imagination helped me out if you don't know about arendelle they have a youtube channel that focuses mostly on procedural stuff in blender and it's really good and their server has been really helpful to me also a link to their channel is in the description so if you'd like to know how to use real volumetrics with this i'll show you how to do that really quickly basically what i'm going to do is i'm just going to add in a cube this is what we're going to be adding our volumetrics to i'm just going to apply that same material that we're using to this and then right here i'm just going to click this and that's basically going to duplicate it so that i'm not altering the first one that way it's separate i'm just going to name this volume or just ball for volume and basically i'm just going to you know delete this mix shader right here add in a principled volume and then it's just going to be like a series of masks that i'm using so we want to add together the mask for the flames and the embers right there or the sparks or whatever i called them it's going to plug the volume into the volume right here and i'm going to add in a math node i'm just going to leave that on add i'm going to add these two together this one right here and we can actually get rid of this too i'm just going to leave this just so we can reference the color and then i'm going to plug the add into the density i also want to clamp this that way this doesn't go over one so it looks like we're having a problem here and i think it's because this needs to be inverted so you can either use the invert node but i like to use another math node i'm just going to change this to be connected to the bottom value switch this to subtract make sure you turn clamping off and set the top one to one and this should invert it also i added this multiply node right here and this is going to control basically this the strength so now if i turn this up higher you can see it gets a little darker and if this is hard to see you can mess with your volumetric settings over here right now i'm using ev and you can like set the tile size right here if you set it smaller it gets higher quality but it'll also run slower next i'm going to work on the color so i'm going to add in a mix rgb we're just gonna mix some colors together so we're gonna add the color from our color ramp in here and i'm just gonna hover over the color of our embers and hit ctrl c and then ctrl v for this other one right here and then we're just gonna use our ember mask for the factor right there and we can just plug this into the emission color and for the emission strength i'm just going to duplicate this just so we can have separate values to control the strength of the emission that way we can control the density and the emission separately i'm just going to crank this up a little higher and i think these might be in the wrong spot so i'm just going to move this to the top and then put the ember color in the bottom right there you can see it's coming through now we're getting our colors and uh you can play in real time but volumetrics look kind of funky when you try to play them real time so i'll just put a rendered animation up right here to show you what it looks like when you render it and once again this also works in cycles and you won't have that problem that we were having when you layer multiple planes together you won't have to mess with the transparency as much but it will you know unfortunately take longer to render so you know pros and cons okay that's pretty much it i hope you all find this useful and once again if you don't want to make this yourself you can go grab it on gumroad for a few bucks as well as some of my other stuff like the lightning pack barbed wire and glitch shader thanks for watching have a good one [Applause] you
Info
Channel: Joey Carlino
Views: 3,937
Rating: undefined out of 5
Keywords: blender, cg, cgi, blender 2.9
Id: q6deuB-bGvg
Channel Id: undefined
Length: 29min 16sec (1756 seconds)
Published: Sun Mar 07 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.