Unity Products:Amplify Shader Editor/If Community and Unity Products:Amplify Shader Editor/Matrix4X4: Difference between pages

From Amplify Creations Wiki
(Difference between pages)
Jump to navigation Jump to search
m (1 revision imported)
 
ampwiki>Amplify RnD Rick
No edit summary
 
Line 1: Line 1:
[[Unity_Products:Amplify_Shader_Editor/Nodes | Back to Node List]]
== Matrix4X4 Node ==


== If [Community] Node ==
The Matrix4x4 node generates a 4x4 Matrix variable containing a total of 16 float components. Matrix variables cannot be set as shader properties so, unlike other property nodes like [[Unity_Products:Amplify_Shader_Editor/Float|Float]] or [[Unity_Products:Amplify_Shader_Editor/Vector4|Vector4]], their [[#paramtype|Type]] can only be set as Constant or Global.
These type of data structures are commonly used on different situations like transforming data between different coordinate spaces, per example transforming a position from local to world space, rotating vector position or directions among others.


The If [Community] node compares two float inputs [[#paramA|A]] and [[#paramB|B]] and outputs a value from on one of its inputs [[#paramA>B|A > B]] , [[#paramA==B|A == B]] or [[#paramA<B|A < B]] according to the comparison result.  
<br/>'''NOTE:''' Most of the more commonly used transform matrices already have specific nodes like p.e. [[Unity_Products:Amplify_Shader_Editor/Object_To_World|Object To World ]] or [[Unity_Products:Amplify_Shader_Editor/World_To_Object|World To Object]].


<img class="responsive-img" src="http://wiki.amplify.pt/images/Nodes/IfCommunity.jpg">


{| class="wikitable" style="width: 100%;"
{| class="wikitable" style="width: 100%;"
|-
|-
! style="width: 10%;" | Node Parameter !! Description !! style="width: 10%;" | Default Value
! style="width: 10%;" | Node Parameter !! Description !! style="width: 10%;" | Default Value
|-
| id="paramtype" | Type
| A set of ways the value behaves in different situations.
* '''Constant:''' the value is assigned directly in shader code and can't be dynamically changed.
* '''Global:''' the value can only be set by script and this defines a static variable that is shared between all shaders that use it. It's useful to change a value globally.
* '''Instanced:''' the value can only be set by script and this defines the shader as an instanced shader. ( see more here: [https://docs.unity3d.com/Manual/GPUInstancing.html GPU Instancing] )
* '''CBuffer:''' the variable is set inside '''UnityPerMaterial''' constant buffer. Only available over SRP(HDRP/URP) shader types.
| Constant
|-
| id="paramname" | Name
| Name to used on generating the shader [[#parampname|Global Variable]] name if its type is set to [[#paramtype|Global]]. Otherwise it is ignored but still useful for organization purposes
| Matrix #
|-
|- style="background: #e5e5e5;" |
|- style="background: #e5e5e5;" |
| id="paramA" | A
| id="paramVariable Mode" | Variable Mode
| First value of the comparison operation. Only visible if the respective input port is not connected.
| Defines if the current global variable is to be created on the current shader.
| 0
* '''Create:''' Global variable is created in the shader
* '''Fetch:''' Does not register variable, useful when p.e. there's need to using global variables declared over a included cginc
| Create
|-
|- style="background: #e5e5e5;" |
|- style="background: #e5e5e5;" |
| id="paramB" | B
| id="paramAutoRegister Mode" | Auto-Register
| Second value of the comparison operation. Only visible if the respective input port is not connected.
| If toggled on, creates the property and/or global variable even if not connected to an Output node
| 0
| Off
|- style="background: #e5e5e5;" |
|-
|id="paramA>B" | A > B
| Value to be outputted if value of A is greater than value of B. Only visible if the respective input port is not connected.
| 0
|- style="background: #e5e5e5;" |
|- style="background: #e5e5e5;" |
|id="paramA==B" | A == B
| id="paramprecision" | Precision
| Value to be outputted if value of A is equal to value of B. Only visible if the respective input port is not connected.
| Defines the amount of bytes the variable can hold, effectively defining how precise the value is. It's usefulness is bond by the hardware specifications necessary. Lowest precision is slightly faster but might produce errors and artifacts.
| 0
* '''Float:''' Highest precision, useful for values that can be very high or very low in value (ie: positions, coordinates, etc)
|- style="background: #e5e5e5;" |
* '''Half:''' Medium precision, in most cases is as good as '''Float''' but at half of it's precision
|id="paramA<B" | A < B
| Value to be outputted if value of A is less than value of B. Only visible if the respective input port is not connected.
| 0
|- style="background: #e5e5e5;" |
| id="paramEqualThreshold" | Equal Threshold
| Value used on the equality test to define a comparison threshold and prevent precision errors. Only visible if the respective input port is not connected.
| 0
|}
 
{| class="wikitable" style="width: 100%;"
|-
! style="width: 10%;" | Input Port !! Description !! style="width: 10%;" | Type
|-
| A
| First value of the comparison operation.
| Float
|-
| B
| Second value of the comparison operation.
| Float
| Float
|-
|-
| A > B
| Default Value || This is the value the shader currently holds. It's also the default value that is used when a new material is created with this shader.  
| Value to be outputted if value of A is greater than value of B.
| 0
| Float <sup id="ref1">[[#anchor|[1]]]</sup>
|-
| A == B
| Value to be outputted if value of A is equal to value of B.
| Float <sup id="ref1">[[#anchor|[1]]]</sup>
|-
| A < B
| Value to be outputted if value of A is less than value of B.
| Float <sup id="ref1">[[#anchor|[1]]]</sup>
|-
| Equal Threshold
| Value used on the equality test to define a comparison threshold and prevent precision errors.
| Float <sup id="ref1">[[#anchor|[1]]]</sup>
|}
|}


----
# <span id="anchor1">'''[[#ref1|^]]'''</span> Port automatically adapts to all connection types except [[Unity Products:Amplify Shader Editor/Texture Object|Sampler]] types.


[[Unity_Products:Amplify_Shader_Editor/Nodes | Back to Node List]]
[[Unity_Products:Amplify_Shader_Editor/Nodes | Back to Node List]]
[[Category:Nodes]][[Category:Logical Operators]]
[[Category:Nodes]][[Category:Constants And Properties]]

Revision as of 16:41, 23 August 2021

Matrix4X4 Node

The Matrix4x4 node generates a 4x4 Matrix variable containing a total of 16 float components. Matrix variables cannot be set as shader properties so, unlike other property nodes like Float or Vector4, their Type can only be set as Constant or Global. These type of data structures are commonly used on different situations like transforming data between different coordinate spaces, per example transforming a position from local to world space, rotating vector position or directions among others.


NOTE: Most of the more commonly used transform matrices already have specific nodes like p.e. Object To World or World To Object.


Node Parameter Description Default Value
Type A set of ways the value behaves in different situations.
  • Constant: the value is assigned directly in shader code and can't be dynamically changed.
  • Global: the value can only be set by script and this defines a static variable that is shared between all shaders that use it. It's useful to change a value globally.
  • Instanced: the value can only be set by script and this defines the shader as an instanced shader. ( see more here: GPU Instancing )
  • CBuffer: the variable is set inside UnityPerMaterial constant buffer. Only available over SRP(HDRP/URP) shader types.
Constant
Name Name to used on generating the shader Global Variable name if its type is set to Global. Otherwise it is ignored but still useful for organization purposes Matrix #
Variable Mode Defines if the current global variable is to be created on the current shader.
  • Create: Global variable is created in the shader
  • Fetch: Does not register variable, useful when p.e. there's need to using global variables declared over a included cginc
Create
Auto-Register If toggled on, creates the property and/or global variable even if not connected to an Output node Off
Precision Defines the amount of bytes the variable can hold, effectively defining how precise the value is. It's usefulness is bond by the hardware specifications necessary. Lowest precision is slightly faster but might produce errors and artifacts.
  • Float: Highest precision, useful for values that can be very high or very low in value (ie: positions, coordinates, etc)
  • Half: Medium precision, in most cases is as good as Float but at half of it's precision
Float
Default Value This is the value the shader currently holds. It's also the default value that is used when a new material is created with this shader. 0


Back to Node List