Difference between revisions of "Working with Populations"
(→Controlling Where Instances Appear)
(Added links to the other three population guides)
|Line 118:||Line 118:|
Revision as of 23:34, 21 January 2020
Populators are one of the more important nodes in Terragen. Populators allow you to quickly and easily cover large areas with many copies of an object. You can use populators to create forests, meadows, rocky wastes and much, much more.
The Professional and Creative editions of TG can create an unlimited number of populations. The Free edition is limited to 3 populations.
Each populator node can handle one object. The populator is able to add many copies of that object into the scene. It does this in a very memory efficient manner. The full object is only stored once in memory. The populator is able to add millions or even billions of copies of the object to the scene using relatively little extra memory compared to what would be used by millions of separate objects. The copies of the object the populator creates are called "instances".
Each population is set up to cover a certain area. The populator creates instances in this area according to spacing and randomness parameters that you set. By default the populator positions instances in a completely random pattern but you can control things so it's anything from completely random to a regular grid.
The populator can randomly scale and rotate instances, within limits you set. This helps to create more variety and realism in a population. The populator can also make instances lean according to the slope of the underlying terrain.
When populators are created they're automatically set up so their instances sit on the terrain. This is done using the settings in the Terrain tab of the populator. If you ever find that a population is mysteriously floating in the air check those settings. Normally you would want the Sit on terrain parameter to be connected to the last Compute Terrain node in the Terrain group. Clever manipulation of these settings can also let you place a population, of bird objects perhaps, up in the air.
There are several ways to create populators. Typically when you create a populator you also choose what sort of object you want to use for the population. For example you might choose to create a population which uses an OBJ Reader to populate an imported OBJ model or create a population using the built-in Rock or Grass Clump objects.
There are several different ways you can create a populator:
- Use the "Add Object" button in the top left of the Objects project view in the main window. Click the button to show the menu, go to the "Population" submenu and choose the type of object you want to populate.
- Use the "Import Object" submenu of the File menu. Choose one of the "as Population" items to create a population of that object type. For example choose "Terragen Object (.tgo) as Population" to create a population using TGO objects.
- Context click in the Network view and choose the desired object type from the "Create Population" submenu.
- Use the Library window. When you select an object in the Library window two buttons will appear in the bottom right, one of which will be "Import Population". Click that button to create a population using that object.
- You can use the Node Palette to create a population of the desired type.
An object node of the desired type is automatically created and connected to the populator node. This object node is created in the populator node's internal network. You can see the object node by doing one of the following:
- Open the population parameter view. Click on the Action button beside the name field and choose "Edit internal network" from the menu which pops up. This will show the object node in the network view.
- Open the population parameter view. Click the Assign button next to the Object maker parameter and choose "Go to" menu item. This will open the parameter view for the object node in a floating window.
- Go to the population node in the network view. Double click on the internal network icon (grey cross).
When you create a population using an object type that requires a file loaded from disk the Open File dialog will open so you can choose the file. If you don't want to choose a file right away you can cancel the file dialog and the population and object node are still created. When you are ready you can specify the file to be used by going to the object node for the population (see above) and choosing the file there.
Populating or Creating Instances
The process of creating the instances is called populating. You can populate manually or you can leave it to be done automatically when you start a render.
When you change certain settings in either the population or its attached nodes (object node or density shader for example) the population needs to be repopulated to bring it up-to-date with the changes. This doesn't happen automatically because it can take a long time in some cases. The population keeps track of whether it's up-to-date. If you start a render with populations that aren't up-to-date TG will automatically populate them.
Typically you would want to populate manually so that you can see populations in the 3D Preview. There are a couple of ways you can populate manually:
- You can populate each population individually. The Populator node has a Populate Now button in its parameter view. Click the button to start populating.
- You can populate all populations using either the "Populate All" button below the Objects Node List or from the "Populate All" submenu in the Project menu. In both cases you have two options - "Needing update" and "Force update". The "Needing update" option will only do population for populators that aren't up-to-date. "Force update" will populate all populations.
Populations which are quick to populate don't show any feedback during the population process. Populations which take longer show a progress dialog. You can cancel the progress dialog and only instances created up to that point are added to the population. Something to look out for is that if you cancel the population process the rest of the instances aren't created when you start rendering. You'll need to repopulate manually.
The Populator v4 supports instance caching. This lets you save the population instances to a file so that when the population is next loaded the instances are read from the cache file instead of being calculated again. Using the cache file may be quicker than recalculating the instances. You can find out more about instance caching here.
Controlling Where Instances Appear
By default the populator will create instances over the entire area covered by the populator. You do have some control over where the instances appear however. There's a couple of ways you might do this. One method is to use a density shader. The populator uses greyscale values from the density shader to control how many instances it positions in different parts of the population.
The other method (new in TG3) is to edit the instance positions manually, which you can do using the Populator v4. You can move and scale instances as well as delete them. You can find out more about instance editing here.
Using a density shader is the best method when you want to control where instances appear more generally or over a large area. For example you might want to instances to only appear where the terrain slope is below a certain angle. Editing the instances directly is better for finer control, for example you might want to move an instance away from a path or move them to prevent overlapping. You can use both methods at the same time.
Each populator only handles a single object. However you might want to have several different objects appearing in the same area, perhaps to give a mixed woodland or an alpine meadow. If you have a particular distribution you want to use for the objects you can connect the same density shader to each populator. This also means that when you make changes to the density shader it will effect all the connected populations.
There is no guarantee that the instances of the different populations covering the same area won't overlap each other. One way to help avoid this is to try using different Seed values to change the pattern used to place instances. You can also experiment with the spacing parameters. For the best control you can edit the instances directly.
You can find out more about instance editing here.
Using a Density Shader
The populator uses greyscale values from the density shader to control how many instances it positions in different parts of the population. If the value from the density shader is white instances are placed at full density. If the density shader value is black no instances are placed. Shades of grey inbetween mean more or less instances are placed.
To put it simply lighter shades mean more instances and darker shades mean less instances. You can use all sorts of shaders as a density shader. Here are just some of the things you can do:
- You can use a Distribution Shader to control the range of altitudes and slopes that instances can appear on, just like you would with a surface layer. You might use this to prevent instances being created below sea level for example.
- You can use an Image Map Shader to load an image that controls where instances appear. If you use a colour image the luminance of pixels is used to convert to greyscale values.
- You can paint where the instances should appear directly into the scene using a Painted Shader.
- You could use a Distance Shader to only create instances with a certain distance of the camera.
- You could use a Power Fractal Shader to distribute instances based on a fractal pattern. Using the Colour Contrast setting you can control the density of your fractal pattern for denser populations.
You could use all those techniques at once by merging different shaders. There really is a very wide range of possibilities.
Make sure you're using appropriate settings for the populator. Try to only make it as big as it needs to be. If you make the area covered by the population twice as large in each direction 4 times as many instances will be created, so it's not a good idea to make a population cover a massive area if it doesn't have to.
The same goes for object spacing. Making the object spacing half as large (i.e. going from 10m to 5m) will mean 4 times as many instances are created. Of course objects need to be spaced appropriately for your scene so you don't have a lot of freedom in this respect, but it's something to keep in mind. Imagine you're using a small flower object to make a meadow. If the object was spaced very closely and the population covered a large area a lot of instances could be created. However because the object is small it may not be visible too far away and you might be able to use some other technique, such as an appropriately coloured surface layer, to give the impression of the object in the distance. This would allow you to make the population area much smaller.
TG can certainly handle many, many instances but perhaps your computer can't! Creating a lot of instances is probably the easiest way to use up the available memory on your machine. If you're using the 32 bit version it's possible to run out of memory and that can lead to render errors. This is much less likely if you're using the 64 bit version but you might find things get very slow as RAM is used up and virtual memory starts to be used. TG will still render the scene but it could take a very long time. This is important if you are using many populations in your scene as well.
If you have a lot of instances or perhaps a complex density shader than you may find that it's quicker to use instance caching than having the population recalculate instances. You can find out more about instance caching here.
Checking the Clip to camera checkbox in the Populator node tells the populator to only create instances that are inside the current render camera view. This can help to speed up the population process. One drawback is that if you have reflective objects in your scene the absence of instances might be visible in reflections.
If you're animating the camera and want to use Clip to camera it's also a good idea to check the Repopulate every frame parameter. This will make sure the populated area matches the changing view of the camera. However it's not generally recommended to use the combination of Clip to camera and Repopulate every frame if you are animating motion of the camera since it can cause pop-in of instances at the edge of the camera view. It will also increase population time (since it now occurs on every frame instead of just once), potentially negating some or all of the benefit of having to populate fewer instances.
The Distance Shader can be useful for limiting the area populated. Attach the render camera to the Distance shader and connect the Distance shader to the Density shader parameter of the populator. This will prevent instances being created further away than the Distance shader allows. You will probably also want to check the Invert density shader parameter of the populator as by default the Distance shader uses colours in the opposite way to what the populator expects.
As an example of how this could be useful imagine you have a scene with heavy fog. Nothing is really visible more than a few hundred metres away so you could use a distance shader to limit the area populated to 600m from the camera, for example. An advantage of this method is that it avoids problems with missing instances in reflections that you might get if you use Clip to camera.
The Render quality parameter of the Populator node lets you control the detail the population is rendered with. This parameter only has an effect if Ray trace objects is turned off in the Render node. TG can reduce the level of detail in the model the further away it is from the camera. This parameter controls how much the amount detail is reduced. Using a lower quality can make the population render more quickly. However if you notice that the quality seems a bit low you might want to choose a higher quality setting. Ray trace objects is recommended and enabled by default in newer versions of TG, so this setting is less often needed now.
There is currently an issue when objects with very dense geometry (many very small polygons) are used in populations. If you have Ray trace objects turned off you might find that polygons appear to be missing from objects close to the camera. In this case you will want to choose a higher quality Render quality setting in the populator. It's probably best to use Ultra quality or simply enable Ray trace objects.
The following project files give examples of using the populator in different ways. All these projects use the built-in Rock object for convenience but of course the same techniques could be used with many sorts of objects. The easiest way to get the populations to populate when you open the project is to choose "Needing update" from the "Populate All" submenu in the Project menu.
The projects are explained in greater detail in the Comments section of the project settings. To view this click the Project Settings button in the bottom left of the main window. You might need to right click and choose "Save as" (Windows) or option-click (Mac) on the project file links to download them directly and prevent them opening in your browser.
This project shows a population that places all its instances on a grid.
This project has two populations, each of which has its instances controlled by a Distribution Shader.
This project shows how to use a Distance Shader as a density shader.
This project shows how to use a Painted Shader as a density shader.
Population Instance Editing
This guide describes how you can edit individual instances in a population to precisely control your scene.
Population Instance Caching
This page tells you how to make use of population instance caching to speed up population loading.
Population Colour Tinting Techniques
This is a gentle guide to using the tinting tools to change the colours of instances in lots of interesting ways.
A single object or device in the node network which generates or modifies data and may accept input data or create output data or both, depending on its function. Nodes usually have their own settings which control the data they create or how they modify data passing through them. Nodes are connected together in a network to perform work in a network-based user interface. In Terragen 2 nodes are connected together to describe a scene.
A parameter is an individual setting in a node parameter view which controls some aspect of the node.
A shader is a program or set of instructions used in 3D computer graphics to determine the final surface properties of an object or image. This can include arbitrarily complex descriptions of light absorption and diffusion, texture mapping, reflection and refraction, shadowing, surface displacement and post-processing effects. In Terragen 2 shaders are used to construct and modify almost every element of a scene.
This is essentially the brightness of the colour. Terragen converts RGB colours to greyscale by taking the luminance of the colour.
Virtual memory is provided by the operating system to allow a program to use a larger amount of memory than the size of the installed RAM allows. For Terragen this means that it's possible to render scenes it might not otherwise be able to, but virtual memory is slow to access and this means rendering can slow noticeably.