Tutorial: Realistic Lightning in Blender 3.0

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
i have originally made a tutorial on this lighting here but the blender 3.0 things are a lot more beautiful for example i can draw the lighting into the air i can make exactly what i want for the lighting the growing animation works a lot better this time and it actually doesn't need too many nodes as well just a little you know collection as you see here and it works so let's start and we are not going to keep the default cube this time although i do this pretty often so let's delete this yeah i'm sorry and let's add a circle or any other curve it has to be a curve we go to the edit mode and we just delete everything and then we have this possibility to draw as you see here we have a drawing thing here and we can draw a spline so for example this one here and we can use this as the basis of our lighting or we can do maybe something like that yeah let's use this i'm gonna close this spreadsheet let's start by randomizing the position of this lighting bolt so let's use a set position to set something zigzaggy for the sliding bolt and let's also use a random value for the offset so let's set this to vector because we are doing this three dimensionally in all the possible locations right so let's use the as the offset the vector random values offset and the first problem i see is that the layout is extremely bad to use so i'm just gonna go to the uh here right okay now this looks a lot better it isn't doing too much when we change the seat it's just like wiggling around and back and forth and the reason is that we have only you know one two three control points for this uh spline or this curve so let's resample this re sample curve you know this works well but the problem is that we have a count here so for example if you draw like a very very very long lightning bolt then we have very low resolution lighting board because we have a fixed count instead let's use the length this is gonna give us like the same detail level so i'm gonna delete the one i added before and let's make like the first level of details being something like that and i'm also gonna make this uh minus one and plus one okay something like that and let's now add another set position and another one and let's maybe add even another one so now we have a lot of those and let's duplicate this random value like that and connect all of those into the offset you're asking why did we add three of those well the reason is that we need three levels of detail this one here has 0.8 uh this one here has 0.4 and this one here has 0.2 and the last one has 0.05 so some like fine detail you know now this looks very very crappy and the reason is that we are just adding too much of this right so let's disable the last ones here so we only keep like um two of those and for this one we are to add half of the displacement we added before or maybe even a quarter this time and the last turn the first one down a little bit i mean you just have to see what looks best for you and this and then we need this one to be like 0.1 maybe let's enable uh this and the last one is very very fine detail and this is going to be 0.03 maybe yes now we have this lighting bolt and it's looking pretty nice okay this step is done now we need some branches to the sliding bolt before with the last you know geometry notes this was actually pretty hard we had to like add separate objects and all that stuff now we don't have to do this anymore let's take all of this and command j or control j on windows we have this little box of the mesh here and let's start by adding some branches to it so to add some branches let's as an instance to point node instance and points and let's use an ico sphere as the thing that we want to add here right so instance massive amount of phycospheres we don't like this instead what we need to do is to um first control the amount of points that are actually going to be turned into some branches so to do that what we need is a curve to uh points node logical right current points and bum and that's good and all uh but the problem or like a little little detail is that i mean they have all the same distance between them so if you want to for example have like a random like here and here two branches and then maybe here three and one and like that then this is impossible this way because they all have the same distance so let's add more resolution like maybe 25 and now let's select random points among those points so for that we need a random value we switch this to boolean and then we're gonna connect the value to the selection and this is how we can change you know maybe we want to select only the half of those then we are selecting the probability 0.5 and to see this is gonna give us different lighting bolts i don't want to select half maybe like that i think this is how the notes look nothing too complex here so you can follow along easily and let's go on now we need some branches instead of those ico spheres so let's delete these atmospheres we don't need you anymore and you think okay let's use the same lighting bolt as the branch like clever no it's not very clever because they become a little bit shifted and the reason behind this shifting is that when you you know this original one here these are our instance instances here uh the reason is that this thing here is gonna be instanced on the same thing using this as the center point because this is the center point of the object and you know when i for example move this further or further away this starts to also move double the distance when i may put this like here you know then it's gonna kind of be working but it's not a good solution because maybe we want to draw a lighting like here then it's gonna be like very crazy so uh what we need to do is to have a curve here like the segment of the lighting that is uh just starting from the center here so how do we do this well we just copy all of this here command copy and command where we however this letter is pronounced and we take a quadratic bezier as the input instead of our drawn curve so this is the curve we have drawn and this one here is a quadratic bezier looks like um looks like that you know just a curve and we need to just you know be just a straight line up so how do we do this just some number work so the start is gonna be zero zero zero um the end is gonna be uh zero zero one so it's gonna be like up here and the middle point now this works very nicely okay let's take this one and let's connect this to our resample curve input and let's see how this output looks now it looks very crazy well the reason is first of course let's make this a bit longer because i feel like um yeah let's make this like four meters long the reason is that it's getting randomized and this thing is still shifting it's not in the yellow dot here so how do we put this into the yellow dot well for that we would have to multiply the displacement that we do here with zero everywhere where there is the beginning of the line and luckily the beginning of the line is only only one spot and we have a special node for this which is called the curve parameter i call the spline parameter in blender 3.1 and you take this curve parameter and this is going to give you like a gradient from 0 to la la la up until the end until one if you want to use this well very simple you just take a vector math note a vector math node now this creates some you know these things are starting to shift around this is very bad so go to this view setting up here and turn off auto offset if you don't like this i don't like this so for example if i now add a vector math here this is gonna be in the same place which is what i like so i'm gonna hide all of those with h make them a bit smaller you know and with this addition i'm gonna switch this to multiplication to factor to here now okay this doesn't give too many effects right now put this multiplied you all of our displacements so like that and now we can connect this to all of those things and you see it is working but with a huge problem it's very very smooth it's not actually a huge problem it just needs a treat of a color ramp put it here and you can i mean make this very extreme so only like the top part is starting to wiggle but you can also like move this white thing here until only the start is in the position and everything else is doing its free movement also if you want to change the seed of this thing what we need is to connect a controller to the seat of the random value right this is the bottom green diamond and we connect another one and another one i believe there's like a meme on another one so maybe this would be a nice time to put it here okay another one so this works that way we can change the seed and to see it is grounded in this location it's not moving anywhere because we have made a really good work here and also let's add the seed to the upper things here i know these are like the most boring parts of the tutorial but they are worth the time i believe it's it's working right now let's uh group those using a command j and let's go up here and instance this uh freshly created curve onto our uh lightning bolt right okay now these are instanced on the thing we can change the probability we want to have a lot a lot or just a little bit and this should be like rotated a bit more randomly right so what we need to do is to use a random value which is uh has to be set to a vector it doesn't have to be set to vector but it's nice because then we get more random rotation because rotation as you know is in a 3d space to express 3d space we need three values and the vector has three values actually a vector can have even more values but in blender we don't need too much minimum would be minus pi and maximum would be pi which is you know you can google how radians work to understand why the maximum rotation is pi and you plug this into the rotation and you have something very crazy um let's change the seat like that probably we should have those things uh rotating a bit more like down you know so they should be pointing a bit towards the ground and to do that what we need is an aligner rotation vector node or euler to vector last time i said euler and i received some corrective comments about this so now i'm gonna say euler like euler with some very german accent we have to use these settings here i mean nothing too much to explain here z-axis and vectors should be pointing downwards on the z axis to minus one and now we can point them a bit more towards the ground and it's looking pretty fine i think so let's see if our drawing works well let's draw a lighting bolt yeah it's it's something working nicely actually i don't like lightning bolts like that i'm gonna keep it like that okay yeah this is nice the next thing that we need is uh is to randomize the scale so i'm gonna keep those things here and random value i'm gonna show the full notes in a second so i mean you don't have to be worried so float because the scale we don't want to scale them on all the different axises this is possible but we don't just want to do this and connect this to the scale now the maximum scale is the maximum scale and the minimum scale is the minimum one i think we're gonna use like two for the maximum and one for the minimum so this is doing its job pretty well let's add some let's take the seed controller from the start so i'm gonna move this here and let's control the seed and let's also control the seed of the random value and we can change the seed and we have a lot of different lighting bolts okay this is how the nodes look right now look at this okay up here we have the lighting bolt then we have the branch and here we have some instancing on the surface right very nice now what we need to do is to add the third level of branches right so we can use the same thing there are no problems at all with that we are gonna instance on those instances right so instance on points you're going to take the instances plug them here and let's join those together we haven't instanced anything but let's drag like from the branch and well they have a massive massive amount of those of course we don't need too much as much so let's take the curve of the points put it here decor the points and let's use the random value as well i'm gonna move this down so it's a bit more understandable what is happening here a random value to this selection and let's really select like a really small amount of those branches and the random values should be uh what like is very small scale so maybe 0.3 to 1 i think or maybe 0.6 even and we also need to rotate this so i'm going to take the copy the rotation part shift d move this here and connect this to the rotation you see those branches are not pointing towards the right z axis they're like pointing towards the local z axis as you see here like we'll mention yellow so you can see this so like unaligned and when we align this it's like aligning in some i don't know we're at random z-axis so instead what we need to do is to realize those instances that the curves lay on so for example right now they are doing this in the right way so pointing downwards right and now let's add a little box around those things here and also around the other things here and let's connect the main curve also to the join geometry and now let's animate this and do all this crazy and beautiful stuff here but first if you want to learn more about geometry i made a beginner class on skillshare about geometry notes in predator 3.0 also some nice procedural animation techniques and all that stuff and skillshare is also sponsoring this video you're asking what is skillshare how can i find this beautiful raspberry well skillshare is a learning platform and it has like a lot of different things you can basically learn whatever you want i'm learning houdini right now there i actually joined skillshare because of this class from marcus brownlee about youtube content creation as it has worked pretty well i mean the views are going up now how is skillshare useful for you there are a lot of interesting 3d classes on skillshare for example salter and scotty i think is the most popular blender skillshare creator i know he has like tens of thousands of students and this class is like a really nice introduction to characters and now if you want to start learning on skillshare you are in great luck they gave me a magical link and the first 1 000 people use this link will get the one month free trial of skillshare now as a sponsor skillshare also paid me some money i'm gonna give some of this back to you so one of the first 20 people who uses the link and comments unlimited raspberries under my class on skillshare gets 100 dollars good luck and see you on skillshare and now let's do the exciting stuff with the lightning bolt so let's animate this and make this mesh and all that stuff so we have here three inputs right uh this and this and this shift track by the way we have to turn all of those into meshes so let's make them a bit more wide open and let's add a curve to mesh node a curved mesh and we need a circle curved circle to use as the profile curve so this is going to be the same for all of those meshings so i'm gonna move this here and use this as the profile curve now the middle one has turned into something extremely extremely thick and gross so let's turn on the resolution first like maybe eight and also let's turn down the radius but to see the problem with moving the radius here is that we cannot do this differently in different locations of the lighting so it has to be like very very small down here and quite big up here so how do we do this well we cannot input anything like different per point here because it's a it's a circle it means it has only one value here the curved mesh is here and we need to change the radius of the curve for that we have a set curve radius put it here and we can do this i mean the same thing as before but this time we have a little diamond here which is very good this means that we can input fields there so for example the curve parameter we can take this and input this into the radius bump and look at that up here it's zero and the gradient goes down down down like a snake until we reach one and this just has to be inverted so for that let's use nothing else than a good old map range and from the original range of zero and one which it was we are going to do this we are going to convert this into one and zero and now this is the exact inverse we just have to make this maybe a bit like thinner at the top something like that now we have the numbers in place and i mean to make this grow just have to animate this from maximum value here but we're not animating this right now first let's turn all of those other things into uh curves so i'm gonna move this one up up up and let's use the same nodes so a curved mesh node let's put this here and also let's copy this map range thing and let's connect the profile curve so okay let's connect this thing there and we have set curve radius now exactly the same setup as down here nothing too too different there but the problem is that yeah it's it's it's a bit too thick all right so let's make this uh let's have the right thickness there and if we go like down here then these things are way way way too thick for this middle branch here right it should be something like that instead so what we need is to have these curve parameter of the middle branch to affect the thickness of the secondary branches to do this what we need is um attribute transferring so we have to transfer the attribute from this thing here to this thing here like this thing here that has been instanced straight so let's use an attribute transfer uh transfer attribute and we're gonna transfer this from here so this is like a target mesh where the attribute is getting transferred from and we are transferring the curve parameter of this um middle uh branch here as you see a core parameter of this branch connect this here and connect the attribute into the to minimum because we want to change this value right now everything has disappeared and yes we have a warning sign the target geometry must contain a mesh yes but let's change this to the index mode instead so this works in the index mode and now with this transfer attribute here what we're going to do is that we're going to connect this to of course our 2 min because we want to change the 2 min right at least like before we wanted to change the two min to increase like or determine how thick the secondary branches have to be we connect this here and we have some problems um so let's add a color ramp to fix those problems i mean so when you add the color ramp here you see we can like change but they are all changing at the same time it doesn't seem like it's working right this like the some areas like this one should be smaller than this one or like the inverse at least there should be some kind of a difference but there isn't so the reason lies in this thing here this is instant some points and we are just using the instances but we haven't realized them so if the instances aren't realized they cannot have different attributes in blender at least to my knowledge so this means that they're always the same you can only change the rotation uh location like scale things like that but not anything like inherent to the internal structure of the mesh so let's use to realize instances and now you know the things are starting to work so you see when i move the color ramp the things up there up there are they are disappearing so this means it's working the gradient is just shifted a little bit right so here you see it says like the transfer attribute like index it uses indices so let's shift those indices by using an input index here and use a math node to just like make this work basically so if we use an addition it probably just moves like down and with something like that probably okay yeah but we use a multiplication like that and multiply with one and let's okay let's track this all the way here so you see it starts disappear here but we want this when it's around here this should be this route we disappeared all the way to the end that is what we want so let's um adjust the multiplication here to like that okay a that's a meme number for sure i know that so um the gradient is working and now let's invert those like that because we want them to be thicker up there and thinner down here but it's way too thick up here so let's change the color here it currently is using the value of one up there so instead we want to use like maybe point three let's go and and and convert the last things here into the mesh now with these things here with this like last i'm not gonna bother to like create any like attribute transferring crap here because like yeah that's too much of work so um let's use the curve to match instead and let's let's delete this one actually correctly mesh and where is our little circle here profile color now they're very thick and ugly and the next thing is that we need to use the curve parameter and up range right so ah set the curvatures as well so set the curve radius and move these things here okay now these seem to be okay they're way way too thick so um something like that and they can disappear into the infinity so i'm gonna put zero here now we just have to animate this the last step okay from maximum we just have to change this value here like that so let's first tackle the middle one here where are you here okay let's add a controller so you take this overly controlled group input here that is already under the burden of many control lines and you add this one here from max and i'm gonna call this the age uh parameter okay now this is here and i'm gonna make this so the minimum value is zero maximum value is one now let's move this thing back there and let's see so uh when i make this like small the middle branch disappears but when this is like really small at zero it also like comes back because um so we have to make sure that the minimum value here is not zero but 0.01 for example and now when we move this you know this is like that actually the front minimum should be smaller so minus 0.01 maybe now this is working extremely extremely well let's add the same control for the i'm gonna add like a little uh shift track here for a good measure and move this up here and here i'm gonna do so that i'm gonna put this into the from maximum of course and they are all animating at the same time which is a problem but we need to fix this so as you remember you know as you see the from max here is is basically giving us like the growth right we have to make this different for things up here and down here so for that let's use a math note it's always a good measure to do some math and now we have to think what exactly is we should do with this map so um we have a different gradient for like the up here we have like zero and down here we have one uh by using this transfer attribute here right that we have transferred from the middle branch so let's drag from the transfer attribute to the addition node here let's see if this works actually yeah maybe kind of let's switch this to subtract actually and let's uh see how this works now okay now this works a lot better but we also have some you know negative stuff happening here so let's turn on the clamp nothing happened but to get rid of this negative stuff we just have to decrease the map range from min so let's type in here like 0.01 yeah like some kind of a small negative number and also uh this two max here i had it set to like something like this and i was like getting freaked out here because i thought my system isn't working it's working you just have to put zero here and now everything disappears okay and when you go to the side view and when you use this h slider here then it's gonna um uh you have to clamp this also right so then it's gonna do its job very very very nicely like it has to and we also have this last few things here um so we need to make those growing and doing whatever stuff as well so where are they actually okay they are down here so this from max let's um let's connect the same gradient we have to the from max and let's see if this works uh okay a small negative value here 0.02 maybe and now we don't have anything and when we make this grow we have a lightning bolt except we have this problem that you know these little third level branches are just appearing from the plein air which is logical because we weren't very intelligently creating them but we can just do so that we offset they are their creation a little bit so this from max value let's just add a math note here and let's just uh subtract like okay let's clamp this also 0.7 from here and let's make sure the limit is turned off here like 100 and now we can you know these are growing like after right so they are working very nicely here okay these are the notes like the first part looks pretty beautiful but the second part is not so beautiful but the project file is on patreon so if you need this you can always check this out it's on the cheapest tier but now let's add the material so uh where is the material part shading uh first you have to add the material i'm sorry i'm i'm i'm a dumb person right now so let's add a set matte set material put it here and select the material that we want we don't have any materials in scene so let's add a new material a light ning and let's check till lighting material from here let's go to the shading and this is i mean it's a pretty complicated material it basically means that you have to add you know an emission shader and then we have to do such a hard thing that you have to switch this to blue and string to tree and layout turn on the bloom and yeah pretty much the material is finished so nothing too complex here okay i hope you enjoyed this little remake look at that nice [Music] you
Info
Channel: Bad Normals
Views: 125,381
Rating: undefined out of 5
Keywords:
Id: 2bG4zN4dGvA
Channel Id: undefined
Length: 29min 46sec (1786 seconds)
Published: Sat Jan 15 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.