Difference between revisions of "Warp Input Shader"

From Terragen Documentation from Planetside Software
Jump to: navigation, search
(Added example images for Warp input shader, and conformed to new layout.)
Line 1: Line 1:
 +
[[File:WarpInput_00_GUI.png|none|470px |Warp Input Shader]]
  
The Warp Input Shader performs a domain distortion on any shaders which are upstream (via its main input connection), using the displacement vectors from the shader attached to its '''Warper''' input. It does this by offsetting the texture coordinates before they are used by the input shaders. This almost looks like the warper bends the final result, but it's actually bending the space before it is read by the shader. A simplistic way you can think about it is that the shapes from the warper will bend the final texture (but in the opposite direction).
 
  
The difference between the Warp Input Shader and the [[Warp Merge Shader]] is:
+
== Overview ==
 +
The Warp Input Shader and Warp Merge shader perform a domain distortion on any shaders which are upstream from its Main input connection using the displacement vectors from the shader attached to its Warper input.
 +
It does this by offsetting the texture coordinates before they are used by the input shaders. While this looks like the warper bends the final result, it's actually bending the space before it is read by the shader.
 +
A simplistic way to think about it is that the shapes from the warper will bend the final texture (but in the opposite direction)
 +
The difference between the Warp Input Shader and the Warp Merge Shader is:
 +
The Warp Input Shader warps the shader attached to the Main input and any shaders further upstream of the Main input.
 +
The Warp Merge Shader warps the shader attached to the Shader input and any shaders further upstream of that input (in other words a "side branch"). It merges the side branch with the main input, but only the side branch is warped.
 +
When the Warp Input Shader is asked to shade or displace a point, the following happens. First, the shader attached to Warper is called to produce a displacement vector. To produce the warp effect the warper must be a displacement shader or a network of shaders producing displacement. The displacement is not applied to the surface; its vector is merely stored for the next step. Next, the texture coordinates ("position in texture") are offset by the displacement vector, and the main input shaders are called. The main input shaders now produce different results because they work with modified texture coordinates. Finally, the texture coordinates are reset so that shaders following the Warp Input Shader will not be affected.
  
* The Warp Input Shader warps the shader attached to the main input ('''Input node''') and any shaders further upstream of the main input.
+
{|
* The [[Warp Merge Shader]] warps the shader attached to the '''Shader''' input and any shaders further upstream of that input (in other words a "side branch"). It merges the side branch with the main input, but only the side branch is warped.
+
|-
 +
| [[File:WarpInput_01_On.jpg|none|800px|The texture coordinates as seen from the render camera’s point of view, followed by the unwarped landscape, and then the result of warping via a Power fractal shader.  Note that the red and dark blue axis lines are not affected by the warp as they are located downstream from the Warp input node.
 +
]]
 +
|-
 +
| [[File:WarpInput_02_On.jpg|none|800px|A closer view of the texture coordinates being warped by a Power fractal shader assigned to the Warp input shader.  Note that the red and dark blue axis lines are not affected by the warp as they are located downstream from the Warp input node.
 +
]]
 +
|}
  
  
When the Warp Input Shader is asked to shade or displace a point, the following happens. First, the shader attached to '''Warper''' is called to produce a displacement vector. To produce the warp effect the warper must be a displacement shader or a network of shaders producing displacement. The displacement is not applied to the surface; its vector is merely stored for the next step. Next, the texture coordinates ("position in texture") are offset by the displacement vector, and the main input shaders are called. The main input shaders now produce different results because they work with modified texture coordinates. Finally, the texture coordinates are reset so that shaders following the Warp Input Shader will not be affected.
+
'''Tip 1:''' If you have a colour shader, colour function, scalar function or vector function that you want to use as your warper, you can turn it into displacement using a [[Displacement Shader]] or a [[Vector Displacement Shader]]. If you want to use a shader that already produces displacement, you can connect it directly.
 +
 
 +
 
 +
'''Tip 2:''' You may see the Warp Input Shader and the [[Redirect Shader]] used in the same context. The reason the Warp Input Shader and the [[Redirect Shader]] often work well together is because the [[Redirect Shader]] allows you to construct displacement vectors which go in all directions, which can be useful for warping a 3D function such as the Power Fractal. If you just use a single fractal operating along the normal as your warper, you might not easily see its warping effect.
  
  
'''Tip 1:''' If you have a colour shader, colour function, scalar function or vector function that you want to use as your warper, you can turn it into displacement using a [[Displacement Shader]] or a [[Vector Displacement Shader]]. If you want to use a shader that already produces displacement, you can connect it directly.
+
'''Settings:'''
  
 +
*'''Name:''' This setting allows you to apply a descriptive name to the node, which can be helpful when using multiple Warp Input shader nodes in a project.
  
'''Tip 2:''' You may see the Warp Input Shader and the [[Redirect Shader]] used in the same context. The reason the Warp Input Shader and the [[Redirect Shader]] often work well together is because the [[Redirect Shader]] allows you to construct displacement vectors which go in all directions, which can be useful for warping a 3D function such as the Power Fractal. If you just use a single fractal operating along the normal as your warper, you might not easily see its warping effect.
+
*'''Enable:''' When checked, the node is active and the settings below will affect the surface. When unchecked, the node is ignored.
  
 +
*'''Warper:''' The shader or function nodes assigned to this setting generate the displacement vectors used to warp or distort the texture space for all the nodes upstream from its position in the node network, downstream nodes are unaffected. 
 +
<ul>
 +
[[File:WarpInput_03_VariousInputs.jpg|none|800px|Various shaders assigned as the Warper to illustrate the many ways in which the texture coordinates can be manipulated.  Note that the red and dark blue axis lines are not affected by the warp as they are located downstream from the Warp input node.]]
 +
</ul>
  
===Exceptions===
 
  
 +
== Exceptions==
 
Some shaders are not always affected by warp shaders, depending on their settings:
 
Some shaders are not always affected by warp shaders, depending on their settings:
  
Line 37: Line 58:
 
* Twist and Shear Shader - uses world space
 
* Twist and Shear Shader - uses world space
 
* Visualise Normal - normals are not changed by warp shaders
 
* Visualise Normal - normals are not changed by warp shaders
 
 
===Settings===
 
<ul>
 
<li>
 
'''Warper:''' The shader attached to this input generates displacement vectors that define the warp or distortion which affects the main input.
 
</li>
 
</ul>
 
  
  

Revision as of 02:55, 3 August 2021

Warp Input Shader


Overview[edit]

The Warp Input Shader and Warp Merge shader perform a domain distortion on any shaders which are upstream from its Main input connection using the displacement vectors from the shader attached to its Warper input. It does this by offsetting the texture coordinates before they are used by the input shaders. While this looks like the warper bends the final result, it's actually bending the space before it is read by the shader. A simplistic way to think about it is that the shapes from the warper will bend the final texture (but in the opposite direction) The difference between the Warp Input Shader and the Warp Merge Shader is: The Warp Input Shader warps the shader attached to the Main input and any shaders further upstream of the Main input. The Warp Merge Shader warps the shader attached to the Shader input and any shaders further upstream of that input (in other words a "side branch"). It merges the side branch with the main input, but only the side branch is warped. When the Warp Input Shader is asked to shade or displace a point, the following happens. First, the shader attached to Warper is called to produce a displacement vector. To produce the warp effect the warper must be a displacement shader or a network of shaders producing displacement. The displacement is not applied to the surface; its vector is merely stored for the next step. Next, the texture coordinates ("position in texture") are offset by the displacement vector, and the main input shaders are called. The main input shaders now produce different results because they work with modified texture coordinates. Finally, the texture coordinates are reset so that shaders following the Warp Input Shader will not be affected.

The texture coordinates as seen from the render camera’s point of view, followed by the unwarped landscape, and then the result of warping via a Power fractal shader.   Note that the red and dark blue axis lines are not affected by the warp as they are located downstream from the Warp input node.
A closer view of the texture coordinates being warped by a Power fractal shader assigned to the Warp input shader.   Note that the red and dark blue axis lines are not affected by the warp as they are located downstream from the Warp input node.


Tip 1: If you have a colour shader, colour function, scalar function or vector function that you want to use as your warper, you can turn it into displacement using a Displacement Shader or a Vector Displacement Shader. If you want to use a shader that already produces displacement, you can connect it directly.


Tip 2: You may see the Warp Input Shader and the Redirect Shader used in the same context. The reason the Warp Input Shader and the Redirect Shader often work well together is because the Redirect Shader allows you to construct displacement vectors which go in all directions, which can be useful for warping a 3D function such as the Power Fractal. If you just use a single fractal operating along the normal as your warper, you might not easily see its warping effect.


Settings:

  • Name: This setting allows you to apply a descriptive name to the node, which can be helpful when using multiple Warp Input shader nodes in a project.
  • Enable: When checked, the node is active and the settings below will affect the surface. When unchecked, the node is ignored.
  • Warper: The shader or function nodes assigned to this setting generate the displacement vectors used to warp or distort the texture space for all the nodes upstream from its position in the node network, downstream nodes are unaffected.
    Various shaders assigned as the Warper to illustrate the many ways in which the texture coordinates can be manipulated.  Note that the red and dark blue axis lines are not affected by the warp as they are located downstream from the Warp input node.


Exceptions[edit]

Some shaders are not always affected by warp shaders, depending on their settings:

  • Distribution Shader v4. If the Altitude Key is set to "Final position" then it uses world space instead of texture space, so warp shaders have no effect, although its mask may be warped.
  • Geog Image Map Shader. If georeferencing is enabled it uses world space instead of texture space, so warp shaders have no effect, although its mask may be warped.

Some shaders are not affected by warp shaders, although their masks may be:

  • Any displacements following a 'Compute Terrain' node or 'Tex Coords from XYZ' node - these nodes reset the texture coordinates for downstream displacements
  • Cloud layers (Cloud Layer v2/v3 and Easy Cloud) - these are world space volumetric objects, but warps can be applied separately to their inputs
  • Constant Shader - produces the same output everywhere
  • Distance Shader - uses world space
  • Heightfield Shader - uses world space, although its mask may be warped
  • Lambert Shader - uses the same albedo everywhere
  • MOLA Map Shader - uses undisplaced normal to infer position on the planet, although its mask may be warped
  • Planet Atmosphere - this is a world space volumetric object, but warps can be applied separately to its inputs
  • Shadow Catcher Shader - is only affected by lighting
  • Twist and Shear Shader - uses world space
  • Visualise Normal - normals are not changed by warp shaders


See also: Warp Merge Shader

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.

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.

A scalar is a single number. 1, 200.45, -45, -0.2 are all examples of scalar values.

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.