Shader Array

From Planetside Software Wiki
Jump to: navigation, search
Shader Array


Node Description and Purpose
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.

Shader array schematic.png

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.

Example Files

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.

Media:Shader_array_example.tgd

Shader array example.jpg



Node Type: Shader

Settings:

  • Position: This sets the position of the lower 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.


  • Number of columns: This sets the number of columns in the array.
  • Column spacing: This setting controls distance between columns.
  • Number of rows: This sets the number of rows in the array.
  • Row spacing: This setting controls the distance between rows.
  • 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.


  • Shader: This is the shader used for the array.
  • 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: Choose the direction for displacement.
    • Displacement amplitude: Set the amount of displacement.
    • Displacement offset: Set the starting offset of the displacement.


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

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.