We take the x component of the pixel and threshold it with the smoothstep. Now any point which is closer than 0.01 units from the center of the tree is black.
We are using abs because we want pixels to both right and left relative to the center of the tree.
But what about that annoying top part?
We can change the selection by changing the (2nd) smoothstep. Here we are selecting every pixel above the center of the canopy and 0.4 units above it. So everything above 0.4 is erased.
Move aside, tree.
They grow up so fast!
But, I’ve seen real palm trees and I don’t think the trunks grow quite that straight.
Add a sin component to bend the trunk.
The trunk still doesn’t look right.
But I thought palm trees liked living on beaches?
But the sky’s boring.
Use the mix function to supply two colors and a “weight” based on y value of pixel. (More yellow when y is closer to 1.0, more orange when closer to 0.0).
Coordinates go from 0 to 1. Taking the sqrt of a number from 0 to 1 makes the number bigger (like sqrt(0.5) ~ 0.77). Bigger numbers in this case means more yellow. It’s important that sqrt doesn’t change 0. That means the orange will always be there on the bottom, it won’t disappear completely.
//////////////////
And there you have it. A tree for you and me.