Population Masking Techniques
Terragen is often praised for the quality of its atmosphere, clouds and skies, but equally important is Terragen’s implementation of populations, that is, its ability for creating many instances of 3D geometry in a scene. The fact that Terragen can handle billions of instances is incredible.
Setting up populations
Let’s get familiar with Terragen’s population controls in an empty scene first. From the Objects Node List click on the “Add Object” button and select “Population” then “Tgo object”, and choose a 3D object to instance.
Notice two new nodes show up in the Object Node List. The first new node represents the population and the second node represents the object being populated or instanced. With the population node selected click on the “Populate Now” button at the bottom of the population's Distribution tab.
A bunch of bounding boxes appear to show each instance of the object. Reduce the number of instances so you can better see what’s going on. Change the “Object Spacing in a,b” values to “100”, and recalculate the population by clicking the “Populate Now” button again.
Now we see fewer instances, randomly scattered around the terrain as defined by the “Area length a,b” settings. Changing the value in one or both of the area length fields will resize the area’s width or length.
The “Spacing variation” value sets the maximum allowable distance that an instanced item can be offset from the object spacing values. Setting this value to “0” will cause the instanced items to be positioned as defined by the object spacing values, and they will all appear to be neatly lined up in rows and columns.
Now the instanced objects are lined up, but still have random rotations. Align them by setting the Maximum Y Rotation value to 0 on the Rotation tab and recalculating the population.
Now all our instances are aligned in rows and columns. If you used a tree as your object you should now see an orchard instead of a forest.
Masking with the Camera's Field of View
Terragen also has the ability to create populations that are only within the camera’s field of view. Enable the “Clip to camera” checkbox on the Distribution tab and recalculate the population.
Notice that all the trees behind the camera have disappeared. By placing instanced items only where they will be visible in a shot reduces the number of instances, and allows you to have more instances in the field of view. Optimizing your populations in this way leads to faster scene loading, calculating and rendering times.
Masking with Painted Shaders
“Masking” is the term used to limit the instanced items to certain areas. Instead of masking the population by the camera’s field of view, let’s mask it by a paint shader. First allow the 3D Preview to completely refresh, then click on the “Pause” button at the top of the 3D Preview pane. From the main menu click on the “Paintbrush” button to start or stop a Painted Shader paint session, then select “Start Painting Shader” and “Create and paint new shader”.
In the dialog window append a description to the “Name” field, so it will be easy to identify our mask later on. Change the brush type to “Use view-relative brush” under the Brush tab, which will change the brush size based on our perspective view of the scene.
Left click and drag to start painting the mask on the terrain. When you’re done click on the Paintbrush button and select “Stop painting”.
To apply the mask you just painted, click on the green “Plus” button next to the “Use density shader” and select the “Assign shader” option from the drop down menu and select the name of the mask you just painted. You can also do this in the Node Network pane by dragging a connecting line from the painted shader node’s output to the population’s density input. Either method will enable the “Use density shader” checkbox.
Uncheck the “Clip to camera” checkbox and recalculate the population.
The instances are now generated only where the mask was painted. To reverse this, check the “Invert density shader” checkbox and recalculate the population.
Masking with Simple Shape Shaders
If you want to create a common shape for a mask, like a square, rectangle or circle, use Terragen’s built-in “Simple shape shader - Colour” node.
Bring up the “Quick Node Palette” in the Node Network pane pane by pressing the “N” key or the “Tab” key, then start typing the word “Simple”, and choose the “Simple shape shader - Colour” node.
You can choose the shape used by the Simple Shape Shader and reposition it as desired.
Combining Masking Shaders
We can combine these two shaders together with an “Add colour” node from the Quick Node Palette.
Drag the output of the Painted shader into the Main Input of the Add colour node and the output of the Simple shape shader into the Input 2. Then double click on the Add colour node to bring up its interface. Click on its “Open shader preview” button and zoom out as necessary to view the results of combining the two nodes into one.
When the two shaders overlap the resulting value is greater than 1.0 so these areas appear brighter in the preview. Let’s add a “Colour adjustment” shader to clamp the highest value at 1.0.
Now drag the output of the Color adjustment shader to the population’s Density shader input and recalculate the population to see the results.
Masking with Power Fractal Shaders
You can use Terragen’s “Power fractal” node to create organic shapes as masks. Add a Power fractal node the same way as the other nodes and open its preview window.
We want to create a high contrast noise pattern that doesn’t have a lot of detail. Under the Colour tab set the “Colour contrast” to “1” and the “Colour roughness” to “0”. Then use the “Colour adjust” slider to get a good balance between light areas and dark.
Experiment with the different types of noise patterns under the “Tweak Noise” tab.
Under the Warping tab, use the “Lead-In warp effect” and “Lead-in warp amount” to create swirling wave-like patterns.
Now, you can adjust the size of the fractal pattern using the “Feature scale” and “Lead-In scale” settings on the Scale Tab. If you’re unsure of the sizes to choose, use the built in measuring tool to sample the distances.
In the Node Network pane, copy and paste an instance of the Color adjustment node previously used, and connect the Power fractal node to it. Adjust the “White point” as necessary to eliminate most of the grey areas, and then connect the node to the population’s Density input, and recalculate the population.
Masking with Distribution Shaders
The final type of mask we’ll explore is the Distribution shader, which allows us to limit populations by altitude and slopes. To see this effect better, disable the Simple shape shader that’s applied to the default scene’s Fractal terrain node.
The terrain should no longer be flat beneath our population. Increase the area of our population and recalculate it so that the instances sit on the new terrain. Hovering the mouse pointer over the terrain updates the XYZ coordinates and slope values displayed beneath the 3D Preview. We can use these values to set the limits of our constraints in the Distribution shader.
Click on the green Plus button next to the population's “Use density shader” setting and select “Create new Shader”, then “Colour Shader”, then “Distribution shader v4”.
Limit the tree population to the crest of the mountain ridgeline. The Y axis shows that it’s about 200 meters high, so under the Altitude constraints tab, enable the “Limit minimum altitude” checkbox and set the “Minimum altitude” value to “200” and the “Min alt fuzzy zone” value to “0”. The fuzzy zones allow for soft transitions to take place, but for now we want to see a definite cut-off point to the population. Time to recalculate the population.
Now reduce the “Minimum altitude” to “50” meters and enable the “Maximum altitude”, setting it to about “200” meters, with a fuzzy zone of “0” as well, then recalculate the population.
As you can see, using these basic masking concepts allow you to completely control where your instances are placed, and like many other tools in Terragen, these masking techniques can be applied to other shaders as well, not just to populations.
Working with Populations
This page introduces you to populations and how to work with them.
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.
Tutorial: Population Colour Tinting Techniques
This tutorial shows you how to use the tinting tools to change the colours of instances in lots of interesting ways.
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.
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 sample refers to a value or set of values at a point in time and/or space. The defining point of a sample is that it is a chosen value out of a continuous signal. In Terragen 2 it is usually a mathematical (procedural) function that is being sampled.