Houdini Free Tutorial: Interference Patterns On Surfaces

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today I want to revisit an old setup of ours I want to revisit the interference patterns build mode did some years ago because with Houdini 19.5 we got a note for computing the geodesic heat distance which will allow us to calculate these patterns on 3D surfaces instead of just two-dimensional grids that probably all sounds a bit strange so let's quickly get a Refresh on interference patterns and then jump into edini and get going so what are interference patterns all about well let's take a situation like this we have for example a surface of water and then multiple Pebbles we've thrown into the water and those Pebbles will make circular waves radiating outwards from the point where those Pebbles hit and at some point those circular waves will overlap and this is where interesting stuff will happen because some waves might amplify each other other ways might cancel each other out and in general those overlapping waves will create very interesting and intricate looking patterns on the water surface the way we calculate this in Houdini is we take a grid of files or a measure of points and reprocess each point on that mesh and this will be a water surface and what we do for each point is we simply measure the distance to each wave emitter so this one this one and this one and then we take that measured distance and simply pluck all of them into different sine functions and then simply add all those sine functions up and this is all we need to do to create those intricate looking wave structures the problem we have with 3D surfaces however is we can't just take the direct measurement from one point to another the direct distance we have to measure the distance along the surface to create accurate waves and this is exactly where the geodesic heat node comes in because this node will allow us to do just that measure the distance along the surface instead of a direct line so this is a quick refresher now let's jump in DVD I'm starting out with a small scene that you can already find in the scene file download this is just a simple base that I created and this will be our base surface to create waves on what I want to do first of all is I want to create Point normals on the surface because I later want to use dot Point normals for displacing the points of the mesh to create a waves drop down a normal node or add this in set the mode to points and we're done here now let's introduce the node that we're already interested in and for now I just want to work with a single wave emitter and then simply get more complex later in the setup so you know that we are looking for is called heat geodesic let's drop this down and what this node expects as an input is simply a wave emitter as a point group so let's click this button here and let's select one single point maybe this one here this will be a wave emitter and what this note creates is a disk attribute and the disk attribute encodes well the distance to the point and we can also get an idea on the distance if we simply bring up the info panel and then click onto this right here on the point attributes and here we get this heat map that shows us the distance to this point let's turn the heat map back off and let's implement the very simple way of displacing our surface based on that heat map so for this I want to use a Point Wrangle I want to wire this in and on my pointer angle I first of all want to calculate the wave amplitude based on the distance so this will be a variable I want to call amp and as we remember we want to calculate this base on the sine function so this would be sine and we want to plug in our F at dist and I want to make the distance a bit larger to create more waves so I simply want to multiply this by a value of 50 and once we have amplitude we can just place a points position by that amplitude so that will be vlp and we want to add to a vlp we add n or normal Vector times our amp and also times a simple displacement slider so a slider like this let's create a slide and see what we get let's bring this up a bit we can already see stuff happening but we need to fix our normals as well so it's wrapped on another normal node down below that's why this end had a few output here and yes we got waves on our surface now of course we just have a single wave emitter we need more of them but also waves look a bit odd here at the back and I want to modify my code here a tiny bit to make this look a bit more natural I want to do two things I first of all want to create a Decay so waves get smaller and smaller and smaller and then I also want to modify the frequency based on a distance so the waves also get wider the further they travel from the resource Point Let's implement this for this to work I first of all want to find the biggest distance on my entire mesh this is quite simply done using an address promote note that's why this below our geodesic heat distance and we want to process our distance attribute we want to promote the us to detail we want to find the maximum the largest distance you want to change the name of this to Max and we don't want to delete the original like this and now in our code I first of all want to grab that Max attribute that I created so let's create another float call it Max and in here we want to grab a detailed attribute on geostream 0 called Max and we want to grab the first component of that attribute and then with this I want to create a Decay variable so let's call that variable Decay and this should be equal to a fit function when we plug in our F at this again this will be between 0 and our max value and I want to remap this or fit this between a value of 1 and 0 like this and what I can do now is when I calculate my amplitude I can simply multiply this by rdk and once I do my ways will fade out over time again I also want to have control over the frequency so for this let's also create a variable called Frick for frequency and this also will be a fit node I also want to process F at this here this again will go from 0 to Max and in here I want to start out with a fairly high frequency so I have 80 and I want to end up with a fairly low frequency so value of 30 like this and now I can simply replace here on my amp calculation down here the fixed value of 50 in here with my frag value like this and if I do that waves are now fading out very nicely the last thing that I want to do in here is I want to add also a Time Factor so waves are animated so for this let's create a float called time and this should be a card frame number and to make this look nice I want to divide the spiral value of -10 this look nice in my opinion and then finally I can take again my amplitude function right here and simply inside those parentheses add my time value as well and now if I play on my timeline I now get animated ways so this is a code for a single wave done before we jump to multiple waves there's a one additional thing that I want to do here right now we are just selecting a single point on my geodesic heat distance node right here but what I want to use in the end is I want to Simply scatter points on my Surface and then those should be the source points for my heat distance calculation like moded in this original video so scattering is easily done let's drop down is get a node write this in if I know I just want to scatter one single point and now we have to somehow convert this one single scattered point to a point group that we can use on a heat geodesic node down here this is a trick that's quite handy quite often so let's for this here's a natural Wrangle I want to set this to detail to run only once and this should go on our main geostream and I want to wire in the scatter on the second input and what I want to write in here is I first of all want to find the near point on my main mesh to the single point that I'm adding in here so this will be an integer called PT and this will be the near point on geostream 0 and the position I want to search from is a point attribute or gs31 called PE and that point that I want to process is point zero because on this Geo stream we just have one point and let's close all our parentheses this is the point that later will become a point group and to get it into a point group we want to use the set point group function this would be NGS frame 0. the point group should be called npt the point that we want to add to it is is PT point you want to set a value of 1 and we want to set this group like this in order to actually see if this works we can go to the bindings tab on our Wrangle and simply in the output selection group input npt and if we take a look around now yeah we got one point in our mesh and that point should also be very close to the scatter point that we're putting in so this is working and now on a geodesic node under the source points we simply have to enter npt and this should be working again and it is now this is the entire setup done for one single point now we have to make this work for multiple points and this will be a bit difficult because we can't just enter a group node with multiple points into a heat geodesic node down here this will also work but it won't give us the output that we're looking for so simply to demonstrate this let's select two different points maybe this one and this one let's see whether this gets us and this gets us to some other interesting output but again not the overlapping waves that we're looking for so let's again set this back to npt and let's take a look at how we can process multiple points in here what I want to do in the end is up here right around this area I want to process all of this in a for Loop and I want to calculate multiple heat distance values for each point and then just save them into an array not just in a single attribute and then later inside my point Wrangle down here I want to process that array and do all my calculations here based on these multiple entries of my array now first of all the only for Loop where we can take multiple values and merge them into an array is a follow-up with feedback so let's first of all drop a for loop with feedback down and I want to go from my normal node into the following feedback I'm going to go from there into this attribute angle through my heat duelistic distance and then back out and this single is interact with promote like this now I want to run this for Loop the feedback as many times as I have points on this geostream right up here so first of all I have to create some more points up here let's maybe set this to five and I also want to create a simple reference point as a null and let's call it now in underscore pts and now the value on my follow-up feedback I want to modify is this value right here the loop iterations and I want to set this equal to the number of points on this node right here to do this I want to use a simple expression and here I want to write endpoints so I use the endpoints function which will give us the number of points for the node that I want to grab I want to jump out of this node with this two colons right here and then I want to grab my in pts node right here and then I simply want to close the brackets and this null should give us the right number of iterations based on the points that we're scattering on here which is correct now on this attribute or angle right here the next thing that I want to do is I want to not in here simply grab always the first point and this will always be the same point on here that we're scattering but I want to grab a point based on the iteration of our array in here so for our first iteration I grabbed the first point for a second iteration and grab the second point and so on for this I first of all need an attribute that stores iteration and I can create this by creating a meta import node here let's maybe make some and on this metadata block if I take a look at the info panel I have this iteration detail attribute which we'll store our current Loops iteration I want to get this onto our main geostream right here for this I can use a natural copy simply copy this over attribute is not called CD but instead it's called iteration and this should be a detail attribute like this now we have alteration on a major stream and we can ignore this warning up here let's bring this into attribute angle right here let's create another Point Rebel let's call this girl PT and this should be equal to a detailed attribute on Geo stream 0 called iteration and we want to grab the first component again and now we want to plug in near Point position not for a first point but for a goal point I like this now for now let's simply disable our heat your desktop mode down here and let's simply jump to the end block down here and and also had to fix a small spelling mistake here on iteration but what I wanted to show here on the last note is a little problem that we have because if you take a look at the info panel here and we take a look at our Point group npt we now see that we don't have a one point in here but we have five points in here and also if I create this Max iteration slider and I set this first of all to one then we have just one point in a group if I set this to 2 then we have two points in our group and if yes it's too far we have four points in a group and this is of course what we don't want we just want always a point group with a single point in there so what we can do to fix this is before we set our Point group in here we simply want to delete the point group that's already in this Loop so for this let's drop down a group delete delete our npt group and now if we take a look at the for each and the max iteration a four of it still have just one point in here and over full iterations we still just have one point in here so this is now working so no for each Loop iteration we got another Point group that we can feed into a heated geodesic node right here now the only thing left to do for us in here is to find a way to store the value that we're calculating on the C geodesic node into an array so first of all for that work I need to create an array for this up here below a normal node I want to create a pointer angle and I want to use this simply to initiate an array attribute so F at this and let's simply end with a semicolon this should be enough to give us a dist array attribute then we can enable our heat geodesic node in here again this is still processing our npt group and then simply as a last step in our Loop I want to use another Point Wrangle and simply append this this value that we calculated onto our array and to do this I'll just simply write append I want to specify the array that we are pending to so F square brackets at this and I want to append F add dist like this now finally this should be our entire Loop done let's take a look at the output at the geospreadsheet and now on our Point level we have this this attribute and this is an array for Five Points that we're feeding in so this is exactly what I want let's finally also make this work with a point Wrangle down here what we still need to do is we want to find the maximum value of all the values that we calculated in the beginning we could just use Nash we promote node for this now it's a bit more complicated first of all I have to find the maximum entry of every array on every point and then we have to find the maximum of that so for this let's drop down another Point ring a last Point ring is for today and on here we want to create an attribute called Max and in here we want to store the maximum entry of r as at this array like this and then on that we promote I don't want to promote my dist I want to promote Max I don't want to change the new name and I don't want to delete the original and now on the gear spreadsheet on a detail level we have a Max attribute like this and then we can finally make a point Wrangle in the end work because right now this is set up to work still on a single point so the very last step that we want to do in here is we want to first of all bring in our disks array as well so float this is equal to F at this like this and then I want to basically take all of this and wrap this into a for Loop before I do all of this I first of all have to create an empty Place folder for my amp so fluid amp is equal to zero then we create a for Loop so for each float dist and this array I want to do all of this and in here first of all let's exchange our F at this with our test variable occurred array entry that we're processing like this and then also we can get rid of the float before I am because we already declared that up here and we of course want to add each wave to the amp that we already have so let's add a plus equal in here and this should be all we need to do here so let's keep our fingers crossed let's click out of this array we got some error in here and this also needs square brackets to turn this into an array let's try this again and yep now this is working a displacement is a bit too strong so let's make this a bit weaker like 0.15 but this is now looking a lot better and what we can also do is go way up here to a subdivide node and then simply subdivide this a bit further get more detail no cooking will also go a bit slower but in the end we're still left with a nice and wavy surface and now we also got all those nice interference patterns that emotion in this tutorial but now on the 3D surface and we can even hit play and get this really nice looking animation so we did a lot of stuff today let's quickly recap what we did I also did a bit of color coding here to make this more readable so first of all on input Geo we calculated Point normals because later we want to use those Point normals to this place or points in and out of our surface let's skip this point Wrangle for now the next thing that we did is we created a point group based on each point that we're scattering on a surface that we can later feed to heat duelistic node right here and we did that by creating a for Loop the feedback that runs for this name number of iterations as we have points on this geostream what we can then do is grab the iteration of our current Loop to grab the right point on our Geo stream right here and that we're feeding in and based on that point position we create a group that only has a single point in it the point that we later want to feed to the heat geodesic node down here and also to make this work for each Loop iteration to get rid of the feedback because in this case we don't want any feedback we also have to delete that group that we created on this node then we want to calculate our geodesic heat distance and we want to store this into an array so first of all we create an array then we run our distance calculation right here which will give us an attribute called this and then for each point we simply write the distance attribute into an array that we created with this node up here then for all of our array entries for all of our points we have to find the maximum value because we want to later use this in our Decay and our frequency change on our last Wrangle so for this we first of all use the max function to find the biggest entry in each array of each point and then we simply use an attribute promote to find the largest max value for each point and then finally on a point Wrangle we first of all grab maximum value and then we also grab our array then we also create a placeholder for the amplitude that we later want to use to displace each point on the surface and then we simply process each value in the array of each point and for each entry in the array we want to calculate a Decay value which we do based on our distance stolen that array and the maximum distance and those output values right here we do the same for frequency you also create a timing factor and then we simply plug all of this into a sine function right here and simply add this to the amp value that we created down here and in the end we take the final and value that we calculated and simply use this to displace the position of each point and this is our entire setup done so a bit more complicated than the original setup and mostly because it's now a lot more complicated to get an array of distances but still I think it's worth the effort for the very nice effect that we get in the end so until next time it's cheers and goodbye
Info
Channel: Entagma
Views: 9,297
Rating: undefined out of 5
Keywords:
Id: IliafCzn82I
Channel Id: undefined
Length: 22min 33sec (1353 seconds)
Published: Mon Sep 25 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.