Planetside Software Forums

General => User-contributed Tutorials => Topic started by: KyL on May 04, 2016, 01:09:55 PM

Title: Control object placement with map
Post by: KyL on May 04, 2016, 01:09:55 PM
Hello guys!

While looking for a solution to precisely populate objects on a terrain using a map, I came across this topic: http://www.planetside.co.uk/forums/index.php/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:
[attach=1]

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"!
[attach=2]

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!


Title: Re: Control object placement with map
Post by: Dune on May 05, 2016, 02:46:01 AM
Very logical indeed, and very useful too! Great find. Thanks for posting!
Title: Re: Control object placement with map
Post by: AP on May 05, 2016, 03:31:51 AM
Interesting and it makes sense.
Title: Re: Control object placement with map
Post by: Kadri on May 05, 2016, 10:59:39 AM

Thanks. Good to know.
Title: Re: Control object placement with map
Post by: bobbystahr on May 06, 2016, 08:47:58 PM
Boffo, a Cinco de Mayo present...well thought out.Thanks for sharing this.
Title: Re: Control object placement with map
Post by: pixelpusher636 on January 22, 2021, 08:32:00 AM
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. 

Thanks!
Title: Re: Control object placement with map
Post by: Tangled-Universe on January 28, 2021, 07:08:15 PM
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.