Houdini Tutorial: FLIP Interface Reactions

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi folks i'm sorry it's been so long since i posted last these are of course crazy times but that's no reason we can't learn a little bit of houdini um so i wanted to get back into things with a relatively simple uh little project here but i think it's an interesting workflow it's something that lets you have sort of different types of fluid interact and as opposed to just setting their individual properties having them actually come together and create some new fluid uh that has sort of its own properties and i'll talk a little bit more about what i mean by that but basically we're looking kind of binary fluid reactions so we have fluid type a fluid type b and where they meet we create some new fluid type and give it some different properties and this can let us have all sorts of different effects all sorts of different reactions what i'm going to focus on today is kind of this droplet-like interaction where we have a dissolving particle that will release a whole bunch of bubbles so let's just get right into it i'm going to drop geometry node here and i'm just going to call this my uh let's call it flip reactions and the first thing i want to do is just sort of show you a little bit about what i mean and basically show you pretty much everything we're going to do the rest of it will just be flip setting up i just want to give you a sense of the approach we're going to take here so i'm just going to lay out a grid that's much larger than i need let's just give ourselves a little grid to look at here i'm going to scatter a bunch of points on here let's say i don't know 10 000 what does that look like that's not bad oh let's even go higher it doesn't really matter sure nice dense grid um i'm going to put some noise on here and i'm going to use this to drive partitioning this into sort of two different types of fluid and again this is just for showing what we're going to be doing so i'm going to make an attribute i'll just call it noise i want this to be one dimensional and i want it in the range zero to one we can go ahead and visualize that dial in the element size a little bit to get something we like i want this a lot smoother for right now um that's probably okay maybe something like that and then all i'm going to do here is drop down an attribute wrangle and i'm going to say if this noise value is less than 0.5 i'm going to set something i'm going to call val a to 1 and otherwise we'll call this val b so if i turn off this visualizer now and i just say color one of these so let's just say valet is greater than zero we'll color these ones by default it'll set everything to white so let's just pick some other color and we have to specify that this is a point group and so there you go we're basically just partitioning this into two different sets i'm gonna scale this again a little bit maybe something like oh i don't know this is fine this really doesn't matter so this is our setup and once we get into flip we're going to have something very much like this we're going to have individual particles that are either part of one fluid our val a fluid or part of another our valve b fluid and what we want to do is identify those regions where they're next to each other we want to figure out which particles are in an area where it's a boundary between valley and valve b and there's a variety of different ways you can do this i'm going to do it in a relatively i think straightforward way and the basic idea is first i'm going to blur these two values so i'm going to blur using actual blur vote both val a and val b and i'm just going to make sure this gets nice and blurred so i'll set the step size up blurring iterations up and then of course if we were to do this initially it won't change anything so if we just look at this color and by default attribute blur is going to be by connectivity and none of these points are connected to each other and if we're doing a flip sim again we won't have any connectivity but we will have proximity so we can use that and for the radius here you can see this is very large once we're in the sim we're going to drive this by p scale these particles don't have a p scale we have 40 000 within a 1 by 1 square so we could work that out but i'm not really going to bother let's just dial this down a little bit lower and here it's not really making much difference but the overall idea now is that we are sort of um and actually if i make this a ramp we'll see this even better let's just ramp by valet and you can see that we're blurring out this edge so here it was a nice sharp edge and we're just blurring it and we're doing the same thing for val b it's also blurring out and the idea here then is that where uh let's see if i can show this more easily yeah let's just ramp these into two different colors so we can say that cd it's just going to be zero zero and then we'll say our red channel will be val a and our blue channel will be val b so now again here we just have red and blue after the blur we have red and blue where they're not near anything so all of these blue particles stay blue because they're not near enough to any of the red ones to get any of that blurring same with the red ones on the inside but in this middle ground we get this sort of magenta color we get this overlap and this is what we want to target so we basically want to find points where now valet and val b are closer together and what do we mean by closer together we really just mean that the difference is smaller so what i'm actually going to do is going to jump in here and i'm just going to say basically what we want is to take our maximum a valet and valve b and subtract our minimum and we can call this something like delta so if we visualize this and what have we got going on here i turned off the visualizer now you can see we get these nice little bands here so yeah this is our general idea here and this is basically what we're going to use to drive our flip center and what we're going to do is basically just say if this is bigger than a certain amount so if delta is let's say or i should say smaller if it's less than i don't know let's set an arbitrary value here let's say 0.3 then we can say these particles we're going to convert and if we were to just sort of color based on that value convert greater than zero we're not going to ramp we're just going to make it constant turn off our visualizer again now you can see we're just isolating this band and so what we're going to do in the flip sim is we're going to have these two fluids our valet and val b interacting but we're going to convert them into a new type of fluid only at the boundaries between those two types so hopefully that makes sense um we'll be coming back through all of this in the flip sim itself but i just wanted to kind of show the general idea of what we'll be up to here so i'll just call this our demo so let's go ahead and set ourselves up for flip so what i want to do here is set up basically a box so basically a container of fluid and we're going to drop a little droplet into there and where it sort of falls through it's going to fizz and turn into bubbles that's kind of the idea we're looking for so i'm going to start with the box one by one by one is just fine i'm going to just raise it up so it's sitting kind of on the ground here there we go so we'll move it up by half of a type so that'll be our base box we're going to get some points from volume these will be our initial particles i'm not going to worry about the point separation because we're going to drive that from inside the flip simulation so i'll just leave that here as it is for now and then we're going to want to set some attributes first i'm going to set this same kind of thing i'm going to say val a equals one i'm going to give this a color so we can visualize it um our base box let's just keep that i don't know like a dark red or something we're not going to use this really at any point in rendering or anywhere else this is just so we can keep track of the differences and then we're probably going to want to set some properties here so we can set things like density so i'm going to go with something like 10 and i'm going to set a viscosity in here as well let's say 0.1 should do nicely so this will be our basic container and then we want to drop a little droplet into there so we're going to want a sphere for our droplet that's obviously going to be way too large so let's just bring this down something like i don't know that's looking pretty good in there i'm gonna bring that up maybe there-ish that's looking pretty all right and i want to turn this into polygons even though i'm gonna scatter points into it and i'll show you why if you do points from volume from a basic sphere i mean these points are much too small so let's really pack them in there um i'm just going to go to a null because it's showing us that that outer part and i don't want to see that um you can't necessarily see it too clearly here if i were to i'm going way down the rabbit hole here but that's all right if we were to surface this and same general property you can see it gets sort of it's a little bit faceted and basically what's happening is that points from volume it doesn't really recognize this as being a perfect sphere or anything it's going to turn this into polygons first so the very first thing this is going to do i think if we dive inside we can probably find that somewhere in here might even be this triangulate this is a mess in here um this thing has not been organized terribly well so well let's not worry about that but the first thing it's going to do is turn this into polygons and it chooses relatively low resolution version of that so if we do this ourselves we can set this nice and high we can give it a really nice clean round polygon shape and that's going to get rid of any sort of faceting it was going to do we're still getting these sort of flat edges but in general i prefer to start from polygons on the sphere because i find it gives you a better sort of round result here now the other reason we want to start from polygons is because maybe we don't want this perfect sphere maybe we actually want to give this a little bit of noise that'll make the simulation itself a bit more interesting so i'm just going to drop a mountain here and this is all much too much maybe just a little bit of interest in here again i'm going to take the roughness down i really just want to give this a bit of distortion so even that's probably more than i want so there's a normal sphere we'll just bulge that out there just a little bit of noise just something to shake things up a bit so again we'll turn this into points obviously we're not going to get very many points if we use that same particle sampler separation is over here but we are going to fix that soon so this is our droplet source so we're just going to go in here and we're going to give it a different value so it's going to be val b and then we also want to look at its properties i'm going to give it a color we'll just make that black so there's those particles again we're going to have more in a second and the last thing i want to do is if i want this droplet to sort of sink through this other fluid then the density should be a bit higher so let's just call this 15. so i'm going to merge these i'll grab both of them i'm going to alt and drag that'll give me a merge node and then drop down to this null and i'll call this our flip source so here's our particles this is basically all we need to go into the flip simulation itself so let's just go ahead and drop down a dot network i'll call this flip sim and we'll dive inside and we really don't need very much here we're going to want some gravity we're of course going to want a flip solver and we're going to want a flip object wire these all together and the first thing i want to do is change my initial data here to a particle field and i'm going to go ahead and grab that flip source we just made so it'll bring that in i'm going to go to my guides to my particles and of course turn it from sprites to particles and finally i don't care about the speed visualization i don't actually want to see that so i'm just going to go to none here and that will give me those color values we set outside last thing i want to do this particle separation is way too high but first we need to actually tie it to where we generated those particles so i'm going to copy this parameter and i'm going to go back to these and i'm going to paste relative references and paste relative references so now we can go in here and we can tune this a little bit let's say 0.02 that's looking pretty good we can probably even go a little bit lower maybe 1 6. uh if we do this then we're getting about 250 000 points so that's that's pretty good um that should be fast enough for now maybe i'll even no i i do want enough resolution that we can actually see some things here so that should be good for now next i want to deal with these volume limits because right now if we were to simulate this it's all just going to fall so we want to give it a container so i'm going to go to my volume tab here and i'm going to go to my volume limits and i know that this box is one by one by one so let's just make it one by one on these axes and we don't need much space but i do want it to be a little bit taller than that box just so we have room for some splashing and some sort of jostling at the top so i think about three high and one by one should be a good little container there so this will be our volume i'm going to turn off the visualization because we don't need that but i do want to go back to this flip object and make sure we're closing these boundaries because again if i were to run this now it's just going to fall through that floor and now all our stuff is gone so we want to close these boundaries if we do that then we get the beginning of our sim but of course we're not quite there yet even for our initial setup of course we have no reactions going on here but if you watch this dynamics these dynamics and if you've done much sort of flip simulating before you'll realize two things um one it doesn't look like our different densities really had any effect at all um this droplet just sort of fell and they all merged together and splashed and jostled around two this doesn't look like it has much of any viscosity going on and both of those things are true because we need to do a little bit of extra setup so again on our flip solver under our sort of volume information first we want to go to viscosity and we want to enable it if we don't do that it's never going to use viscosity and we also want to check viscosity by attribute now right now both of our sources have the same viscosity 0.1 and 0.1 once we add our reaction fluid we might want to change the viscosity for that one so we do want to make sure this is by attribute here and then for density density is of course always enabled because it's mass it's got mass it is a material so it's going to have density no matter what but by default it's just taking a single value and that value is coming from over here on this physical tab there's our default density so what we want to do instead is density by attribute and so this is going to pull our density from this attribute here so once we've enabled those two things now it should behave a little bit better we should see it dropping and now you can see we don't get it all merging together instead this more dense fluid is actually pushing away the less dense fluid and then we're going to get this little bit of a kick back here now this is fine and if it's what you want then that's what you want um but i actually don't really want this splash especially since uh what we're going to do is we're going to generate where it interacts where it has these boundaries we're going to generate a fluid that's even less dense something sort of like bubbles we're going to get this huge tail of a splash coming up here and i don't necessarily want that right now so what i'm going to do instead is i'm actually going to start this droplet inside this fluid here so let's just go and set that up and so what we're going to do is just a slight variation on what we've got here we're going to generate our initial box here and we're going to again have this mountain sphere but instead of having it up here we're going to move it down inside this fluid i should get that box visible so we're going to have it somewhere down in here in fact maybe let's see this just so our mountain and we'll just start it somewhere near the top but inside this box now we don't want to just generate these points all throughout here and it would work fine from sort of the the fluid simulation perspective but in terms of what we're going to do here basically everything is going to be adjacent to other stuff it's all going to blur together so what we want to do is not overlap these two things but basically find those points from this box here that are inside this area and call those the other type so we'll just delete this stuff and what i'm going to do instead is again i'm going to take this mountain sphere i'm going to do a vdb from polygons and this will give us a surface density function this doesn't have quite enough resolution for me i'm going to pull it just way down we only have to do this once so we don't really care about any overheads here and even that is very cheap so this gives us a nice little representation here so we're just going to drop in fact maybe i'll just copy this one we're going to pipe through here and now what we'll do is basically say if our volume sample from that sdf from that surface density function at this current position is less than zero then we're inside that shape oops deleting everything wrong here move all of this over and so what this shape is um just quick reminder this is a surface density function so basically everywhere in this volume it's not actually storing this surface it's storing the distance of each voxel in this volume to this surface so it's giving us a representation of the polygon so positive values are going to be outside negative values are inside so if we sample that volume at the position of each particle that we have from here so each of these points is going to ask where am i in this volume am i getting a positive value which means i'm outside of that shape or a negative value if we're getting a negative value then we're inside that shape and so we're going to switch ourselves to val b and when we do that we just want to make sure we set val a which by default was 1 to 0. and so now we have our full box and we're going to replace all the points that were inside this shape with that other type and so i want to use that for our flip source so now if we go back to our simulation here it's going to behave pretty similarly but we won't get that huge splash so again you can sort of see through here that that sort of darker particle is falling and we should get a little bit of displacement at the surface here just a little bit from it kind of passing through and causing that sort of kickback but basically we're not getting that huge splash that we were seeing before and that's what i wanted to avoid and you can see that all of this has come down and hit the bottom here which is what we would expect for a denser fluid now believe it or not we are basically almost done all we need to do now is take this logic over here from this sort of demo and apply it inside of our flip solver that's very easy to do we'll just sort of fully replicate it back in here so in our flip sim we're going to drop down a sop solver and we're going to just tie that right into our post solve we don't need to set up anything crazy here we want it to do its default normal thing and we're going to use this default normal geometry so it's just pulling from our flip sim it's pulling from our flip object this geometry container and this container just holds all of these points so we're just going to get these particles um yeah so here we're getting all those particles you can see them here they have their valet and val b they have their viscosity they have their density all of that good stuff so the first thing we want to do is that attribute and we're just going to put in those same settings as before we're going to say val a and val b are the attributes we want to blur i'm going to use the same values 3 and 1 here and i'm going to do by proximity now for my radius i only really want to consider particles that are pretty nearby and nearby in this case actually has a pretty clear definition we've specified our particle separation right here so i'm actually going to copy that value and i'm going to paste it in here and i'm going to say maybe within three times that particle separation so give ourselves a little bit of space but we're not going to be considering particles a long long way away and to make sure this thing stays relatively quick we don't even need to think about very many neighbors let's just check the nearest 16. so here we're blurring these values and if we go over and look we'll see a bunch stay the same but we should find i guess we need to look basically at the middle uh oh here we go so you can start to see these are we have too many particles to easily scroll through here but you can see that they're starting to sort of blur together and somewhere around here somewhere near the middle we'll get sort of closer values together but at this point they're sort of far apart but we are getting this blurring so the next thing we want to do is again get that sort of difference between those values so we're going to say we'll call this delta and it's basically just going to be the difference between the maximum of these values and the minimum of these values now you'll see i've sort of dragged this over to the side i'm not lining it up obviously you can put these things anywhere you want but i just did this for a reason because we don't actually want to blur these values on our original particles and the reason for that is that these are supposed to represent each particle is either type a or type b we don't want them to be fractional types that's not what we're trying to do here that is one way to approach reactions between fluids what we want to do is say you are discreetly either a or b or the new type that we're about to create so i want to do this blurring on sort of a secondary branch and then reference that value back into the original geometry so we'll put another wrangle here and we'll just pipe this in on that second input and because we're coming straight from this list of particles and these are all just particle operations we're not changing the ordering anywhere here so that means particle one here is going to be the same particle as particle one here everything's been processed it's all in sequence we haven't shuffled or rearranged anything we haven't added or deleted particles so we can very safely just reference these values using app pt num so we're going to do that so the first thing we'll say is let's just flip these values because delta right now when it's close to zero that means they're really really on a border when it's close to one that means they're not on a border so these are actually ranging from zero to one for uh on a border versus not on a border and we kind of want to flip that so what i want to do well let's just say yeah let's get a value we'll call it convert and we're going to reference those values so it's going to be input 1 which is our second input the attribute is called delta that's what we specified here and we can just refer to p2 not so now we've pulled over this value and you can see it ranges from zero to very very small so there are some cases where they're really really close together and these ones would be sort of boundary points so what we could do here is basically just say if convert is oh and i didn't flip it so let's say one minus that's what i meant to do so now if we look at these again you can see usually it's zero which means we won't convert but there are cases where it's up at one and these are cases that are on the boundary so we've just remapped this zero to one range to a one to zero range so one means we should convert zero means we shouldn't so now we can ask if convert is greater than some threshold value um let's even just make a little channel here then we're going to do something i'll make that channel and let's say if it's greater than 0.8 uh we're going to dial this stuff in a little bit differently soon but this is the basic idea so if that's true the first thing we might want to do is set a group i'm going to set that as rx and this is just short for reaction so we're basically saying this is our reaction group if we're in that group we're going to want to say we're no longer interested in ballet and val v so these are going to go straight down to zero and we might want to set some new properties so i want these to be like bubbles so i want them to float up to the top so that means i want my density to be much lower than usual so i'll set that as something like four and finally i'm going to give it a new color just so we can see it nice and easily so i'll set that to white now because we're setting these groups and we're running over this each pass on the first pass we don't have any of this group but on the second pass we do so what i actually want to check is if we're in this group we'll do some reaction specific stuff and we'll come back to that in a moment otherwise we'll do this stuff um save it's going to be upset the reason i'm doing this you can't easily tab over a whole group in this view but if you go to edit string and bring up this little dedicated editor now i can grab all of this and tab it over all at once and that's just a little bit easier so there we go so basically if we're in the reaction group then we're going to do whatever we might want to do with it otherwise we're just going to check this so if we're not in the reaction group we're going to check if we should be and if we are then we'll sort of move ourselves over so if we apply and accept that this is most of what we need to do we're going to add a little bit of extra stuff just to make this more interesting in a minute but this is basically the whole thing so let's go here and switch this to the output so now and in fact i'm just going to use a dot import here to bring in these fields it's not strictly necessary under this circumstance because we're really just fetching this geometry and there's no other geometry in there but it's it's good practice so here's our information you can see we have that blob in there um i'm going to maybe just so we can take a look at this i'm going to delete everything that is z less than zero we'll put this on points and let's see ah okay so you can see it has deleted those points this is just a viewport thing so new scene view there we go so now we can see that blob inside and if we step forward here you can see that our reaction is happening way too quickly uh so it's just sort of bursting outwards and covering everything so that's all right we can deal with that first thing we might want to do is set this threshold a lot higher maybe even like nine five we can try that again that's just sort of swamping pretty much everything so maybe instead what we want to do is have a bit of an accumulation here and so instead of just saying at each step let's grab this delta value let's actually accumulate this value so we're going to say on each step we're going to add this delta and then we're going to compare that to a much larger value so let's say if we get up to 5. let's head back out and now it's still instantaneously getting this big ring here but we are having it come in a little bit slower so that's almost what we're looking for and the problem that we're running into here ah that's right what i actually want to do here i don't want to do this for every single sort of test we're doing i basically only want to look at this expression if we have sort of a reasonable amount of overlap and we can define a reasonable amount of overlap by saying that our minimum value should be a certain size or larger so if we're way out in the other ranges we don't want to even consider it because what's happening with our blur our blur is pretty wide and we want our blur to be doing a lot of work to make sure we're getting nice mixing so we can actually compare these values but we don't want to compare them all the way inside here we really want to restrict our consideration to this sort of range near the outside so what we can do for that is basically say if our minimum is greater than some certain value uh and let's use that point three we had back out there i'll just make a note here 0.3 is is arbitrary so if that's the case then our delta is going to be max minus min otherwise we'll just say that it's one so even if it might have been much larger we're just going to say that it's 1. so this is going to be restricting our attention to only cases where we have a fair amount of overlap where our minimum value is at least 0.3 so this is really going to restrict our range a whole lot more so now hopefully we can get our scene view to refresh there we go now we should have it come through slowly and only on the outside there so that's what i'm looking for i want to see these particles this this exchange happening over on only on the outside and so right away you can see that this is basically working pretty much exactly like we might like only where we're getting that interface between the red and the black fluids we're having it turn into these sort of white bubbling fluids and those are getting that new density which is much lighter and they're drying themselves all the way up to the top there so there we go now we've got this sort of nice little effect going on here and this is more or less all that we want and all that we need so i'm just going to do a couple extra things a little bit of sort of quality of life and a little bit of setting up for other effects if you want those and in particular one of the things we might want to know is how old are these newly reacted particles so to do that when we first create these new particles we're going to store a new attribute and i'm going to call this rx onset and i'm just going to set this to the current time um so now we're keeping track of when this particle was first created now we can use that up in this reaction specific stuff so first what we can do is get our age and that'll just be the current time minus that rx onset and so this is going to be specified in seconds um this can be nice because if you change your frame range this won't change this will still behave the same on the other hand if you want it to be in slow motion but you want the same relative sort of timing then you'll have to change this to frames or you'll have to change this relative to that but basically right now this is going to be in terms of seconds you could also do it in terms of frames you could just say at rx onset f for frame uh is their sort of current frame uh that doesn't work in here i guess we need to use i think a frame or something like that um i'm gonna keep time though it just makes more sense to me to work in terms of seconds right now uh but of course you can do that any old way so now that we have this age factor let's just use that to drive something else so for example maybe we can drive viscosity with it so we could say our viscosity can be fit using our age and maybe we want to go from sort of uh maybe half a second up to three seconds maybe we go from our original viscosity or even a lower viscosity to start straight from zero and maybe we ramp up to a much higher one and so now for each of these new particles that are created these little bubbles they're going to start and they're initially going to be very low viscosity they'll flow very easily and as they get older as they get to about three seconds old they're going to start to get sort of thicker and thicker and drag more and more if we really wanted to shape this we could even put a ramp on here viscosity from age and just use that in there um we would normally this is going to return in the value in the range zero to one so these ramps will always return in the range of zero to one um i actually want to go from zero to one for viscosity so that's fine but if you didn't then you could just drop a bit of one around here and map that to your min and max whatever those might be but in this case zero and one seem pretty good to me well let's let's just keep this here just in case just in case so here's our ramp that's all good and we'll just map that to zero to one so this extra fiddle one right now is redundant but if i decided actually i want it to be even more viscous or i want it to start sort of higher we can tune that more easily now so here's our ramp and what we might do is basically let it go and sort of bend up near the end there so we'll have it accelerating near the end and i'm going to change these too i like camel rom it's just a little bit rounder okay so if we do this it should look pretty similar but as these particles get older they're also going to get and we could even let's just visualize this let's take our rx group and we can do a rant from attribute and we can ramp viscosity just so we can take a look at this and let's make this maybe like a black body color or something um this is not a good ramp for this let's use that's not a great ramp either let's just make sort of a blue toned one all right good enough now we can just see it against these other colors that we had so now as this comes through you'll see the viscosity starts very low it flows really freely as it gets older you can see sort of the color range is changing and this should also be changing that viscosity so as these particles are getting older after their creation they're getting more and more viscous and they should start to sort of move a lot more sluggishly and that's really just kind of a look tweaking but depending on what you're trying to do it may not be bubbles you can do any sort of thing with this same process you might want to sort of drive viscosity you might want to drive divergence you might want to drive temperature there's all sorts of things you could drive with both age and this sort of this reaction creation so i'm just going to do one extra thing here instead of cutting down the middle there let's just pull out now it's not showing me anything why not oh this is just val i want vowel hey there we go and i want to delete select it there we go so now we can just pull out that central part and we can see what that looks like and we're getting this nice sort of dissolving effect here and we can see that sort of viscosity is ramping over time so honestly that's pretty much everything for this effect and because this is a nice short tutorial and a simple sort of effect i'm going to talk a little bit about how you might go about rendering this so to do that the first thing you would probably want and i'm not going to bother here just because it's a pretty lightweight simulation so we don't need to but you would probably want to throw a file cache in here just to save out these particles um i wouldn't do a compressed fluid output necessarily because you've got sort of custom particles and things going on here you can set that up in your compressed fluid cache um but anyway i'll leave you to do that on your own and then what we want to do here the way i rendered this in the sort of demo i showed at the beginning the idea was we had this clear fluid on the outside and then we had this droplet falling in and that was turning into bubbles so we basically have three different things we want to set up here so let's just give ourselves some little placeholders so i'll call this our uh our base fluid and then over here we want to do maybe our droplet and we'll want to do our bubbles so for our base fluid i actually just want to do a particle fluid surface with the whole thing in here i want to take everything regardless of what its type is and i want to mesh that all together so we're going to copy that particle separation and we're going to drop that into here based relative references if you're using anything other than mantra you might want to turn this to surface polygons i use redshift it does not like uh surface polygon supes it only like surface polygons so i just switch that there and so we're just going to mesh all of this now an extra little bit of cleanup if we look at this in our smooth shaded view it's not too bad right now but you can see that we're getting sort of a little bit of rough edges and especially you can see it on the bottom here and depending on where you're at in the simulation you might get this you can see these pock marks along the edges if we're thinking of this as like a glass container this isn't super ideal we wouldn't really see this on the edges here we want these to be nice and crisp and so one really easy way to do that is to just intersect this with a nice plain regular box so i know we had something that was one by one so let's just make this some big tall box that we know is going to span everything we are interested in i might even make this a little bit taller or a lot taller that's just fine and then let's just scale it a tiny bit just enough that we're cutting on the inside here and now we can just do a nice boolean intersect so we'll take this mesh another reason to use surface polygons instead of the soup and we'll just cut that um these guys have different sort of normals set up so we just want to sort of re-establish our normals here and now we get this nice crisp set of edges um with just the fluid sort of being meshed on top there you can see we also get the bottom we don't necessarily care about the bottom but in case we do let's just do our old friend oops pastries references and just set this up right at the ground there um that's right the scaling is going to be no good there let us set that back to one and we'll just do that here 0.95 and we can go plus 0.05 so that'll just bring it up a little bit from the bottom as well so there we go so now we have a nice sort of flat bottomed and flat sided tank with just the fluid meshed on top here if we look at our flat wire shaded um it's doing a pretty good job sometimes what you'll see and maybe actually if we put this as a polygon mesh and give it some divisions here sometimes you'll get some sort of ugly effects along the sides here sometimes you'll get really weird normals right now we don't have much rippling near the edge so it's fairly regular but if you do get any of that you can just go into here and turn off this de-triangulation because it sometimes causes some real trouble it can make the geometry a little bit weird it makes it lighter weight but it can cause troubles with normal so if you're seeing any of that just turn off that that detriangulation so this is our outer surface and i would probably just render this as like clear water very very simple the next thing we want is our droplet and so for this one we want to isolate specifically that one set so that was going to be val b i believe yes so our droplet is val b so we just want to isolate val b greater than zero and we have to specify that this is points and so that gives us just these ones here and again we'll do a particle fluid surface to get that and the last thing i want to do here actually is under filtering because i want the bubbles to be sort of sitting on the exterior of it not necessarily embedded in it i want to actually erode this a little bit so by default these things are all linked so i'll just delete this channel you can see it was blue now we can turn on erosion only again delete this channel which is normally tied to dilate the reason for this is basically you dilate filter and then erode back by the same amount this is like a classic workflow if you look at vdb reshape sdf uh open and close are doing that um you're basically dilating and then filtering and then eroding um or eroding filtering and then dilating um i forget which one is which but basically by their names one of them will tend to open up holes the other one will tend to close them up uh so that's what all this is about that's the reason these things are by default uh tied together because a normal workflow would be to dilate it smooth it a little bit and then erode it but we just want to erode and just a little bit just enough so that our surface is kind of pulled back from where the bubbles will be and at this resolution this is pretty ugly um and that's really because we're doing kind of a low res sim here we don't have a whole lot of particles to work with and we're fairly late where it's getting dissolved uh if we move back to here it's not quite so bad um so your mileage may vary you may not want to keep this especially if you have a relatively low res sim you might want to just keep sort of this level but i like to have this in here as that an alternative if you don't have many particles you can go back and change your droplet scale so if i change that to 0.8 we also get this sort of in setting uh but instead of in setting by a whole sort of voxel we're just in setting by a little bit of an offset and what we're basically saying is our individual droplets are are smaller than they actually are so just because we're working with a low res simulation here maybe i'll do that here instead so let's call this point eight and that'll pull that back so this was our base fluid now this will be our droplet and the last thing we want are our bubbles here and so for our bubbles we want to split out just those reaction particles and fortunately we have a group for that so that gives us just these particles here and then what i like to do for bubbles and what i did in that that render that we're kind of basing all of this off of is i start them small and then as they get older they grow and get larger and so this is another case where we want to use that rx age that we defined so to do this i'm just going to go down here and do a couple of things to pscale first i just want to set it um a little bit randomized from point to point just to give it a bit of noise so that they're not all exactly the same size so i'll just randomize from id and that reminds me i'll come back to this in a second um and maybe from 0.01 to 0.05 seems fine to me now of course the issue here and you can see this right away uh id is just negative 1 everywhere because we've asked it to use id but id did not actually exist if you're doing pop simulations id is there by default if you're doing flip simulations it is not so if we go back to our solver to our particle motion we want to add an id attribute and so now we'll get a unique id for everything and that's what we really wanted here so we'll have to resend this but that's fine the other thing i should note if you've seen any of my other sims you'll note i often turn off reseeding i didn't in this case however if you want to use this effect to drive for example divergence you're going to want to make sure that you do turn this off because when you recede if you say so so the the use case i might be thinking of here if you're reacting fluid if you set high divergence there so that it all pushes away if you have reseeding divergence is going to push them apart that means it's going to get less dense that means it's going to add extra particles it's going to interpolate those or it's going to grab them from the nearest ones which are going to have high divergence and the whole thing will just explode so just make sure you're mindful of when you're using this and when you're not in general when you have your own effects in your own stop solvers in here you really need to be mindful of how they're going to play with reseeding in this case it's really not a big deal we just have two fluid types they're going to sort of reseed they're not going to interpolate valet and val b they're just going to get the nearest particle so that's all fine so everything will actually work just fine with receding in this setup so i just thought i'd mention that but the real reason we came in here was just to make sure we add this id attribute so let's just run this again and now if we look on these particles they do in fact each have individual ids that means this p scale will give them a nice sort of variable range here so p scale is ranging from 0.05 to 0.01 so that's perfect so that gives us some initial noise now we just want to factor in our age so this is like our base scale now what we want to do is multiply this by some other value so i'm going to do my old fiddle one ramp ramp there we go call this our age scale and we're going to fit this from our reaction age and let's say what did we use in here and here we went from basically 0.5 up to three so three seconds was our sort of uh when we hit our maximum viscosity so we might want something like three seconds for our sort of uh our growth here as well so let's just fit this from zero to three map that into zero to one so we go into our ramp nicely um so our ramp is just going to reshape so basically from time 0 to 3 we're going to use the ramp that we're going to reshape here and that's going to return a value in 0 to 1 and then we're going to fit that into something so we can multiply this from let's say they'll start very small and then they'll get up to their full size so if we add this ramp here and we can give it kind of a similar shape to what we saw before i want to bring this up enough that it's really showing up initially something like this is looking pretty good to me so if we were to i guess we can just visualize this let's just grab our p scale um oh yeah that won't work quite right because it's going to automatically fit that range i'm just going to use a ramp you can do this in the visualizer itself you can sort of fit its range but at this point it's easy enough to just now why is it i guess on frame one because there are no rx particles it's getting confused but if i specify points what it's doing if i don't specify anything it doesn't recognize this group it doesn't see it anywhere so it just says i don't know what to do if i tell it explicitly this should be a point group it doesn't see it anywhere so it says okay i guess i haven't found anything split can be a little bit weird in fact most of the nodes with the group type they're okay at guessing but they're not great at guessing so it's often good to make it explicit yeah so if we do a ramp from attribute on p scale it should go from basically 0 to 0.05 turn this into something a bit more interesting like infrared so now you can see at the beginning they start and they're pretty much all very small and as it goes through they have their individual sort of variants so we get differences in size but we also get them sort of moving more and more towards these sort of higher values and of course they're not all going to get into this range because some of them have a minimum size of 0.01 if we were to narrow that range let's say just 0.03 to 0.05 we'll see a lot more in that upper range there but again we're not even up to our three seconds yet so if we let that keep going now you can see we get our maximum size particles out here and again the new particles are still showing up very small as they get initially created so i'm going to drop this back down maybe to 0.02 is fine and these are our bubbles so now i would come back out here this is really just my simulation i'm not going to render that i'll drop a new geometry for each of those other things i'll call this base fluid i'll call this droplet call this bubbles and we'll just object merge into each of these so our base fluid we're going to grab that base fluid there here it is our droplet we're going to grab our droplet there's that sitting inside and our bubbles we'll go ahead and grab those bubbles so now we've got pretty much everything um what am i seeing here yeah so now you can see these weird normals i was talking about i thought i fixed that uh it should be not doing that maybe i want to get rid of these tiny see me jason edges no maybe my cusp is just not good enough there we go all right we'll cusp a little bit more um hide everything just showing me this i just want to make sure i'm not cusping my surface too much that's not too bad let's find balance i want to make sure the edges are okay but also the surfaces i'm getting all weird and faceted well now i'm higher than i was before has to definitely be lower than 60 because we saw it at 60. let's just go to like 55. hopefully that's good enough okay so here's everything all together uh we've got our particles we've got our droplet we've got our base fluid i'm going to render this in redshift just to sort of show you how this would look it'll be a little bit different in mantra but everything's faster in redshift even if it doesn't always look as nice so i'm just going to use that so i'm going to need a light dome i tend to be pretty basic with my lighting i really usually just use an environment light so i'm going to grab a map for that and i've got let's make sure your eyes here i'll just use something like this and i don't actually want to see that in the background and i don't want to see it in the background well i'll leave it up in the render actually we want to see this kind of from the front here so i'll just set up something like this and make a camera control click to get a camera there i'm going to lock it and switch to this mode so i can kind of zoom into something nice and i'm going to change this camera to be something like a nice instagram format we all love that all right there we go good enough so we've got a light we've got a camera now we need some materials go to the shop network make three materials we'll call this bubbles droplet and base and we're going to use some real simple materials here again you could do something very similar with mantra so really i'm just going to use a straight water shader for this i'm not going to do anything extra there another material oops another material here for the droplets i'm going to use a tinted glass shader i'm going to set my ir to the same as water and i want it to be bluish on a nice blue droplet that's going to be too dark something like that is probably fine we'll play with the absorption scale in a second and for my bubbles i don't need anything too fancy i'm going to again i'm going to call this water to begin with but i'm going to tweak my ior to be basically like going through air practically so just very very small and i'm going to call this thin walled and that should be good for that so if i go back to here my base fluid i want to give that base material my droplet i'm going to give that droplet material and my bubbles i'm going to give the bubble material and i'm going to make sure that this is rendered as particles so let's see what that looks like and there we go that's coming along a little bit um that background is much too bright for me let's just uh let's just pull that down that's looking a lot better pull it down even further there we go um these bubbles are probably a little bit too big here for me so let's just scale them here that's looking okay uh we're getting something weird in the reflection on the bottom i think what am i seeing there these bubbles are a little bit weird um ah right yeah um i forgot about this so when we clipped the bottom of this thing back in here this box we kind of clipped the bottom of this whole thing and that meant that our droplet can actually extend past there whereas it won't extend past the bottom of this so let's just see if we can this just enough to get a flatter bottom honestly even at zero it might be too much and this is really just tweaking i just want to make sure that yeah that should be okay i want to make sure that this droplet is entirely inside of this mesh so that should fix whatever we were seeing there okay the reflections are still weird i think this is going to be a reflection refraction limit on the renderer um again there's a whole lot of tweaking that would need to be done in all of this um the reflections on everything are very strange here it might even help if we just took off that background now we just get the reflections i don't want to get too deep into this but this is basically the setup that i used um you would probably want to put maybe a grid back here to get this to look proper our xy plane i'm going to unlock that go back now our grid is kind of cutting through push that back there maybe now we can't see our poor bubbles at all so this is all going to be a matter of sort of tweaking until you get something that uh that you like i can make this a little bit darker now we start to see that stuff coming in a little bit more and you can start to get the sense of how you would set this up but i don't want to spend this whole time sort of reconstructing these shaders but you can see how it's pretty easy to set up these nice little variable bubbles here you can start to see them they're all sort of moving upwards and at the top which we've cut off here i'm no longer locked in my camera we get this nice sort of surface interaction as well we get all these bubbles kind of foaming together so that's really all i wanted to uh to show today as i say it's a pretty simple setup um but you can do a whole lot with this um so making bubbles is not kind of the only thing that you can do when you're sort of setting things up you can tweak any of these different properties density viscosity divergence temperature any of your own custom attributes you might be using across these two fluids and of course when you create your third fluid um you can set it to do whatever you like um so here i did something very similar uh simple rather i only changed density and then we ramped viscosity a little bit over uh age um but again you can set any new properties here um you can set anything you like across age as well so if you want it to change and then revert back you could do that very easily you could even say you know if age is greater than some value maybe once it's 10 seconds old you might say now i'm not in this group anymore and go back to one of the other values so you can do all sorts of things in here this is really just a skeleton framework that i think hopefully provides something useful um finding these little boundaries and reacting based on them is a really very simple step but it gives you a whole lot of power to do some some interesting some fun custom things here as always thank you very much for watching um i hope to have more of these things coming out soon it's been sort of a whirlwind of the past few months i had a move internationally in the middle of a pandemic changed my career all sorts of stuff has been changing so i'm sorry i haven't posted recently but i'm hoping to get back on top of things and i thought i'd start us off with something nice and simple so if you enjoyed this please do let me know if you use it for anything i would love to see it and as always if you've got any questions or concerns or comments or requests please do leave them below and if you're not subscribed please do consider doing that thank you very much and goodbye you
Info
Channel: Diffuse FX
Views: 4,088
Rating: 5 out of 5
Keywords: houdini, vfx, tutorial, FLIP, DOPs
Id: VbpnGHacARo
Channel Id: undefined
Length: 66min 1sec (3961 seconds)
Published: Sat Oct 10 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.