Generate flowers from ANY curve! (Part 1) | Blender Geometry Nodes Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey guys thanks for tuning in so in this tutorial we will look at how to generate flowers from curves using geometry notes we'll build a node system with which you can just draw the outline of flowers the leaves the stems and get a 3D flower mesh in the end we will also build a few parameters so that you can tweak attributes like number of petals leaves they're with their noise displacement in real time so we'll split this tutorial into two parts in part one we'll focus on generating the base mesh for the flower in part two we will apply the chaotic magic that is noise onto the mesh to bring some life into it and we'll also look at making some noise and vision and material for it there are lots of flower geometry no tutorials out there but this one that I say is one of the most precedural and parametric because we literally generate everything from math it is extremely quick and flexible you can shape your flower in the exact way that you want and keep tweaking it until your heart is content so buckle up for some better math a lot of Curves and let's Dive In okay so we will mostly be looking at the X Y plane into the z-axis I'm using blender 3.6.1 but anything from the last few minutes should work first let's look at how blender stores spasia curves because we will be talking about this so much you will get a headache whenever I measuring curves again the smallest unit of a basic curve is a bezier segment it has a starting point it has an end point the starting point has a handle that specifies its outgoing Direction and the endpoint also has a handle that specifies as incoming Direction so if you open this pressure Tab and look at the spreadsheet data for a sec and you'll see that we currently have one spline with two control points the start and the end so if we get rid of that spline and draw a more complicated spline you see that we still have one spline but it has more control points if we look at this control points they all have handle left and handle right stored with them These Are the In and Out handles for those control points now if we draw a second spline who have two splines within the same curve object and at the same time you also have more control points each spline will remember which control points it stores all right let's draw three curves so let's draw one for the outline of the flowers should the D duplicate delete the vertices and then draw one for the outline of the leaves and finally duplicate delivery vertices again and draw one for the stem let's drop in a mesh and create a Geo node on top of it name it flower chin um we're gonna drop the three nodes let's rename them first this one is flower curve Leaf curve a stem curve alright so let's drop the three curves into the geometry node make sure to select relative on the object info node so that you always get the world position of the curves let's start by resampling the flower curve dropping a resample curve node make the count a group input let's call the input pedal count because this parabenator is going to control how many petals will generate by the way I'm using the node Wrangler plugin this allows me to just comment shift click on any node and then preview is output in the viewport which is really neat all right let's instance a bunch of Curves onto the points drops in a instance on points we're gonna feed a bezier segment as the instance and you can see a bunch of battery curves appearing but we're not gonna use any of the default points so let's set all the points to zero zero zero for now they all disappear because they become zero length curves let's use a um realized instance knows to turn the instances into real geometries now you can see there are seven splines that each have two control points and the control points are positioned around the flower curve no we're gonna select half of these points and then position them at the center of the flower so that we will have a bunch of Curves radiating from the center the general idea is that we're gonna sweep another profile curve along these lines so that we get the pedal geometry mesh so I'm going to use a set position node and since I only want to select half of the points I'm gonna use selection and use a modular node here fit in the ID of the control point and modulo it by two now I'm gonna use a compare equal node to select the points that modulo to zero now how do we get the center of the flower well we can Define it as one of the endpoints of the stem curve so to get that position we're going to connect position to a sample curve node we're going to connect that to the stem curve geometry and connect the position to position as you can see if we move the fatter it's going to give me the position for points along different factor of that curve we're just going to leave it at zero for now let's use a curve to mesh for the profile curve we're going to supply another curved line that goes from negative one zero zero zero to one zero zero let's go to object tab viewport display enable wireframe so that we can actually see the wireframe of the geometry let's also take a look at why the lighting is kind of weird oh turns out I just have this random value plugged into the viewer let's unplug that all right starting to look like a flower but let's make the petal look nicer drop in a set radius note so that we can control the width of the profile curve we're gonna feed the radius to a float curve feet a spline fatter field to the value of flow curve what is the spline Factor you might ask well it's basically a fraction that progresses from zero to one for every point along the Curve so for the point in the beginning it has fraction zero and then for the one in the end it has fraction one now let's try to control the shape of the pedal with this flow curve there's an issue though which is we don't have enough geometries on the curve it only has two points so when both of their radius become zero it just disappears so let's give it a little more resolution by dropping another resample curve in front of the cell curve radius node no every pedal curve have 10 points on it and we can scope it however we like by inserting more planes you can get really elaborate if you want but for now I'm just gonna leave it simple so our geometry is starting to look like a flower but when you increase the pedal count it's looking kind of dead it's super artificial several reasons first of all it's quite literally falling flat it's super flat let's think about how we can fix it to make it more three-dimensional well an obvious thing to do is to just lift the curves up into the z-axis let's connect our nose to the group output and now the pedals have the shape of a cone this is looking okay but it's still a bit unnatural because if you look at the petals they're all perfectly aligned on the outline curve plants don't quite do that in nature especially when they have a lot of petals and leaves that they want to spread out evenly so commonly they follow this pattern which according to Wikipedia is called a Philo tactic spiral in this spiral each pedal scales down a little bit as it approaches the center of flower every two petals are also separated by a fixed angle and for maximum spread the golden angle to use here is the magical 137.5 degrees pretty cool right let's build it out well first let's do a few cleanups let's let the nose that we use for extruding the pedals and put them into a group note and let's call it extrude petals Also let's disconnect it for now so that we can get a better look at just the central curves let's move our nose around a bit to give us more space to work with and these two nodes over here for sampling the flower center are going to become very useful later so let's put the frame around them before we forget and call it flower center to form the big spiral we need two types of translation for each petal scaling and rotation to get the scaling let's go to our original flower curve right after the resemble curve drop in the set position and then connect it to a mixed note we will be mixing between the center of the flower which we have already computed and then mix that between the original Point position for the factor of the mix we will drop in a spline fatter field and there the puzzle curves are already looking spirally for rotation if we ignore the curve for attack and just imagine a abstract Loop that goes from 0 to 360. the first petal would start at zero and then the second pattern would be at 137.5 degree the third would be at 137.5 times 2 and basically the nth point would be at 137.5 times n minus 1. to take the curve into consideration we're going to do an approximation it's not a perfect Loop but we're going to pretend that fraction zero is at zero degree and then at fraction 1 which is the end point is at 360 degree well for the first petal we can simply put it at fraction zero where should the second petal go well we can simply Advance it by a fraction that roughly maps to 137.5 degrees that means the fractional increment is going to be 137.5 over 360 which is about 0.38 now for the next pedal and the next pedal we keep repeating the same thing which is incrementing the fraction by 0.38 and what happens when the fraction goes over one well we can simply modulo it by one which is basically taking the fraction this way the points will go around the loop forever okay so previously we were mixing between the center and the position so let's get rid of the position drop in a ID node use a multiply node so that each increment is 0.38 apart and we will take the fraction so that it doesn't go over one and then we're going to fit this to a sample curve node so this will be the sampling fraction the curve is the flower curve itself and we will feed the position to the input of the mix and voila you see here the distribution is a lot more spread out and if I increase the pedal count it's kind of looking like the distribution of a flower petal you may notice that the smallest petal is really small it always goes all the way to the very center so if you don't want it to zoom in that much what we can do is we can plug in another mix node plug in the this result and then plug in the position that would be if there were no scale effect and then feed the new results to the position when the factor is one there's no zooming in but when zero is fully zoomed in this is kind of an important parameter for the shape of the flower so let's make this a group input and I'm just going to call it petal inset great all right so if we connect the screw pedal is looking more interesting I promise you that the spiral is gonna look a lot better when we fix the other half of the problem which is our pedals are still super duper flat if you look at them from the side view the pedal curves are straight lines they look like this remember these curves are bezier curves so we can bend them with handles if we move their Handles in the direction that is perpendicularly pointing away from the main curve Direction the final curves might bend like this how do we compute the position of this handle well we're going to use a little bit of a better math so for each pedal we already have a direction from the center of the flower to the endpoint we can call this third and we also have the tangent of this point on the original flower outline curve so these are a bunch of tangents along the current right so we can call this t so if we do a cross product between T and the Russian we're going to get a third letter that is perpendicular from the two and that will be the direction that we move our Handles in all right let's do this let's get rid of the viewer node for now and go back to the very beginning look at the flower input curve right after the resemble the tangent is easy to get because we have already computed it remember the sample curve note that we used earlier when we form the big spiral well if we just drop down a store named attribute change the type to Vector we can simply plug in the tangent that we have sampled from this spiral as the value of the attribute let's call this attribute tangent next let's compute the direction from Center to Pedal tip if we look at this realized instance note the point at this point are already at the tip of the pedals you can see them because all the curves have zero length but we can visualize it by dropping a instance on points and then feed an icosphere as the instance let's make the ecosphere smaller and voila the points are following the layout pattern let's add a store named attribute right after the realized instance and we will be storing a letter with each point by the name of there and for this letter we are actually gonna drop in a subtract to subtract the position of the current point from the center of the flower we'll also use a normalized node so that this direction is normalized a quick note here I actually want the resample curve here to go into the extrude pedal note group because it's a preparation for the extrude so let's just quickly put it into that note group now let's move the bezier handles dropping a store named attribute we will set a vector on a point attribute that already exists called handle right and voila already the curves are bending all towards zero zero zero because we haven't set the value yet to bend the other side of the handle simply duplicate the store named attribute and change the field name from handle right to handle left so I always have trouble remembering what's handled right and what is handle left which is in-going which is outgoing so my waiver figuring out is I will connect the value to a position same for the other one as well I'm gonna offset this position by using a better math ad I'm going to add the position with a little offset let's just do a X offset and now as you can see it's very obvious the handle right is for the uh the endpoints right because it's shaking the most so now we know the handle left is for the center point all right let's compute the actual handle offset drop in a cross product connected to the ad we're going to feed it two named attribute that we just computed one called dirt the other one called tangent let's also drop in a normalized node to make sure that everything is normalized and voila as you can see is working our pedals are bending a few things to tweak first of all I think it would look better if the pen amount scales with the length of the pedal to get the distance from the center of the flower to each tip let's go to duplicate it change the name to distance change the type to float and then we can fit it the length of the batter that goes from the center to the tip going back to where we set the handles now here right after the normalize we can drop a multiply actually let's drop a scale node and feed it the named attribute called distance let's connect the scale to the ad we can do is skill again after the scale and this scale is kind of like a bendiness control so let's expose this as a group input and we'll call this pedal Bend perfect now let's set the handle position for handle right I believe this entire network of nodes over here can directly be reused so let's just feed this add node which is what we feed for handle right to handle left as well yay seems like it's working correctly all right now if we control this through pedal this is looking a lot better we can change freely the number of pedal accounts we can also change the pedal bendiness easily we can even have it bent the wrong way the opposite way I'm just gonna give it a little bit of Bend um we can control how much it zooms towards the center and the awesomeness of this approach is it's fully non-destructive and fully procedural so when you move the stem flower center moves with you you can even move it outside the flower which I think produces some of the more interesting results because when this happens if you look at the side view of the flower petals some of them are actually bending upwards some of them are bending downwards thanks to the better math that we did just know so you get some nice occlusion results there's still one quick thing that we can fix right now there's not enough resolution across the horizontal direction of the pillow let's fix that let's go to the extrude pedal here we're just sweeping a curved line that's probably only two points right so we can drop in every sample curve node here I'm gonna change the mode to lens so that I can resample by the segment length and I'm going to promote the length parameter to a group level input so that we can tweak it from one level up let's call it resample length it's already looking a lot better with more geometry we can even make the resample length a input of the entire node group and we can use the same length to resemble the direction that goes from the center to the tip let's look at where that resemble should happen I think it should also happen within this extrude pedal note group let's dive into that no group find the first resemble curve change the mode to length and plug in the same resample length and sweet now you have resolution control in both directions in the pedal now let me show you more fun parameters to tweak remember this flow curve node that we used to define the shape of the pedal well if we just plug another multiply after it feed the result to set radius let's make the other input to multiply a group input and call it pedal width let's go one level up and make the pedal with a Geo node input now you have a control for well the width of the pedal Ctrl H to hide the unused input now let's annotate our graph before it gets too crazy this whole session here is for endpoint layouts well paddle endpoint layouts to be specific well these three guys over here the instance a bunch of bezier segments that are zero length onto a bunch of points so let's put them into a group note and call them instance zero curse now all of the rest of the nodes here are really for positioning the bezier control points and bezier handles so let's put them into a frame and call it position bezier curves and these last few guys are for Extrusion great all right I think we're done with the flower petals for now let's move on to the stem and the stem is actually quite easy to make so we already have the stem curve here let's connect it to a curve two mesh and as for the profile curve that's connected to a curved Circle now we have a tube now let's work on the shape of the stem a little bit let's drop in a flow curve and connect its value to you guessed it spline Factor and let's just play with the Curve here until we get something we like all right I think I'm pretty happy with this shape where there are two bumps on the end every time a curve Extrusion disappears after your tweak as radius it might be because you don't have enough points on that curve to fix it drop in a resample curve node let's resample with the length this time and let's keep tweaking the curve a little bit and okay I'm okay with it so this section of the graph is actually quite a reusable operation so let's throw them into a no group and call it extrude stem to join the stem with the flower petals drop in a drawing geometry and connect the stem geometry with the petal geometry and voila here is a full flower I'm just going to turn off the wireframes for now because they're getting a little distracting and uh yeah we're getting there all right now let's move on to the leaves well first thing first I change the leaf curve a little bit so that I know instead of going around the whole stand it's only staying on one side So the plan of the leaves are going to be very similar to the paddles we're going to instance a bunch of Curves and set their end points so that they go from the leaf curve to the stem curve like this all right let's start with the resemble note here again let's make the count a group input and call the input leave count now to instance a bunch of Curves we're going to use instant zero curves now that we just created remember this is what we use to um to instance the flower curves you can't see anything but you can visualize by dropping a instance on point node feed a icosphere as the instance Yep they're actually all on the leaf curve since these two nodes are really useful for visualizing why don't we just put it into a group node and call them visualize points all right now we have a bunch of splines with exactly two endpoints let's use again a set position node and for selection we will use a modulo and a ID field so modulo the ID by two and if the result is equal to zero or comparing to ins here we select the points let's get rid of this visualizer so as for the position we want to sample the position from the stem curve so let's drop in a sample curve node and connect the curve input to the stem curve here connect the position output to the position here for the factor input we actually want to sample with the factor of the starting curve which is the leaf curve so we have that factor actually here right after the resample curve node so we're going to use a capture attribute node here connect the value to a spline parameter and then we will feed the output to the factor voila a bunch of Curves going between the leaf curve and the stem curve now let's introduce some bendiness to this curve so that they don't look so mechanical well as you might have guessed we can again move the bezier handles so that the point in the tangent direction of the end curves so we will drop a store named attribute node we'll set better on handle left and immediately there's bendiness but they're all pointing towards zero zero so instead of zero zero zero let's use a at and let's add between the original Point position and the tangent of that point along the curve so it's tempting to directly connect a curved tangent but that won't work because this tangent value when we use it here will actually be the tangent value of this small curved segment so they will actually be pointing like this but the temperature we want to use is the tangent along the outline curves so we need to get that with a simple curve node fortunately there's already a simple curve node here assembling the tangent of the stem curve so let's just try to feed the tangent into the add here and what I already you can see it's bending in more of a reasonable Direction one issue here is we actually want to bend the other side of these curves with the stem tangent so that means instead of the candle left we actually won't handle right here voila that's better to bend the other side we can simply duplicate this store named attribute this time we will use handle left and then for the position same thing we will use a vector math add node to add between the position and the tangent so for the tangent we'll use another sample curve note this time we'll be sampling along the leaf curve and for the sample Factor here we can use the same captured attribute here and fit it to fatter let's feed the tangent to the add now we have bendiness on both sides all right to build a little bit of control of how bendy we want these curves to be we can simply add a scale node after the tangent let's make this skill factor a group input and we will call this Leaf Bend now let's add the same thing to the other side connect the tangent to a scale and then feed the leafband to the scale but now we have a little control which is pretty sweet finally let's connect a pedal extrude node this is what we use to extrude the panels earlier right and we can tweak The Petal with however we want put everything together let's connect the extrude pedal results to the strain geometry voila you have a flower with a bunch of leaves so to get leaves on the other side we can simply reuse this section of the network except another curve input and then generate leaves for the other side I'm gonna put all of this into a group name this group gel leaves for the inputs the first one connects to the leaf curve we can call this Leaf curve the second one must be the stem curve and then the scale is actually the bend skill let's move things around to make it look more readable let's duplicate it I'm gonna duplicate the leaf curve get rid of the points and then draw it on the other side drop our second curve into the Note 3 connect it to leave curve connect the stem to the stem curve voila there's the other half and we can just join the other half to the drawing geometry here now we have a full flower if you don't want leaves generating all over the stand curve there's an easy trick that you can do which is to drop in a trim curve node onto the stem curve and this is basically trimming the stem input that we feed to these two gen lymph nodes so that you only get leaves on a subsection of the stem curve all right at this point our no setup is basically complete you can try to tweak the Curves in the viewport and everything should move as you move the curves it's really quite sweet I can even have a little flower open animation if I want by animating the Curve if you want a second flower just duplicate all the curves from the first flower or create new ones however you want and change out the shape let's add a mesh object and assign the chain flower geometry note to it and now you can see a problem which is all of our curves were previously hard coded into the geometry node to make them configurable let's make all of these group inputs let's call this flower curve stem curve same for here and then let's clear the default input on all of these inputs sweet now for my second flower let's select the other set of curves that I just drew well make sure to always select relative otherwise it will use some weird local position suits now one note is this setup should work pretty well when you have 3D curves now everything is in the Sy plane but if I move the curve up like this it should all work pretty well you can really position this curse however you want in 3D like lifting the sleeves side this side of the leaf up lifting this side of the lever perhaps for the sake of this tutorial I will keep things mostly within the Sy plane but feel free to tweak it however you want in your own workflow all right let's get rid of this flower for now get rid of the unused curves some of you might wonder how to generate the filaments well the process can be really similar to that of the paddles essentially you can take the pedal line curve and then generate the second curve that is roughly the same shape but just uh closer to the flower center and more scale down like this and then you will probably also use a smaller width to generate the paddles and then as a result you have a bunch of filaments that are pedal like I will not go into detail about that flow because I think it's quite redundant however I want to show you something that's even cooler so because we're quite literally generating everything with math we have a lot of control on the exact shapes for example we go to the extrude pedal on the flowers so here we're fitting in The Petal width directly instead of using a constant we can actually make the width Dynamic for each petal so say if we have 10 petal Curves in total one two three four all the way to 10. I can specify it such that the zeroth curve have the smallest width and then the 10th pedal has the max width and everything in between either interpolates smoothly or follow some kind of float curve so to do that we'll need to compute the fraction for each pedal to represent how far along they are to the flower center starting from the edge zero and then going all the way to one which is at the very center let's drop in another store named attribute and feed it the spline Factor parameter it's called the center Factor so this attribute will stay on the points Center Factor let's just make sure that we don't lose it when we generate the geometry so in the generated curve here they still have a center factor which is great it's right here all right so for pedal width let's feed in a name attribute called Center fatter and already as you can see they're getting various width and I'm gonna drop in a float curve node and now you can freely tweak the curve so that I have a custom mapping of the factor let's drop in another multiply node connect the inputs pedal with to the other input and then connect it to the pattern width this way we can still use this slider here for pedal width to control the overall multiplier for pedal width so I'm going to increase the pedal inside here so that they Zoom inwards a lot I'll create a lot more pedals and just play around with the Curve until I get something that I like yeah I think this is quite nice everything is looking kind of nice I want to give a little more geometry on my pedal so I'm gonna go to resample length and give it a smaller value ah there you go all right friends I'm gonna pause here and take a break because I really need to get a life but part two is coming there are so many more cool tricks that I want to share to give you a preview we will be breathing life into the flower by introducing noise of different intensity levels literally everywhere into the mesh into the material and maybe even into the animation alright thank you for watching please like comment and subscribe for more tutorials in the future I'll see you in the next one happy creating and don't forget to save
Info
Channel: Yem3D
Views: 27,441
Rating: undefined out of 5
Keywords: blender tutorial, blender, blender 3d, blender geometry nodes, flowers, procedural generation, 3d modeling
Id: M58jpYXHSSU
Channel Id: undefined
Length: 35min 9sec (2109 seconds)
Published: Sun Jul 30 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.