Control object placement with map

Started by KyL, May 04, 2016, 01:09:55 PM

Previous topic - Next topic


Hello guys!

While looking for a solution to precisely populate objects on a terrain using a map, I came across this topic:,9685.msg101614.html#msg101614
The first experiment I did gave me good result but there was always that special case where you would have two trees on the same spot or a missing tree.

After a bit more work I managed to come out with a 100% reliable solution that gives you the ability to distribute trees (or any other objects) exactly where you want on the terrain.

First thing, you will need to make you map so that 1 pixel = 1 meter. Each pixel will determine the precise location of the instances of the object you want to populate. So ideally you will have something like this:

In Terragen you have several option to place your texture. Use an image map shader with the projection type on "Plan Y" and determine the size manually. Or you can use a geog image map shader and do the same thing. If you do so, you will have do change the load method to "terragen" and remove "georeference from file" to manually setup your area.
What's really important here is to have the exact same value between the definition of your map in pixel and the size of the texture in meters.

Now in the image map shader Colour tab, be sure to turn off Smooth interpolation, Unpremultiply, and turn on Data is linear. This is mandatory to be sure your texture is not affected in any way before driving the population density.

In the populator, place object spacing to 1,1 and spacing variation to 0,0

Click "populate"!

You should have a 1:1 match between your map and the populated result. Something I noticed is that you will always have one instance invisible as a bounding box. Don't panic, if you switch to shaded preview or render the scene, the object is there. I think it might be because it's either the first or the last instance to be populated and for some reason its bounding box is invisible.

I am using this technique heavily now and it turns out really efficient. I usually use 10k map to have a large enough area to drive my population.
One last thing, try to keep you population area as low as possible. Population with a 1m spacing takes time, even if 99% of you map is empty.

Some of you might already know this technique, but as I couldn't find anything really reliable I rather liked to do a quick post here.

happy tree painting!


Very logical indeed, and very useful too! Great find. Thanks for posting!


Interesting and it makes sense.


Boffo, a Cinco de Mayo present...well thought out.Thanks for sharing this.
something borrowed,
something Blue.
Ring out the Old.
Bring in the New
Bobby Stahr, Paracosmologist


Thanks for the info KyL! Very thorough and easily understood. The first two image attachments in your post refuse to load but the explanation pretty much filled the void. 

The more I use Terragen, the more I realize the world is not so small.


To compensate for the disabled position "jitter" you can add a slight offset on X or Z.
The instance will still be placed at the same position, but the offset will then move it outside of the center of the pixel and since random rotation on Y is still active it means that you will get back some position jitter again.
If this does not work, then the checkbox for sampling terrain before density shader might help out, but I think the default behavior of the populator should allow the above to work as I postulate.