Pine Prints - Shaping Perlin noise

Christmas post number two woo! Don't tell me it's the 14th already, I'll flip.

To me, a source of infinite potential is the way that one can shape Perlin noise. I have made a couple of posts about specific shapes of Perlin noise - strangely, both related to flames - in shaping a flame and a sun. But I never really explained the thought process at all.

Let's imagine noise(x,y) as being a function that outputs a random Perlin noise with an average of zero. We could then start with:


noise(x,y) > 0

Without a specific shape, this formula just outputs what looks like a map. There is an equally high probability of any part of the canvas to be coloured in.

If we increase the right hand of the equation, 0, to for instance 5, much less of the canvas would be filled in.

And if we substitute the 0 with the x-coordinate, the probability of being filled in would decrease along the x-axis.

We want to create a pine-tree. What kind of shape does a pine-tree have?
noise(x,y) > abs(x-midscreen_x)

The first shape we apply will increase the probability along the mid-axis and decrease it towards the edges.

Do note that the actual numbers are fudged a bit to keep the lines of code readable. Here, for instance, we have to increase the probability for anything to be drawn at all, as well as multiplying the influence of noise to not just get a straight vertical line.


noise(x,y) > abs(x-midscreen_x)-y/4

We don't just want a line, but rather, a triangle. To this end, we should increase the probability of points being filled in as we reach the bottom part of the image. For this, we can use the y-coordinate.

Here, the y-coordinate is divided by four, since the pine-tree should have edges with this specific level of incline.



















noise(x,y) > abs(x-midscreen_x)-y/4+max(0,3*(y-lowerscreen_y)

Then to cut-off the bottom of the pine tree, we can add in a strong deterrent along the y-axis. But wait, now we are both using the y-axis to increase and to decrease the probability. Therefore, we need to use a min/max function to make sure that the new y-axis deterrent only kicks in after a certain point, here named lowerscreen_y.

This additive effect that kicks in at a certain point can be seen as the sharp (literally obtuse) angle at the bottom.












And now, as the shape finally works, we need to do something about, well, the Perlin noise. Currently it is a nondirectional warping - well, that's useless and has nothing to do with the shape of a pine tree. So far we've shaped the figure, but not the noise.

 Pine branches are mostly horizontal, but multiplying the x-coordinate of the Perlin noise does not really give the desired effect.
noise(x,y,y+abs(x-midscreen_x)) > ...

Rather, adding in a new factor into the noise, one which relies on the diagonal distance to the central spine of the image, will give us some more branch-like structures.
 It is, however, necessary to keep both the x- and y-parts of the Perlin noise for the effect to work. Here we see just the diagonal distance and y-coordinate, which gives a neat, symmetrical pine-tree that looks wholly unnatural.
 This is an attempt to make the noise more branch-like by making the effect more low-frequency. However, this also goes to create very lumpy trees.

Another thing is that the diagonal distance now takes in more of the x- than y-coordinate, so that the branches go at an around 20° angle.
I think this is how far as I got before I unfortunately lost the project I was working on :(

Therefore, I do not have either link to the source code or more examples, nor an animation, this time.

Welp.

Perhaps I'll go back and recreate this from the pseudocode written above. It is a tutorial, after all.

Comments