Difference between revisions of "Shader Array"

From Terragen Documentation from Planetside Software
Jump to: navigation, search
(Shader Array)
m (Added Fun with Shader Arrays and content.)
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:IMPORT]]
+
[[File:ShaderArray_00_GUI.png|none|470px|Shader Array]]
='''Shader Array'''=
 
  
[[Image:drex_module_170_image_0.png|485pxpx|Shader Array]]
 
__NOTOC__
 
 
<!-- imported from file: module_170.html-->
 
<!-- imported from file: module_170.html-->
  
'''Node Description and Purpose'''<br />
+
==Overview==
The Shader array creates an array, or grid, of shaders. You might think of it like a populator for shaders, although it only 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 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 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.
Line 13: Line 10:
 
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.
 
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.
  
[[File:shader_array_schematic.png]]
+
[[File:shader_array_schematic.png|shader_array_schematic.png]]
  
 
Currently the Shader array is only applied in a straight-up-and-down Plan Y projection.
 
Currently the Shader array is only applied in a straight-up-and-down Plan Y projection.
  
<u>Performance note:</u> 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 covered a defined 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.
+
<u>Performance note:</u> 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|Simple shape shader]] or [[Image_Map_Shader|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.
<br /><br />
+
 
'''Node Type:''' Shader
 
 
<br /><br />
 
<br /><br />
 
'''Settings:'''
 
'''Settings:'''
 
<br />
 
<br />
 
* '''Position:''' This sets the position of the lower left corner of the Shader array.
 
* '''Position:''' This sets the position of the lower left corner of the Shader array.
 +
<ul>
 +
[[File:ShaderArray_02_Position.jpg|none|800px|Changing the X and Z axis values repositions the bottom left corner of the Shader array.]]
 +
</ul>
 +
 +
 
* '''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.
 
* '''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.
 +
<ul>
 +
[[File:ShaderArray_03_Rotation.jpg|none|800px|Changing the rotation value rotates the Shader array around its bottom left corner position.]]
 +
</ul>
 
<br />
 
<br />
 +
 
* '''Number of columns:''' This sets the number of columns in the array.
 
* '''Number of columns:''' This sets the number of columns in the array.
 +
<ul>
 +
[[File:ShaderArray_04_NumberColums.jpg|none|800px|Increasing the number of columns duplicates the shader.]]
 +
</ul>
 +
 +
 
* '''Column spacing:''' This setting controls distance between columns.
 
* '''Column spacing:''' This setting controls distance between columns.
 +
<ul>
 +
[[File:ShaderArray_11_ColumnRowSpacing.jpg|none|800px|Decreasing the Column and Row spacing values.]]
 +
</ul>
 +
 +
 
* '''Number of rows:''' This sets the number of rows in the array.
 
* '''Number of rows:''' This sets the number of rows in the array.
* '''Row spacing:''' This setting controls the distance between rows.
+
<ul>
 +
[[File:ShaderArray_05_NumberRows.jpg|none|800px|Increasing the number of rows duplicates the shader.]]
 +
</ul>
 +
 
 +
 
 +
* '''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.
 
* '''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.
 
** '''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.
 +
<ul>
 +
[[File:ShaderArray_13_BoundryPadding.jpg|none|800px|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.]]
 +
</ul>
 +
 
<br />
 
<br />
* '''Shader''': This is the shader used for the array.
+
* '''Shader''': The shader or function nodes assigned to this setting are used for the array.
 +
<ul>
 +
[[File:ShaderShape.PNG|none|400px|Simple shape shaders combined to use as the array shader.]]
 +
</ul>
 +
 
 +
 
 
* '''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.
 
* '''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.
+
<ul>
** '''Displacement amplitude:''' Set the amount of displacement.
+
* '''Displacement direction:''' This popup menu contains five options in which to choose the direction for displacement.
** '''Displacement offset:''' Set the starting offset of the displacement.
+
<ul>
 +
[[File:ShaderArray_01_DisplacementDirection.png|none|429px|Displacement direction options]]
 +
</ul>
 +
 
 +
<ul>
 +
{|
 +
|-
 +
| [[File:ShaderArray_14_DisplacmentDirection_AlongVertical.jpg|none|266px|Displacement direction = Along vertical]] || [[File:ShaderArray_15_DisplacmentDirection_AlongNormal.jpg|none|266px|Displacement direction = Along normal]] || [[File:ShaderArray_16_DisplacmentDirection_VerticalOnly.jpg|none|266px|Displacement direction = Vertical only]]
 +
|-
 +
| [[File:ShaderArray_17_DisplacmentDirection_LateralOnly.jpg|none|266px|Displacement direction = Lateral only]] || [[File:ShaderArray_18_DisplacmentDirection_LateralNormalized.jpg|none|266px|Displacement direction = Lateral normalized]] ||
 +
|}
 +
</ul>
 +
 
 +
 
 +
* '''Displacement amplitude:''' Set the amount of displacement.
 +
<ul>
 +
{|
 +
|-
 +
| [[File:ShaderArray_24_DisplacmentAmplitude10.jpg|none|266px|Displacement amplitude = 2]] || [[File:ShaderArray_25_DisplacmentAmplitude_0003.jpg|none|266px|Displacement amplitude = 10]] || [[File:ShaderArray_26_DisplacmentAmplitude25.jpg|none|266px|Displacement amplitude = 25]]
 +
|}
 +
</ul>
 +
 
 +
 
 +
* '''Displacement offset:''' Set the starting offset of the displacement.
 +
<ul>
 +
{|
 +
|-
 +
| [[File:ShaderArray_19_DisplacmentOffset_AlongVertical.jpg|none|266px|Displacement direction = Along vertical, Displacement offset = 10]] || [[File:ShaderArray_20_DisplacmentOffset_AlongNormal.jpg|none|266px|Displacement direction = Along normal, Displacement offset = 10]] || [[File:ShaderArray_21_DisplacmentOffset_VerticalOnly.jpg|none|266px|Displacement direction = Vertical only, Displacement offset = 10]]
 +
|-
 +
| [[File:ShaderArray_22_DisplacmentOffset_LateralOnly.jpg|none|266px|Displacement direction = Lateral only, Displacement offset = 10]] || [[File:ShaderArray_23_DisplacmentOffset_LateralNormalized.jpg|none|266px|Displacement direction = Lateral normalized, Displacement offset = 10]] ||
 +
|}
 +
</ul>
 +
 
 +
</ul>
 
<br />
 
<br />
* '''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 show 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 (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.
 +
<ul>
 +
{|
 +
|-
 +
| [[File:ShaderArray_27_PreviewAllInstancesOff.jpg|none|400px|Preview all instances = off]] || [[File:ShaderArray_28_PreviewAllInstancesOn.jpg|none|400px|Preview all instances = on]]
 +
|}
 +
</ul>
  
  
'''Example Files'''
 
  
This file shows an example of using a Shader array to create a grid of Simple shape shaders.<br />
+
== Fun with Shader Arrays ==
 +
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 [https://www.dropbox.com/s/1zoc5cbrndus92o/Terragen4_FunWithVectorDisplacement_Content01.zip?dl=0 here] to download the content files for the image below.
 +
 
 +
[[File: VDS_15_VDSCraterShaderArray.jpg |none|800px|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_Shader|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]]
 
[[Media:Shader_array_example.tgd]]
 +
[[image:Shader_array_example.jpg|none|320px|thumb]]
 +
 +
[[Category:Colour Shader]]
 +
[[Category:Displacement Shader]]

Latest revision as of 00:49, 11 December 2021

Shader Array


Overview[edit]

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.



Settings:

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

Media:Shader_array_example.tgd

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.