6
$\begingroup$

I'll preface this by saying that I don't really know what I'm doing.

To put my question into context, I'm creating a 3D area based on satellite data from the GIS add-on. I want to add randomly distributed trees across the whole area. The way I'm doing it is in Geometry Nodes, where I use the Distribute Points on Faces node to trigger many instances of a tree model. What I want to do, and can't figure out how to do, is to modulate the density input of the Distribute Points on Faces node according to the vertical (Z) position of the ground mesh, basically having an increasing gradient of tree density as the Z coordinate increases. I've tried using a Position node, separating the Z value and linking that to the density, but the position node doesn't seem to actually indicate anything. Here's my (functional) node setup with static density:

Static density node tree

The density value shows as 0, but I set it at 0.00001, just to be clear.

Additionally, if anyone knows how to restrict the domain of points to only a specific area, in this case the camera's view angle, that would also come in handy. The camera stays static, so I'm not asking to dynamically update points.

$\endgroup$
2
  • $\begingroup$ Hello and welcome to Blender.SE! How is the view angle of the camera related to the result? Can you please explain this in a little more detail? $\endgroup$
    – quellenform
    Jul 13, 2023 at 6:40
  • $\begingroup$ The camera thing is just to save resources by not rendering instances that wouldn't be visible in the final render. $\endgroup$
    – Extone
    Jul 13, 2023 at 7:05

1 Answer 1

7
$\begingroup$

The higher the value for the Density, the higher the density of the distributed points.

Therefore you have to use the Z-position there somehow.

In your case, since you also want to control the range individually, I would recommend the node Map Range:

enter image description here

If you plug the Z-position into the input Value, you have the possibility to define the input range with From Min and From Max, and the density value with To Min and To Max. In this example, it starts at $0$, because there should be more trees at the bottom, and ends at $1$, because there are no trees at the top.


To use the view of the camera, you need to know the angle of the camera.

To do this, create a curve line and transfer the position and rotation of the camera to it. Then, using Sample Index, transfer its tangent (the viewing direction of the camera) to the points, compare the direction vector between point and camera with it and filter out the points whose angles are not within a certain range (which you define with Epsilon). This actually works quite well, but in this example the field of view is square.

This could look something like this:

enter image description here

$\endgroup$
4
  • $\begingroup$ Thanks for your answer! I can tell I definitely was on the right track, my scaling was just off I guess. I used math nodes for scaling, but the range node is better for that I guess. In my case, I want the lower elevation areas to have less trees since they've been cut down in the valleys. $\endgroup$
    – Extone
    Jul 13, 2023 at 7:18
  • $\begingroup$ @Extone If you want to have less trees at the bottom than at the top, just switch the values for To Max and To From. This will reverse the density. PS: You should adjust the values for From Min and From Max to the height of your terrain anyway. $\endgroup$
    – quellenform
    Jul 13, 2023 at 7:24
  • $\begingroup$ If I understand the camera thing properly, you're setting a threshold (epsilon) for the angle between the camera's normal axis and the angle between camera and coordinate, which deletes points above a certain value. What does the curve line node represent here? Is it just the camera's axis? Then, is the sample index and curve tangent node just getting the camera's normal vector? What is the attribute you're getting from the capture attribute node? Also, could I use this chain beforehand to control the density, use it as a Boolean value and multiply it with the height based value? $\endgroup$
    – Extone
    Jul 13, 2023 at 7:57
  • $\begingroup$ @Extone Yes, you got that right: Epsilon is a kind of threshold in this case. The Curve Line is used to obtain the camera's viewing direction, since this is not directly available as a value (a workaround, so to speak). Capture Attribute I use here to be able to capture the camera's line of sight in the point domain of the object to be modified. And yes, you can of course use this before that to control density. To do that, you'd have to process the points of the mesh in the same way, rather than using the distributed points. $\endgroup$
    – quellenform
    Jul 13, 2023 at 8:04

You must log in to answer this question.

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