Population Colour Tinting Techniques
The Terragen Populator has a rich feature set that distributes 3D object instances in very realistic ways. But even with variation in placement, scale and rotation, each population is limited to one piece of geometry, and the textures or materials it was created with, which can result in a visible repetition that limits the realism of the end result. What you want is each object to be slightly different, and one solution is to use the populator’s colour tinting tools.
Basic rock population setup
Let’s explore this in an empty scene by creating a population of rocks.
- Click on the “Objects” button beneath the Main Menu.
- Click on the “Add Object” button and select “Population” from the drop down menu and select “Rock” from the population types list.
Two new nodes appear in the object list, the first one is the population node and the second one is the geometry node that will be instanced by the populator.
Let’s create an evenly spaced and orderly array of rock objects in order see the tinting effects most clearly. To do that we'll remove any object rotation, spacing and scale variation. In order to minimize the number of rocks needed to fill up the entire population area, we'll scale the rocks a bit larger and reduce the overall area to be populated.
- Select the “Pop Rock 01” item from the Object List and under the Distribution tab reduce the "Area length a" and "Area length b" values to “100.0”.
- Set the “Object spacing in a,b” value to “5.0” and the “Spacing variation in a,b” value to “0.0”.
- Under the Rotation tab set the “Maximum Y rotation” value to “0.0”.
- Under the Scale tab set the “Minimum scale” and “Maximum scale” values to “4.0”.
Click the “Populate Now” button, and then pull back your camera until you get a good view of the rocks. To learn more about positioning the camera and navigating around your project, click here.
Click on the “RTP” button to enable the Ray-Traced Preview mode, which provides the best view of the project without rendering a frame.
The rock object’s Surface shader is assigned the “Default shader 01”, which gives each instance of the rock a diffuse colour value of 0.5. You can see this by selecting the “Pop Rock 01/Rock 01” item in the object list and clicking on the green “Plus” button to the right of the Surface shader field and selecting “Go to Default shader 01”.
Tinting the population
Colour variation is applied to a population by assigning a shader, like a power fractal shader or an image shader, to the "Tint diffuse colour" input located on the Colour tab of the population. For demonstration purposes, we'll use a power fractal shader to provide a naturalistic looking noise texture throughout the rock population. To learn more about the power fractal shader click here.
- Select the “Pop Rock 01” item from the Object list.
- On the Colour tab click on the green “Plus” button to the right of the “Tint diffuse colour” field.
- Select “Create new shader” > “Colour shader” > “Power fractal shader v3”.
With the power fractal shader now assigned to the Tint diffuse colour, we’ll adjust the scale of the noise pattern to better fit the size of the rocks and population area, which will make it easier to see the effects of the tinting process, and rename the node to something more descriptive so that it's easier to find in the node lists.
- Click on the green “Plus” button to the right of the “Tint diffuse colour” field and select “Go to Power fractal shader v3 01”.
- Rename the Power fractal node to “Rock tints”.
- Click the “Open shader in new preview” button to the right of the Name field, which will conveniently display the power fractal pattern in its own floating window.
- On the Scale tab reduce the “Lead-in scale” value to "100.0".
We want to increase the contrast of the fractal noise pattern in order to make the colour variation more visible. We'll use the Colour contrast, offset and roughness parameters located on the Colour tab to do this. To learn more about these parameters click here.
- Set the “Colour contrast” value to “1.0”.
- Set the “Colour offset” value to around “-0.4”.
- Set the “Colour roughness” value to “0.0”.
As you can see in this rendered frame, the rocks are now shaded in a variety of gray values. Internally, Terragen multiplied the rocks diffuse color value by the value supplied by the tinting function. We’ll get into the math in a moment, but generally speaking, this has the effect of darkening each rock.
Let’s repeat this step once more but this time use colours other than black and white for the fractal noise pattern.
- Click on the “Apply high colour” colour swatch and choose a red colour with RGB values of “255,0,0” or linear values of “1.0,0.0,0.0”.
- Click on the checkbox to enable the “Apply low colour”, then give it a green colour with RGB values of “0,255,0” or linear values of “0.0,1.0,0.0”.
In the render below we can see that the tinting process has given the rocks new hues of reds, greens and yellows.
The math behind color tinting a population
Let’s review our progress so far to understand the math that is taking place internally in Terragen.
- The diffuse colour value of a particular spot on an object is made up of its three colour component values; one value for each of the red, green and blue components. The rock object’s diffuse colour value is 0.5 for each of its colour components.
- The power fractal shader assigned to the population’s “Tint diffuse colour” generates a tint colour for each instanced object. The generated colour will be somewhere between the “Apply high colour” and “Apply low colour” values, but if either of the High and Low colours are disabled then a value of 0.0, or black, is used for that colour. Each instanced object will get a different tint colour based on the position of the instanced object in 3D space in relationship to the noise patterns of the fractal. Terragen multiplies the object’s diffuse colour RGB values by the RGB values of the generated tint colour.
- Using the last image as an example, the rock object’s diffuse colour red component value was 0.5 and that was multiplied by a value between the High colour red component value which is 1.0 and the Low colour red component value which is 0.0. This means that the maximum red component value would be 0.5 and there’s a good chance it would be less. This is repeated for the other color components as well to determine the final colour value.
- There is one other consideration in determining the final colour value and that is the “Diffuse colour multiplier” value located on the Colour tab. The value in this field is multiplied by the diffuse colour in order to provide a way to adjust the overall colour value. For example, the rock object’s diffuse colour value of 0.5 would be multiplied by the Diffuse colour multiplier, which defaults to 1.0, so there would be no change, but if the Diffuse colour multiplier value was 2.0, then the rock object’s diffuse colour value would be 1.0, which would be twice the diffuse value as before.
In conclusion, the math behind the final tinting value looks something like this: Object’s diffuse colour component value * Diffuse colour multiplier * Tint diffuse colour component value = Resulting diffuse colour component value
A more real world example
In our examples so far, the object being tinted had a single diffuse colour value to start with, but most of the time we’ll be populating objects that use texture maps which contain many diffuse colour values. We can recreate this by assigning a new power fractal shader directly to the rock object’s texture, and scaling the noise pattern to appropriately fit the size of the rock which is about 1 meter.
- Select the “Pop Rock 01/Rock 01” item in the Object List.
- On the Surface Shader tab, click on the green “Plus” button to the right of the Surface shader field, and select “Go to Default shader 01”.
- Click on the green “Plus” button to the right of the “Colour function” field and select “Create new Shader” > “Colour Shader” > “Power fractal shader v3”.
- Click on the green “Plus” button again and select “Go to Power fractal shader v3”.
- When the dialog pane opens, rename the power fractal node “Rock Object Colours”.
- Click on the “Open shader preview in new window” button and click the "Zoom in" button until the 3D preview scale displays about 4 meters.
- On the Scale tab, change the “Feature scale” to “0.1” and the “Lead-in scale” to “1.0”.
- On the Colour tab, enable the “Apply low colour” checkbox and choose a some what dark, but not black, color of your choice. We used the linear values of “0.39,0.34,0.21”, or RGB values of “99,86,54”.
- Adjust the “Colour offset” slider until you see a good contrast between the “Apply high colour” and “Apply low colour” values in the 3D preview window.
Temporarily disable the population's tint function so we can see what the new rock texture looks like.
- Select the “Pop Rock 01” node in the Object list.
- On the Colour tab, uncheck the “Tint diffuse colour” checkbox.
In the rendered frame below, we see that every rock now has texture variation to begin with.
Here is the same rendered frame, but with the "Tint diffuse colour" checkbox enabled. Now the tinting function is taking into account the texture variations in each rock.
Keep in mind that generally speaking, applying a tint colour will darken the final colors of the instanced objects. If the objects become to dark, we can use the "Diffuse colour multiplier" and apply a value greater than 1.0 to help lighten them back up. In the rendered image below, we've set the “Diffuse colour multiplier” value to “2.0” so that we can see the new texture for the rocks with the tint applied and with twice the diffuse value.
Last of all, the “Diffuse colour multiplier” can be used to globally darken the instanced objects by entering a value less than 1.0. In this rendered frame, the "Diffuse colour mulitplier" value has been set to “0.5”, and we can see the new texture for the rocks with the tint applied but only half the diffuse value.
Any type of shader can be used as the source for tinting the population. Here is an example of using an image shader as the source for tinting the population. By setting the rock object’s diffuse value to “1.0” the instanced objects take on the colour values from the image texture map.
In conclusion, knowing how the tinting process works behind the scene gives us a lot of control for adjusting the final colors of our instances.
Download this project file to further explore tinting populations in Terragen. Media:Tutorial_WIki_TintingPopulations.zip
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.