Unity Products:Amplify Shader Editor/Vector4 and Unity Products:Amplify Shader Editor/Vertex Position: Difference between pages

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


The Vector4 node ''( shortcut: numeric 4 key )'' generates a float4 value containing four float components. This value is usually useful to either define a [[#paramtype|Constant]] value which is directly used in shader calculations or to define an exposed [[#paramtype|Property]] value that can be modified by the material inspector that uses it.
The Vertex Position node outputs the vertices position in object space. This data is extracted directly from the mesh and contains the vertex position relative to the object origin, this means the position values don't change whatever transform value your gameobject has. This is usually useful to use in the '''Local Vertex Offset''' output or to create effects that are bound to the object and stay exactly the same even if your gameobject changes position, rotation or size.
<br/>Depending on where this node is being used ( vertex or fragment/surface function ) it will either return a direct value ( on vertex functions ) or an interpolated value between vertices( on fragment/surface functions ).


<img class="responsive-img" src="http://wiki.amplify.pt/images/NodeDetail/Vector4.jpg">
'''NOTE:''' Do not confuse with [[Unity Products:Amplify Shader Editor/World Position|World Position]] node.
 
<img class="responsive-img" src="http://wiki.amplify.pt/images/NodeDetail/VertexPositionNode.gif">
<br/><font size="1">Nodes used:  
<br/><font size="1">Nodes used:  
[[Unity_Products:Amplify_Shader_Editor/Vector4|Vector4]]
[[Unity_Products:Amplify_Shader_Editor/Texture_Sample|Texture Sample]],
[[Unity_Products:Amplify_Shader_Editor/Vertex_Position|Vertex Position]],
[[Unity_Products:Amplify_Shader_Editor/Saturate|Saturate]],
[[Unity_Products:Amplify_Shader_Editor/Lerp|Lerp]]
</font>
</font>


{| class="wikitable" style="width: 100%;"
{| class="wikitable" style="width: 100%;"
|-
|-  
! style="width: 10%;" | Node Parameter !! Description !! style="width: 10%;" | Default Value
! style="width: 10%;" | Input Port !! Description !! style="width: 10%;" | Type
|-
|-  
| id="paramtype" | Type
| id="paramsize" | Size
| A set of ways the value behaves in different situations.
| The size of the position vector.
* '''Constant:''' the value is assigned directly in shader code and can't be dynamically changed.
* '''XYZ:''' Retrieves the 3 coordinates position.
* '''Property:''' the value becomes available in the properties of the material that uses the shader and can be changed in the material inspector or by script.
* '''XYZW:''' Retrieves the 3 coordinates position and one more. This is mostly useful to facilitate matrix transformation operations where the W value is needed with the value 1 or if you want to retrieve packed data in the W channel.
* '''Instanced Property:''' 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] )
| XYZ
* '''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.
| Constant
|-
| id="paramname" | Name || Name of the property holding the value. This is the name that will be shown in the material properties label if type is set to [[#paramtype|Property]], if not this name is ignored but still useful for organization purposes or to generate a [[#parampname|Property Name]] || Vector #
|-
| id="paramVariable Mode" | Variable Mode
| Defines if the current property/global variable is to be created on the current shader.
* '''Create:''' Property and/or global variable is created in the shader
* '''Fetch:''' No variable nor property is registered on shader, useful when p.e. there's need to using global variables declared over a included cginc
| Create
|-
| id="paramAutoRegister Mode" | Auto-Register
| If toggled on, creates the property and/or global variable even if not connected to an Output node
| Off
|-
| id="paramprecision" | 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
* '''Inherit:''' Use global precision set on master node properties
| 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
|-
| colspan="3" style="background:white; text-align: center; font-size: 11px;"| Other Parameters
|- style="background: #e5e5e5;" |
| style="width: 10%;" id="parampname" | Property Name
| This is the variable name that contains the value, this is automatically generated using the [[#paramname|Name]] parameter, it's greyed out and not editable. The generation process removes special characters, whitespaces and adds an underscore at the beginning ( ie: "''My Property Name''" becomes "''_MyPropertyName''" ). This parameter is only visible in [[#paramtype|Property]], [[#paramtype|Instanced Property]] and [[#paramtype|Global]] types to indicate what's the variable name to use when editing this value by script.
| style="width: 10%;" | _Vector#
|- style="background: #e5e5e5;" |
| Material Value
| This is the value the node the material currently holds. This parameter is only visible in [[#paramtype|Property]] and [[#paramtype|Instanced Property]] types which are the two types that let you change the value per material.
| 0
|-
| colspan="3" style="background:white; text-align: center; font-size: 11px;"| Attributes
|-
| style="width: 10%;" id="paramHideInInspector" | Hide in Inspector
| Does not show the property value in the material inspector
| style="width: 10%;" | Off
|-
| style="width: 10%;" id="paramHDR" | HDR
| Indicates that a  property expects a high-dynamic range (HDR) value
| style="width: 10%;" | Off
|-
| style="width: 10%;" id="paramGamma" | Gamma
| Indicates that a property is specified as sRGB value in the UI and possibly needs conversion according to color space used
| style="width: 10%;" | Off
|-
| style="width: 10%;" id="paramPerRendererData" | Per Renderer Data
| Indicates that a property will be coming from per-renderer data in the form of a MaterialPropertyBlock.
| style="width: 10%;" | Off
|-
| style="width: 10%;" id="paramHeader" | Header
| Sets up a title for that property, to be automatically shown over the material inspector.
| style="width: 10%;" | Off
|-
| style="width: 10%;" id="paramRemapSlider" | Remap Slider
| Vector2 variable is shown as a remap slider between min value set on Z and max value set on W on the material inspector.
| style="width: 10%;" | Off
|-
| style="width: 10%;" id="paramCustomAttributes" | Custom Attributes
| Allows adding custom attributes directly on a textfield
| style="width: 10%;" | -
|}
|}


{| class="wikitable" style="width: 100%;"
{| class="wikitable" style="width: 100%;"
Line 88: Line 30:
! style="width: 10%;" | Output Port !! Description !! style="width: 10%;" | Type
! style="width: 10%;" | Output Port !! Description !! style="width: 10%;" | Type
|-  
|-  
| XYZW
| XYZ(W)
| Returns the assigned vector4 value
| Returns the vertex position in object space
| Float4
| Float3(4)
|-  
|-  
| X
| X
| Returns only the X component of the vector4
| Returns only the X component of the vertex position
| Float
| Float
|-  
|-  
| Y
| Y
| Returns only the Y component of the vector4
| Returns only the Y component of the vertex position
| Float
| Float
|-  
|-  
| Z
| Z
| Returns only the Z component of the vector4
| Returns only the Z component of the vertex position
| Float
| Float
|-  
|- style="background: #e5e5e5;" |
| W
| W
| Returns only the W component of the vector4
| Returns only the W component of the vertex position (By default set to 1). Only visible if [[#paramsize|Size]] is set to '''XYZW'''.
| Float
| Float
|}
----
{| style="width: 100%; horizontal-align: right;"
|
Math Operators - Vectors
|{{#evt:
service=youtube
|id=https://youtu.be/dbch2XNVIr8
|alignment=right
}}
|}
|}


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

Revision as of 10:50, 9 November 2017

Back to Node List

Vertex Position Node

The Vertex Position node outputs the vertices position in object space. This data is extracted directly from the mesh and contains the vertex position relative to the object origin, this means the position values don't change whatever transform value your gameobject has. This is usually useful to use in the Local Vertex Offset output or to create effects that are bound to the object and stay exactly the same even if your gameobject changes position, rotation or size.
Depending on where this node is being used ( vertex or fragment/surface function ) it will either return a direct value ( on vertex functions ) or an interpolated value between vertices( on fragment/surface functions ).

NOTE: Do not confuse with World Position node.


Nodes used: Texture Sample, Vertex Position, Saturate, Lerp

Input Port Description Type
Size The size of the position vector.
  • XYZ: Retrieves the 3 coordinates position.
  • XYZW: Retrieves the 3 coordinates position and one more. This is mostly useful to facilitate matrix transformation operations where the W value is needed with the value 1 or if you want to retrieve packed data in the W channel.
XYZ
Output Port Description Type
XYZ(W) Returns the vertex position in object space Float3(4)
X Returns only the X component of the vertex position Float
Y Returns only the Y component of the vertex position Float
Z Returns only the Z component of the vertex position Float
W Returns only the W component of the vertex position (By default set to 1). Only visible if Size is set to XYZW. Float

Back to Node List