Procedural Modeling Of Water Droplets

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi there welcome to the next intimate tutorial today I want to talk about an effect that you can see a lot in advertising water droplets the effect if a surface is covered in small drops of water and you render this with nice depth of field and it just looks pretty and makes a product or is an object appear fresh so basically this effect is very simple it's just distributing spheres on the surface of an object but there are some details that can make the effect look more realistic them more pretty so I decided to do a tutorial about this kind of thing I prepared the scene here with a pumpkin I decided to use the pumpkin as my objects to put the water drops on and this pumpkin is scanned 3d scanned and the scene is provided you can download it from the link below the video inside of this scene I have this pumpkin object if I dive inside it's just the file node that imports the obj geo file transforms it and then feed it into dotnet and I make it fall because I want the pumpkin to sit exactly on the surface here and then this top import node just fetches a simulated object from the drop net and I froze this node meaning that I now can scrub and nothing happens another possibility would have been to export the result and then re-import it but this is a little bit more straightforward for you because then you don't have to download a second BG or file and then we have this out node and then I build a Cyclorama so this background object here this is very straightforward too it's just a box with some poly splits and then a sub divide node in the end and there are two area lights in the scene one on the left that you can see here and one on the right with different intensities I give the balanced lighting and I have a camera okay so let's start and build the water droplet effect let's put down into your node and dive inside but before we dive inside that's called this water droplets inside you'll need a reference to the pumpkin because we want distribute says on the surface of the pumpkin so I need a object marriage yeah and this object merge will refer to my pumpkin object here it is and don't forget to specify that this has to be transformed into this object otherwise the transforms won't match here is our pumpkin now the first thing is we don't have point normals but we will need point normals later on so put down the normal mode let's generate point normals quickly point normals now we have blue point normals if you wonder what happened here the object comes with vertex normals and these are green here in the viewport and now that I create point normals the numbers are blue indicating that these are point normals and I want point normals because these are easier to work with the next thing is that I want to subdivide my pumpkin i will subdivide this in the render engine directly but for his cloning purposes I want a subdivided object too because I want to put my spheres on the subdivided object not on the low poly like so for now we can switch to hide other objects now we see or subdivide the pumpkin very nice great so time to scatter some points put down a scatter node and append it here what about scattering 1,200 points like so and before we put spheres on these points let's create a pop to set the piece scale value point like so point up and call this set P scale it will do nothing for now and now append a copy to point feed this into the template points and let's create a sphere and we want to feed the sphere into the first input of the copy to point and you see that you now get very large spheres so time to set the P scale actually let's dive inside the set piece count out and think about how to set the P scale values correctly I'd like to vary my piece scale with a noise function so let's put down an anti aliased noise as this executed faster than the unified noise and for our purposes it's sufficient connected here because we need to sample position for the X function to know where to look up the noise in space and you have to know that the anti aliased noise node outputs values between minus 0.5 and 0.5 so to make it easier to work with this we want to fit it so create a feed arrange node and append it here and just fit the values minus 0.5 0.5 to the value range of the relative 1 because now we can append a ramp node the ramp parameter node and we can use this to remap the distribution of the values even further switch this to a float ramp because this is a float and connected here now we have the possibility to remap the values but the values are still in the range between 0 and 1 and we need some possibilities to set the final values for the minimum size and the maximum size of our spheres so another fit node will do this this will be used to transform the range between 0 to 1 to our final destination values for this to work let's promote the desk min and test Max values because these are the values that the range will be mapped to and then we need a bind export call this P scale this is a attribute name that is recognized by the copied points it's more or less building and connected here and you see as soon as we do that all the spheres in the viewport disappear because they are all set to zero now because all these values default to zero before we go one level up and set the values let's first promote the frequency of the noise and offset of the noise because these two parameters are important for shaping the result and go up one level now let's set the values what about zero point there are five and maximum radius will be zero point zero two like so and you see that you don't have any variation that is due to the fact that the ramp is just set to zero and the ramp will remap the values if you alter this you get distribution and by moving these knobs here you can make the transition between small and big spheres a little bit harder but the noise is very very large so increase the frequency to say 15 and you get a nice sort of random distribution of the sizes of these spheres and note that these spheres are all aligned to the surface and that is due to the fact that we have point normals if we don't have point normals the spheres would appear here on the surface with global orientation before we go on let's go to the sphere and switch this to the polygon mesh and increase the subdivisions to say 24 and 48 because primitives cannot be converted to volumes later on and you notice this all shading here and that is due to the fact that the copy' the points node copy is not only the geometry but it transfers the template point attributes for example n that means that all the points of the spheres get the N attribute of the surface underneath we wanted to avoid this to avoid this what we can do is here in this field just put a little hat and then and you see now you have the fading back cool weird um not really because we have spheres on the surface now but what we want is drops and drops look a little bit different than just a sphere let's quickly turn show all objects on and you see we have nice spheres sitting here on the surface but what we want is elongated drops how can we accomplish this well basically in the end I plan to turn all these spheres into a volume and this enables me to put more than one sphere and then merge them all together with the volume so what if I would put a smaller sphere above every sphere and then merge them together in the volume and blur them that would give a drop like shape so let's try this well basically we can just duplicate the point we have and then move them along the surface a little bit up how can we do this we need a vector that points along the surface in the up direction and we can calculate such a vector with a double cross product before we implement this with a whap let me quickly explain to you what a cross product is and what I plan to do when working with vectors you can do different mathematical operations on them you can state vector A plus vector B or a vector a minus vector B and of course you can multiply vectors you can state a dot B that's the first type of vector multiplication and then there is a cross B that is a different kind of vector multiplication both are different in how the actual math is executed so what exactly happens but that is not important important if the geometric meaning of these operations and the cross product gives you the vector that is orthogonal to the plane spanned by these two vectors so if vector C that means if I have a vector a here and I have a vector B these two vectors span a plane this plane here and C is the vector that is orthogonal to this plane this is C so this vector is perpendicular to the plane and thus it's a plane normal that is very useful especially in our case because in our case we want to find the vector along the surface so imagine you have a surface this is our surface here and you have a point here this is our point and this point has a normal vector pointing outwards from the surface this is n now I want the vector that goes here along the surface in the up direction how can I find this well first I can define the global up direction that is why it's just global and the vector is 0 1 0 that is the global Y and if I now do a cross-product between the normal and this global Y vector what I get is this is global Y why I get the normal to this plane here so the cross product will be something like this a vector that is orthogonal to this plane like so and if I now do a second cross product between this new found vector and n I get the normal to this plane here that is spanned by this new vector and N and you can easily see that this direction is exactly the direction we are looking for the direction that is more or less in the global Y direction but along the surface so by using two cross products one after the next can find this vector and then we can displays our original point along the surface in the up direction let's implement this create another point whap point and call this move along surface like so but we want to put this before the copy two points because we want to work on the input points so connect it here for now and this operates on all the points let me quickly make the point a little bit bigger so that you can see them better okay now dive in right the normal that we need we already got what we don't have is the global y direction so create a constant and switch it to vector and just specify zero one zero this is global Y let's call this global Y like so and now let's do this our cross product so cross and we want to cross this global direction with the normal and let's have a look on what we calculated so let's quickly do a bind export causes debugger tie this vector and connect this vector here now we can create a new visualizer type vector and call this debug like so debug and debug like so close now we have back here you see nothing because I wired this incorrectly so let's quickly cut this connection to time and use N and here you have the result let's make this vector a little bit smaller in scale so Rivera tips and you see as outlined in my drawing the first cross product gives us a vector along the surface but more or less in the horizontal direction so but what's closely these two vectors in new yellow one and our normals form a plane and the normal to this plane is exactly the direction that we want so let's do another cross-product turn the visualization off for now and now cross a normal with the result from the first cross product and let's put this into debug and you see this is exactly the vector we are after now we have vectors that point along the surface of the pumpkin in the up direction these are exactly the vectors we want to have now let's use them and put down a displace a long normal mode it's called displace long normal but it displaces along every vector happily so specify the vector by buying the output of this cross product to the normal and then P into P and now we can fire as a result to global peak like so and if I now use this displacement amount slider you've seized at the points move along the surface in the up direction that is exactly what we want so let's put zero and zero one for now like so so now we have points and we have translated points and what we can do now is just merge them together points translated points merge them together and wire is this into the copy two points if I make this active now I not only have points or spheres on my surface let me quickly turn the point display back again but I now have two sitting on top of each other and this already looks a little bit more like a droplet to get closer to a droplet shape we want to make the top both spheres a little bit smaller so dive again in our node let's clean this up a little bit such that it is not so confusing and get rid of the debug you don't need it anymore display the lognormal geometry output what we want to do is we want to scale them down so let's find P scale here P scale like so and then just put down multiply constant let me quickly go up and switch back an instance on because then this will be more responsive again multiply constant and then a find export by an export again P scale because we want to read the scale of the points scale it down and then set it again and if we now say zero point eight for example you see that the top most spheres are all smaller giving more a drop like shape the problem is that the distance of displacement is the same on each drop so no matter if the sphere is big or small we have always the same displacement amount here are the same distance between the two spheres this is not good because the small droplets really fall apart and the big ones stick too much into each other so let's correct this and we correct this by using P scale again we want this distance to be large if the P scale value is high and if the P scale value is low we want the distance to be small so why don't we just Yussef it rained and his piece kale and now we want to again I wired his wrong be careful when this wiring here and we want to transform the P scale range back to a range of 0 and 1 because we want to use this as a multiplier so we want to know the maximum and minimum P scale values and we already know them because we said them ourselves so if we just promote the thoughts mean and sauce mix parameters what we can do is we get these two channels here and now we can go to the sets P scale where we specify these values and just say copy parameter and paste relative references and that's the same with the maximum value copy parameter paste relative references and now we have these values here and this will make the fit note transform all the P scale values between 0 and 1 at the moment we just put the displacement amount here but that won't work anymore if we want to drive this amount with the output from this now Jania so we will need a parameter and we call this parameter displacement amount like so displacement amount and now we can just multiply this displacement amount by this correction factor that we calculated and drive the amount with this all the spheres snap back to 0 or to the old position because this displacement amount defaults to zero but if I now move that you can see that spheres that a big move a large distance and here with very small particles you see that no movement happens and that is not perfect either so let's put 0.02 here for example go inside and let's go to this fit node and up the destination bend a little bit your part 1 or maybe 0 1 2 to give even the small ones a little bit of displacement so now you see that we have relative displacements regarding the sizes of the individual spheres which gives much more natural results cool the next thing is that the individual droplets are very very round and in reality these drops would be a little bit flatter so we want to make them flat let's make some flat for this I use an even another point and called it flatten and appended here after the merge because it should affect all the CS the initial ones and the top ones and dive inside so making these spheres flat is basically very simple because there is not only attribute called P scale which is just float and define the scale in all directions uniformly but there is a second template point attribute that copied points understands and this is called scale and scale is a vector that means with the scale attribute you can scale the individual copies differently in the three directions so if we just bind export a new vector attribute and call it scale like so we can create a constant type vector and set this year and everything will disappear because as always this defaults to zero but if I put 1 1 1 here I have my spheres back and then we can see that we can alter the scale just in Z to make them flatter so let's have C dimension and now we have flat droplets so now let's create the actual droplets and I want to do this by using video bees so put down a VDB from polygons and let's convert these copies into V DB the voxel size is too large let's say 0.01 still too large 0.001 and now I have a VB scientist and filled with my droplet and this allows me to blur them so we'll be smooth stf and this will all the droplets let's put this to caution because it skips gives more of the smoothing effect and really smears the two spheres into each other like so but you see that they lose a lot of volume and to counteract this lets append a VDB reshape and this allows you to enlarge or shrink VDB so put this before the smooth and let's just dilate them by factor 3 and if we now smooth them they should maintain their volume more or less like so so before and after pretty much the same but it looks quite okay now we have actual droplets but these droplets are still round if I hide the pumpkin you see that they go to the inside and real droplets are have a different curvature on the top and on the bottom how can we achieve this well makes a pumpkin visible again we can't just turn the pumpkin into the nvd be two and subtract it from the droplets so create a duplicate from this VD b from polygons and cut this connection and use the subdivide as an input such that we create a scientist in field from the pumpkin itself and now we can use VDB combine and we will use this before we do the reshaping and the smoothing so we will combine the droplets and the VDB from the pumpkin the operation is saying copy a that's a standard but we want to do the SDF difference and if we do so you see that the pumpkin is subtracted from our tablets and if I now put this into the reshape and smooth I get nice droplets that perfectly conform to the surface of the pumpkin very good so this is pretty much it we have just one last problem and that has to do with the type of fader we want to apply it these droplets should be water so they are transparent or refractive and at the moment the inner surface of the droplets is in the exact same position as a surface of the pumpkin and that means that a ray tracing engine has a hard time figuring out the transition from water to pumpkin because it has double surfaces there and the render result will be so much better if the droplets would intersect the pumpkin a little bit just a little bit which is not the case at the so if we render this this wicked give artifacts so let's move all the droplets along the normal of the pumpkin inwards just a tiny little bit so I promised the last point what before today point upend it and make it visible ah and don't forget to use a VD be convert now convert will be to turn the VD be into polygon first so go here and say polygons and thus this will give us polygons again now we can use a point and let's call this move inwards dive inside so this point what runs over all the points of these droplets but these points have normals that are specified by the surface of the droplets but we need the normal of the underlying surface how can we get this well indeed there is this XYZ distance function and this XYZ dysfunction gives you the closest point on a primitive on a surface from a sample location so we can say please sample where P is so wherever the point is and now we have to tell the XYZ dysfunction which surface it should sample via this input here so we have to make the aware of the surface so grab so subdivide and put it into the second input here now we can dive inside and use the second input so now this X where it is gives us a primitive number and a prim UV vector and what this is it's very centric coordinates so the primitive number tells us on which primitive of the surface the closest point lies and the premiere v gives us a vector a two-dimensional vector the third coordinate is usually zero that tells us we're on this primitive the point lies so this is not normal what we want is the normal of the surface so we have to sample it and for this we use the premier e function primitive attribute pre-movie we connect the same surface and then just tell the pre movie the primitive and the UV coordinates of the barycentric coordinates and then we can specify which attribute to sample in our case it's n now we have the normal for every point of the droplet of the underlying surface and now it's very easy because we again use just displace by normal or its place along normal we want to displace the points and the normal to use is the sample normal so connected here and then connect this to the global P and if we now play with the amount you see that all the droplets are moved away from the pumpkin so let's promote this parameter go up one level and just put a negative number like zero minus 0.03 same and you see now they are diving a little bit into the surface of the pumpkin and this fixes over rendering artifacts so now append a now call this out pumpkin or our two droplets just because this is good practice put the render flag and the visibility flag on it and this concludes the modeling of water droplets on the surface of the pumpkin so thank you so much for listening I hope you learned something I hope this was inspirational for you and see you next time as always a very big thank you to all our patrons on patreon especially Mohamed alabbar II and Joseph Howerton thank you so much for supporting us and making this all possible
Info
Channel: Entagma
Views: 9,798
Rating: 5 out of 5
Keywords:
Id: 0GAFEyvVC4g
Channel Id: undefined
Length: 32min 5sec (1925 seconds)
Published: Thu Dec 26 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.