Houdini is HIP - Part 15: Sparkling Water Project

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
F Diamond welcome back to Houdini is hip in the previous part we looked at how we can work with flip fluids we looked at the basics and really we only looked at sourcing in this next part what I want to look at is a much more complex shot this is going to be the first part in the series where we're actually working towards a production ready shot so this is something you may do if you're working for a studio or if you're freelancing this this is the type of work that you might receive from a client so I'm going to show you the type of process that I would usually take when working through a project like this and this next part is probably going to be broken down into three parts so this first part I'm just going to be doing some setup and things and explaining foundational understandings the second part is probably going to be the most complicated and then the third part is mostly going to be rendering so what exactly are we doing well very commonly you'll see adverts for champagne or beer and those scenes are often done with VFX now we're going to be doing a non-alcoholic version we're just doing sparkling water right now the look is quite different you don't have as much of that foam collection as you do with champagne or beer but I do also think that that makes it a bit more interesting because we have to take a bit more of a nuanced approach to the particles that collect at the top so let's go ahead straight into Houdini we'll begin with just some basic setup stuff and then we'll just ramp this up until we're getting into some of the most complicated things that we've covered thus far so let's go straight ahead in Houdini I'm going to go ahead and drop a geometry node and just call this glass right go ahead and drop a curve node so we're just going to drop a curve node over here we haven't used this one yet let's go into our viewport press space and three on your npad to go into the front viewport you can also click over here set view front viewport this will lock us to an orthogonal view of our front viewport we can then go over here to our transform handles and with our curve selected we're going to just draw out the shape of a glass we're not going to draw out the the entire shape we just going to draw the one side of it so something like that then go ahead and use a revolve node so revolve over here and what that'll do is it'll take our curve and spin it around turning it into a geometry press space plus one to return to your perspective viewport and this is what we've ended up with right now what we want to do over here is make some changes to our revolve the first thing we're going to do is make sure that we don't have this blue tinting on the outside this means that our faces are reversed you can see the ones on the inside are the regular gray the ones on the outside are this blue color so just reverse the crosssections over here we're going to add some end caps so that it closes the top and the bottom and we don't actually need UVS so we can disable compute UVS right so we just end up with something like that okay that's cool so now let's just go ahead and blast the top of this so we're just going to use a blast node over here click on this group over here the arrow and select the top face press enter that'll just blast that away then we're going to use a poly extrude node we're going to extrude our glass out a bit so just increase the distance something that seems reasonable so 0.7 and I'm going a bit heavier on it than I usually would because I'm going to be using a subdivide and that's going to smooth it out we can also just output the back phase so that this is a closed piece of geometry and from there we can go ahead and use a subdivide so just subdivide this over here give it maybe three divisions right so something like that so you can see we end up with this very smooth tumbler type glass and it looks pretty good you can make changes to this of course the cool thing is you can always go back to this curve over here and you can make changes to it so if I switch the mode over here to this first one that's going to be for editing and I can edit the points on this curve right so you can do all sorts of things this curve node with revolve is super useful you can do all sorts of really cool things with it it's useful for making things like fountains and making things like statues you can do all sorts of really cool things making vases but yeah just play around with it until you end up with a shape that you're happy with I basically just want something like this so I'm going to settle for that right cool so I've got my glass so now the only thing that I want to fix is the transformation and orientation of this as you can see it's going through the ground plane a bit we don't really want that and it's also massive right this is about 1 met in height so it's massive for a glass what we're going to do is transform it down until it's about 15 cm maybe like 20 cm so we'll get uniform scale of 0.2 right something like that that's assuming that we now have it scaled down to about 20 cm the next thing that we're going to do is just use a match size so match size over here is extremely useful for aligning things to a particular position so over here where it says justify why we don't want Center to same we want Min to same right so what that will do is if we go before over here you can see that it was going through the ground after we've used this match size it now fits exactly on the ground plane this is extremely useful for making sure that things sit on the ground plane and you don't have to you know manually get them to rest on the ground plane this kind of just checks the bounding box of this thing and then sticks it onto the ground plane cool so now we can add a null and this is just going to be our glass out glass out I'm going to go ahead and save this so I'm just going to make a new directory in Houdini's hip called carbonated and I'm just going to call this part one so part one. hip for carbonated right so I would suggest you do the same and just save this as we going but that's all we have for now cool so let's actually begin on creating a simulation so we can make use of this glass we'll go over to the side over here and just drop a new geometry node we'll call this one fluid base Dynamics dive inside and we can actually keep this glass ghosted over here what we're going to do is add a sphere and having this glass ghosted just makes it a lot easier for us to align this as a source so we're going to scale this down to about 0.04 and we're going to move this up and over to the side what we basically want is for there to be some velocity coming from this side into the glass right so we're not dropping it directly down it's coming from the side into the glass right we'll end up with some nice swirling and things so that's pretty cool now we have this sphere over here but we actually wanted to scale down over time right I want the sphere to as it goes we're just going to scale it down and taper off this sourcing so at frame 48 we're going to go over to the uniform scale press Al click on uniform scale move over a bit to frame 54 alt and click and then just drop this uniform scale to zero so between those frames it'll shrink down to nothing so that just mimics the idea that we're pouring in water and then we're done pouring at around 48 frames right okay so that's pretty nice we have our sphere over there and that's going to be our source now we're going to go ahead and use a flip doop Source right as we've done before flip doop Source right over here and as we saw in the previous part we need to make sure that our voxal size and particle separation matches the scale of our scene right so because the sphere is so small 0.04 we should do something smaller than 0.04 so the size of your source is usually going to give you a good indication of what your scale should be so I would say usually a safe range for what you're sourcing is going to be about a tenth of what the scale is for your Source object so if we have 0.04 we can assume that 0.004 is going to be good over here so we're going to go 0.4 over there and 0.4 over there and we end up with that right so it's looking pretty good that's pretty high resolution but it plays back at a decent rate so it's not too much of an issue to have it at this resolution we will be making changes for testing purposes we might push this higher we might go lower it all depends right so we also want a velocity so over here we can activate velocity and let's add a velocity in the negative X Direction because if we look in the bottom left we have the X Direction which is moving towards the the right and so we want to kind of add some velocity towards the netive X Direction just go ahead and say netive 0.8 something like that it might be a bit much but we'll come back and make adjustments to it and if we switch on our Point Trails you can see that it's kind of going that way you can also add some downward velocity to make it seem like it's actually pouring out from a bottle and is already kind of gathering momentum before the simulation plays but it's okay as it is right those are just changes that you can make if you feel it's necessary go ahead and drop a null plug this in over here this is just going to be our flip Source now just a refresher this is going to be two parts it's going to have a surface right that's going to be the VDB and then it's going to have a particle group right so if we just see something like a blast node then we can see this so if we go over here and we blast the particles we just have the surface if we blast everything but the particles we just have the particles right so you can see that it's two things that make this up and the velocity is being carried on the actual points right because if it was being carried on the volume then you would have to have a velocity volume it wouldn't just be surface surface is just this one that represents the surface of the fluid but as you can see we have a point attribute called V so that's velocity and that exists on the actual particles not in the volume all right cool so we can now feed this into a flip simulation but before we do that I want to also just set up the colliders for the glass so let's go ahead and we can actually do it inside of this glass over here so we have this glass out what we're going to do is we're going to grab two nulls we're going to directly take this null into here and we're going to call this glass surface out right so that's the one and over on this side we're going to make another one and this one is going to be glass volume out right so this one on the left is fine as it is we're just going to leave it this one on the right we're going to use a VDB from polygons bdb from polygons right over here and this one over here we're going to use to convert this into a surface volume right so as you can see we have a distance VDB over here or a fog VDB over here we've worked mostly with fog vdbs if we go over here and we switch this on this will also switch our background to dark if we decrease the voxal size to increase the resolution so 0.005 you'll see that we have this glass right and it's represented now as a volume because we've converted it to a fog VDB which is made up of density right we don't really want a fog VDB we want a surface VDB so we have that over there an SDF right so we just want this over here and we can decrease the voxal size even more 0.003 2 even one right so pretty high resolution okay so that is a volume again you can see over there that it is a volume it's a VDB so we just have this glass over here and that's going to be the glass volume out so we have the surface and the volume and I'm going to show you why we have two of them it's actually a technique used sometimes in production to ensure more accurate collisions where we use both a surface and a volume and I'm going to be showing you how to do that so let's go over here to the fluid based Dynamics inside of here we can of course use a dop net and that is what we're going to be using for this the dop Network so let's go ahead and rename this do net to flip fluid solver let's dive inside of this flip fluid solver and inside of here we're going to drop a flip solver so just to clarify the flip solver inside of a DOT context or Dynamics context as you can see in the top right of this window over here is different to the one at the geometry level right this flip solver over here oh whoops flip solver this one over here is different right this one has all of our settings at this level and it deals with everything basically it does gravity and all of that stuff this one over here is different so this flip solver is more PA bones right it's just a component of the sub level flip solver cool so let let's go ahead and add a flip object flip object into the left input over here go back to frame one and you'll see this big mass of spheres we don't want an initial volume so we can remove that then we can go ahead and just add our volume Source over here into the last input the sof path is going to be over here in fluid base Dynamics flip Source just choose that and initialize to Source flip now we still have these massive spheres we're going to go over to guide and particles visualization switch it to particles so that we just have this over here now our particle scale is going to be really weird we also have this issue over here where we have these giant bonds so go over to the flip solver volume motion change your box size to one by one by one and then just to ensure that the actual Source isn't lying outside of the box Move It Up by 0.5 on the y- AIS just so that we have something like that right okay so we have that in place now our particle separation over here is not very good we want to link this particle separation to the flip Source separation over here and the voxal scale so what we can do is we can grab it from here so particle separation click copy parameter and paste it in these two Fields paste relative references paste relative references right the reason we're doing it this way where we have this one affecting these two is because it makes more sense than having these two affecting this one because we're going to be working in this sort of context more often than working outside of it so it's nice to have control over everything from this single control and affecting these two out here with that rather than having to jump up each time to make a change so let's go ahead and change the particle separation back down to 0.004 and we just have that over there play this back and we don't have any gravity so it just shoots off to the side go ahead and drop a gravity force over here start again play it back and there we just have it right it's just this this stream of particles now our source doesn't look very interesting because it's basically just perfect right as it's going so we need to make some changes to how it's being sourced over here on the flip Source after we've done this let's just add an attribute noise over here we're going to set this to v v over there to affect our velocity let's take a look at our velocity trails and you can see that it's affecting it way too much so drop the amplitude to something like 0.01 and then we're going to set it to Zer centered let's increase our amplitude to 0.1 0.15 something like that looks good and then scale down the element size to something like 0.1 as well we're then going to add animation to it and decrease the pulse duration to something low like 0.15 if we play it back this is what we end up with where there's just a little bit of movement so that's going to be useful for not having that perfect stream of particles and if we go back and try it again let's see what we have right so that adds a little bit of something to it we can make some changes to this so that it's a smaller element size 0.05 we can also increase the roughness so go over to fractal increase the roughness try that and that's probably better right the other thing that we can also do is on the flip Source over here we have this Jitter scale and jit seed we can actually change this jits seed to Dollar FF what this will do is each and every time we run this and calculate the particle positions it'll adjust them slightly so let's take a look at what this looks like with a blast node so if we blast everything but the particles over time you can see how they jump around right so they're not consistent if we were to change this so let me just set this back to what it was right zero over here then you can see that they all stay static the second that we make this time dependent by doing dollar FF or frame that's just fetching the frame number we end up with that jit okay so that's cool right back in here we just have that and once it reaches frame 48 or so it just disappears right so that's what we have cool let's go ahead and set up our colliders now we can go ahead and use a static object for this and we're going to need to merge it in so let's merge this over here before gravity after gravity doesn't really matter make sure that the collider is coming into the left side of the merge node so you can switch them around over here alternatively setting it to Mutual does the same thing for us so on the static object we have some options let's go ahead to our soft path over here and go to Glass we're going to grab glass surface out you can see how it brings in our glass this isn't exactly what we want if we go over to the collisions Tab and take a look at the Collision guide you'll see that we have that blue collision geometry being shown over there and then we can display our geometry or we can hide it and if we hide it we can see what we have right this collider doesn't look exactly how we want it and also this big box is kind of making things awkward for navigation so I'm going to go over to my flip solver and just deactivate the visualized limits okay back to the static object this static object is not exactly how we want it to look it's a bit rough and in a lot of cases it's just not going to be as accurate as we want it to be so instead of allowing it to generate this Collision for us what we can actually do is change the mode over here to volume sample this is where that other volume that we created earlier is going to come into play Under proxy volume at the bottom go ahead and choose from your glass volume out when we bring that in we'll have a much higher resolution Collision geometry over here and this is the one that's being generated over here we use this VDB from polygons and then output it that's what we're seeing over here right that's what we're seeing and this is a really good way of doing it especially if you have deforming geometry because what you can do is you can actually calculate your colliders so let's just say that you have a really complicated creature that's like breaching an ocean surface what you can do is you can say clip it to only where it's interacting with the surface you can file cache that to disk and then because it's file cached to disk this flip solver won't need to calculate at every single frame right so deforming geometry usually it would have to calculate a collision guide every single frame but if we explicitly say we want this to be our volume then it doesn't have to calculate it it can just pull it from this over here and this could be saved to disk we can make all sorts of changes to this at the SOP level it's really good to do it like this it gives us a lot of flexibility now I'm just going to play this back and I want to show you an issue that we have with this now you'll see these particles flying out through our volume and this isn't actually an issue with our glider sometimes there's just not really that much we can do about it we can remedy it by increasing things like substeps and things like that but we don't really want to be doing that not necessarily and not right now so let's rather correct this issue now and then we can increase our substeps if we have to substeps should be sort of Last Resort something that you should only do if you really need to do it so over here this is actually a weakness of volume colliders volume colliders are great at ensuring movement along a surface so as you can see these particles that sort of like move along the surface but they're not great at tracking these sorts of collisions where it's passing through so what we can do is actually also use a surface collider now how do we know whether we're using volume or Surface colliders you can see over here that on the static object it says use solver default for the flip solver your solver default is going to be volume collisions so it's the same as setting it as volume collisions right that won't actually change anything this is now a volume Collision however we can also change this to a surface Collision now I just want to hide our Collision guide over here and change this to a surface Collision then go over to the surface Tab and say show Collision radius and this is something different right this one over here is just the actual surface that we're bringing in so this over here on the left hand side this over here this geometry it's just using that surface as a collider right so it's not a volume Collision the issue is that when we play this back it doesn't behave so nicely you can see that if we look inside the fluid doesn't really play too nicely with the inside of this glass it does some weird things and there's some volume loss and all of that but it doesn't penetrate the glass so a really cool trick that we can do is to actually use both a surface collider so having it as surface collisions and a volume collider so just click alt and drag this over that will make a duplicate and on this one over here I'm just going to hide show Collision radius and I'm going to switch this back to use volume collisions so the one on the left over here is using surface collisions the one on the right is using volume collisions and then we just merge these two together and we end up with The Best of Both Worlds so I'm just going to hide both over here play this back and as you can see we get that nice movement that you get from volume collisions and we also ensure that we don't have any of those particles going through our collider because we're using surface collisions so it's just a nice trick you can use both surface collisions and volume collisions and this will actually help your simulation quite a bit in terms of accurate Collision detection for simulations where we're doing something with like large scale water simulation and we don't need it to be this accurate I would forego the surface collisions and just use volume collisions right so ignore surface collisions just use volume collisions surface collisions can get quite expensive so once again don't use that try to use volume collisions cool so we play this back and we expect our fluid to fill up the glass but it doesn't really do that right we have the fluid slowly filling up but it's not really the amount that's coming in you can see that there's a little bit of a disconnect between the amount that's going in and the amount that's kind of staying in the glass but you can see that eventually we have our fluid that's just kind of coming to rest in our glass and that's quite nice now you will notice that it does lose volume over time it'll actually kind of collapse in on itself over time and that isn't what we want there's a couple of things that we need to take note of right okay so for this part I'm just going to bring up my drawing app so that we can revisit the concept that we looked at in the last part okay so in the previous part we looked at this concept of there being particles and voxal one thing that I want you to take note of is that in a flip simulation because we have both particles and volumes that actually work back and forth to maintain the level of particles that we require right so let's just say that we have some voxal so some little block that's a field right so that's not a particle that is a field that's once again looking at oan inside of that we could have you know any number of particles right so a number of particles inside this particular voxel what happens is if the density of particles in here is too high so let's just say we have two situations right it's too high or it's too low right so too high or too low then we should do one of two things if it's too high then we should kill particles to get us to our required particle separation in our case we know it's that value of like 0.4 if it's too low we should birth particles so we should add particles to the simulation to bring us up to the required level to maintain fluid volume levels right so this over here is what you'll commonly see referred to as re seeding reeding right when you Reed your simulation you're checking for voal densities if the particles in the voxal are too low you birth some new particles to meet a threshold if there's too many particles then you kill some now an interesting thing that happens and this might not just be from receding there's a couple of other things that it does like the surface level and all of that but we're not going to look at that too much but the idea is that we have our glass right so we just have our glass over here and our part is parles are coming in as this fluid and when they interact with the surface you end up with particles all going from a very high velocity so this is a very high velocity Zone to a very low velocity zone right they're suddenly stopping when they hit this glass and what happens is particles will stack on top of each other so let's just say we have like four particles or three particles and they all kind of moving in this direction right when they impact the glass so when they impact our glass they're all kind of going to stack on top of each other right they're going to stack on top of each other and then receding is going to kick in and it's going to be like hey wait there's too many particles here let's kill some of them so all of that volume that you had over here right so you had maybe three particles going in they Collide and you still have three but then it gets reeded and you end up with a situation where all you're left with is actually one particle right you have one particle over there that's an issue because we're losing volume right we're going from three it's all getting compressed together it's getting red in this voxel as they're being too high of a density so let's kill particles to maintain a density and you end up with just one particle right so you're losing you know a third of your volume in this situation now there's a couple of solutions to this firstly we can look at substeps because if we have enough substeps then these particles will collide with each other right this one will be over here and it'll be like oh wait this particle's in the way I can't go through it so I'll just sit on top of it and I'll sit on top of it and then it sort of maintains the kind of spacing that is required for us to not kill it right so this is just one understanding that I need you to have is that particles can all be kind of squashed together if we don't have enough substeps and what can happen is then we can reced it and kill them and end up with volume loss another thing that can happen is simply if some particles are at rest this exact same thing can happen right so I'm just going to hide this GD I don't really need it right now so let's also have the situation where we just have some particles at rest you might have this issue you might have had it before if you've worked in Houdini but the idea is you just have some particles at rest right so they're all just kind of filling this glass but I just want you to notice something right these particles over here say there's like some particles that are sitting kind of like that right these are going to have lower densities than these over here because these are only surrounded by a few particles right while these ones are surrounded by many so what it'll actually do is it'll kill off these particles right that top layer will be killed off then the new layer is going to be here and then this layer is going to get killed off and the new layer is going to be here and then this layer is going to get killed off and you're just going to lose volume in your simulation and there's other ways that this can occur but the idea is if there's like weird spacing issues or grid scale issues you're going to lose volume and so there's a couple of ways to work around this and I'm going to show you pretty much as many as I can but often times there going to be different causes for this so do keep that in mind you will have different causes for your volume loss in different simulations but there's some ways to work around it perfect so now back in Houdini we know that we have this fluid and it's pouring into this glass let's make a few changes to ensure that firstly we're not having this issue of losing volume because as you can see this is exactly the issue I was talking about they're getting compressed down to closely because they're going from High Velocity to low velocity so they're all kind of stacking on top of each other so we're losing some volume that's why it's not filling up as it should it's still filling up but this isn't how much you would expect it to fill up right this filling rate seems a little bit off so we're going to have to make some changes okay so the first thing I actually want to change is going over to this volume motion Tab and we have this velocity transfer option over here of flip splashy splashy is just a calculation method that ensures that our fluid splashes around a lot right now if you want a fluid that doesn't Splash too much and kind of just swirls around itself you can change this from splashy to Swirly alternatively you can push up the velocity smoothing swirly is just a different method of velocity transfer it tries to ensure that it's a more smoothed out velocity so if you play this back you'll end up with a less well splashy volume and it'll be more swirly right so we're now just ending up with swirling occurring in that volume okay so that's cool right that's helping the movement of our simulation we still haven't address this issue of losing volume so let's go ahead and actually just increase our substeps now you have two options of increasing substeps over here under the substeps tab you have the max substeps over here this is based on a CFL condition basically it tries to figure out when more substeps are needed and only uses it when they're needed so if we increase this value to something like three we can play this back and see what we end up with and a lot of the time this will actually fix your volume loss issues and in this case it might have again it's tough to tell when you're playing it back at the speed but we'll play it back afterwards and just see what we end up with so then the fluid kind of tapers off and you can see we have much more volume in the this fluid than we did before right it's at a much higher fluid level and it looks pretty decent so let's just play this back and see what we have right so that looks a lot better to my eye there's of course some issues that I have for example I don't like these little bits of particles that kind of fly up I think that they look a bit weird but once again we'll get to fixing that okay so substeps kind of helped our one issue the other thing that we can do is go over to the particle motion tab over here under separation if we have particle separation applied it'll try to move particles away from each other until we reach this particle separation so all it's doing is trying to enforce that separation this is also useful for maintaining a fluid level in your simulation it'll try and push particles apart that are too close together and like collapsing in on each other but we don't necessarily want such a high separation rate we'll do something like 0.5 to test with and what you should end up with is a more volumous fluid but also a more uniform distribution of points it should feel as if they sort of collecting in certain areas and doing weird things this little particle separation thing extremely useful for maintaining a fluid level once again so these are just two tricks so far we just looked at substeps and we looked at particle separation right so cool now our particles are trying to stay apart and they're not really collapsing down so this is nice we have this fluid that falls up this cup looks good okay I just want to show you one other thing that you can work on to ensure that particles are resolved correctly and that is this grid scale over here grid scale isn't often adjusted that much but basically the field size of your simulation so when we look at voxels what sort of voxal scale are we talking about it's calculated by taking your grid scale I believe it's your particle separation times your grid scale and that gives you the field size so the foxal size for your simulation so if we decrease the grid scale we're increasing the resolution of the grid right of the oian side of things so if we decrease this grid scale to something like 1.5 it's actually going to increase the resolution of our simulation so our simulation is going to run a bit slower but it's going to increase the fluid density inside of our simulation right so we play this back and perhaps you can see that you end up with more volume in your fluid right there's a more volume as fluid and so this is also a change that you can make I don't always make this change I prefer to rely on other things first but this grid scale is a good option and for our situation over here we might keep it at 1.5 right so particle separation and then grid scale and what you'll notice is that the actual resolution of our simulation is increased because the field resolution is based on particle separation and grid scale so even though our particle separation has stayed the same our grid scale has gone down so our resolution has gone up that's just something that I want you to keep in mind right so it's a nice simulation but we're now having perhaps too much fluid so I'm going to just dial this back right but you play with these settings until you find something that works for you so you can see at this level I'm just having these particles pour over I don't really like that so grid scale can go up to like 1.75 and I'm not going to play that back it's probably going to be good enough for what I want okay so let's go ahead and make a few more changes over here on the particle motion right so under the particle motion tab on your flip solver I want to add a few things I want to add an ID attribute and I want to age particles now adding an ID attribute all that does is attracts the IDS of each particle so that you have something that's constant for the particles and and I'll explain why this is extremely important later so just know that a lot of the time we do want this ID attribute it's extremely useful it also doesn't take up much space because it's just an integer so it's not like a vector that's going to stay on your points it's just an integer ID extremely useful always consider adding ID if you're going to be doing things with your simulation post Sim which you are in most cases aging the particles just adds an age attribute that tells you the age of the particles throughout the simulation so newly sourced particles are going to be younger and then particles that have been around for a while are going to be older and we can do certain things based on that now these are going to be saved as attributes and if we go uper level and just switch our display flag over here so over here under the object the only thing that we want is actually that flip object so go over here and just select flip object that's the only thing that we actually want right so we just have these particles coming out I'm just going to add a null over here and we're just going to call this fluid particles out right so these are the particles that are coming out of our simulation and I just want to show you the attributes that exist on it you'll see that there's a whole bunch of attributes we have life we have dead we have age we have all of these weird things going on most of them you don't really need to worry about the solver is actually using a lot of these behind the scenes but the ones that we added is just ID over here so you can see that each and every ID is unique we also have life and we have age right so age as these particles get older you can see at they age and this is cool because we can also do things like this I just want to show you a way of visualizing it if we drop down a node and we go ramp from attribute we can choose something like age and let's ramp it as black body and ghost other objects just want to show you that as this age increases so the particles that have been around for a long time they're getting older so it's moving up this way right and this is in seconds So after 24 frames you're going to have ages of one right so you can see over here age is approaching one right if I go one frame more age is now one for all of them right so you can see which particles have been around for long okay so that's one thing but there are actually other attributes that you can add to your simulation to really control the way that it looks there's three that I want you to focus on and maybe even two I'll I'll reduce it to two right so let's go over here to the volume motion on our flip solver under viscosity we have this over here where it says enable viscosity we have viscosity by attributes currently gray out same thing with density density by attribute and we also have Divergence these are the three main ones that I want us to focus on Divergence you can sort of ignore for now um I'm not going to worry about it too much density and viscosity are the two that you're going to be using most for small scale simulations and to quickly explain what viscosity is it's simply the thickness of the fluid so fluids that are thicker tend to share their velocity with their neighbors a lot more if you think of honey and perhaps honey being made up of loads and loads of particles you can think of all of the particles moving in a very similar way right they all share a very similar velocity when you're sort of pouring honey out if you look at something like water each and every water particle could have very different velocities right it's very splashy so viscosity is basically the thickness of the fluid now if we go over to density we have this density by attributes being controlled by an attribute now density is basically the weight of the fluid and that's not entirely correct terminology but the idea is that you have a density of a thousand and a thousand represents water because 1 Mill of water is 1 G so in a liter of water you have a th G so you can actually do that same calculation and you can work out whichever fluid you need right so as density increases you end up with something that's a heavier fluid per milliliter right so the amount of fluid that you have is heavier so that's the idea behind it and these are all controlled by attributes and quickly Divergence um just in case you're interested this is an attribute which kind of pushes particles apart right they diverge away from each other so they almost expand this is useful for things like fo and stuff uh we will be using it at some point but we don't need to worry about it too much density and viscosity are the two that we're interested in right now fortunately the attribute names are viscosity density and Divergence so if we enable viscosity and say viscosity by attribute and also go up to our flip object we go over to the initial data and tell it that we actually want a viscosity attribute then we can start messing around with viscosity so it's just those three things that you have to change add viscosity on the actual flip object enable viscosity under the volume motion and also do viscosity by attribute don't worry about viscosity with adaptivity that might sound like varying viscosity where you have like some low viscosity and high viscosity areas that's not what it means viscosity with adaptivity is just about the Adaptive solving so again don't worry about that we won't really be focused on that okay so I just want to show you what that means for us now that we have viscosity active let's just go ahead and add an attribute Wrangle over here and actually initialize that viscosity attribute so we'll just say at viscosity equals 50 right so this should work and this weird occurrence over here happens right where this should technically be going into our glass over here but there's clearly an issue and this is actually something that I hadn't really seen before because most of my colliders didn't really have this issue so I just want to go back to our glass over here the glass geometry and I want to show you something so over here on this video VDB you can see that it creates this box around our VDB now notice how close this box Edge is to the top of our VDB this is actually what's causing that issue and so this is a bit of a unique case where the collider's edge is actually exactly in an area which is going to cause us some issues this is just something that will sometimes pop up in your projects there'll be weird things that happen and you kind of need to troubleshoot them the thing that we're going to do over here is increase the exterior band voxal over here so push that up to 10 what that allows is this little bit of space over here so that the VDB can function correctly what's currently happening and I'm not sure exactly why it happens when we have our viscosity and not otherwise but it actually views this as a closed off Surface so we're just going to set this to 10 and that will fix our issue so we can go back and give this another run and see what happens there we go so now it works I'm just going to hide this collider again and we can see what we have right so as you can see viscosity makes this fluid much thicker you can see how it's now sort of gathering just in the one corner of the glass if we play this back you can see how thick that fluid is right so that's just an example I just wanted to show you how viscosity works right we enable our viscosity over here and we drive it with a viscosity attribute now this is actually going to become useful because if we go lower on this viscosity so just something like 0.1 what you'll see is that we still have something that more or less behaves like water or a very thin fluid but it kind of holds its shape a lot better right it maintains its shape the other thing that I want you to note is that some of these particles over here stick to the edges of the glass that has to do with the slip scale on collision so viscosity tends to make things sticky right you'll end up with a much more sticky fluid if you are working with viscosity and so you can enable slip on collision right so slip on collision over here the default for slip scale will be 0.1 but this is often times not enough so we can maybe do something like like 0.3 let this play back and what it should do is those particles over there should now slide back down and join back in with the fluid yeah so it prevents those little particles from kind of sticking to the side of the glass and this is just a useful thing to know right so when you're working with viscosity if you don't want it to have that stickiness upon Collision you can enable slip scale and it'll slip down the Collision right so you can end up with something like this so why am I telling you about viscosity now well that's because we're actually going to be using viscosity for the areas where there's bubbles right because our foam layer actually behaves more like a viscous fluid than it does as if it were water it behaves more like a thicker fluid than it does a thinner fluid so we're going to be using viscosity for that right now I'm just going to set my viscosity on this attribute Wrangle back to zero and let's take a look at another important attribute over here we have density I'm going to go ahead and enable density we can leave our viscosity settings as they were with slip scale and everything we're now going to be looking at density if we enable density and we play back our simulation you would assume that this would add the density attribute over here to our geometry spreadsheet but it doesn't there is no density attribute you can check it by typing density over here right it just assumes that all of these particles currently have a density of 1,000 if there is no density that has been defined the important thing about density is not the density itself but the difference in density so what do I mean by that well what's important when we're working with density is inside of this fluid which particles have a lower density and which particles have a higher density because higher density particles are going to tend to sink and low density particles are going to tend to rise so what is that going to be useful for that's going to be useful for things like bubbles right our bubbles are going to be little trapped pockets of air so they have very low density so they float to the top our water however is going to have a higher density so it's going to sink to the bottom that's how you end up with those two distinctive layers of water and foam that's going to be particularly useful if you're looking at something like a beer or champagne simulation and in our case it's still going to be important so let me show you how this works all I'm going to do on this attribute Wrangle where we set off viscosity is I'm going to just add a little expression I'm going to say if and this is just a conditional so if and then we Open brackets and inside of these brackets if a conditions met then the things inside these curly brackets that follow the if statement will get Run Okay so this if whatever in these brackets returns true do whatever's in here right that's sort of the format of an if statement so in here we can say if and we're going to say at frame with a capital f less than 24 then let's make our density equal to 200 density equals 200 right something like that and then we're going to add something after this if statement where we say else and then we open new curly braces and in here we can say add density equals 1,000 okay so what am I doing I'm saying if this condition is true then set my density to 200 otherwise set my density to 1,000 if all statements are extremely useful for controlling logical flow so you have something like this we say if our frame or our current frame is less than 24 our density is 200 if it's greater or equal to 24 make our density a thousand and we can actually see this if we go to our geometry spreadsheet and we click over here we you can see that our density over here is 200 and as we go towards 24 we get a th000 so anything after 24 will have a density of a thousand okay so that's kind of cool because now what we can do is we can go into our simulation over here and we can play this back and you won't notice anything different immediately that's because we don't really have a way of visualizing the two different densities just yet but I'll show you how to visualize that shortly okay so let's go ahead and add a color node color nodes are extremely useful for just ramping things by certain attributes and so we can go over here to color type ramp from attribute set this to density we know our minimum density is 200 and we know our maximum is 1,000 and if we do that you can now see the difference over here but let's just give this two distinct colors so if it's low we'll give it a color of white and if it's high we'll give it a color of blue right sort of mimicking this idea of foam being low density and water being high density so if we play this back you'll see something cool right so over there that's where that change occurs this is all going to be that density of 200 based on this attribute Wrangle that we're feeding in over here and then after frame 24 it's going to switch right to the high density fluid so to the one that's 1,000 because of this if Al statement if frame is less than 24 do this otherwise do this so that's what we're ending up with over here and now I want to show you what happens right as you can see all of the blue liquid or blue particles they go towards the bottom and our low density particle come towards the top and this is extremely useful right this is exactly the situation that we need to achieve when we're working with something like foam so we have the situation where low density high density and then they separate right so we end up with this nice separation based on density again a density of 1,000 is the density of water if you're going higher than 1,000 then you're no longer trying to replicate water this is just 1,000 G per liter right that's the density over there and so that's what we've ended up with Okay cool so now that we have this let's try to think of a way to actually utilize this in a more nuanced approach because currently we're just saying okay here's some low here's some high mix them together what we actually want is for these low density particles to be created based on some other condition so how about if when they hit the glass they start emitting some foam right so some of these particles get turned to foam based on some parameter now what can we use to define what gets turned to foam this is going to bring us onto another useful attribute so over here I'm just going to go and I'm going to remove this if statement over here I'm going to set our density to 1,000 right we're just initializing it initializing your attributes is always a good idea so that nothing defaults to a value that you don't intend to have right so for example if we didn't set this to 1,000 over here and then we make some changes in our flip fluid solver we could end up with a situation where some of our particles that are being sourced in end up with a density of zero and then our simulation would break so we just make sure that every particle has a density of 1,000 we're initializing it over here okay so let's move on to our next issue how do we Define which areas are going to be areas that are kind of hitting the glass or areas that are turbulent well there's a really useful attribute in the flip solver if we go over to the particle motion tab let's go over to verticity and say add vity attribute and verticity is just the swirling in a simulation so I'm going to once again let this just run for a bit and I'm going to show you what the verticity actually looks like Okay so let's take a look at this in our geometry spreadsheet we can go over here and just see what our foric looks like right over here vorticity ranges from 0 to 270 so let's once again use our color node over here this time for vorticity and we're going to set the range from Z to 280 right just to make sure we get the entire range and flip this around make this darker okay so perhaps now you can see what we're ending up with right these are the areas of high verticity you can see that as the fluid's coming in it's not really swirling there's no Distortion to it so vity is low but when it starts swirling around in this glass we end up with high verticity so areas like this where it's hitting the glass and kind of spinning about that's going to cause high vorticity now you can see that this vorticity is kind of blurring out over time right and that's going to be because of this preservation rate that we have on our vity attributes what we can do is we can reduce this preserv rate to something like 0.05 or even lower 01 right so a fairly low value and what that will do is it won't maintain the vity for as long and what that's going to allow us to do is to very closely Define which areas are high voltic because all we really care about is that initial swirling that occurs upon impact right so let's just take a look at this and let's narrow this range over here right so if we narrow it in you can see that that's the area of highest verticity right those particles over there play this back and that is going to be a pretty good area to emit low density particles from right that is more or less how particles are going to be spawned because we're pouring a fluid into a glass and because it's like tumbling and rolling over itself we're going to end up with loads and loads of little air bubbles so let's use that right let's use the higher end of the vorticity range to emit some foam particles okay so now it's starting to get a bit complicated right just a recap we have vity which controls the thickness of our fluid currently it's zero so we just have water density controls how light or heavy our fluid is and it's only rarely important when we have varying densities so low densities will rise and high densities will sink at the moment we have it set to 1,000 for all particles because all of our particles are initially going to be considered as water we also have this vorticity attribute over here and this vity attribute tells us how much swirling we have in our simulation Okay cool so inside of here let's once again just look at the settings that we had to enable for this we had viscosity enable and viscosity by attributes we also have to go over to the flip object go over to initial data and just say add viscosity attributes then we had density we enabl the density attribute in particle motion we had vorticity and we don't really care about maintaining vorticity we just care about the initial swirling so reduced the preservation rate okay cool now let's go ahead and figure out a way to group certain points based on verticity for this we're going to be using a pop group so pop group over here pop group gets plugged into the particle velocity input so that's that second input over there and by default it doesn't actually do anything right so over here we need to give this a group name this is going to be our foam right what we want is we also want to preserve this group this is important because each and every frame we want to be adding foam to our foam group we don't want to reinitialize our foam group every frame we care about an accumulation of foam not just one frame's foam so we say preserve group so particles that are supposed to be in this group get added to the group that was existing right so we end up with an accumulation of foam over time over here we say enable and this is Rule based right so you can see that by default it's just saying in group equals one this over here this in group is something that's pretty unique to poer angles right this is just a bit of a command inside of poer angles and it's just saying put this into the group right 1 equals true 0 equals false so0 equals not in the group one is in the group and so over here we can once again use a conditional we can say if something right some condition is true then we just wrap this in some curly brackets like this press tab over here to indent this tab indents and now we can say if some condition is true then put these points into the phone group and we already know what we want we want if at verticity is greater than some amount we're going to choose 150 as a starting value and let's just see if that works okay so we go upper level and we play this back and what we want we can actually make a new color node over here this one we're just going to set all of our points to this bluish color and then we're going to make another color node over here and this one we're going to say make our fo white this is just a nice way for us to visualize our foam points right so this one over here make everything blue this one over here make our our foam white okay so let's play this back and see what kind of foam accumulation we end up with so there as you can see we're now getting particles added to that foam group right this is based on verticity anything that has a verticity of 150 or more is going to be added to that foam group right so anything that's really swirling about quite violently that's going to be added to a foam group now currently there's nothing to separate it right we're not telling our foam to do anything in particular we're just adding it to a group so we just have a custom group called foam and it's not really doing anything just yet so inside of our flip fluid solver what do we want it to do well this is where we're going to need to use a pop Wrangle right so after our pop group we add a pop Wrangle over here and over here we're going to enable this group and we're going to choose foam right so this is just something that we want only our foam particles to be influenced by in here all we're going to say is at density equals 200 right we can also say at viscosity equals 0.01 something like that so now our foam particles that we're creating by using this pop group over here are going to get a lower density and a higher viscosity than the rest of the fluid and if we once again jump up a level and play this back you'll now see a really interesting thing where the particles that are part of the foam group are going to rise towards the top and they're going to kind of cling together because they have a higher viscosity so I'm sure you can already more or less see that effect taking place right those white particles are moving towards the top and their movement looks a bit more uniform right a bit more smoothed out than the rest of the fluid and there we go right so that's what we have all of those foam particles move towards the top and the dark blue particles stay towards the bottom and we're separating the concentration just like that there's a few changes that I do want to make to this I don't like how much fluid is actually ending up in the glass so what I'm going to do over here is I'm just going to decrease my part itical radius scale to something like 1.1 right so if I play this back now cool so there's multiple ways to do what I just did over there where you reduce the amount of volume that's being brought in what you could do is you could reduce the amount of time that this particle source is emitting for you can decrease the size of the emitter you can go over here you can decrease your particle separation so that you have a higher resolution simulation you can increase your grid scale but what I did over here by decreasing this particle radius scale is I've made it so that each and every particle is considered slightly smaller than it was and this is useful because what you end up with is more interesting movement in your simulation especially for small simulations I wouldn't necessarily do this for a large scale simulation but for a simulation at this size by decreasing the size that these particles are treated as you're getting more interesting movement in your simulation and you're getting less volume right so the alternative is also true if you were to push this value up you would end up with a more smooth out simulation but you would also end up with more volume right so I'm just decreasing this slightly so we have less volume in the simulation cool and once again it's separating quite nicely because we have this foam over here the last two things that I'm going to do over here is just add a pop drag right over here this adds a bit of air resistance so we add our pop Dragon over here and a value of one is really really high so let's just do something like 0.05 that's quite a low value but do remember that this is going to be used every single frame so it's going to be slowing things down every single frame I do like to always add just a little bit of drag just so that you don't have crazy movement going on it kind of tames everything a bit the other thing that you'll often see is a pop speed limit so a pop speed limit over here and you just say maximum speed and you choose some maximum speed right so speed is going to be the length of your velocity vector and so let me just move this away for a second we can actually calculate what that value is if we just let the this play back if we go over here and add an attribute Wrangle this is just for interest sake what you can do is you can say add speed or you can call it whatever you want right but we're going to call it at speed and we're going to say is equal to the length of V at V semicolon at the end this little line of code is just going to calculate our speed value so we can actually see what our speed value is if we go over here we can see that our speed ranges from about 2.62 right so that's useful because then we can use that in the pop speed limit over here we can say Okay anything faster than let's just say four right because we had values that were going between Z and 2.7 or so and so anything higher than that is going to look odd so we can limit it to a certain level we're going to limit our speed to four just that we don't have any crazy particle movement or anything like that this is more of a safeguard than it is a look Dev thing you'll have a very similar looking simulation if you don't have this but it is just good to have in place okay so that's all we're going to do for this part part right we can play this back and take a look at what we have okay but basically we've got enough particles to separate into foam and this fluid at the bottom and in the next part we're going to start working on smarter ways of actually separating these two over here and we're going to work on ways of actually controlling certain attributes and things so that we have much better control over this simulation currently we have many particles that are still kind of floating around inside of the fluid we have a lot of extra movement that we don't necessarily want and there's loads of things that we could improve about the simulation so that's what we're going to be looking at in the next part and we're also going to be looking at how we can then take this and mesh it and start looking at how we can create Bubbles and things like that okay so that's all for this part I hope you enjoyed it I'll see you next time bye
Info
Channel: Nine Between
Views: 13,625
Rating: undefined out of 5
Keywords:
Id: Xs2tHiVFKF0
Channel Id: undefined
Length: 57min 42sec (3462 seconds)
Published: Wed Nov 29 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.