Shader Array

From Terragen Documentation from Planetside Software
Jump to: navigation, search
Shader Array


The Shader array creates an array, or grid, of shaders. You might think of it like a populator for shaders, although it works on a regularly spaced grid rather than random locations like a populator does. The Shader array takes a single shader and reproduces it multiple times in different locations.

The Shader array shows quite a lot of information in the 3D Preview. It draws an orange dot at the location of each shader instance in the array. It draws a box around the area of the array. If you choose to limit the effect area (see the Settings section for more information) then it draws a dashed outline showing the the extents of the array plus the "Boundary padding". By default the Shader array displays the shader instances at each corner of the array. You can choose to preview all of the shader instances but this can make the 3D Preview slow and difficult to interact with.

The image below illustrates what rows and columns mean, as well as the overall layout of the shader array. This array has 3 rows and 3 columns. The shaders are represented by the orange dots.


Currently the Shader array is only applied in a straight-up-and-down Plan Y projection.

Performance note: The Shader array can be slow, particularly with a large number of rows and columns. A 10 x 10 array will have 100 items in it. A 100 x 100 array will have 10,000 items. That's a lot of shader calculations. The most efficient shaders to use are ones which cover a limited area like the Simple shape shader or Image map shader. To improve performance you can also use the Limit effect area and Boundary padding settings to restrict the area covered by the Shader array.


  • Position: This sets the position of the lower left corner of the Shader array.
    Changing the X and Z axis values repositions the bottom left corner of the Shader array.

  • Rotation: This param sets the rotation of the array around the lower left corner. You can only rotate the array around the Y (upright) axis.
    Changing the rotation value rotates the Shader array around its bottom left corner position.

  • Number of columns: This sets the number of columns in the array.
    Increasing the number of columns duplicates the shader.

  • Column spacing: This setting controls distance between columns.
    Decreasing the Column and Row spacing values.

  • Number of rows: This sets the number of rows in the array.
    Increasing the number of rows duplicates the shader.

  • Row spacing: This setting controls the distance between rows. (See example image under Column spacing.)

  • Limit effect area: If this setting is checked then the effects of the shaders are not applied outside the the area enclosed by the array. You can use the Boundary padding settings to expand this area.
    • Boundary padding: This setting expands the area around the boundary of the array when Limit effect area is turned on. This could be useful if the shaders in the array are being clipped undesirably, as in the image below. It basically pads the array out on all sides.
    When the Limit effect area is checked, you can adjust the Boundary padding value so that shaders that extend beyond the array dimensions are not cut off.

  • Shader: The shader or function nodes assigned to this setting are used for the array.
    Simple shape shaders combined to use as the array shader.

  • Use shader colour for displacement: If this is checked then the shader array will use the colour from the attached shader to generate displacement, rather than using the displacement information from the shader. This is especially useful when the attached shader doesn't actually handle displacement.
    • Displacement direction: This popup menu contains five options in which to choose the direction for displacement.
      Displacement direction options
      Displacement direction = Along vertical
      Displacement direction = Along normal
      Displacement direction = Vertical only
      Displacement direction = Lateral only
      Displacement direction = Lateral normalized

    • Displacement amplitude: Set the amount of displacement.
      Displacement amplitude = 2
      Displacement amplitude = 10
      Displacement amplitude = 25

    • Displacement offset: Set the starting offset of the displacement.
      Displacement direction = Along vertical, Displacement offset = 10
      Displacement direction = Along normal, Displacement offset = 10
      Displacement direction = Vertical only, Displacement offset = 10
      Displacement direction = Lateral only, Displacement offset = 10
      Displacement direction = Lateral normalized, Displacement offset = 10

  • Preview all instances (slow): The default behaviour of the Shader array is to only preview shader instances at the corners of the grid, which means 4 instances are shown at most. If this is checked then the shader array will show all shader instances in the grid in the 3D Preview. This can be slow, especially with a large number of rows and columns.
    Preview all instances = off
    Preview all instances = on

Fun with Shader Arrays[edit]

In the image below, we created a Terragen project with a single crater shader and assigned a Fake stones shader to its Rim shader input for detail. We rendered several vector displacement EXR images of the crater, each time slightly adjusting the crater settings to generate a unique crater. We combined these vector displacement images in Zbrush to create a new vector displacement image with lots of craters. Note, Terragen could also be used to combine the individual EXR files, but it's easier to “paint” these features in Zbrush. Back in Terragen, the new vector displacement image with lots of craters was assigned to a Shader array and duplicated across the terrain.

Click here to download the content files for the image below.

A vector displacement image of lots of craters duplicated across the terrain with a Shader array.

This project file shows an example of using a Shader array to create a grid of Simple shape shaders. You might need to right click and choose "Save as" (Windows) or option-click (Mac) on the project file link to download it directly and prevent it opening in your browser.


Shader array example.jpg

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.

Literally, to change the position of something. In graphics terminology to displace a surface is to modify its geometric (3D) structure using reference data of some kind. For example, a grayscale image might be taken as input, with black areas indicating no displacement of the surface, and white indicating maximum displacement. In Terragen 2 displacement is used to create all terrain by taking heightfield or procedural data as input and using it to displace the normally flat sphere of the planet.

A vector is a set of three scalars, normally representing X, Y and Z coordinates. It also commonly represents rotation, where the values are pitch, heading and bank.