3
$\begingroup$

first of all, I'm absolutely not sure whether I'm right about the title. If the title is wrong, please let me know. :)

I have not been working intensively with Geo Nodes for very long and am currently facing a supposedly simple problem, which unfortunately I cannot solve.

I'm working on a node setup which is supposed to create a nettle. This is my current status, I'm pretty satisfied so far.

Nettle current state

What bothers me now is that the leaf layers all have the same distance to each other. I would like to bring in a little more variation.

At the moment I trim the curve to determine the start and end and I use the resample node to determine how many leaf layers should be created.

example Setup

Now I ask myself how I have to continue after the resample curve to slightly change the distances of the leaf layers to each other.

Here is a section of the entire node setup with the resample curve node.

part of the whole system

Thanks a lot in advance! <3

$\endgroup$
1
  • $\begingroup$ I think the actual question is "How to resample curve by uneven (random) lengths?" $\endgroup$ Dec 15, 2023 at 12:55

2 Answers 2

4
$\begingroup$

This answer is similar to the existing one by @Crantisz, but since I was already finished I thought I'll add it anyway. In my setup you have control over where exactly on the curve you want to start and where to end distributing points (on which you can instance something later).

First I use an Integer for the count of points to create. Then I subtract 1 from it because the indices of $n$ points go from 0 to $n$-1. Dividing the Index by $n$-1 and using this as Factor for the Sample Curve to determine the position of each point on the curve will spread the points evenly along the curve from start to finish.

Now I use a Random Value node with Min set to 0 and Max to an arbitrary value (in my example 0.05) to get some variation by adding the random value to the ratio of Index divided by $n$-1, which results in getting a factor start value between 0 and 0.05 and an end value between 1 and 1.05 at maximum.

This would already randomize the positions of the points along the curve. To determine now a guaranteed start and end value for the factor, I use a Map Range node.

I enable Clamp on the Map Range node, set the From Min value to the Max value I used for the Random Value node. This way, the first point will always be mapped to the To Min value. The From Max value I leave at 1, this way the last point will always be mapped to the To Max value. And that is how to determine the start and end position, in my example I distribute the points between factor 0.3 and 0.9 of the curve.

You could plug the Index into the Seed input of the Random Value node so every point gets its own seed, but I leave it unconnected to simply change the seed until I like the distribution.

random point distribution on curve

//EDIT: As I know by now, you are using a Color Ramp node to assign a scale to the distributed instances and want to keep it that way. To do this, you can plug the result of the Divide node into the Color Ramp. The division assigns a value evenly spread from 0 to 1 on the points, like the Spline Factor according to the position on the curve.

Now changing the position afterwards by adding random values and map them to a different range does not change the "factor" they are given, which means a Color Ramp using this initial range would still apply the same values to the same instances like on the unaltered even distribution. In the following image you can see the initial distribution (with Add and Map Range nodes muted), below is the new randomized distribution and the nodetree. You can see the icospheres are still scaled the same, although their absolute position changed:

scaling via color ramp

By the way, one reason why you should avoid to use a trimmed, resampled curve for instancing when you are using the original curve for the stem is the following: if you try to align instances along the curve according to the curve's tangent, the result might seem incorrect - that is because the tangents on the trimmed resampled are most likely from the ones on the original smooth curve - and you cannot sample the tangent from the original curve either because the factor does not fit the trimmed curve.

resampled tangents

Another thing: You are trimming a curve coming directly from the Group Input - which means, you have added the Geometry Nodes modifier directly to a curve object, not a mesh object. If you now created a nettle and for whatever reason you want to apply the Geometry Nodes modifier, you cannot do this via Apply in the modifier menu even if the instances are realized. Because the Apply option cannot write mesh data into a curve object. If you want to convert it to a real mesh, you have to use the viewport menu Object > Convert > Mesh or the shortcut Ctrl+A > Visual Geometry to Mesh.

$\endgroup$
5
  • $\begingroup$ As you said, it's like the first answer, only explained in more detail. Many thanks for that too! $\endgroup$
    – Knudsen
    Dec 15, 2023 at 14:25
  • $\begingroup$ @Knudsen Well, it was a bit of a simplification from me to say its the same, but well... I've added a bit more information in the end that might be interesting to you although it has nothing to do with distributing the points. $\endgroup$ Dec 15, 2023 at 14:53
  • $\begingroup$ @ Gordon Brinkmann Many thanks for that! I understand what you mean. Distributing the leaves works well now. Unfortunately, there are many other problems as a result. Just a humble question, is it possible to get in touch with you and clarify one or two questions? Funnily enough, I found out from your profile that you are practically a neighbor, I live in Bielefeld :D $\endgroup$
    – Knudsen
    Dec 15, 2023 at 15:07
  • 1
    $\begingroup$ @Knudsen Really funny, been in Bielefeld 3 weeks ago. You can find me under my name at Insta, just my full name without any spaces, dots or anything $\endgroup$ Dec 15, 2023 at 15:20
  • 1
    $\begingroup$ @Knudsen I've edited my answer to fully solve your problem with the addition of the color ramp scaling. $\endgroup$ Dec 18, 2023 at 12:49
6
$\begingroup$

You can use sample curve node to sample curve at any factor. So that you can add a random number to sample factor like this:

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ This answer literally addresses the OP's approach to modify base distance, but if you want more randomized distances without overlapping, I would suggest using accumulate field node, and a little bit of excess points guaranteeing to populate the entire curve (and removing the excess with randomized factor above $1$). $\endgroup$ Dec 15, 2023 at 14:03
  • $\begingroup$ This is very close to the distribution I had in mind. I am now trying to implement the idead from @Markus von Broady and then implement the whole thing into my system. Thank you very much! $\endgroup$
    – Knudsen
    Dec 15, 2023 at 14:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .