Realistic CG Snowflakes - Free Houdini Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello and welcome to this houdini tutorial on how to create procedural snowflakes so i have not had to model any of these they're all procedurally done with either noise which is something like this so slightly less realistic but very interesting to look at and then the second method i'll be showing you how to make uses an l system based approach which creates shapes that you probably recognize a bit more when you look at macro footage of snowflakes so like i said this is entirely procedural this is the setup that essentially generates our snowflakes so if asked to visualize just one of them you can see the snowflake here however the real beauty of this setup is that we can feed it as many points as we like and for every point that this setup gets fed it will vary some attributes and i'll be showing you how to do this i.e the noise offset or the type and it will then produce an entirely unique snowflake for every time that this setup is run so here i have seven points which i'm going to feed into this setup and as you can see we have seven completely unique snowflakes so now i'm going to feed it 64 points and as you can see we have 64 completely unique snowflakes without having to do any hand modeling next i'll be showing you how we can do a very quick pop sim that gives us behavior that's typical of snow falling and then finally i'll be showing you how we can then instance our snowflakes that we generated onto these points to create this final snowflake scene let's jump right into it alright so starting off an empty scene as always first thing we're going to do is drop down a geocontainer which i'm going to call snow so the first thing we're going to do is create one procedural snowflake to do that i'm going to use a circle node so the first parameters we're going to change is the primitive type which we're going to set to polygon and then the orientation we're going to set to z and x then if we set the arc type to slice dark and because i have wireframe on which you can enable here smooth wire shaded you can see that we now have segments so the idea with this setup is that we're going to cut out our unique shape a bit like if you were making a paper snowflake you would fold up your paper into one triangle you would apply your cut out shape and then once you unfold it you have a repeating pattern so we are just going to apply that same logic to this so if i reduce the division size something like eight for now just to keep it simple we are going to keep one of these segments so to do that i'm going to use a last note and i'm just gonna keep primitive zero for now so if we put zero in the group and take glee on selected we have one triangle then if i remesh it we can then give ourselves some more topology to work with so i'm just going to decrease the target size now to something smaller and we can always decrease this later if we want higher detailed snowflakes the next node we're going to drop down is our attrib noise we visualize that we can start to see that it's applied some random color we set it to float it's just going to quickly set it to black and white at the moment you may be wondering why the top is blue and the underneath is gray and that is because we have by default if we hit d and our display options come up we have tint back faces at the moment since the normals are actually pointing down that's giving us a blue indicator that we are actually looking at the underneath of this polygon we can simply just untick tint back faces and as you can see both sides are now grey that helps us visualize our color better at the moment we're not really seeing much detail out of the noise so first thing i'm going to do is just change our noise type to early cellular manhattan ft minus f1 which is just a noise type that i liked but you can pick a different one and then if i enable the remap ramp then gives us the ability to play around with the noise to kind of make it a bit more crunchy i found that inverting it by hitting this button and then just bringing down this top slider gave me some shapes that i felt looks quite interesting as a snowflake kind of these cellular branching shapes next we can play with our element size i think i've reduced it down to something like 0.8 and then finally i'm just going to take post-process minimum and maximum just to make sure our values aren't exceeding those boundaries next we're just going to set the attribute class on our noise to primitive and the idea is that we're going to cut out anything that's below a certain threshold to leave us with some interesting patterned shapes so if we jump down the blast node we can then inside this group box we can use at cd less than 0.2 so essentially blasting away any shapes that are less than that value and then much like the clyde escape if you've watched those kaleidoscope tutorials we're going to drop down a mirror set the direction to the one in the zed so we've essentially flipped it then we can use our copy and transform mode to finally clean the shape round to complete our snowflake so this rotate value is going to be 360 which is a complete circle divided by the amount of divisions that we have and then times two since we've already mirrored it once then our total number we can also do procedurally which is going to be 360 divided by the value of this rotate parameter here based relative reference so as you can see we now have our very basic procedural snowflake generator set up if i was to play with the noise settings here like the offset you can see we can just very quickly get some procedural interesting shapes now we're going to give our snowflake a bit of thickness so to do that i'm going to use the extrude node holy extrude and we're going to set divide into to be individual elements then if we just add a bit of distance our normals are pointing down so positive values are going to go down so just to counteract that i'm going to use negative distance values something like that for now just to see what we're working with and the next thing we're going to do is tick output back so this has given us an overall thickness however it'd be quite nice if the darker areas i.e the edges are not as high as the inner parts and to do that we can use local control which by default this distance scale is looking for z scale but if we give it our cd attribute you can see now we are using our colors to control how high each tower is going to go so if we visualize this copy again you can see we have our extruded snowflake in one axis and then simply to get it going in both directions we're just going to use another mirror which we can set the direction to one in the y now we have our very basic extruded snowflake there's a few things we can do to now clean up our snowflake geometry and one of the nodes i probably would recommend to do that would be one of the labs tools which is auxiliary mesh if you can't see this node then make sure you're using one of the latest versions of houdini and if you just enable this side effects labs shelf taking it here you can then hit update toolset and you should get access to all these nodes so voxel mesh so by default it's going to make our entire shape black and to fix that we're just going to add some color white just to see what it is so this is kind of made it one continuous mesh we can also potentially turn on projector original which is just going to crispen up some of those edges maybe even ticking sharpen feature if that's what you wanted i'm just going to leave it just slightly more rounded if you're wondering how you might be able to procedurally delete any shapes that aren't attached to the main body like you can see these little bits are floating then another labs tool i would recommend would be delete small parts and if you plug that in we can then change this to extract largest piece and as you can see it's deleted those smaller shapes so this is a noise based approach if you're looking for something that resembled more of a classic looking snowflake and we can use an l system for that so i'll show you how to do that now first node we're going to drop down is l system which saves us a lot of time and by default it's going to give us this rough looking tree if we hold down this cog it gives us a bunch of presets which you can cycle through i'm going to be using 2d plant d now we're just going to lie down this tree so that it lines up with our segment that we have here so we're going to be using a transform node and if we rotate it around 90 and then lay it flat that way now we can use a node called match size which is going to as you've probably guessed match size so we can plug the second input into our arc and visualize it we want to enable scale to fit and we're going to set our justify x to min and then the other two to none so then as you can see it's lined up nicely with our arc here next we're going to be using an actual transfer just to transfer over this pattern so we can drop down a color nose here leave it to white we can then drop down another color node and plug it into our remesh and set this all to black make sure it's plugged into the remesh and not the attribute noise and first input is going to be the arc black arc and the second one is going to be our l system then if we visualize that the whole thing is white we just need to bring down this distance threshold before we do that if we go over the attribute section just make sure we're only transferring over cd and then in our conditions we can bring down our distance threshold something really small like 0.5 if you wanted a bit more resolution we can just bring down our remesh target size to something like 0.5 and you can start to see that shape a bit more clearly now we're going to use an archery promote just to put that color information onto the primitives instead of the points so by default original classes point new class is going to be primitive and we are looking for cd so as you can see here just promoted that and then if we plug it into the rest of our network and visualize the end we have our classic looking snowflake all right now that we have our two different ways of creating a procedural snowflake i now want to be able to run this multiple times that we can create a stack of snowflakes for us then to instance onto our snowy points that we'll make later so to do that we're going to be using a for each loop for each point specifically there's a few different ways we can do this but i'm going to be using a copy to point so the first input is going to go into our snowflake generator setup and then the second is going to be here for now i'm just going to be using a add and then in this ad we're just gonna tick so that we have one point being fed into our setup and then if we visualize the end you can see that we have one snowflake being generated if we wanted to increase this i'm just going to add another point here and then just offset it slightly you can see we now have two snowflakes being generated however they are identical so the next step would be to randomize a few different parameters within this setup based on the point number that we are currently iterating on so to do that the first thing we're going to do is press create meta import node which is going to give us this node here which allows us to access detail attributes such as the iteration number which is useful because we're going to use the current iteration number ie the point that we're on to randomize an attribute here first attribute we're going to randomize is going to be using this noise-based approach that we built earlier and the easiest one would be this offset which if i change here you can see randomly offsets this noise so we're going to be using a bit of an expression here of x expression and we are going to be using detail to access this detail attribute iteration which has been created so detail open brackets and then we are going to look for that meta import node and then we are looking for that iteration number and then simply zero as the last input so currently that is just feeding in iteration as is if you wanted to control that then you could always wrap this around a fit but for now i'm just going to leave that as is because we're already getting some unique snowflakes here so if i was to add another point you can see we now have three completely unique snowflakes because we have fed this set up three points the next step would be to then randomize this l-system-based setup that we've got here and something i found that was quite good to randomize would be this generation number so if we visualize our l system set up you can see this is what we currently have then if i was to lower this generation number it should make this shape slightly more simple so we put into something like three and you may notice that you're just getting points and that's because we currently don't have enough points on this geometry here that's transferring over to the mesh it's leaving us with lots of blank spaces so to fix that we can just drop down a resample here and then i'm just going to decrease this length so we get more points along our branches something like that you can see now that we're being see that shape so this generation number we're going to control based on the iteration however i'm going to use iteration as a random seed so the first thing i'm going to do just to save us a bit of time is just copy this which is accessing that current iteration number and paste that in here and wrap this around a rand function which is going to give us a random float between zero and one and then that means that we can wrap the round with a fit01 because we know that this round is producing values between zero and one and then we can pick the min and max outputs of this entire expression and for that i'm gonna do a minimum generations of three and a maximum amount of generations of five at the moment we're getting a number of four but then for each snowflake we would get a different value so that's one thing we can randomize another thing i might like to randomize would be something that affects both setups and that would be the amount of divisions we have here so we get slightly more complex snowflakes and then slightly more simple snowflakes so to do that again to save us some time i'm just going to copy this expression and i'm going to paste that into our division parameter here except the min and max amount of divisions we want probably not three and five we probably want a minimum of six and then a maximum of ten now the way that the setup works is that we mirror a segment and then we copy it over so that kind of requires us to have a even amount of divisions so to make sure that this number is always going to be even we are going to be using a round expression which we can add at the front and then we're going to divide this output by 2 and then if we close the brackets and then times this round expression which essentially rounds to the nearest integer by dividing by two and then timesing by two we are essentially always making sure that we have a even number great i reckon that's enough randomization for each setup now what i'd quite like to do is randomize which setup we're going to be using so to do that i'm just going to pop down a switch and then this switch is randomly going to pick between 0 and 1. so to do that we're just going to quickly copy our iteration number paste that into there and then i'm going randomize that so we're getting an attribute that's between zero and one and then we just wanna round to the nearest integer so now that we're randomizing a few key attributes you could keep adding this to other things that you wanted to play with for example maybe you could randomize the element size or maybe the amount of fraction you get in the noise etc but now i'm just going to say that's enough and i'm going to quickly show you that this works with more points so if i just pop down a grid and at the moment it's 10 rows 10 columns which gives us 100 points i'm just going to lower that so we have 16 and i'm just gonna leave the size 10 by 10 for now now just to quickly speed up this whole setup we're just going to turn off box or mesh if i plug this into our for each loop and visualize that you can see at the bottom it's running 16 times and we have 16 completely unique snowflakes so the next thing we're going to do is set up a very basic pop sim that resembles something like falling snow so if you don't know how to do that then i'll show you now if you do then you can skip to the last part of the video so i'm going to just drop down a grid and i'm just going to lift it up and this is essentially going to be where our snow gets emitted from so this is almost like our fake cloud and then i'm going to drop down a subdivide after it and then i'm just going to increase our subdivide so we have some more geometry to work with then if i drop down an attribute noise this is essentially going to work as our density mask for our emission so i can set this to density and then set that to float and then we can't see what we're working with so if we just hit this toggle here we can visualize density i'm just going to increase this element size and then an animation i'm just going to hit animate noise so making sure that we have real time toggle on just going to press play you can see our noise is animated next i'm going to do is drop down a scatter node and by default it's not looking for this density attribute so i can just hit density now it's using that density as a mask to scatter our points at the moment it's not very visible and that's because of this relaxed iteration so if i decrease it you can see that we have some high density areas and low density areas which just makes the simulation more interesting i'm just going to decrease the force counts a little bit smaller for now then we can feed this into a pop net and if we dive inside our pop net first thing we're going to do is change our source to be all points the mission type and we're also going to add some gravity so we press play see we have some falling points the next thing we're going to do is add a bit of variation a bit of wind so to do that we can use a pop wind node which we can just plug into here and then here we have the amplitude which is the amplitude for the noise that we're going to add so i'm just going to increase up to 7.5 so we can see what it looks like i'm just going to decrease the roughness because we don't want this wind to be too jittery to be smooth and if we add in a pop drag it's just going to slow things down to make them look a bit less chaotic and a bit more sort of realistic there's air resistance which increases something quite high so if you press play you can see we have some falling snow so you can tweak these settings first thing i'm going to tweak is probably increase the swell size something a bit bigger and maybe my pulse length i'm also going to increase something a lot larger as well just so the noise isn't moving so much now my pop drag i think at the moment is too high so if i press play that will do for now you can like i said play around with these until you're happy with the type of snow falling that you have if i get back up i'm just going to decrease the amount of points we're emitting on each frame just so it's a bit faster we're still visualizing density which is why these points are colored so i'm just going to go back over and hit this toggle again and it's disabled it so now we have our simulation you don't need to set up these points to have the attributes that a copy to point or look for so if you followed my dust tutorial then you probably know what's coming so copy to points node first input is going to be our snowflakes so at the moment we're instancing our snowflakes on a grid we need all of our snowflakes to be at the center a few different ways we can do that the easiest way would be to just use a line stop which i've set that length to zero and then this parameter will just control how many unique snowflakes we have so i'm just going to have 10 for now so they're all at the origin which is what we need and then the second input is going to go into our pop net so the first thing we're going to enable is our packet instance just to make things a bit faster if we visualize what that looks like at the moment you can see that our snowflakes are massive so the first thing we're going to control is our p scale so we just drop down and actually randomize you can call it p scale and then the attribute name is obviously gonna be p scale dimensions is one because this is just a float and then our max and min value we're gonna set to 0.5 and 1 and then this global scale is what we're going to use to set the overall scale of these snowflakes so something quite small i think zero five that's good for now so we're not randomizing at the moment our snowflakes so to do that we need to be using the attribute from pieces node which we're going to drop here so the first input is going to go into our popnet and the second is going to go into our collection of snowflakes so this node needs an attribute to be unique for each snowflake so to do that we are going to be using an attribute create and then we're going to call this attribute name and then the value is going to be again the current iteration number which we can copy and paste in from here [Music] so now in our attribute from pieces we're going to be looking for that name attribute that we just set and then if we plug our copy to points in here on our copy to points we can then look for the piece attribute name now if we visualize our copy to points you can see it's randomly selected one of our snowflakes so on our attribute from pieces we can shuffle them up also setting the motor random is probably going to help the next thing we need to make sure we enable is this source points id attribute because our snowflakes will eventually die if you dive inside here you can see that in the birth tab we have a life expectancy which you can probably decrease to about three seconds or increase it if your snow is falling a bit slower so when they die it's going to reset the point numbers and that's obviously going to change the seed for the selection but by using this id attribute which we get out of the sim it's going to stay unique for each point and not change throughout the shot so we also need to enable that in our attribute randomize in the options tab the seed attribute we need to tick which is by default looking for this id so the next thing we're going to do is add a bit of rotation so to do that we're just going to copy in this attribute randomize and then we're going to initialize this n attribute so the global scale can be one again making sure that this is ticked for the seed attribute and then our dimensions is going to be three and we can set this back to zero next we're going to drop down on wrangle and we're going to call this round called orient and this is where we're going to use a bit of vex code to set our orient to be moving throughout the shot so to do that first thing we're going to do initialize a float that we're going to call angle and then we're going to set this angle parameter to be equal to at the frame which is going to grab the current frame number and then the first thing we're going to do is multiply that by a attribute we're going to call global mult or rather global speed might be a bit more intuitive so that's our global speed then we're going to multiply that by a fit a1 function which inside is going to be giving us a random value between 0 and 1 which is going to be unique for each id and then the minimum max of this round is essentially going to be our min mult speed and our max mold speed so for now i'm just going to set that to half speed and one so hit this it's going to initialize our global speed toggle that we've got here so we can just set that to something small like 0.1 for now then on the next line we're going to initialize that orient attribute which is the one that this copy to points is looking for to set the orientation of each snowflake and then we're going to equals that to the quaternion function which takes in that angle attribute that is changing throughout time and then that n attribute that we set before in here then if we set up which is another intrinsic attribute a copy of the points is looking for n we can see that suddenly our snowflakes have shifted and then if we press play you can see each snowflake has got a bit of spin so something that i've noticed is that if you set the mode to random the snowflakes will actually change if one of them dies and that is because if we unlock this node and dive inside you can see that the random attribute randomize here doesn't have this seed attribute enabled which is unfortunate but we can just quickly enable that and if we go back up you can notice that it's no longer switching so that's only if you wanted to use the mode random so this is now ready for rendering the next step would be to apply materials and then set our scene up with a camera and some lights if you're unsure on how to do this with mantra then check out one of my other tutorials such as the atmospheric dust i hope you found this tutorial useful thank you for watching [Music]
Info
Channel: Carvalho VFX
Views: 16,385
Rating: undefined out of 5
Keywords: houdini, sidefx, cg, rendering, render, snow, flakes, procedural, how to, modelling, storm, macro, frost, crystals, ice, carvalho
Id: KPf9vp1I4k8
Channel Id: undefined
Length: 30min 43sec (1843 seconds)
Published: Tue Apr 27 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.