Difference between revisions of "Population Colour Tinting Techniques"

From Terragen Documentation from Planetside Software
Jump to: navigation, search
(Incorporating suggestions made by OG on 10/10/19. This version is still a work in progress.)
Line 1: Line 1:
 
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.   
 
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, then click on the “Add Object” button and select “Population” from the drop down menu and finally select “Rock” from the population types list.
 
Let’s explore this in an empty scene by creating a population of rocks. Click on the “Objects” button beneath the Main Menu, then click on the “Add Object” button and select “Population” from the drop down menu and finally select “Rock” from the population types list.
  
[[File:Tutorial_Generic_AddRockPopulationCropped.png|Adding a rock population.|800px]]
+
[[File:Tutorial_Generic_AddRockPopulationCropped.png|Adding a rock population.|530px]]
  
  
 
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.   
 
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.   
  
[[File:Tutorial_Generic_RockPopulationAndObjectNodes.png|The rock population node and the 3D geometry node in the Object List.|800px]]
+
[[File:Tutorial_Generic_RockPopulationAndObjectNodes.png|The rock population node and the 3D geometry node in the Object List.|530px]]
  
  
Let’s create an evenly spaced and orderly array of rock objects in order see the tinting effects most clearly.   
+
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, and in order to minimize the number of rocks needed to fill up the entire population area, we'll scale the rocks a bit larger.
  
Select the “Pop Rock 01” item from the Object List and under the Distribution tab reduce the size of the area to be populated by entering a value of “100.0” in the “Area length a” and the “Area length b” fields.  Set the “Object spacing in a,b” value to “5.0” and the “Spacing variation in a,b” value to “0.0”.   
+
* Select the “Pop Rock 01” item from the Object List and under the Distribution tab reduce the size of the area to be populated by entering a value of “100.0” in the “Area length a” and the “Area length b” fields.   
 +
* 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 both the “Minimum scale” value and “Maximum scale” value to “4.0”.   
  
Under the Rotation tab set the “Maximum Y rotation” value to “0.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 in your project, [https://www.youtube.com/watch?v=yQYUpyvW7yw click here].   
  
Under the Scale tab set both the “Minimum scale” value and “Maximum scale” value to “4.0”. 
+
Click on the “RTP” button to view the scene in Ray-Traced Preview mode.
 
 
Click the “Populate Now” button, and then pull back your camera view until you get a good view of the rocks.  Click on the “RTP” button to view the scene in Ray-Traced Preview mode.
 
  
 
[[File:Tutorial_TintingPopulations_03PopRockDistribution.png|An evenly spaced rock poplulation, 100 meters x 100 meters.|800px]]
 
[[File:Tutorial_TintingPopulations_03PopRockDistribution.png|An evenly spaced rock poplulation, 100 meters x 100 meters.|800px]]
Line 29: Line 32:
  
  
To apply colour variation to the rock population, return to the Objects layout and select the “Pop Rock 01” item from the Object list. Under the Colour tab click on the green “Plus” button to the right of the “Tint diffuse colour” field and select “Create new shader”, then “Colour shader” and finally “Power fractal shader v3”.
+
===== Tinting the population =====
 +
Colour variation is applied to a population by assigning a shader to the "Tint diffuse colour" input located on the Colour tab of the population.
 +
* 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”.
  
 
[[File:Tutorial_TintingPopulations_09ColourTabTint.png|Applying a power fractal shader to the Tint diffuse colour parameter.|800px]]
 
[[File:Tutorial_TintingPopulations_09ColourTabTint.png|Applying a power fractal shader to the Tint diffuse colour parameter.|800px]]
Line 39: Line 46:
  
  
We want to increase the contrast of the fractal noise pattern.  Under the Colour tab set the “Colour contrast” value to “1.0”, the “Colour offset” value to around “-0.4” and the “Colour roughness” value to “0.0”.
+
We want to increase the contrast of the fractal noise pattern in order to make the colour variation more visible.  Under the Colour tab set the “Colour contrast” value to “1.0”, the “Colour offset” value to around “-0.4” and 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.
 
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.
Line 52: Line 59:
 
[[File:Tutorial_TintingPopulations_13RockTintsColourTabColours.png|Applying colour values to the power fractal shader's high and low colour parameters.|800px]]
 
[[File:Tutorial_TintingPopulations_13RockTintsColourTabColours.png|Applying colour values to the power fractal shader's high and low colour parameters.|800px]]
  
 
+
===== 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.
 
Let’s review our progress so far to understand the math that is taking place internally in Terragen.
  
Line 65: Line 72:
 
In conclusion, the math behind the final tinting value looks something like this:
 
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
 
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 examine this more closely by modifying the rock object’s texture.
 
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 examine this more closely by modifying the rock object’s texture.
Line 92: Line 101:
 
[[File:Tutorial_TintingPopulations_16RockPopTintColour.png|Tint settings applied to rock population.  Rock has been surfaced with a power fractal shader.|800px]]
 
[[File:Tutorial_TintingPopulations_16RockPopTintColour.png|Tint settings applied to rock population.  Rock has been surfaced with a power fractal shader.|800px]]
  
 +
Keep in mind that generally speaking, applying a tint colour will darken the final colors of the object instances, but by applying a value greater than 1.0 to the “Diffuse colour multiplier” can help lighten them back up.
 +
Now set the “Diffuse colour multiplier” value to “2.0”.  Here is a rendered frame so we can see the new texture for the rocks with the tint applied and with twice the diffuse value.
  
Now set the “Diffuse colour multiplier” value to “2.0”. Here is a rendered frame so we can see the new texture for the rocks, twice as diffuse, with the tint applied.
+
[[File:Tutorial_Wiki_TintingPopulations_wip2_v001.0006.png|Rendered image of rock population with the diffuse colour multiplier enabled.|800px]]
  
[[File:Tutorial_Wiki_TintingPopulations_wip2_v001.0006.png|Rendered image of rock population with the diffuse colour multiplier enaabled.|800px]]
 
  
 +
[[File:Tutorial_TintingPopulations_17RockPopTintColourMultiplier.png|Tint settings and diffuse colour multiplier enabled.|800px]]
  
[[File:Tutorial_TintingPopulations_17RockPopTintColourMultiplier.png|Tint settings and diffuse colour mulitplier enabled.|800px]]
 
  
 
+
Last of all, set the “Diffuse colour multiplier” value to “0.5” and this is the rendered frame so we can see the new texture for the rocks with the tint applied but only half the diffuse value.
Last of all, set the “Diffuse colour multiplier” value to “0.5” and this is the rendered frame so we can see the new texture for the rocks, half as diffuse, with the tint applied.
 
  
 
[[File:Tutorial_Wiki_TintingPopulations_wip2_v001.0007.png|Tint settings and diffuse colour multiplier applied to rock populations.  Rock has been surfaced with a power fractal.|800px]]
 
[[File:Tutorial_Wiki_TintingPopulations_wip2_v001.0007.png|Tint settings and diffuse colour multiplier applied to rock populations.  Rock has been surfaced with a power fractal.|800px]]
Line 111: Line 120:
  
  
Knowing how the tinting process works behind the scene gives us a lot of control for adjusting the final colors of our instances.    Keep in mind that generally speaking, applying a tint colour will darken final colors of the object instances, and that by applying a value greater than 1.0 to the “Diffuse colour multiplier” can help lighten them back up.
+
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.   
 
Download this project file to further explore tinting populations in Terragen.   
 
[[:Media:Tutorial_WIki_TintingPopulations.zip]]
 
[[:Media:Tutorial_WIki_TintingPopulations.zip]]

Revision as of 04:33, 15 October 2019

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[edit]

Let’s explore this in an empty scene by creating a population of rocks. Click on the “Objects” button beneath the Main Menu, then click on the “Add Object” button and select “Population” from the drop down menu and finally select “Rock” from the population types list.

Adding a rock population.


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.

The rock population node and the 3D geometry node in the Object List.


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, and in order to minimize the number of rocks needed to fill up the entire population area, we'll scale the rocks a bit larger.

  • Select the “Pop Rock 01” item from the Object List and under the Distribution tab reduce the size of the area to be populated by entering a value of “100.0” in the “Area length a” and the “Area length b” fields.
  • 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 both the “Minimum scale” value and “Maximum scale” value 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 in your project, click here.

Click on the “RTP” button to view the scene in Ray-Traced Preview mode.

An evenly spaced rock poplulation, 100 meters x 100 meters.


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”.

The rock object's surface shader.  The Diffuse colour is set to 0.5.


Tinting the population[edit]

Colour variation is applied to a population by assigning a shader to the "Tint diffuse colour" input located on the Colour tab of the population.

  • 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”.

Applying a power fractal shader to the Tint diffuse colour parameter.


Open the Power fractal shader by once again clicking on the green “Plus” sign to the right of the “Tint diffuse colour” field and selecting “Go to Power fractal shader v3 01”. Rename the Power fractal node to something descriptive like “Rock tints”. Click on the “Open shader in new preview” button to the right of the Name field to display the power fractal pattern in its own window. Under the Scale tab reduce the “Lead-in scale” value to 100, to better match the scale of the area being populated with rocks.

The power fractal shader's interface and preview window.


We want to increase the contrast of the fractal noise pattern in order to make the colour variation more visible. Under the Colour tab set the “Colour contrast” value to “1.0”, the “Colour offset” value to around “-0.4” and 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.

Adjusting the colour paramaters of the power fractal shader.


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”. Enable the “Apply low colour” by clicking on the checkbox and then click on its color swatch and choose a green colour with RGB values of “0,255,0” or linear values of “0.0,1.0,0.0”.

Now we see that the rocks have taken on the hues of reds and greens and yellows

Applying colour values to the power fractal shader's high and low colour parameters.

The math behind color tinting a population[edit]

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[edit]

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 examine this more closely by modifying the rock object’s texture.

Select the “Pop Rock 01/Rock 01” item in the Object List and under 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”, then “Colour Shader”, and then “Power fractal shader v3”.

Click on the same green “Plus” button and this time select “Go to Power fractal shader v3”, and when the dialog pane opens, give the Power fractal shader a descriptive name like “Rock Object Colours”. Open the Power fractal shader node’s 3D preview by clicking on the “Open shader preview in new window” button and zoom in until the 3D preview scale is about 4 meters.

On the Scale tab change the “Feature scale” to “0.1” and the “Lead-in scale” to “1.0” because the scale of the rock object is about 1 meter.

On the Colour tab enable the “Apply low colour” checkbox and click on the “Color swatch” to the right of the parameter field. In the Colour picker pane select a colour around the linear values of “0.39,0.34,0.21”, or RGB values of “99,86,54”.

Finally, adjust the “Colour offset” until there is a good contrast between the “Apply high colour” and “Apply low colour” values in the noise pattern.

Select the “Pop Rock 01” node from the Object list and temporarily disable the “Tint diffuse colour” by unchecking the checkbox to the left of the field. Here is a rendered frame so we can see the new texture for the rocks.

Rendered image of rock population.  Rock object has been surfaced with a power fractal shader.


Enable the “Tint diffuse colour” by checking the checkbox to the left of the field. Here is a rendered frame so we can see the new texture for the rocks and the tint applied.

Rendered image of the rock population with the tint applied.


Tint settings applied to rock population.  Rock has been surfaced with a power fractal shader.

Keep in mind that generally speaking, applying a tint colour will darken the final colors of the object instances, but by applying a value greater than 1.0 to the “Diffuse colour multiplier” can help lighten them back up. Now set the “Diffuse colour multiplier” value to “2.0”. Here is a rendered frame so we can see the new texture for the rocks with the tint applied and with twice the diffuse value.

Rendered image of rock population with the diffuse colour multiplier enabled.


Tint settings and diffuse colour multiplier enabled.


Last of all, set the “Diffuse colour multiplier” value to “0.5” and this is the rendered frame so we can see the new texture for the rocks with the tint applied but only half the diffuse value.

Tint settings and diffuse colour multiplier applied to rock populations.  Rock has been surfaced with a power fractal.


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.

Using an image texture map shader the Tint diffuse colour.


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.

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.