Unity Products:Amplify Shader Editor/Clip and Unity Products:Amplify Shader Editor/Color: Difference between pages

From Amplify Creations Wiki
(Difference between pages)
Jump to navigation Jump to search
ampwiki>Amplify RnD Rick
No edit summary
 
ampwiki>Amplify RnD Rick
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]]
== Color Node ==


== Clip Node ==
The Color node ''( shortcut: numeric 5 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 function of this node is very similar to the [[Unity Products:Amplify Shader Editor/Vector4|Vector4 Node]], the difference is the convenience of representing and changing the values with a color picker.


The Clip node conditionally discards a pixel before being outputted. This happens when [[#paramAlpha|Alpha]] value is less than [[#paramThreshold|Threshold]]  '''(Alpha - Threshold < 0)'''. 
<img class="responsive-img" src="http://wiki.amplify.pt/images/NodeDetail/ColorNode.jpg"><br/>
<br/>
<font size="1">Nodes used:  
'''NOTE:''' This node can only be connected to graphs attached to Output node's fragment input ports.
 
<img class="responsive-img" src="http://wiki.amplify.pt/images/NodeDetail/ClipNode.gif">
<br/><font size="1">Nodes used:  
[[Unity_Products:Amplify_Shader_Editor/Texture_Sample|Texture Sample]],  
[[Unity_Products:Amplify_Shader_Editor/Texture_Sample|Texture Sample]],  
[[Unity_Products:Amplify_Shader_Editor/Sin_Time|Sin Time]],
[[Unity_Products:Amplify_Shader_Editor/Color|Color]],  
[[Unity_Products:Amplify_Shader_Editor/Float|Float]],
[[Unity_Products:Amplify_Shader_Editor/Multiply|Multiply]]
[[Unity_Products:Amplify_Shader_Editor/Scale_And_Offset|Scale And Offset]],
[[Unity_Products:Amplify_Shader_Editor/Clip|Clip]]
</font>
</font>


Line 19: Line 14:
|-
|-
! 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.
* '''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.
* '''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] )
* '''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]] || Color #
|-
| 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, 0 ,0 ,0 )
|-
| Auto Gamma To Linear
| Only shown when on Constant Type, performs gamma correction on value set if a gamma color space is detected on the project.
| On
|-
| colspan="3" style="background:white; text-align: center; font-size: 11px;"| Other Parameters
|- style="background: #e5e5e5;" |
|- style="background: #e5e5e5;" |
| id="paramAlpha" | Alpha
| style="width: 10%;" id="parampname" | Property Name
| First value of the clip operation. Only visible if the respective input port is not connected.
| 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.
| 0
| style="width: 10%;" | _Color#
|- style="background: #e5e5e5;" |
|- style="background: #e5e5e5;" |
| id="paramThreshold" | Threshold
| Material Value
| Second value of the clip operation. Only visible if the respective input port is not connected.
| 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
| ( 0, 0 ,0 ,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="paramCustomAttributes" | Custom Attributes
| Allows adding custom attributes directly on a textfield
| style="width: 10%;" | -
|}
|}


Line 33: Line 90:
{| class="wikitable" style="width: 100%;"
{| class="wikitable" style="width: 100%;"
|-  
|-  
! style="width: 10%;" | Input Port !! Description !! style="width: 10%;" | Type
! style="width: 10%;" | Output Port !! Description !! style="width: 10%;" | Type
|-  
|-  
| Input
| RGBA
| Value connected here is directly relayed to output port.
| Returns the assigned color value
| Float <sup id="ref1">[[#anchor|[1]]]</sup>
| Float4
|-  
|-  
| Alpha
| R
| First value of the clip operation.
| Returns only the R component of the color value which corresponds to the X component of a Vector4
| Float <sup id="ref1">[[#anchor|[1]]]</sup>
| Float
|-
|-
| Threshold
| G
| Second value of the clip operation.
| Returns only the G component of the color value which corresponds to the Y component of a Vector4
| Float <sup id="ref1">[[#anchor|[1]]]</sup>
| Float
|-
| B
| Returns only the B component of the color value which corresponds to the Z component of a Vector4
| Float
|-  
| A
| Returns only the A component of the color value which corresponds to the W component of a Vector4
| Float
|}
|}


----
----
# <span id="anchor1">'''[[#ref1|^]]'''</span> Port automatically adapts to all connection types except Matrices and [[Unity Products:Amplify Shader Editor/Texture Object|Sampler]] types.
{| style="width: 100%; horizontal-align: right;"  
|
Math Operators - Floats and Color
|{{#evt:
service=youtube
|id=https://youtu.be/EktUo_n1uPk
|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:Miscellaneous]]
[[Category:Nodes]][[Category:Constants And Properties]]

Revision as of 16:30, 25 August 2021

Back to Node List

Color Node

The Color node ( shortcut: numeric 5 key ) generates a float4 value containing four float components. This value is usually useful to either define a Constant value which is directly used in shader calculations or to define an exposed Property value that can be modified by the material inspector that uses it. The function of this node is very similar to the Vector4 Node, the difference is the convenience of representing and changing the values with a color picker.


Nodes used: Texture Sample, Color, Multiply

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.
  • 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.
  • Instanced Property: the value can only be set by script and this defines the shader as an instanced shader. ( see more here: GPU Instancing )
  • 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
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 Property, if not this name is ignored but still useful for organization purposes or to generate a Property Name Color #
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
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
  • 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, 0 ,0 ,0 )
Auto Gamma To Linear Only shown when on Constant Type, performs gamma correction on value set if a gamma color space is detected on the project. On
Other Parameters
Property Name This is the variable name that contains the value, this is automatically generated using the 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 Property, Instanced Property and Global types to indicate what's the variable name to use when editing this value by script. _Color#
Material Value This is the value the node the material currently holds. This parameter is only visible in Property and Instanced Property types which are the two types that let you change the value per material. ( 0, 0 ,0 ,0 )
Attributes
Hide in Inspector Does not show the property value in the material inspector Off
HDR Indicates that a property expects a high-dynamic range (HDR) value Off
Gamma Indicates that a property is specified as sRGB value in the UI and possibly needs conversion according to color space used Off
Per Renderer Data Indicates that a property will be coming from per-renderer data in the form of a MaterialPropertyBlock. Off
Header Sets up a title for that property, to be automatically shown over the material inspector. Off
Custom Attributes Allows adding custom attributes directly on a textfield -


Output Port Description Type
RGBA Returns the assigned color value Float4
R Returns only the R component of the color value which corresponds to the X component of a Vector4 Float
G Returns only the G component of the color value which corresponds to the Y component of a Vector4 Float
B Returns only the B component of the color value which corresponds to the Z component of a Vector4 Float
A Returns only the A component of the color value which corresponds to the W component of a Vector4 Float

Math Operators - Floats and Color

Back to Node List