Difference between revisions of "Displacement Shader to Scalar"

From Terragen Documentation from Planetside Software
Jump to: navigation, search
m
(Updated descriptions and added example images.)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''Node Description and Purpose:'''<br />
+
<div style="float:right; border-style:solid; padding:20px"><categorytree mode=pages hideroot=off>Convert</categorytree></div>
The Displacement shader to scalar node extracts the displacement generated by the connected shader, and returns the dot product (inner product) of that displacement vector and the current normal. Effectively this is the amount of displacement in the direction of the current normal. It may be positive or negative.
 
  
 +
[[File:DisplacementShaderToScalar_00_GUI.png|none|470px|Displacement Shader to Scalar]]
  
'''Node Type:''' Function<br />
+
 
 +
__TOC__
 +
 
 +
 
 +
==Overview==
 +
The Displacement shader to scalar node extracts the displacement generated by the shader or function nodes assigned to its Main input, and returns the dot product (inner product) of that displacement vector and the current normal. Effectively this is the amount of displacement in the direction of the current normal. It may be positive or negative.
 +
 
 +
 
 +
In general, shaders may displace in any direction, so displacement is a vector. However, most of the time when you want to extract displacement for use in other functions you expect a scalar value. Most shaders displace along the normal, so by returning the dot product of the normal and the displacement vector, this node produces the displacement value you would typically expect.
  
  
'''Settings:'''<br />
 
 
This node has no other settings apart from the Input node.
 
This node has no other settings apart from the Input node.
 +
 +
 +
'''Settings:'''
 +
 +
*'''Name:''' This setting allows you to apply a descriptive name to the node, which can be helpful when using multiple Displacement shader to scalar nodes in a project.
 +
*'''Enable:''' When checked, the node is active and the conversion operation will take place. When unchecked the values assigned to its Main Input, if any, are passed through, otherwise a value of 0 is passed through.
 +
 +
 +
== Fun with Displacement Shader to Scalar ==
 +
A great use of the Displacement Shader to Scalar node is to create a mask that defines the foamy whitecaps atop a wave. 
 +
 +
 +
Start with the default project, but turn off the node that flattens the terrain around the camera so we can see the full extent of the procedural terrain.  Then add a body of water to the project.
 +
* In the Node network pane, select the Simple shape shader node and press the D key to disable it. <br /n>
 +
* Click on the Water layout button. <br /n>
 +
* Click the Add Water Object button and choose Lake. <br /n>
 +
 +
{|
 +
|-
 +
|[[File:DispShdr2Scalar_01_FunWith_NodeNetStep01.jpg|None|800px| Step 1: A Lake object added to the default project, and the Simple shape shader which masks the terrain disabled.]]
 +
|-
 +
| [[File:DispShdr2Scalar_02_RenderStep01.jpg|None|800px|Step 1: Render with Lake object added to the project, and Simple shape shader disabled.]]
 +
|}
 +
 +
 +
The Water shader node determines the look of the water, and creates waves by displacing the surface of the Lake object.  We can create foamy whitecaps by using the displacement data as a mask for a second shader, for example a  Surface layer shader, which has many features including the ability to add Child layers and masks.  The displacement data must be converted to scalar data via a “Displacement shader to scalar” node, and can then be assigned to the Mask shader input of the Surface layer shader.
 +
* Click in an empty space in the Node network pane to focus attention there, then press the TAB key to bring up the Quick Node Palette. <br /n>
 +
* Start typing the word “Displacement” and the list will automatically update as it tries to find the closest match.  You can use the up and down arrow keys to navigate through the list as well. <br /n>
 +
* With “Displacement shader to scalar” highlighted in blue, press the Enter key to add it to the project. <br /n>
 +
* Repeat the steps above to add a “Surface layer” node to the project as well. <br /n>
 +
* Connect the output of the Water shader node to the Surface layer’s Main input. <br /n>
 +
* Connect the output of the Water shader node to the Displacement shader to scalar node’s Main input. <br /n>
 +
* Connect the output of the Displacement shader to scalar node to the Surface layer’s Mask shader input. <br /n>
 +
 +
{| class="wikitable"
 +
|-
 +
| [[File:DispShdr2Scalar_03_FunWith_NodeNetStep02.jpg|none|800px|Step 2: Use a Displacement shader to scalar node to convert the displacement data to scalar data which can be used as a mask for another layer.]]
 +
|-
 +
| [[File:DispShdr2Scalar_04_RenderStep02.jpg|none|800px|Step 2: Render with the output from the Displacement shader to scalar node used as a mask for a Surface layer.]]
 +
|}
 +
 +
 +
The 3D Preview and the rendered image above show us where the whitecaps occur based on the mask.  While the Surface layer shader does not have the reflective properties that the Water shader does, it does allow us to assign another shader as a Child layer.  This means that the child shader is constrained by the same mask as applied to its parent Surface layer.  By adding a Default shader as a child layer we’ll gain access to reflective properties and other parameters.
 +
* Add a Default shader to the project. <br /n>
 +
* Connect the output of the Default shader to the Surface layer’s Child layers input. <br /n>
 +
* Double click the Default shader to open its window. <br /n>
 +
* Under the Specular tab you can adjust the Fresnel reflectivity, Index of refraction, and other settings as desired. <br /n>
 +
* Under the Colour tab you can adjust the Base colour values and add colour functions.  Add a Power fractal shader as a colour function by clicking on the green plus button to the right of the Colour function label, then Create new Shader, Colour shader, then Power fractal shader. <br /n>
 +
* Click the green plus button again and select Go to Power Fractal shader to open its window. <br /n>
 +
* Under the Colour tab, check the Apply high colour and Apply low colour checkboxes to enable them and assign some colour values.  These values will add some colour randomness and detail into the whitecaps. <br /n>
 +
{|
 +
|-
 +
| [[File:DispShdr2Scalar_05_FunWith_NodeNetStep03.jpg|None|800px| Step 3: The Suface layer node accepts other nodes as Child layers.  Here, a Default shader provides texture parameters such as reflectivity, that the Surface layer doesn’t have.]]
 +
|-
 +
| [[File:DispShdr2Scalar_06_RenderStep03.jpg|None|800px| Step 3: Render with the Default shader assigned to the Child layer of the Surface layer.]]
 +
|}
 +
 +
 +
You can adjust the output from the Displacement shader to scalar node even further, to fine tune where the whitecaps are located, by adding a Colour adjust shader immediately after it.  In this example, raising the Black point value will reduce the whitecaps, while decreasing the White point value will cause more of the whitecaps to become brighter.
 +
* Add a Colour adjust node to the project. <br /n>
 +
* Double click on the node to open its window and adjust the Black and White point values as desired.  <br /n>
 +
{|
 +
|-
 +
| [[File:DispShdr2Scalar_07_FunWith_NodeNetStep04.jpg|none|800px|Step 4: A Colour adjust shader can be used to fine tune the output of the Displacement shader to scalar node, effectively contracting or expanding the mask.]]
 +
|-
 +
| [[File:DispShdr2Scalar_08_RenderStep04.jpg|none|800px|Step 4: Render showing the effect of the Colour adjustment on the mask used to define where the whitecaps are located.]]
 +
|}
 +
 +
 +
<br /n>
  
  
 
[[Category:Convert]]
 
[[Category:Convert]]

Latest revision as of 20:35, 10 March 2022

Displacement Shader to Scalar



Overview[edit]

The Displacement shader to scalar node extracts the displacement generated by the shader or function nodes assigned to its Main input, and returns the dot product (inner product) of that displacement vector and the current normal. Effectively this is the amount of displacement in the direction of the current normal. It may be positive or negative.


In general, shaders may displace in any direction, so displacement is a vector. However, most of the time when you want to extract displacement for use in other functions you expect a scalar value. Most shaders displace along the normal, so by returning the dot product of the normal and the displacement vector, this node produces the displacement value you would typically expect.


This node has no other settings apart from the Input node.


Settings:

  • Name: This setting allows you to apply a descriptive name to the node, which can be helpful when using multiple Displacement shader to scalar nodes in a project.
  • Enable: When checked, the node is active and the conversion operation will take place. When unchecked the values assigned to its Main Input, if any, are passed through, otherwise a value of 0 is passed through.


Fun with Displacement Shader to Scalar[edit]

A great use of the Displacement Shader to Scalar node is to create a mask that defines the foamy whitecaps atop a wave.


Start with the default project, but turn off the node that flattens the terrain around the camera so we can see the full extent of the procedural terrain. Then add a body of water to the project.

  • In the Node network pane, select the Simple shape shader node and press the D key to disable it.
  • Click on the Water layout button.
  • Click the Add Water Object button and choose Lake.
Step 1: A Lake object added to the default project, and the Simple shape shader which masks the terrain disabled.
Step 1: Render with Lake object added to the project, and Simple shape shader disabled.


The Water shader node determines the look of the water, and creates waves by displacing the surface of the Lake object. We can create foamy whitecaps by using the displacement data as a mask for a second shader, for example a Surface layer shader, which has many features including the ability to add Child layers and masks. The displacement data must be converted to scalar data via a “Displacement shader to scalarnode, and can then be assigned to the Mask shader input of the Surface layer shader.

  • Click in an empty space in the Node network pane to focus attention there, then press the TAB key to bring up the Quick Node Palette.
  • Start typing the word “Displacement” and the list will automatically update as it tries to find the closest match. You can use the up and down arrow keys to navigate through the list as well.
  • With “Displacement shader to scalar” highlighted in blue, press the Enter key to add it to the project.
  • Repeat the steps above to add a “Surface layer” node to the project as well.
  • Connect the output of the Water shader node to the Surface layer’s Main input.
  • Connect the output of the Water shader node to the Displacement shader to scalar node’s Main input.
  • Connect the output of the Displacement shader to scalar node to the Surface layer’s Mask shader input.
Step 2: Use a Displacement shader to scalar node to convert the displacement data to scalar data which can be used as a mask for another layer.
Step 2: Render with the output from the Displacement shader to scalar node used as a mask for a Surface layer.


The 3D Preview and the rendered image above show us where the whitecaps occur based on the mask. While the Surface layer shader does not have the reflective properties that the Water shader does, it does allow us to assign another shader as a Child layer. This means that the child shader is constrained by the same mask as applied to its parent Surface layer. By adding a Default shader as a child layer we’ll gain access to reflective properties and other parameters.

  • Add a Default shader to the project.
  • Connect the output of the Default shader to the Surface layer’s Child layers input.
  • Double click the Default shader to open its window.
  • Under the Specular tab you can adjust the Fresnel reflectivity, Index of refraction, and other settings as desired.
  • Under the Colour tab you can adjust the Base colour values and add colour functions. Add a Power fractal shader as a colour function by clicking on the green plus button to the right of the Colour function label, then Create new Shader, Colour shader, then Power fractal shader.
  • Click the green plus button again and select Go to Power Fractal shader to open its window.
  • Under the Colour tab, check the Apply high colour and Apply low colour checkboxes to enable them and assign some colour values. These values will add some colour randomness and detail into the whitecaps.
Step 3: The Suface layer node accepts other nodes as Child layers.  Here, a Default shader provides texture parameters such as reflectivity, that the Surface layer doesn’t have.
Step 3: Render with the Default shader assigned to the Child layer of the Surface layer.


You can adjust the output from the Displacement shader to scalar node even further, to fine tune where the whitecaps are located, by adding a Colour adjust shader immediately after it. In this example, raising the Black point value will reduce the whitecaps, while decreasing the White point value will cause more of the whitecaps to become brighter.

  • Add a Colour adjust node to the project.
  • Double click on the node to open its window and adjust the Black and White point values as desired.
Step 4: A Colour adjust shader can be used to fine tune the output of the Displacement shader to scalar node, effectively contracting or expanding the mask.
Step 4: Render showing the effect of the Colour adjustment on the mask used to define where the whitecaps are located.



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 scalar is a single number. 1, 200.45, -45, -0.2 are all examples of scalar values.

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.

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