This commit is contained in:
2024-09-20 20:30:10 +02:00
commit 4fabf1a6fd
29169 changed files with 1706941 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
# Absolute Node
## Description
Returns the absolute value of the input **In**. Components of the input Dynamic Vector that are positive will remain positive and components that are negative will be inverted and become positive.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Absolute_float4(float4 In, out float4 Out)
{
Out = abs(In);
}
```

View File

@@ -0,0 +1,24 @@
# Add Node
## Description
Returns the sum of the two input values **A** and **B**.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| A | Input | Dynamic Vector | First input value |
| B | Input | Dynamic Vector | Second input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Add_float4(float4 A, float4 B, out float4 Out)
{
Out = A + B;
}
```

View File

@@ -0,0 +1,23 @@
# All Node
## Description
Returns true if all components of the input **In** are non-zero. This is useful for [Branching](Branch-Node.md).
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| In | Input | Dynamic Vector | None | Input value |
| Out | Output | Boolean | None | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_All_float4(float4 In, out float Out)
{
Out = all(In);
}
```

View File

@@ -0,0 +1,34 @@
# Ambient Node
## Description
Provides access to the Scene's **Ambient** color values. When Environment Lighting Source is set to **Gradient** [Port](Port.md) **Color/Sky** returns the value **Sky Color**. When Environment Lighting Source is set to **Color** [Port](Port.md) **Color/Sky** returns the value **Ambient Color**. [Ports](Port.md) **Equator** and **Ground** always return the values **Equator Color** and **Ground Color** regardless of the current Environment Lighting Source.
Note: Values of this [Node](Node.md) are only updated when entering Play mode or saving the current Scene/Project.
Note: The behavior of this [Node](Node.md) is undefined globally. Shader Graph does not define the function of the node. Instead, each Render Pipeline defines what HLSL code to execute for this [Node](Node.md).
Different Render Pipelines may produce different results. If you're building a shader in one Render Pipeline that you want to use in both, try checking it in both pipelines before production. A [Node](Node.md) might be defined in one Render Pipeline and undefined in the other. If this [Node](Node.md) is undefined, it returns 0 (black).
#### Unity Render Pipelines Support
- Universal Render Pipeline
The High Definition Render Pipeline does **not** support this Node.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Color/Sky | Output | Vector 3 | None | Color (Color) or Sky (Gradient) color value |
| Equator | Output | Vector 3 | None | Equator (Gradient) color value |
| Ground | Output | Vector 3 | None | Ground (Gradient) color value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
float3 _Ambient_ColorSky = SHADERGRAPH_AMBIENT_SKY;
float3 _Ambient_Equator = SHADERGRAPH_AMBIENT_EQUATOR;
float3 _Ambient_Ground = SHADERGRAPH_AMBIENT_GROUND;
```

View File

@@ -0,0 +1,22 @@
# And Node
## Description
Returns true if both the inputs **A** and **B** are true. This is useful for [Branching](Branch-Node.md).
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| A | Input | Boolean | None | First input value |
| B | Input | Boolean | None | Second input value |
| Out | Output | Boolean | None | Output value |
## Generated Code Example
```
void Unity_And(float A, float B, out float Out)
{
Out = A && B;
}
```

View File

@@ -0,0 +1,23 @@
# Any Node
## Description
Returns true if any of the components of the input **In** are non-zero. This is useful for [Branching](Branch-Node.md).
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| In | Input | Dynamic Vector | None | Input value |
| Out | Output | Boolean | None | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Any_float4(float4 In, out float Out)
{
Out = any(In);
}
```

View File

@@ -0,0 +1,23 @@
# Arccosine Node
## Description
Returns the arccosine of each component of the input **In** as a vector of the same dimension and equal length. Each component should be within the range of -1 to 1.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Arccosine_float4(float4 In, out float4 Out)
{
Out = acos(In);
}
```

View File

@@ -0,0 +1,23 @@
# Arcsine Node
## Description
Returns the arcsine of each component of the input **In** as a vector of the same dimension and equal length. Each component should be within the range of -Pi/2 to Pi/2.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Arcsine_float4(float4 In, out float4 Out)
{
Out = asin(In);
}
```

View File

@@ -0,0 +1,23 @@
# Arctangent Node
## Description
Returns the arctangent of the value of input **In**. Each component should be within the range of -Pi/2 to Pi/2.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Arctangent_float4(float4 In, out float4 Out)
{
Out = atan(In);
}
```

View File

@@ -0,0 +1,24 @@
# Arctangent2 Node
## Description
Returns the arctangent of the values of both input **A** and input **B**. The signs (whether they are positive or negative values) of the input values are used to determine whether the output components, or channels, are positive or negative within a range of -Pi to Pi.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| A | Input | Dynamic Vector | First input value |
| B | Input | Dynamic Vector | Second input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Arctangent2_float4(float4 A, float4 B, out float4 Out)
{
Out = atan2(A, B);
}
```

View File

@@ -0,0 +1,69 @@
# Artistic Nodes
## Adjustment
|[Channel Mixer](Channel-Mixer-Node.md)| [Contrast](Contrast-Node.md) |
|:---------:|:---------:|
|![Image](images/ChannelMixerNodeThumb.png)|![](images/ContrastNodeThumb.png)|
|Controls the amount each of the channels of input In contribute to each of the output channels.|Adjusts the contrast of input In by the amount of input Contrast.|
|[**Hue**](Hue-Node.md)|[**Invert Colors**](Invert-Colors-Node.md)|
|![Image](images/HueNodeThumb.png)|![Image](images/InvertColorsNodeThumb.png)|
|Offsets the hue of input In by the amount of input Offset.|Inverts the colors of input In on a per channel basis.|
|[**Replace Color**](Replace-Color-Node.md)|[**Saturation**](Saturation-Node.md)|
|![Image](images/ReplaceColorNodeThumb.png)|![Image](images/SaturationNodeThumb.png)|
|Replaces values in input In equal to input From to the value of input To.|Adjusts the saturation of input In by the amount of input Saturation.|
|[**White Balance**](White-Balance-Node.md)||
|![Image](images/WhiteBalanceNodeThumb.png)||
|Adjusts the temperature and tint of input In by the amount of inputs Temperature and Tint respectively.||
## Blend
|[Blend](Blend-Node.md)|
|:---------:|
|![Image](images/BlendNodeThumb.png)|
|Blends the value of input Blend onto input Base using the blending mode defined by parameter Mode.|
## Filter
|[Dither](Dither-Node.md)|
|:---------:|
|![Image](images/DitherNodeThumb.png)|
|Dither is an intentional form of noise used to randomize quantization error. It is used to prevent large-scale patterns such as color banding in images..|
## Mask
|[Channel Mask](Channel-Mask-Node.md)| [Color Mask](Color-Mask-Node.md) |
|:---------:|:---------:|
|![Image](images/ChannelMaskNodeThumb.png)|![](images/ColorMaskNodeThumb.png)|
|Masks values of input In on channels selected in dropdown Channels.|Creates a mask from values in input In equal to input Mask Color.|
## Normal
|[Normal Blend](Normal-Blend-Node.md)| [Normal From Height](Normal-From-Height-Node.md) |
|:---------:|:---------:|
|![Image](images/NormalBlendNodeThumb.png)|![](images/NormalFromHeightNodeThumb.png)|
|Blends two normal maps defined by inputs A and B together.|Creates a normal map from a height map defined by input Texture.|
|[**Normal Strength**](Normal-Strength-Node.md)|[**Normal Unpack**](Normal-Unpack-Node.md)|
|![Image](images/NormalStrengthNodeThumb.png)|![Image](images/NormalUnpackNodeThumb.png)|
|Adjusts the strength of the normal map defined by input In by the amount of input Strength.|Unpacks a normal map defined by input In.|
## Utility
| [Colorspace Conversion](Colorspace-Conversion-Node.md) |
| :----------------------------------------------------------: |
| ![Image](images/ColorspaceConversionNodeThumb.png) |
| Returns the result of converting the value of input In from one colorspace space to another. |

View File

@@ -0,0 +1,40 @@
# Baked GI Node
## Description
Provides access to the **Baked GI** values at the vertex or fragment's position. Requires **Position** and **Normal** input for light probe sampling, and lightmap coordinates **Static UV** and **Dynamic UV** for all potential lightmap sampling cases.
Note: The behavior of this [Node](Node.md) is undefined globally. Shader Graph does not define the function of the node. Instead, each Render Pipeline defines what HLSL code to execute for this [Node](Node.md).
Different Render Pipelines may produce different results. If you're building a shader in one Render Pipeline that you want to use in both, try checking it in both pipelines before production. A [Node](Node.md) might be defined in one Render Pipeline and undefined in the other. If this [Node](Node.md) is undefined, it returns 0 (black).
#### Unity Render Pipelines Support
- High Definition Render Pipeline. Although, this Node does not work in a Shader Graph that targets HDRP's [Unlit Master Node](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Master-Node-Unlit.html).
- Universal Render Pipeline
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Position | Input | Vector 3 | Position (world space) | Mesh vertex/fragment's **Position** |
| Normal | Input | Vector 3 | Normal (world space) | Mesh vertex/fragment's **Normal** |
| Static UV | Input | Vector 2 | UV1 | Lightmap coordinates for the static lightmap |
| Dynamic UV | Input | Vector 2 | UV2 | Lightmap coordinates for the dynamic lightmap |
| Out | Output | Vector 3 | None | Output color value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| Apply Lightmap Scaling | Toggle | True, False | If enabled lightmaps are automatically scaled and offset. |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_BakedGI_float(float3 Position, float3 Normal, float2 StaticUV, float2 DynamicUV, out float Out)
{
Out = SHADERGRAPH_BAKED_GI(Position, Normal, StaticUV, DynamicUV, false);
}
```

View File

@@ -0,0 +1,17 @@
# Bitangent Node
## Description
Provides access to the mesh vertex or fragment's **Bitangent Vector**, depending on the effective [Shader Stage](Shader-Stage.md) of the graph section the [Node](Node.md) is part of. The coordinate space of the output value can be selected with the **Space** dropdown parameter.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Out | Output | Vector 3 | None | **Bitangent Vector** for the Mesh Vertex/Fragment. |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| Space | Dropdown | Object, View, World, Tangent | Selects coordinate space of **Bitangent Vector** to output. |

View File

@@ -0,0 +1,81 @@
# Blackboard
## Description
You can use the Blackboard to define, order, and categorize the [Properties](Property-Types.md) and [Keywords](Keywords.md) in a graph. From the Blackboard, you can also edit the path for the selected Shader Graph Asset or Sub Graph.
![image](images/blackboardcategories1.png)
## Accessing the Blackboard
The Blackboard is visible by default, and you cannot drag it off the graph and lose it. However, you are able to position it anywhere in the [Shader Graph Window](Shader-Graph-Window.md). It always maintains the same distance from the nearest corner, even if you resize the window.
## Adding properties and keywords to the Blackboard
To create a new property or keyword, click the **Add (+)** button on the Blackboard's title bar and select a type. For a full list of property types, see [Property Types](Property-Types.md).
## Editing properties and keywords
Select a property or keyword in the Blackboard or graph to modify its settings in the Node Settings Menu.
| Setting | Description |
|-----------|-------------|
| Name | The property's display name. The Editor strips quotation marks from display names and replaces them with underscores. Rename an item via the Blackboard by double-clicking on its name. |
| Reference | The name that Shader Graph uses internally for this property. Although the Editor populates this value by default, you can modify it. To revert to the original reference name, right-click on the word **Reference** (not the entry field) and select **Reset Reference** in the context menu. If the Reference Name contains any characters that HLSL does not support, the Editor replaces those characters with underscores. |
| Default | The default value of this property in any Material based on this Shader Graph. For example, if you have a Shader Graph for grass and expose the grass color as a property, you might set the default to Green.|
| Precision | Set the precision mode for the property. See [Precision Modes](Precision-Modes.md). |
| Exposed | Enable this setting to make the property available for you to edit via the C# API. Enabled by default. |
## Modifying and selecting keywords and properties
* To reorder items listed on the Blackboard, drag and drop them.
* To delete items, use the Delete key on Windows or Command + Backspace keys on macOS.
* To select multiple items, hold down the Ctrl key while making your selections.
* To cancel the selection of one or multiple items, hold down the Ctrl key while clicking on the items you want to remove from the selection.
## Using Blackboard categories
To make the properties in your shader more discoverable, organize them into categories. Expand and collapse categories to make the Blackboard easier to navigate.
### Creating, renaming, moving, and deleting categories
* To add a category, use **+** on the Blackboard.
* To rename a category, double-click on the category name, or right-click and select **Rename**.
* To move a category within the Blackboard, select and drag it.
* To remove a category, select it and press **Delete**, or right-click and select **Delete**. Deleting a category also deletes the properties within it, so move those you wish to keep.
### Adding, removing, and reordering properties and keywords
* To add a property or keyword to a category, expand the category with the foldout (⌄) symbol, then drag and drop the property or keyword onto the expanded category.
![image](images/blackboardcategories2.png)
* To remove a property or keyword, select it and press **Delete**, or right-click and select **Delete**.
* To re-order properties or keywords, drag and drop them within a category or move them into other categories.
### Creating a category for specific properties and keywords
Select multiple properties or keywords and use **+** on the Blackboard to create a category that contains all of the items you have selected.
### Copying and pasting categories, with or without properties
You can paste empty categories, categories with all of their properties, and categories with some of their properties into one or more graphs. To copy a category with all of its properties:
1. Select the property.
2. Copy it with **Ctrl+C**.
3. Paste it into your target graph with **Ctrl+V**.
To copy a specific set of properties:
1. Select the category.
2. Hold down the Ctrl key.
3. Click the properties you do not want to include to remove them from the selection.
4. Copy the property with **Ctrl+C**.
5. Paste it into your target graph with **Ctrl+V**.
### Using categories in the Material Inspector
To modify a material you have created with a Shader Graph, you can adjust specific property or keyword values in the Material Inspector, or edit the graph itself.
![image](images/blackboardcategories3.png)
#### Working with Streaming Virtual Textures
[Streaming Virtual Texture Properties](https://docs.unity3d.com/Documentation/Manual/svt-use-in-shader-graph.html) sample texture layers. To access these layers in the Material Inspector, expand the relevant **Virtual Texture** section with the ⌄ symbol next to its name. You can add and remove layers via the Inspector.
## Exposing properties and keywords
Unity exposes properties and keywords by default. This enables write access from scripts, so that you can edit them via the C# API, in addition to the graph. Exposed items have a green dot in their label. Enable or disable this feature in the **Node Settings** menu.
## Creating nodes
Drag a property or keyword from the Blackboard into the graph to create a node of that kind. Settings for a node in the graph are identical to those for the related property or keyword in the Blackboard. Expand these nodes to use a sub-member of the property value.
Property node names include a green dot if the property is exposed.

View File

@@ -0,0 +1,33 @@
# Blackbody Node
## Description
Samples a **Gradient** that simulates the effect of black body radiation.
The calculations in this node are based on data gathered by Mitchell Charity.
This node outputs color in linear RGB space and preforms the conversion using a D65 whitepoint and a CIE 1964 10 degree color space.
For more information, see [What color is a blackbody?](http://www.vendian.org/mncharity/dir3/blackbody/)
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Temperature | Input | Float | None | Temperature or temperature map in Kelvin to sample. |
| Out | Output | Vector 3 | None | Intensity represented by color in Vector 3. |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Blackbody_float(float Temperature, out float3 Out)
{
float3 color = float3(255.0, 255.0, 255.0);
color.x = 56100000. * pow(Temperature,(-3.0 / 2.0)) + 148.0;
color.y = 100.04 * log(Temperature) - 623.6;
if (Temperature > 6500.0) color.y = 35200000.0 * pow(Temperature,(-3.0 / 2.0)) + 184.0;
color.z = 194.18 * log(Temperature) - 1448.6;
color = clamp(color, 0.0, 255.0)/255.0;
if (Temperature < 1000.0) color *= Temperature/1000.0;
Out = color;
}
```

View File

@@ -0,0 +1,257 @@
# Blend Node
## Description
Blends the value of input **Blend** onto input **Base** using the blending mode defined by the **Mode** parameter. The strength of the blend is defined by input **Opacity**. An **Opacity** value of 0 will return the input **Base**, unaltered.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Base | Input | Dynamic Vector | None | Base layer value |
| Blend | Input | Dynamic Vector | None | Blend layer value |
| Opacity | Input | Float | None | Strength of blend |
| Out | Output | Dynamic Vector | None | Output value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| Mode | Dropdown | Burn, Darken, Difference, Dodge, Divide, Exclusion, HardLight, HardMix, Lighten, LinearBurn, LinearDodge, LinearLight, LinearLightAddSub, Multiply, Negation, Overlay, PinLight, Screen, SoftLight, Subtract, VividLight, Overwrite | Blend mode to apply |
## Generated Code Example
The following example code represents one possible outcome of this node per blend mode.
**Burn**
```
void Unity_Blend_Burn_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = 1.0 - (1.0 - Blend)/Base;
Out = lerp(Base, Out, Opacity);
}
```
**Darken**
```
void Unity_Blend_Darken_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = min(Blend, Base);
Out = lerp(Base, Out, Opacity);
}
```
**Difference**
```
void Unity_Blend_Difference_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = abs(Blend - Base);
Out = lerp(Base, Out, Opacity);
}
```
**Dodge**
```
void Unity_Blend_Dodge_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = Base / (1.0 - Blend);
Out = lerp(Base, Out, Opacity);
}
```
**Divide**
```
void Unity_Blend_Divide_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = Base / (Blend + 0.000000000001);
Out = lerp(Base, Out, Opacity);
}
```
**Exclusion**
```
void Unity_Blend_Exclusion_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = Blend + Base - (2.0 * Blend * Base);
Out = lerp(Base, Out, Opacity);
}
```
**HardLight**
```
void Unity_Blend_HardLight_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
float4 result1 = 1.0 - 2.0 * (1.0 - Base) * (1.0 - Blend);
float4 result2 = 2.0 * Base * Blend;
float4 zeroOrOne = step(Blend, 0.5);
Out = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
Out = lerp(Base, Out, Opacity);
}
```
**HardMix**
```
void Unity_Blend_HardMix_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = step(1 - Base, Blend);
Out = lerp(Base, Out, Opacity);
}
```
**Lighten**
```
void Unity_Blend_Lighten_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = max(Blend, Base);
Out = lerp(Base, Out, Opacity);
}
```
**LinearBurn**
```
void Unity_Blend_LinearBurn_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = Base + Blend - 1.0;
Out = lerp(Base, Out, Opacity);
}
```
**LinearDodge**
```
void Unity_Blend_LinearDodge_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = Base + Blend;
Out = lerp(Base, Out, Opacity);
}
```
**LinearLight**
```
void Unity_Blend_LinearLight_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = Blend < 0.5 ? max(Base + (2 * Blend) - 1, 0) : min(Base + 2 * (Blend - 0.5), 1);
Out = lerp(Base, Out, Opacity);
}
```
**LinearLightAddSub**
```
void Unity_Blend_LinearLightAddSub_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = Blend + 2.0 * Base - 1.0;
Out = lerp(Base, Out, Opacity);
}
```
**Multiply**
```
void Unity_Blend_Multiply_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = Base * Blend;
Out = lerp(Base, Out, Opacity);
}
```
**Negation**
```
void Unity_Blend_Negation_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = 1.0 - abs(1.0 - Blend - Base);
Out = lerp(Base, Out, Opacity);
}
```
**Overlay**
```
void Unity_Blend_Overlay_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
float4 result1 = 1.0 - 2.0 * (1.0 - Base) * (1.0 - Blend);
float4 result2 = 2.0 * Base * Blend;
float4 zeroOrOne = step(Base, 0.5);
Out = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
Out = lerp(Base, Out, Opacity);
}
```
**PinLight**
```
void Unity_Blend_PinLight_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
float4 check = step (0.5, Blend);
float4 result1 = check * max(2.0 * (Base - 0.5), Blend);
Out = result1 + (1.0 - check) * min(2.0 * Base, Blend);
Out = lerp(Base, Out, Opacity);
}
```
**Screen**
```
void Unity_Blend_Screen_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = 1.0 - (1.0 - Blend) * (1.0 - Base);
Out = lerp(Base, Out, Opacity);
}
```
**SoftLight**
```
void Unity_Blend_SoftLight_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
float4 result1 = 2.0 * Base * Blend + Base * Base * (1.0 - 2.0 * Blend);
float4 result2 = sqrt(Base) * (2.0 * Blend - 1.0) + 2.0 * Base * (1.0 - Blend);
float4 zeroOrOne = step(0.5, Blend);
Out = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
Out = lerp(Base, Out, Opacity);
}
```
**Subtract**
```
void Unity_Blend_Subtract_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = Base - Blend;
Out = lerp(Base, Out, Opacity);
}
```
**VividLight**
```
void Unity_Blend_VividLight_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
float4 result1 = 1.0 - (1.0 - Blend) / (2.0 * Base);
float4 result2 = Blend / (2.0 * (1.0 - Base));
float4 zeroOrOne = step(0.5, Base);
Out = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
Out = lerp(Base, Out, Opacity);
}
```
**Overwrite**
```
void Unity_Blend_Overwrite_float4(float4 Base, float4 Blend, float Opacity, out float4 Out)
{
Out = lerp(Base, Blend, Opacity);
}
```

View File

@@ -0,0 +1,31 @@
# Block Node
## Description
A Block is a specific type of node for the Master Stack. A Block represents a single piece of the surface (or vertex) description data that Shader Graph uses in the final shader output. [Built In Block nodes](Built-In-Blocks.md) are always available, but nodes that are specific to a certain render pipeline are only available for that pipeline. For example, Universal Block nodes are only available for the Universal Render Pipeline (URP), and High Definition Block nodes are only available for the High Definition Render Pipeline (HDRP).
Some blocks are only compatible with specific [Graph Settings](Graph-Settings-Menu.md), and might become active or inactive based on the graph settings you select. You can't cut, copy, or paste Blocks.
## Add and Remove Block Nodes
To add a new Block node to a Context in the Master Stack, place the cursor over an empty area in the Context, then press the Spacebar or right-click and select **Create Node**.
This brings up the Create Node menu, which displays only Block nodes that are valid for the Context. For example, Vertex Blocks don't appear in the Create Node menu of a Fragment Context.
Select a Block node from the menu to add it to the Context. To remove a Block from the Context, select the Block node in the Context, then press the Delete key or right-click and select **Delete**.
### Automatically Add or Remove Blocks
You can also enable or disable an option in the Shader Graph Preferences to automatically add and remove Blocks from a Context.
If you enable **Automatically Add or Remove Blocks**, Shader Graph automatically adds the required Block nodes for that particular asset's Target or material type. It automatically removes any incompatible Block nodes that have no connections and default values.
If you disable **Automatically Add or Remove Blocks**, Shader Graph doesn't automatically add and remove Block nodes. You must manually add and remove all Block nodes.
## Active and Inactive Blocks
Active Block nodes are Blocks that contribute to the final shader. Inactive Block nodes are Blocks that are present in the Shader Graph, but don't contribute to the final shader.
![image](images/Active-Inactive-Blocks.png)
When you change the graph settings, certain Blocks might become active or inactive. Inactive Block nodes and any node streams that are connected only to Inactive Block nodes appear grayed out.

View File

@@ -0,0 +1,25 @@
# Boolean Node
## Description
Defines a constant **Boolean** value in the [Shader Graph](Shader-Graph.md), although internally to the shader this is treated as a constant **float** value that is ether 0 or 1, similar to Shaderlab's [Toggle](https://docs.unity3d.com/ScriptReference/MaterialPropertyDrawer.html) property. Can be converted to a **Boolean** type [Property](Property-Types.md) via the [Node's](Node.md) context menu.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Out | Output | Boolean | None | Output value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| | Toggle | | Defines the output value. |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
float _Boolean = 1;
```

View File

@@ -0,0 +1,25 @@
# Branch Node
## Description
Provides a dynamic branch to the shader. If input **Predicate** is true the return output will be equal to input **True**, otherwise it will be equal to input **False**. This is determined per vertex or per pixel depending on shader stage. Both sides of the branch will be evaluated in the shader, and the branch not used will be discarded.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Predicate | Input | Boolean | None | Determines which input to returned |
| True | Input | Dynamic Vector | None | Returned if **Predicate** is true |
| False | Input | Dynamic Vector | None | Returned if **Predicate** is false |
| Out | Output | Boolean | None | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Branch_float4(float Predicate, float4 True, float4 False, out float4 Out)
{
Out = Predicate ? True : False;
}
```

View File

@@ -0,0 +1,92 @@
# Branch On Input Connection node
The Branch On Input Connection node allows you to change the behavior of a Subgraph based on the connected state of an input property in the parent Shader Graph. You should use the Branch On Input Connection node when you want to create a default input for a port
Shader Graph determines whether the property in the parent Shader Graph is connected, or not connected, and chooses a value to use as an output based on that connection state.
![An image of the Graph window, that shows the Branch on Input Connection node.](images/sg-branch-on-input-connection-node.png)
Shader Graph uses two ports when it determines the node's connection state:
- The Branch On Input Connection node's **Input** port.
- The Subgraph node's matching Property port in the parent Shader Graph. For more information on Subgraph nodes, see [Subgraph node](Sub-graph-Node).
The Branch On Input Connection node's functionality is based on the [Branch node](Branch-Node.md).
> [!NOTE]
> You can't use the Branch On Input Connection node with a Streaming Virtual Texture Property. For more information on Streaming Virtual Texturing, see [Using Streaming Virtual Texturing in Shader Graph](https://docs.unity3d.com/Documentation/Manual/svt-use-in-shader-graph.html).
The Branch On Input Connection node generates branching HLSL source code, but during compilation, the branch is optimized out of your shader.
## Create Node menu category
The Branch On Input Connection node is under the **Utility** &gt; **Logic** category in the Create Node menu. You can only use it in a Shader Subgraph.
To use the Branch On Input Connection node in a Subgraph:
1. Open the Subgraph where you want to add a Branch On Input Connection node.
2. In the Blackboard, do one of the following:
- To add a new property, select **Add** (+), then select a property type from the menu. Enter a name for your new property and press Enter. Then, select your property in the Blackboard and drag it onto your graph to create a Property node.
- Select an existing property in the Blackboard and drag it onto your graph to create a Property node.
3. With your Property node selected, in the Graph Inspector, enable **Use Custom Binding**.
> [!NOTE]
> If you disable **Use Custom Binding**, you can't connect your Property node to the Branch On Input Connection node. If you've already made a connection, the Unity Editor breaks the connection and displays a warning on the node.
4. In the **Label** field, enter the label for the default value that displays on your Subgraph node's port binding in its parent Shader Graph. For more information on port bindings, see [Port Bindings](Port-Bindings.md).
5. Press Spacebar or right-click and select **Create Node**. Find the **Branch On Input Connection** node in the Create Node Menu, then double-click or press Enter with the node selected to add it to your Subgraph.
6. On your Property node, select the output port and drag its new connection to the Branch On Connection node's **Input** port.
7. To specify the value Shader Graph uses when the **Input** port is connected on the Subgraph node in the parent Shader Graph, connect a node to the **Connected** port. To specify the value that Shader Graph uses when the **Input** port isn't connected, connect another node to the **NotConnected** port.
8. To specify how Shader Graph uses your **Connected** or **NotConnected** values in your shader, connect any valid node to the **Output** port on the Branch On Input Connection node.
## Compatibility
The Branch On Input Connection [!include[nodes-compatibility-all](./snippets/nodes-compatibility-all.md)] <!-- ALL PIPELINES INCLUDE -->
## Inputs
The Branch On Input Connection [!include[nodes-inputs](./snippets/nodes-inputs.md)] <!-- MULTIPLE INPUT PORTS INCLUDE -->
| **Name** | **Type** | **Description** |
| :--- | :------ | :---------- |
| **Input** | Property | The property that determines the branching logic in the node, based on its connection state in the parent Shader Graph. |
| **Connected** | Dynamic Vector | The value to send to the **Out** port when **Input** is connected in the parent Shader Graph. |
| **NotConnected** | Dynamic Vector | The value to send to the **Out** port when **Input** isn't connected in the parent Shader Graph. |
## Outputs
The Branch On Input Connection [!include[nodes-single-output](./snippets/nodes-single-output.md)] <!-- SINGLE OUTPUT PORT INCLUDE -->
| **Name** | **Type** | **Description** |
| :------ | :------- | :------------- |
| **Out** | Dynamic Vector | Outputs the value of either **Connected** or **NotConnected**, based on the **Input** property's connection state in the parent Shader Graph. |
## Example Subgraph usage
In the following example, a Branch On Input Connection node specifies the default behavior for a UV Subgraph input property. When a value for the **UV** property is connected in the parent graph, then the value from that property is passed to the Checkerboard node to determine the UV coordinates for the checkerboard pattern. When the **UV** property isn't connected, then the Branch On Input Connection node uses the **UV0** channel from the UV node for the Checkerboard node's UV coordinates:
> [!NOTE]
> When you preview a Subgraph, the Branch On Input Connection node always uses its NotConnected value.
![An image of the Graph window. A UV property is connected to the Input port on a Branch On Input Connection node. The property also connects to the Branch On Input Connection node's Connected input port, while a UV node with its channel set to UV0 connects to the NotConnected port. The Branch On Input Connection node's Out port connects to a Checkerboard node's UV input port.](images/sg-branch-on-input-connection-node-example.png)
## Related nodes
<!-- OPTIONAL. Any nodes that may be related to this node in some way that's worth mentioning -->
[!include[nodes-related](./snippets/nodes-related.md)] Branch On Input Connection node:
- [Branch node](Branch-Node.md)
- [Subgraph node](Sub-graph-Node.md)

View File

@@ -0,0 +1,24 @@
# Built In Blocks
## Vertex Blocks
| | Name | Type | Binding | Description |
|:-----------|:----------------|:---------|:----------------------|:------------|
| ![image](images/Blocks-Vertex-Position.png) | Position | Vector 3 | Object Space Position | Defines the absolute object space vertex position per vertex.|
| ![image](images/Blocks-Vertex-Normal.png) | Normal | Vector 3 | Object Space Normal | Defines the absolute object space vertex normal per vertex.|
| ![image](images/Blocks-Vertex-Tangent.png) | Tangent | Vector 3 | Object Space Tangent | Defines the absolute object space vertex tangent per vertex.|
| ![image](images/Blocks-Vertex-Color.png) | Color | Vector 4 | Vertex Color | Defines vertex color. Expected range 0 - 1. |
## Fragment Blocks
| | Name | Type | Binding | Description |
|:-----------|:---------|:---------|:---------------------|:------------|
| ![image](images/Blocks-Fragment-Base-Color.png) | Base Color | Vector 3 | None | Defines material's base color value. Expected range 0 - 1. |
| ![image](images/Blocks-Fragment-NormalTS.png) | Normal (Tangent Space) | Vector 3 | Tangent Space Normal | Defines material's normal value in tangent space. |
| ![image](images/Blocks-Fragment-NormalOS.png) | Normal (Object Space) | Vector 3| Object Space Normal | Defines material's normal value in object space. |
| ![image](images/Blocks-Fragment-NormalWS.png) | Normal (World Space) | Vector 3 | World Space Normal | Defines material's normal value in world space. |
| ![image](images/Blocks-Fragment-Emission.png) | Emission | Vector 3 | None | Defines material's emission color value. Expects positive values. |
| ![image](images/Blocks-Fragment-Metallic.png) | Metallic | Float | None | Defines material's metallic value, where 0 is non-metallic and 1 is metallic. |
| ![image](images/Blocks-Fragment-Specular.png) | Specular | Vector 3 | None | Defines material's specular color value. Expected range 0 - 1. |
| ![image](images/Blocks-Fragment-Smoothness.png) | Smoothness | Float | None | Defines material's smoothness value. Expected range 0 - 1. |
| ![image](images/Blocks-Fragment-Ambient-Occlusion.png) | Ambient Occlusion | Float | None | Defines material's ambient occlusion value. Expected range 0 - 1. |
| ![image](images/Blocks-Fragment-Alpha.png) | Alpha | Float | None | Defines material's alpha value. Used for transparency and/or alpha clip. Expected range 0 - 1. |
| ![image](images/Blocks-Fragment-Alpha-Clip-Threshold.png) | Alpha Clip Threshold | Float | None | Fragments with an alpha below this value are discarded. Expected range 0 - 1. |

View File

@@ -0,0 +1,71 @@
# Calculate Level Of Detail Texture 2D node
The Calculate Level of Detail Texture 2D node takes an input **Texture 2D** and outputs the mip level of a Texture sample. This node is useful in situations where you need to know the mip level of a Texture, such as when you might want to modify the mip level before sampling in your shader.
![An image of the Graph window, that shows a Calculate Level of Detail Texture 2D node.](images/sg-calculate-level-detail-Texture-2d-node.png)
The Calculate Level of Detail Texture 2D node also has a clamped and unclamped mode:
- **Clamped**: The node clamps the returned mip level to the actual mips available on the Texture. The node uses the [CalculateLevelOfDetail](https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-to-calculate-lod) HLSL intrinsic function. Use this mode when you want to know which mip to sample your Texture from and restrict the result to an existing mip.
- **Unclamped**: The node returns the ideal mip level, based on an idealized Texture with all its mips present. The node uses the [CalculateLevelOfDetailUnclamped](https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-to-calculate-lod-unclamped) HLSL intrinsic function. Use this mode when you need a more generic value for your mip level.
For example, a Texture might only have 3 mips: a 64×64 mip, a 32×32 mip, and a 16×16 mip. When you use the Calculate Level Of Detail Texture 2D node in its **Clamped** mode, the node restricts the **LOD** output to one of the 3 mips on the Texture, even if the ideal mip level might be a smaller resolution, such as an 8×8 version. In its **Unclamped** mode, the node outputs the ideal 8×8 mip level, even though it doesn't exist on the Texture.
> [!NOTE]
> On platforms where these HLSL functions don't exist, Shader Graph determines an appropriate approximation to use, instead.
## Create Node menu category
The Calculate Level of Detail Texture 2D node is under the **Input** &gt; **Texture** category in the Create Node menu.
## Compatibility
The Calculate Level of Detail Texture 2D [!include[nodes-compatibility-all](./snippets/nodes-compatibility-all.md)] <!-- ALL PIPELINES INCLUDE -->
The Calculate Level of Detail Texture 2D [!include[nodes-fragment-only](./snippets/nodes-fragment-only.md)] <!-- FRAGMENT ONLY INCLUDE -->
## Inputs
The Calculate Level of Detail Texture 2D [!include[nodes-inputs](./snippets/nodes-inputs.md)]
| **Name** | **Type** | **Binding** | **Description** |
| :--- | :------ | :------ | :---------- |
| **Texture** | Texture 2D | None | The Texture to use in the mip level calculation. |
| **UV** | Vector 2 | UV | The UV coordinate to use to calculate the Texture's mip level. |
| **Sampler** | SamplerState | None | The Sampler State and corresponding settings to use to calculate the Texture's mip level. |
## Controls
The Calculate Level of Detail Texture 2D [!include[nodes-single-control](./snippets/nodes-single-control.md)]
| **Name** | **Type** | **Options** | **Description** |
| :--- | :--- | :------ | :---------- |
| **Clamp** | Toggle | True, False | When enabled, Shader Graph clamps the output mip level to the actual mips present on the provided **Texture** input. When disabled, Shader Graph returns an ideal mip level, based on an idealized Texture with all its mips present. |
## Outputs
The Calculate Level of Detail Texture 2D [!include[nodes-single-output](./snippets/nodes-single-output.md)] <!-- SINGLE OUTPUT PORT INCLUDE -->
| **Name** | **Type** | **Description** |
| :------ | :------- | :------------- |
| **LOD** | Float | The final calculated mip level of the Texture. |
## Example graph usage
In the following example, a Calculate Level of Detail Texture 2D node calculates the mip level of the **Leaves_Albedo** Texture for a set of UV coordinates and a specific Sampler State. It sends the calculated mip level for the Texture to the **LOD** input port on a Sample Texture 2D LOD node, which samples the same Texture:
![An image of the Graph window, that displays a Texture 2D asset node connected to a Calculate Level of Detail Texture 2D node. The node sends the calculated mip level as an input to the LOD input port on a Sample Texture 2D LOD node.](images/sg-calculate-level-detail-Texture-2d-node-example.png)
## Related nodes
<!-- OPTIONAL. Any nodes that may be related to this node in some way that's worth mentioning -->
[!include[nodes-related](./snippets/nodes-related.md)] Calculate Level of Detail Texture 2D node:
- [Sample Texture 2D LOD node](Sample-Texture-2D-LOD-Node.md)
- [Sampler State node](Sampler-State-Node.md)
- [Gather Texture 2D node](Gather-Texture-2D-Node.md)
- [Texture 2D Asset node](Texture-2D-Asset-Node.md)

View File

@@ -0,0 +1,38 @@
# Camera Node
## Description
Provides access to various parameters of the **Camera** currently being used for rendering. This is comprised of values the **Camera**'s GameObject, such as Position and Direction, as well as various projection parameters.
#### Unity Render Pipelines Support
- Universal Render Pipeline
The High Definition Render Pipeline does **not** support this Node.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Position | Output | Vector 3 | None | Position of the Camera's GameObject in world space |
| Direction | Output | Vector 3 | None | The Camera's forward vector direction |
| Orthographic | Output | Float | None | Returns 1 if the Camera is orthographic, otherwise 0 |
| Near Plane | Output | Float | None | The Camera's near plane distance |
| Far Plane | Output | Float | None | The Camera's far plane distance |
| Z Buffer Sign | Output | Float | None | Returns -1 when using a reversed Z Buffer, otherwise 1 |
| Width | Output | Float | None | The Camera's width if orthographic |
| Height | Output | Float | None | The Camera's height if orthographic |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
float3 _Camera_Position = _WorldSpaceCameraPos;
float3 _Camera_Direction = -1 * mul(UNITY_MATRIX_M, transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V)) [2].xyz);
float _Camera_Orthographic = unity_OrthoParams.w;
float _Camera_NearPlane = _ProjectionParams.y;
float _Camera_FarPlane = _ProjectionParams.z;
float _Camera_ZBufferSign = _ProjectionParams.x;
float _Camera_Width = unity_OrthoParams.x;
float _Camera_Height = unity_OrthoParams.y;
```

View File

@@ -0,0 +1,23 @@
# Ceiling Node
## Description
Returns the smallest integer value, or whole number, that is greater than or equal to the value of input **In**.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Ceiling_float4(float4 In, out float4 Out)
{
Out = ceil(In);
}
```

View File

@@ -0,0 +1,29 @@
# Channel Mask Node
## Description
Masks values of input **In** on channels selected in dropdown **Channels**. Outputs a vector of the same length as the input vector but with the selected channels set to 0. Channels available in the dropdown **Channels** will represent the amount of channels present in input **In**.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| In | Input | Dynamic Vector | None | Input value |
| Out | Output | Dynamic Vector | None | Output value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| Channels | Mask Dropdown | Dynamic | Selects any number of channels to mask |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_ChannelMask_RedGreen_float4(float4 In, out float4 Out)
{
Out = float4(0, 0, In.b, In.a);
}
```

View File

@@ -0,0 +1,38 @@
# Channel Mixer Node
## Description
Controls the amount each of the channels of input **In** contribute to each of the channels of output **Out**. The slider parameters on the node control the contribution of each of the input channels. The toggle button parameters control which of the output channels is currently being edited. Slider controls for editing the contribution of each input channnel range between -2 and 2.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| In | Input | Vector 3 | None | Input value |
| Out | Output | Vector 3 | None | Output value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| | Toggle Button Array | R, G, B | Selects the output channel to edit. |
| R | Slider | | Controls contribution of input red channel to selected output channel. |
| G | Slider | | Controls contribution of input green channel to selected output channel. |
| B | Slider | | Controls contribution of input blue channel to selected output channel. |
## Shader Function
## Generated Code Example
The following example code represents one possible outcome of this node.
```
_ChannelMixer_Red = float3 (OutRedInRed, OutRedInGreen, OutRedInBlue);
_ChannelMixer_Green = float3 (OutGreenInRed, OutGreenInGreen, OutGreenInBlue);
_ChannelMixer_Blue = float3 (OutBlueInRed, OutBlueInGreen, OutBlueInBlue);
void Unity_ChannelMixer_float(float3 In, float3 _ChannelMixer_Red, float3 _ChannelMixer_Green, float3 _ChannelMixer_Blue, out float3 Out)
{
Out = float3(dot(In, _ChannelMixer_Red), dot(In, _ChannelMixer_Green), dot(In, _ChannelMixer_Blue));
}
```

View File

@@ -0,0 +1,10 @@
# Channel Nodes
|[Combine](Combine-Node.md)| [Flip](Flip-Node.md) |
|:---------:|:---------:|
|![Image](images/CombineNodeThumb.png)|![Image](images/FlipNodeThumb.png)|
|Controls the amount each of the channels of input In contribute to each of the output channels.|Adjusts the contrast of input In by the amount of input Contrast.|
|[**Split**](Split-Node.md)|[**Swizzle**](Swizzle-Node.md)|
|![Image](images/SplitNodeThumb.png)|![Image](images/SwizzleNodeThumb.png)|
|Offsets the hue of input In by the amount of input Offset.|Inverts the colors of input In on a per channel basis.|

View File

@@ -0,0 +1,35 @@
# Checkerboard Node
## Description
Generates a checkerboard of alternating colors between inputs **Color A** and **Color B** based on input **UV**. The checkerboard scale is defined by input **Frequency**.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| UV | Input | Vector 2 | UV | Input UV value |
| Color A | Input | Color RGB | None | First checker color |
| Color B | Input | Color RGB | None | Second checker color |
| Frequency | Input | Vector 2 | None | Scale of checkerboard per axis |
| Out | Output | Vector 2 | None | Output UV value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Checkerboard_float(float2 UV, float3 ColorA, float3 ColorB, float2 Frequency, out float3 Out)
{
UV = (UV.xy + 0.5) * Frequency;
float4 derivatives = float4(ddx(UV), ddy(UV));
float2 duv_length = sqrt(float2(dot(derivatives.xz, derivatives.xz), dot(derivatives.yw, derivatives.yw)));
float width = 1.0;
float2 distance3 = 4.0 * abs(frac(UV + 0.25) - 0.5) - width;
float2 scale = 0.35 / duv_length.xy;
float freqLimiter = sqrt(clamp(1.1f - max(duv_length.x, duv_length.y), 0.0, 1.0));
float2 vector_alpha = clamp(distance3 * scale.xy, -1.0, 1.0);
float alpha = saturate(0.5f + 0.5f * vector_alpha.x * vector_alpha.y * freqLimiter);
Out = lerp(ColorA, ColorB, alpha.xxx);
}
```

View File

@@ -0,0 +1,20 @@
# Circle Pupil Animation Node
This node applies a deformation to a normalized IrisUV coordinate to simulate the opening and closure of the pupil.
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| ------------------------------- | ----------------------------------- | ------------------------------------------ |
| **Circle Pupil Animation Node** | No | Yes |
## Ports
| name | **Direction** | type | description |
| -------------------------- | ------------- | ------- | ------------------------------------------------------------ |
| **IrisUV** | Input | Vector2 | Position of the fragment to shade in object space. |
| **Pupil Radius** | Input | float | Direction of the incident ray in object space. Either from the camera in rasterization or from the previous bounce in ray tracing. |
| **Maximal Pupil Aperture** | Input | float | The normal of the eye surface in object space. |
| **Minimal Pupil Aperture** | Input | float | The index of refraction of the eye (**1.333** by default). |
| **Pupil Apertur** | Input | float | Distance between the end of the cornea and the iris plane. For the default model, this value should be **0.02** |
| **IrisUV** | Output | Vector2 | Position of the refracted point on the iris plane in object space. |

View File

@@ -0,0 +1,25 @@
# Clamp Node
## Description
Returns the input **In** clamped between the minimum and maximum values defined by inputs **Min** and **Max** respectively.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Unclamped input value |
| Min | Input | Dynamic Vector | Minimum value |
| Max | Input | Dynamic Vector | Maximum value |
| Out | Output | Dynamic Vector | Clamped output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Clamp_float4(float4 In, float4 Min, float4 Max, out float4 Out)
{
Out = clamp(In, Min, Max);
}
```

View File

@@ -0,0 +1,27 @@
# Color Mask Node
## Description
Creates a mask from values in input **In** equal to input **Mask Color**. Input **Range** can be used to define a wider range of values around input **Mask Color** to create the mask. Colors within this range will return 1, otherwise the node will return 0. Input **Fuzziness** can be used to soften the edges around the selection similar to anti-aliasing.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| In | Input | Vector 3 | None | Input value. |
| Mask Color | Input | Vector 3 | Color | Color to use for mask. |
| Range | Input | Float | None | Select colors within this range from input **Mask Color**. |
| Fuzziness | Input | Float | None | Feather edges around selection. Higher values result in a softer selection mask. |
| Out | Output | Float | None | Output mask value. |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_ColorMask_float(float3 In, float3 MaskColor, float Range, float Fuzziness, out float4 Out)
{
float Distance = distance(MaskColor, In);
Out = saturate(1 - (Distance - Range) / max(Fuzziness, 1e-5));
}
```

View File

@@ -0,0 +1,55 @@
# Color Modes
## Description
Shader Graph can display colors on nodes in your graph to improve readability. This feature uses **Color Modes** to change which colors to display in the graph. Use the **Color Mode:** drop-down menu in the top right corner of the [Shader Graph Window](Shader-Graph-Window.md) to change the **Color Modes**.
![](images/Shader-Graph-Toolbar.png)
## Modes
| Name | Description |
|:-----|:------------|
| None | Does not display colors on the nodes. All nodes use the default gray. |
| Category | Displays colors on the nodes based on their assigned category. See **Category Colors** below. |
| Precision | Displays colors on the nodes based on the current [Precision Mode](Precision-Modes) in use. |
| User Defined | Lets you set the display colors on a per-node basis. These are custom colors for your graph. See **User Defined Colors** below. |
### Category Colors
This mode displays colors on the nodes based on their category. See the [Node Library](Node-Library.md) to learn about the different categories available.
![](images/Color-Mode-Category.png)
The table below lists current categories and their corresponding colors.
| Name | Color | Hex Value |
|:-----|:------|:----------|
| Artistic | ![#DB773B](https://placehold.it/15/DB773B/000000?text=+) | #DB773B |
| Channel | ![#97D13D](https://placehold.it/15/97D13D/000000?text=+) | #97D13D |
| Input | ![#CB3022](https://placehold.it/15/CB3022/000000?text=+) | #CB3022 |
| Math | ![#4B92F3](https://placehold.it/15/4B92F3/000000?text=+) | #4B92F3 |
| Procedural | ![#9C4FFF](https://placehold.it/15/9C4FFF/000000?text=+) | #9C4FFF |
| Utility | ![#AEAEAE](https://placehold.it/15/AEAEAE/000000?text=+) | #AEAEAE |
| UV | ![#08D78B](https://placehold.it/15/08D78B/000000?text=+) | #08D78B |
**Note:** [Sub Graph](Sub-Graph.md) nodes in a main [Shader Graph](Shader-Graph.md) fall in the Utility category. If you select **Category** mode, all Sub Graphs use the Utility color.
### Precision Colors
This mode displays colors on the nodes based on their current precision. If you set a node to **Inherit Precision**, the display color reflects the currently active precision. See [Precision Modes](Precision-Modes.md) for more information about inheritance.
### User Defined Colors
This mode displays colors on the nodes based on user preferences. In this mode, the user defines colors for each node. If a custom color is not set, the node displays in the default gray.
To set a custom color for a node, right-click on the target node to bring up the the context menu, and select **Color**.
| Option | Description |
|:-------|:------------|
| Change... |Brings up a color picker menu and lets you set your own custom color on the node. |
| Reset | Removes the currently selected color and sets it to the default gray. |
![](images/Color-Mode-User-Defined.png)
## Overriding Default Colors
For each project, you can override preset colors in the **Category** and **Precision** modes. Unity uses a `.uss` style sheet and Hex color codes to set colors. The default style sheet in your project is `Packages/com.unity.shadergraph/Editor/Resources/Styles/ColorMode.uss`.
The best practice is to create a copy of this file to override the presets. Under your project's **Assets** folder, create a new `Editor/Resources/Styles` folder structure, and place a copy of `ColorMode.uss` in the `Styles` folder. Change the Hex color codes in this `.uss` file to override the presets and use your own custom colors for the **Category** and **Precision** modes.

View File

@@ -0,0 +1,28 @@
# Color Node
## Description
Defines a constant **Vector 4** value in the shader using a **Color** field. Can be converted to a **Color** [Property Type](Property-Types.md) via the [Node's](Node.md) context menu. The value of the **Mode** parameter will also respected when generating the [Property](Property-Types.md).
NOTE: In versions prior to 10.0, Shader Graph assumed that HDR colors from the Color Node were in gamma space. Version 10.0 corrected this behavior, and Shader Graph now interprets HDR colors in linear space. HDR Color nodes that you created with older versions maintain the old behavior, but you can use the [Graph Inspector](Internal-Inspector.md) to upgrade them. To mimic the old behavior on a new HDR Color node, you can use a [Colorspace Conversion Node](Colorspace-Conversion-Node.md) to convert the HDR color from **RGB** to **Linear**.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Out | Output | Vector 4 | None | Output value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| | Color | | Defines the output value. |
| Mode | Dropdown | Default, HDR | Sets properties of the Color field |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
float4 _Color = IsGammaSpace() ? float4(1, 2, 3, 4) : float4(SRGBToLinear(float3(1, 2, 3)), 4);
```

View File

@@ -0,0 +1,128 @@
# Colorspace Conversion Node
## Description
Returns the result of converting the value of input **In** from one colorspace space to another. The spaces to transform from and to are defined by the values of the dropdowns on the node.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Vector 3 | Input value |
| Out | Output | Vector 3 | Output value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| From | Dropdown | RGB, Linear, HSV | Selects the colorspace to convert from |
| To | Dropdown | RGB, Linear, HSV | Selects the colorspace to convert to |
## Generated Code Example
The following example code represents one possible outcome of this node per from/to permutation.
**RGB > RGB**
```
void Unity_ColorspaceConversion_RGB_RGB_float(float3 In, out float3 Out)
{
Out = In;
}
```
**RGB > Linear**
```
void Unity_ColorspaceConversion_RGB_Linear_float(float3 In, out float3 Out)
{
float3 linearRGBLo = In / 12.92;;
float3 linearRGBHi = pow(max(abs((In + 0.055) / 1.055), 1.192092896e-07), float3(2.4, 2.4, 2.4));
Out = float3(In <= 0.04045) ? linearRGBLo : linearRGBHi;
}
```
**RGB > HSV**
```
void Unity_ColorspaceConversion_RGB_HSV_float(float3 In, out float3 Out)
{
float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
float4 P = lerp(float4(In.bg, K.wz), float4(In.gb, K.xy), step(In.b, In.g));
float4 Q = lerp(float4(P.xyw, In.r), float4(In.r, P.yzx), step(P.x, In.r));
float D = Q.x - min(Q.w, Q.y);
float E = 1e-10;
Out = float3(abs(Q.z + (Q.w - Q.y)/(6.0 * D + E)), D / (Q.x + E), Q.x);
}
```
**Linear > RGB**
```
void Unity_ColorspaceConversion_Linear_RGB_float(float3 In, out float3 Out)
{
float3 sRGBLo = In * 12.92;
float3 sRGBHi = (pow(max(abs(In), 1.192092896e-07), float3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4)) * 1.055) - 0.055;
Out = float3(In <= 0.0031308) ? sRGBLo : sRGBHi;
}
```
**Linear > Linear**
```
void Unity_ColorspaceConversion_Linear_Linear_float(float3 In, out float3 Out)
{
Out = In;
}
```
**Linear > HSV**
```
void Unity_ColorspaceConversion_Linear_HSV_float(float3 In, out float3 Out)
{
float3 sRGBLo = In * 12.92;
float3 sRGBHi = (pow(max(abs(In), 1.192092896e-07), float3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4)) * 1.055) - 0.055;
float3 Linear = float3(In <= 0.0031308) ? sRGBLo : sRGBHi;
float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
float4 P = lerp(float4(Linear.bg, K.wz), float4(Linear.gb, K.xy), step(Linear.b, Linear.g));
float4 Q = lerp(float4(P.xyw, Linear.r), float4(Linear.r, P.yzx), step(P.x, Linear.r));
float D = Q.x - min(Q.w, Q.y);
float E = 1e-10;
Out = float3(abs(Q.z + (Q.w - Q.y)/(6.0 * D + E)), D / (Q.x + E), Q.x);
}
```
**HSV > RGB**
```
void Unity_ColorspaceConversion_HSV_RGB_float(float3 In, out float3 Out)
{
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
float3 P = abs(frac(In.xxx + K.xyz) * 6.0 - K.www);
Out = In.z * lerp(K.xxx, saturate(P - K.xxx), In.y);
}
```
**HSV > Linear**
```
void Unity_ColorspaceConversion_HSV_Linear_float(float3 In, out float3 Out)
{
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
float3 P = abs(frac(In.xxx + K.xyz) * 6.0 - K.www);
float3 RGB = In.z * lerp(K.xxx, saturate(P - K.xxx), In.y);
float3 linearRGBLo = RGB / 12.92;
float3 linearRGBHi = pow(max(abs((RGB + 0.055) / 1.055), 1.192092896e-07), float3(2.4, 2.4, 2.4));
Out = float3(RGB <= 0.04045) ? linearRGBLo : linearRGBHi;
}
```
**HSV > HSV**
```
void Unity_ColorspaceConversion_HSV_HSV_float(float3 In, out float3 Out)
{
Out = In;
}
```

View File

@@ -0,0 +1,30 @@
# Combine Node
## Description
Creates new vectors from the four inputs **R**, **G**, **B** and **A**. Output **RGBA** is a **Vector 4** composed of inputs **R**, **G**, **B** and **A**. Output **RGB** is a **Vector 3** composed of inputs **R**, **G** and **B**. Output **RG** is a **Vector 2** composed of inputs **R** and **G**.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| R | Input | Float | None | Defines red channel of output |
| G | Input | Float | None | Defines green channel of output |
| B | Input | Float | None | Defines blue channel of output |
| A | Input | Float | None | Defines alpha channel of output |
| RGBA | Output | Vector 4 | None | Output value as **Vector 4** |
| RGB | Output | Vector 3 | None | Output value as **Vector 3** |
| RG | Output | Vector 2 | None | Output value as **Vector 2** |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Combine_float(float R, float G, float B, float A, out float4 RGBA, out float3 RGB, out float2 RG)
{
RGBA = float4(R, G, B, A);
RGB = float3(R, G, B);
RG = float2(R, G);
}
```

View File

@@ -0,0 +1,77 @@
# Comparison Node
## Description
Compares the two input values **A** and **B** based on the condition selected on the dropdown. This is often used as an input to the [Branch Node](Branch-Node.md).
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| A | Input | Float | None | First input value |
| B | Input | Float | None | Second input value |
| Out | Output | Boolean | None | Output value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| | Dropdown | Equal, NotEqual, Less, LessOrEqual, Greater, GreaterOrEqual | Condition for comparison |
## Generated Code Example
The following example code represents one possible outcome of this node per comparison type.
**Equal**
```
void Unity_Comparison_Equal_float(float A, float B, out float Out)
{
Out = A == B ? 1 : 0;
}
```
**NotEqual**
```
void Unity_Comparison_NotEqual_float(float A, float B, out float Out)
{
Out = A != B ? 1 : 0;
}
```
**Less**
```
void Unity_Comparison_Less_float(float A, float B, out float Out)
{
Out = A < B ? 1 : 0;
}
```
**LessOrEqual**
```
void Unity_Comparison_LessOrEqual_float(float A, float B, out float Out)
{
Out = A <= B ? 1 : 0;
}
```
**Greater**
```
void Unity_Comparison_Greater_float(float A, float B, out float Out)
{
Out = A > B ? 1 : 0;
}
```
**GreaterOrEqual**
```
void Unity_Comparison_GreaterOrEqual_float(float A, float B, out float Out)
{
Out = A >= B ? 1 : 0;
}
```

View File

@@ -0,0 +1,12 @@
# Compute Deformation Node
## Description
This node lets you pass compute deformed vertex data to a vertex shader, and only works with the [DOTS Hybrid Renderer](https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@latest/). You must provide `DeformedVertexData` in the `_DeformedMeshData` buffer. The node uses the `_ComputeMeshIndex` property to calculate where the `DeformedVertexData` associated with the current mesh are located in the `_DeformedMeshData` buffer. To output data, you must either install both the DOTS Hybrid Renderer and DOTS Animation packages, or use a custom solution.
## Ports
| Name | Direction | Type | Stage | Description |
|:--------- |:-----------|:--------|:-------|:------------|
| Position | Output | Vector3 | Vertex | Outputs the deformed vertex position. |
| Normal | Output | Vector3 | Vertex | Outputs the deformed vertex normal. |
| Tangent | Output | Vector3 | Vertex | Outputs the deformed vertex tangent. |

View File

@@ -0,0 +1,17 @@
# Compute Water Vertex Position
This node provides access to the water mesh vertex position. It's used in water instead of the [Position node](Position-Node.html).
The High Definition Render Pipeline (HDRP) uses this node in the default water shader graph. Don't modify the settings of this node. See the HDRP documentation for more information about [the Water System](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/WaterSystem.html).
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| ---------------------- | ----------------------------------- | ------------------------------------------ |
| **Compute Water Vertex Position** | No | Yes |
## Ports
| **Name** | **Direction** | **Type** | **Description** |
|--- | --- | --- | --- |
| **PositionWS** | Output | Vector3 | The position of the water surface vertex in world space. |

View File

@@ -0,0 +1,51 @@
# Constant Node
## Description
Defines a **Float** of a mathematical constant value in the shader.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Out | Output | Float | None | Output value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| Mode | Dropdown | PI, TAU, PHI, E, SQRT2 | Sets output constant value |
## Generated Code Example
The following example code represents one possible outcome of this node per constant type.
**PI**
```
float _Constant_PI = 3.1415926;
```
**TAU**
```
float _Constant_TAU = 6.28318530;
```
**PHI**
```
float _Constant_PHI = 1.618034;
```
**E**
```
float _Constant_E = 2.718282;
```
**SQRT2**
```
float _Constant_SQRT2 = 1.414214;
```

View File

@@ -0,0 +1,25 @@
# Contrast Node
## Description
Adjusts the contrast of input **In** by the amount of input **Contrast**. A **Contrast** value of 1 will return the input unaltered. A **Contrast** value of 0 will return the midpoint of the input.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| In | Input | Vector 3 | None | Input value |
| Contrast | Input | Float | None | Contrast value |
| Out | Output | Vector 3 | None | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Contrast_float(float3 In, float Contrast, out float3 Out)
{
float midpoint = pow(0.5, 2.2);
Out = (In - midpoint) * Contrast + midpoint;
}
```

View File

@@ -0,0 +1,20 @@
# Cornea Refraction Node
This node performs the refraction of the view ray in object space and returns the object space position that results. This is used to simulate the refraction that can be seen when looking at an eye.
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| -------------------------- | ----------------------------------- | ------------------------------------------ |
| **Cornea Refraction Node** | No | Yes |
## Ports
| name | **Direction** | type | description |
| ----------------------- | ------------- | ------- | ------------------------------------------------------------ |
| **Position OS** | Input | Vector3 | Position of the fragment to shade in object space. |
| **View Direction OS** | Input | Vector3 | Direction of the incident ray in object space. Either from the camera in rasterization or from the previous bounce in ray tracing. |
| **Cornea Normal OS** | Input | Vector3 | The normal of the eye surface in object space. |
| **Cornea IOR** | Input | float | The index of refraction of the eye (**1.333** by default). |
| **Iris Plane Offset** | Input | float | Distance between the end of the cornea and the iris plane. For the default model, this value should be **0.02** |
| **RefractedPositionOS** | Output | Vector3 | Position of the refracted point on the iris plane in object space. |

View File

@@ -0,0 +1,23 @@
# Cosine Node
## Description
Returns the cosine of the value of input **In**.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Cosine_float4(float4 In, out float4 Out)
{
Out = cos(In);
}
```

View File

@@ -0,0 +1,22 @@
# Create Node Menu
## Description
Use the **Create Node Menu** to create [nodes](Node.md) in Shader Graph. To open the **Create Node Menu**, either right-click on the workspace in the [Shader Graph Window](Shader-Graph-Window.md) and select **Create Node**, or press the spacebar.
At the top of the **Create Node Menu** is a search bar. To search for a node, type any part of its name in the search field. The search box gives you autocomplete options, and you can press Tab to accept the predictive text. It highlights matching text in yellow.
The **Create Node Menu** lists all nodes that are available in Shader Graph, categorized by their function. User-created [Sub Graphs](Sub-graph.md) are also available in the **Create Node Menu** under **Sub Graph Assets**, or in a custom category that you define in the Sub Graph Asset.
To add a node to the workspace, double-click it in the **Create Node Menu**.
### Contextual Create Node Menu
A contextual **Create Node Menu** filters the available nodes, and only shows those that use the [Data Type](Data-Types.md) of a selected edge. It lists every available [Port](Port.md) on nodes that match that Data Type.
To open a contextual **Create Node Menu**, click and drag an [Edge](Edge.md) from a Port, and then release it in an empty area of the workspace.
### Master Stack Create Node Menu
To add a new [Block Node]() to the [Master Stack](), either right click and select **Create Node** or press spacebar with the stack selected.
The **Create Node Menu** will display all available blocks for the master stack based on the render pipelines in your project. Any block can be added to the master stack via the **Create Node Menu**. If the block added is not compatible with the current Graph settings, the block will be disabled until the settings are configured to support it.

View File

@@ -0,0 +1,50 @@
# Creating a new Shader Graph Asset
After you configure an SRP, you can create a new Shader Graph Asset. Right-click the Project window, locate **Create** > **Shader Graph** in the context menu, then select your desired type of Shader Graph.
The type of Shader Graph available is dependent on the render pipelines present in your project. Some options may or may not be present based on the render pipelines.
The following options are always available:
| | | |
|:------------|:----------------|:------------|
| Blank Shader Graph | A completely blank shader graph. No target is selected and no blocks are added to the Master Stack. |
| Sub Graph | A blank sub graph asset. |
A sub menu for each installed render pipeline may be present containing template stacks for standard shading models ( Lit, Unlit, etc ).
For a full list of provided options, refer to the [Universal Render Pipeline](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@latest) and [High Definition Render Pipeline](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest) documentation.
For this example, Universal is installed so a Unversal Lit Shader Graph has been created.
Double-click your newly created Shader Graph Asset to open it in the Shader Graph window.
## Shader Graph window
The Shader Graph window consists of the Master Stack, the Preview Window, the Blackboard, and the Graph Inspector.
![](images/ShaderGraphWindow.png)
### Master Stack
The final connection that determines your shader output. Refer to [Master Stack](Master-Stack) for more information.
### Preview window
An area to preview the current shader output. Here, you can rotate the object, and zoom in and out. You can also change the basic mesh on which the shader is previewed. Refer to [Main Preview](Main-Preview) for more information.
![img](images/MainPreview.png)
### Blackboard
An area that contains all of the shader's properties in a single, collected view. Use the Blackboard to add, remove, rename, and reorder properties. Refer to [Blackboard](Blackboard) for more information.
![](images/Blackboard.png)
After you've set up a project, and become familiar with the Shader Graph window, refer to [My first Shader Graph](First-Shader-Graph) for more information on how to get started.
### Internal Inspector
An area that contains information contextual to whatever the user is currently clicking on. It's a window that automatically is hidden by default and only appears when something is selected that can be edited by the user. Use the Internal Inspector to display and modify properties, node options, and the graph settings. Refer to [Internal Inspector](Internal-Inspector.md) for more information.
![](images/Inspector.png)

View File

@@ -0,0 +1,24 @@
# Cross Product Node
## Description
Returns the cross product of the values of the inputs **A** and **B**. The cross product of two vectors results in a third vector which is perpendicular to the two input vectors. The result's magnitude is equal to the magnitudes of the two inputs multiplied together and then multiplied by the sine of the angle between the inputs. You can determine the direction of the result vector using the "left hand rule".
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| A | Input | Vector 3 | First input value |
| B | Input | Vector 3 | Second input value |
| Out | Output | Vector 3 | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_CrossProduct_float(float3 A, float3 B, out float3 Out)
{
Out = cross(A, B);
}
```

View File

@@ -0,0 +1,17 @@
# Cubemap Asset Node
## Description
Defines a constant **Cubemap Asset** for use in the shader. To sample the **Cubemap Asset** it should be used in conjunction with a [Sample Cubemap Node](Sample-Cubemap-Node.md). When using a separate **Cubemap Asset Node** you can sample a **Cubemap** twice, with different parameters, without defining the **Cubemap** itself twice.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Out | Output | Cubemap | None | Output value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| | Object Field (Cubemap) | | Defines the cubemap asset from the project. |

View File

@@ -0,0 +1,141 @@
# Custom Function Node
![01](images/Custom-Function-Node.png)
## Description
The Custom Function Node enables you to inject your own custom HLSL code in Shader Graphs. This provides you with an extra level of control when you need it (for example, to do some fine-grained optimization). You can either write small functions directly into graphs by using the string mode, or reference external HLSL include files. Use the [Custom Port Menu](Custom-Port-Menu.md) to define your own input and output ports on the node itself.
## How to Use
Use the [Create Node Menu](Create-Node-Menu.md) to create Custom Function nodes. By default, new Custom Function nodes don't have any input or output ports.
In the [Graph Inspector](Internal-Inspector.md), open the **Node Settings** to access the Custom Function and [Custom Port Menu](Custom-Port-Menu.md) menus.
![02](images/Custom-Function-Node-File.png) ![03](images/Custom-Function-Node-String.png)
### Custom Function menu
| Menu Item | Description |
|:----------|:------------|
| Inputs | A [Custom Port Menu](Custom-Port-Menu.md) that defines the node's input ports. |
| Outputs | A [Custom Port Menu](Custom-Port-Menu.md) that defines the node's input ports. |
| Type | A function type selector. Choose File to reference an external file or string to directly input functions to the node. |
| Name | Part of the name this custom function has in the final generated code. Suffixed by the function type ` _half ` or ` _float `. |
| Source | An asset field to reference the external HLSL include file. **Only available in `File` mode**. |
| Body | A text box where you enter HLSL code. **Only available in `String` mode**. |
### Defining the Function via string
If you select `String` mode, the graph generates the shader function. The `Name` field defines the name of the generated function, and the `Body` field defines the contents of the generated function. Unity handles the arguments, braces, and indent scope automatically. In `String` mode you may use the token `$precision` instead of `half` or `float` in the `Body` field. Unity replaces this with the correct type, based on that node's precision, when the node is processed.
![04](images/Custom-Function-Node-String-wFunction.png)
The example in the image above generates the following function:
```
void MyFunction_float(float3 A, float B, out float3 Out)
{
Out = A + B + 1/2;
}
```
### Defining the Function via file
If you select `File` mode, the graph does not automatically generate the shader function. This mode injects an include reference in the final generated shader, and uses a function from within the referenced file. The `Name` field must match the name of the function you wish to call. The `Source` field contains a reference to the HLSL file that includes the function.
![06](images/Custom-Function-Node-File-wFunction.png)
When you use `File` mode for the Custom Function node, you must manually format the functions properly. One thing to note when creating custom functions for [Shader Graph](Shader-Graph.md) is the precision suffixes. The generated code appends a precision suffix to function names. Your include file function must also append your desired precision suffix (shown below with `_float`), or contain multiple functions with both `_float` and `_half` suffixes, but your `Name` field **must not include the precision suffix**.
```
//UNITY_SHADER_NO_UPGRADE
#ifndef MYHLSLINCLUDE_INCLUDED
#define MYHLSLINCLUDE_INCLUDED
void MyFunction_float(float3 A, float B, out float3 Out)
{
Out = A + B;
}
#endif //MYHLSLINCLUDE_INCLUDED
```
`File` mode allows for more flexbility with custom functions in a graph. You can define uniform variables outside of the function scope, as shown here with a matrix.
```
//UNITY_SHADER_NO_UPGRADE
#ifndef MYHLSLINCLUDE_INCLUDED
#define MYHLSLINCLUDE_INCLUDED
float4x4 _MyMatrix;
void MyFunction_float(float3 A, float B, out float3 Out)
{
A = mul(float4(A, 0.0), _MyMatrix).rgb;
Out = A + B;
}
#endif //MYHLSLINCLUDE_INCLUDED
```
You can define multiple functions in the same file, and call them from your referenced function. Alternatively, you can reference the same file, but use different functions from different Custom Function nodes.
```
//UNITY_SHADER_NO_UPGRADE
#ifndef MYHLSLINCLUDE_INCLUDED
#define MYHLSLINCLUDE_INCLUDED
float3 MyOtherFunction_float(float3 In)
{
return In * In;
}
void MyFunction_float(float3 A, float B, out float3 Out)
{
A = MyOtherFunction_float(A);
Out = A + B;
}
#endif //MYHLSLINCLUDE_INCLUDED
```
You can even include other files that contain other functions.
```
//UNITY_SHADER_NO_UPGRADE
#ifndef MYHLSLINCLUDE_INCLUDED
#define MYHLSLINCLUDE_INCLUDED
#include "Assets/MyOtherInclude.hlsl"
void MyFunction_float(float3 A, float B, out float3 Out)
{
A = MyOtherFunction_float(A);
Out = A + B;
}
#endif //MYHLSLINCLUDE_INCLUDED
```
### Reusing Custom Function Nodes
The Custom Function node, on its own, is a single node instance. If you wish to re-use the same custom functions without re-creating the inputs, outputs, and function referencing, use [Sub Graphs](Sub-graph.md). Sub Graphs appear in the [Create Node Menu](Create-Node-Menu.md), and they enable you to share or re-use your custom functions.
![11](images/Custom-Function-Node-Subgraph.png)
Create your custom function either directly in a Sub Graph, or right-click the existing Custom Function node and select `Convert to Sub Graph`. To add the appropriate input and output ports, use the [Graph Inspector](Internal-Inspector.md) and [Custom Port Menu](Custom-Port-Menu.md). After this, you can reuse your custom function as many times as needed, even within other Sub Graphs.
### Working with texture wires
From version 10.3, Shader Graph has five new data structures to ensure that Custom Function Nodes (CFNs) and SubGraphs input and output data from texture wires in a consistent way. The new structures also make it possible for SamplerState to compile on [GLES2](https://en.wikipedia.org/wiki/OpenGL_ES#OpenGL_ES_2.0) platforms and access data associated with textures via `myInputTex.samplerstate` and `myInputTex.texelSize`.
Four structures are for the texture types, and one is for the sampler state:
* UnityTexture2D
* UnityTexture2DArray
* UnityTexture3D
* UnityTextureCube
* UnitySamplerState
CFNs you create with earlier versions of Shader Graph continue to work after this change. As part of the automatic update, Unity transitions them to the new **Bare** node type. This type replicates the old input and output behavior. All other types pass the new structs.
However, you should manually upgrade CFNs that produce texture or samplerstate types as output to ensure that they behave consistently—and to gain the benefits of the new design. Unity flags this type of outdated Custom Function Nodes with a warning when you open your Shader Graph in 10.3 or later.
#### How to upgrade
1. Change all of the input and output types from **Bare** to **non-Bare**.<br/>
* **String** type: Ensure that your HLSL string already uses Unity's texture access macros (such as `SAMPLE_TEXTURE2D`).
* **File** type: Replace Bare types (such as Texture2D) with the new struct types (such as UnityTexture2D) in your function parameters.
2. If your HLSL code is using platform-specific or non-standard texture operations, you'll need to convert the way you access textures to take that structure into account. For example, `myInputTex.GetDimensions(...)` would become `myInputTex.tex.GetDimensions(...)`
From version 10.3, you can access data associated with textures via `myInputTex.samplerstate` and `myInputTex.texelSize`.

View File

@@ -0,0 +1,65 @@
# Custom Interpolators
## Description
The Custom Interpolator feature provides fine-grained control over the specific calculations Shader Graph uses to bring data from the vertex stage to the pixel stage.
There are two target audiences for Custom Interpolators:
* Technical Directors and Lead Technical Artists setting up environments for their teams.
* Graphics programmers helping artists to optimize content performance.
## Supported data types
Custom interpolators support float, vec2, vec3, and vec4 options.
## Channel limits
The Custom Interpolator feature supports a maximum of 32 channels. A channel is equivalent to four floats. Each float is an interpolator variable.
Different platforms and GPUs have different interpolator variable limits. Exceeding the interpolator limitations of your target platform prevents your shaders from compiling. For detailed information about the number of interpolators supported by common interfaces, see the Unity documentation on [Shader semantics](https://docs.unity3d.com/Manual/SL-ShaderSemantics.html), and view the section **Interpolator count limits**. Test your Custom Interpolators on your target configuration to ensure that your content compiles properly.
Technical directors can set warnings and errors to help their team members avoid creating graphs with too many channels to be compatible with their target pipeline, platform, or GPU. See **Creating channel warnings and errors** below.
## How to use
To use this feature, create a Custom Interpolator block in the Vertex context of the Master Stack and set a name and a data type. Create a vertex node to write data to that interpolator. Use the interpolator in your graph, then connect your graph to the relevant block in the Fragment context.
These instructions include a contextual example illustrating the process of using a Custom Interpolator to fetch per-vertex data from a texture.
To read the HLSL you use to replicate this behavior with the Built In Render Pipeline, see the Unity documentation on [Shader semantics](https://docs.unity3d.com/Manual/SL-ShaderSemantics.html) and view the section **Vertex ID: SV_VertexID**.
### Creating channel warnings and errors
It is not possible to limit the number of channels a user can create in a Shader Graph. However, it is possible to create alerts to let users know when they are close to or exceeding a certain number of channels.
The **Warning Threshold** lets users know that they are approaching the channel limit, and the **Error Threshold** informs them if they have reached or surpassed that limit. The **Warning Threshold** value must be between 8 and 32 channels. The **Error Threshold** value must be higher than the **Warning Threshold**, and has a minimum value of 8 channels.
To configure these parameters, go to the Unity Editor [Project Settings](https://docs.unity3d.com/Manual/comp-ManagerGroup.html) menu and open the **Custom Interpolator Channel Settings**.
### Adding a Custom Interpolator block to the Master Stack
![](images/custom-interpolators-3.gif) ![](images/custom-interpolators-2.png)
1. Right-click in the **Vertex** contex to create a block node.
2. Select **Custom Interpolator**.
3. Select a data type.
4. Enter a name for this interpolator.
In the illustrated example, you use the Vector 4 (vec4) data type.
### Writing data to the interpolator
![](images/custom-interpolators-1.png)
1. Right-click in your graph to create a node.
2. Select the type **Vertex ID**.
3. Connect this node to the Custom Interpolator block.
In the example, you write Vertex ID values from your graph into the Custom Interpolator.
### Reading data from the interpolator
1. Right-click in your graph to create a node.
2. Select **Custom Interpolator**.
3. Connect the Custom Interpolator node to the relevant block in the Fragment context.
![](images/custom-interpolators-4.png)
In this example, you connect to the **Base Color** block in order to pass the Vertex ID from the vertex shader to the fragment shader and use it as color output.
### Deleting the block from the Master Stack
If you delete a Custom Interpolator which is associated with nodes that are still in your graph, Unity displays an alert. If you want to keep using these nodes, you can create a new Custom Interpolator and associate them with it. This prevents the alert from appearing.

View File

@@ -0,0 +1,31 @@
# Custom Port Menu
## Description
The Custom [Port](Port.md) Menu is displayed in the **Node Settings** tab of the [Graph Inspector](Internal-Inspector) by clicking on the [Custom Function Node](Custom-Function-Node.md) and [Sub Graph](Sub-graph.md) output node. This menu allows you to add, remove, rename, reorder, and define the types of your custom input and output ports.
## How to Use
Select the [Custom Function Node](Custom-Function-Node.md) or the [Sub Graph](Sub-graph.md) output node to view the Custom Port Menu in the Inspector. To close the menu, click anywhere in the graph or on another graph-element.
![01](images/Custom-Port-Menu-Empty.png)
### Adding and Removing Ports
To add ports, click the `+` icon at the bottom right corner of the port list.
![02](images/Custom-Port-Menu-Add.png)
To remove ports, select a port using the hamburger icon on the left, and click the `-` icon at the bottom right corner of the port list.
![03](images/Custom-Port-Menu-Remove.png)
### Renaming Ports
To rename a port, double-click its text field and enter the new name. Currently, only the following characters are valid for port names: A-Z, a-z, 0-9, _, ( ), and whitespace. If the name contains an invalid character, an error badge appears.
![04](images/Custom-Port-Menu-Rename.png)
### Reordering Ports
To reorder ports, click and hold the hamburger icon on the left, and drag the port to your desired place in the list.
### Changing Port Types
To change a port type, use the Type drop-down menu on the right. See the [Data Types](Data-Types.md) page for a list of currently valid port types.
![05](images/Custom-Port-Menu-Type.png)

View File

@@ -0,0 +1,23 @@
# DDX Node
## Description
Returns the partial derivative of the input **In** with respect to the screen-space x-coordinate. This node can only be used in the pixel shader stage.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output partial derivative value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_DDX_float4(float4 In, out float4 Out)
{
Out = ddx(In);
}
```

View File

@@ -0,0 +1,23 @@
# DDXY Node
## Description
Returns the sum of both partial derivatives of input **In**, with respect to the screen-space x-coordinate and screen-space y-coordinate respectively. This node can only be used in the pixel shader stage.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output partial derivative value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_DDXY_float4(float4 In, out float4 Out)
{
Out = ddxy(In);
}
```

View File

@@ -0,0 +1,23 @@
# DDY Node
## Description
Returns the partial derivative of the input **In** with respect to the screen-space y-coordinate. This node can only be used in the pixel shader stage.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output partial derivative value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_DDY_float4(float4 In, out float4 Out)
{
Out = ddy(In);
}
```

View File

@@ -0,0 +1,52 @@
# Data Types
## Description
There are a number of **Data Types** in [Shader Graph](Shader-Graph.md). Each **Port** on a [Node](Node.md) has an associated **Data Type** that defines what edges can be connected to it. The **Data Types** have colors for usability, these colors are applied to ports and edges of that **Data Type**.
Some **Data Types** have associated [Property Types](Property-Types.md) for exposing these values to the [Inspector](https://docs.unity3d.com/Manual/UsingTheInspector.html) for [Materials](https://docs.unity3d.com/Manual/class-Material.html) that use the shader.
## Data Types
| Name | Color | Description |
|:------------|:----------------|:------------|
| Float | Light Blue | A **Float** or scalar value |
| Vector 2 | Green | A **Vector 2** value |
| Vector 3 | Yellow | A **Vector 3** value |
| Vector 4 | Pink | A **Vector 4** value |
| Dynamic Vector | Light Blue | See **Dynamic Data Types** below |
| Matrix 2 | Blue | A **Matrix 2x2** value |
| Matrix 3 | Blue | A **Matrix 3x3** value |
| Matrix 4 | Blue | A **Matrix 4x4** value |
| Dynamic Matrix | Blue | See **Dynamic Data Types** below |
| Dynamic | Blue | See **Dynamic Data Types** below |
| Boolean | Purple | A **Boolean** value. Defined as a float in the generated shader |
| Texture 2D | Red | A [Texture 2D](https://docs.unity3d.com/Manual/class-TextureImporter.html) asset |
| Texture 2D Array | Red | A [Texture 2D Array](https://docs.unity3d.com/Manual/class-TextureImporter.html) asset |
| Texture 3D | Red | A [Texture 3D](https://docs.unity3d.com/Manual/class-TextureImporter.html) asset |
| Cubemap | Red | A [Cubemap](https://docs.unity3d.com/Manual/class-Cubemap.html) asset |
| Virtual Texture | Gray | A [Texture Stack](https://docs.unity3d.com/2020.1/Documentation/Manual/svt-use-in-shader-graph.html) |
| Gradient | Gray | A **Gradient** value. Defined as a struct in the generated shader |
| SamplerState | Gray | A state used for sampling a texture |
## Promoting/Truncating
All **Vector** types can be promoted or truncated to match any **Vector** type [Port](Port.md). This behaviour occurs only when the [Port](Port.md) in question is not of type **Dynamic Vector**. When truncating, excess channels are simply removed. When promoting, the extra required channels are filled by default values. These values values are (0, 0, 0, 1).
## Dynamic Data Types
Some **Data Types** are dynamic. This means a port using these **Data Types** can change their underlying **Concrete Data Type** based on what **Data Type** is connected to it. By default, [Nodes](Node.md) using dynamic **Data Types** can only have one **Concrete Data Type**, meaning that once a connected edge has applied its **Data Type** to that port, all other **Dynamic Data Type** slots of that [Node](Node.md) will apply the same **Data Type**.
One notable exception to this is the [Multiply Node](Multiply-Node.md) which allows both **Dynamic** **Matrix** and **Vector** types.
### Dynamic Vector
The **Dynamic Vector** type allows connected edges of any **Vector** type. All connected edges are automatically truncated to the type with the lowest dimension, unless the lowest dimension is 1, in which case the **Float** is promoted.
### Dynamic Matrix
The **Dynamic Matrix** type allows connected edges of any **Matrix** type. All connected edges are automatically truncated to the type with the lowest dimension.
### Dynamic
The **Dynamic** type is a special case. [Nodes](Node.md) that support it must define how it is validated. In the case of the [Multiply Node](Multiply-Node.md), it allows connections of any **Vector** or **Matrix** type, ensuring the correct multiplication is applied depending on the mix of **Data Types**.

View File

@@ -0,0 +1,25 @@
# Degrees To Radians Node
## Description
Returns the value of input **In** converted from degrees to radians.
One degree is equivalent to approximately 0.0174533 radians and a full rotation of 360 degrees is equal to 2 Pi radians.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_DegreesToRadians_float4(float4 In, out float4 Out)
{
Out = radians(In);
}
```

View File

@@ -0,0 +1,59 @@
# Dielectric Specular Node
## Description
Returns a **Dielectric Specular** F0 value for a physically based material. The material to use can be selected with the **Material** dropdown parameter on the [Node](Node.md).
A **Common** **Material** type defines a range between 0.034 and 0.048 sRGB values. The value between this range can be selected with the **Range** parameter. This **Material** type should be used for various materials such as plastics and fabrics.
You can use **Custom** material type to define your own physically based material value. The output value in this case is defined by its index of refraction. This can be set by the parameter **IOR**.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Out | Output | Float | None | Output value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| Material | Dropdown | Common, RustedMetal, Water, Ice, Glass, Custom | Selects the material value to output. |
| Range | Slider | | Controls output value for **Common** material type. |
| IOR | Slider | | Controls index of refraction for **Custom** material type. |
## Generated Code Example
The following example code represents one possible outcome of this node per **Material** mode.
**Common**
```
float _DielectricSpecular_Range = 0.5;
float _DielectricSpecular_Out = lerp(0.034, 0.048, _DielectricSpecular_Range);
```
**RustedMetal**
```
float _DielectricSpecular_Out = 0.030;
```
**Water**
```
float _DielectricSpecular_Out = 0.020;
```
**Ice**
```
float _DielectricSpecular_Out = 0.018;
```
**Glass**
```
float _DielectricSpecular_Out = 0.040;
```
**Custom**
```
float _DielectricSpecular_IOR = 1;
float _DielectricSpecular_Out = pow(_Node_IOR - 1, 2) / pow(_DielectricSpecular_IOR + 1, 2);
```

View File

@@ -0,0 +1,21 @@
# Diffusion Profile Node
The Diffusion Profile Node allows you to sample a [Diffusion Profile](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Diffusion-Profile.html) Asset in your Shader Graph. For information on what a Diffusion Profile is and the properties that it contains, see the [Diffusion Profile documentation](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Diffusion-Profile.html).
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| ---------------------- | ----------------------------------- | ------------------------------------------ |
| Diffusion Profile Node | No | Yes |
## Ports
| name | **Direction** | type | description |
|--- | --- | --- | --- |
| **Out** | Output | float | Outputs a unique float that the Shader uses to identify the Diffusion Profile. |
## Notes
The output of this Node is a float value that represents a Diffusion Profile. The Shader can use this value to find settings for the Diffusion Profile Asset that this value represents.
If you modify the output value, the Shader can no longer use it to find the settings for the Diffusion Profile Asset. You can use this behavior to enable and disable Diffusion Profiles in your Shader Graph. To disable a Diffusion Profile, multiply the output by **0**. To enable a Diffusion Profile, multiply the output by **1**. This allows you to use multiple Diffusion Profiles in different parts of your Shader Graph. Be aware that the High Definition Render Pipeline (HDRP) does not support blending between Diffusion Profiles. This is because HDRP can only evaluate a single Diffusion Profile per pixel.

View File

@@ -0,0 +1,24 @@
# Distance Node
## Description
Returns the euclidean distance between the values of the inputs **A** and **B**. This is useful for, among other things, calculating the distance between two points in space and is commonly used in calculating a [Signed Distance Function](https://en.wikipedia.org/wiki/Signed_distance_function).
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| A | Input | Dynamic Vector | First input value |
| B | Input | Dynamic Vector | Second input value |
| Out | Output | Float | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Distance_float4(float4 A, float4 B, out float Out)
{
Out = distance(A, B);
}
```

View File

@@ -0,0 +1,35 @@
# Dither Node
## Description
Dither is an intentional form of noise used to randomize quantization error. It is used to prevent large-scale patterns such as color banding in images. The **Dither** node applies dithering in screen-space to ensure a uniform distribution of the pattern. This can be adjusted by connecting another node to input **Screen Position**.
This [Node](Node.md) is commonly used as an input to **Alpha Clip Threshold** on the [Master Node](Master-Stack.md) to give the appearance of transparency to an opaque item. This is useful for creating geometry that appears to be transparent but has the advantages of rendering as opaque, such as writing depth or being rendered in deferred.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| In | Input | Dynamic Vector | None | Input value |
| Screen Position | Input | Vector 4 | Screen Position | Coordinates used to apply dither pattern |
| Out | Output | Dynamic Vector | None | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Dither_float4(float4 In, float4 ScreenPosition, out float4 Out)
{
float2 uv = ScreenPosition.xy * _ScreenParams.xy;
float DITHER_THRESHOLDS[16] =
{
1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0,
13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0,
4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0,
16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0
};
uint index = (uint(uv.x) % 4) * 4 + uint(uv.y) % 4;
Out = In - DITHER_THRESHOLDS[index];
}
```

View File

@@ -0,0 +1,24 @@
# Divide Node
## Description
Returns the result of input **A** (dividend) divided by input **B** (divisor).
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| A | Input | Dynamic Vector | First input value |
| B | Input | Dynamic Vector | Second input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Divide_float4(float4 A, float4 B, out float4 Out)
{
Out = A / B;
}
```

View File

@@ -0,0 +1,28 @@
# Dot Product Node
## Description
Returns the dot product, or scalar product, of the two input vectors **A** and **B**.
The dot product is a value equal to the magnitudes of the two vectors multiplied together and then multiplied by the cosine of the angle between them.
For normalized input vectors, the **Dot Product** node returns 1 if they point in exactly the same direction, -1 if they point in completely opposite directions and 0 if the vectors are perpendicular.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| A | Input | Dynamic Vector | First input value |
| B | Input | Dynamic Vector | Second input value |
| Out | Output | Float | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_DotProduct_float4(float4 A, float4 B, out float Out)
{
Out = dot(A, B);
}
```

View File

@@ -0,0 +1,11 @@
# Edge
## Description
An **Edge** defines a connection between two [Ports](Port.md). **Edges** define how data flows through the [Shader Graph](Shader-Graph.md) node network. They can only be connected from an input [Port](Port.md) to an output [Port](Port.md).
Each **Edge** has a [Data Type](Data-Types.md) which defines what [Ports](Port.md) it can be connected to. Each [Data Type](Data-Types.md) has an associated color for identifying its type.
You can create a new **Edge** by clicking and dragging from a [Port](Port.md) with the left mouse button. Edges can be deleted with Delete (Windows), Command + Backspace (OSX) or from the context menu by right clicking on the [Node](Node.md).
You can open a contextual [Create Node Menu](Create-Node-Menu.md) by dragging an **Edge** from a [Port](Port.md) with the left mouse button and releasing it in an empty area of the workspace.

View File

@@ -0,0 +1,28 @@
# Ellipse Node
## Description
Generates an ellipse shape based on input **UV** at the size specified by inputs **Width** and **Height**. The generated shape can be offset or tiled by connecting a [Tiling And Offset Node](Tiling-And-Offset-Node.md). Note that in order to preserve the ability to offset the shape within the UV space the shape will not automatically repeat if tiled. To achieve a repeating dot effect first connect your input through a [Fraction Node](Fraction-Node.md).
NOTE: This [Node](Node.md) can only be used in the **Fragment** [Shader Stage](Shader-Stage.md).
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| UV | Input | Vector 2 | UV | Input UV value |
| Width | Input | Float | None | Ellipse width |
| Height | Input | Float | None | Ellipse height |
| Out | Output | Float | None | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Ellipse_float(float2 UV, float Width, float Height, out float4 Out)
{
float d = length((UV * 2 - 1) / float2(Width, Height));
Out = saturate((1 - d) / fwidth(d));
}
```

View File

@@ -0,0 +1,30 @@
# Emission Node
The Emission Node allows you to apply emission in your Shader Graph.
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| -------- | ----------------------------------- | ------------------------------------------ |
| Emission | No | Yes |
## Ports
| Name | Direction | Type | Description |
| :------------ | :-------- | :------------- | :----------------------------------------------------------- |
| **color** | Input | LDR Color(RGB) | Sets the low dynamic range (LDR) color of the emission. |
| **intensity** | Input | Float | Sets the intensity of the emission color. |
| **output** | Output | HDR Color(RGB) | Outputs the high dynamic range (HDR) color that this Node produces. |
## Notes
### Emission Unit
You can use two [physical light units](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Physical-Light-Units.html) to control the strength of the emission:
* [Nits](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Physical-Light-Units.html%23Nits).
* [EV<sub>100</sub>](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Physical-Light-Units.html%23EV).
### Exposure Weight
You can use Exposure Weight to determine how exposure affects emission. It is a value between **0** and **1** where. A value of **0** means that exposure does not effect this part of the emission. A value of **1** means that exposure fully affects this part of the emission.

View File

@@ -0,0 +1,26 @@
# Evaluate Foam Data
This node calculates water foam intensity.
This node outputs foam as monochrome in the red channel. If you connect the output of this node to a **Base Color** block, all the channels are red. To prevent this, split the output and use only the red channel. You can't apply a tint to foam.
The High Definition Render Pipeline (HDRP) uses this node in the default water shader graph. See the HDRP documentation for more information about [the Water System](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/WaterSystem.html).
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| ---------------------- | ----------------------------------- | ------------------------------------------ |
| **Evaluate Foam Data** | No | Yes |
## Ports
| **Name** | **Direction** | **Type** | **Description** |
|--- | --- | --- | --- |
| **SurfaceGradient** | Input | Vector3 | The perturbation of the normal, as a surface gradient.|
| **LowFrequencySurfaceGradient** | Input | Vector3 | The perturbation of the low frequency normal, as a surface gradient. The low frequency normal is the normal of the water surface without high frequency details such as ripples. |
| **SimulationFoam** | Input | Float | The amount of foam. HDRP uses this property in the default water shader graph to fetch foam data from the simulation. |
| **CustomFoam** | Input | Float | The amount of foam, if you create your own foam. |
| **SurfaceGradient** | Output | Vector3 | The calculated water surface normal, as a surface gradient. |
| **Foam** | Output | Float | The combination of the amount of foam and a foam texture. |
| **Smoothness** | Output | Float | The smoothness of the water surface. For more information about this property, see [Settings and Properties Related to the Water System](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/WaterSystem-Properties.html).|

View File

@@ -0,0 +1,21 @@
# Evaluate Refraction Data
This node calculates water refraction.
The High Definition Render Pipeline (HDRP) uses this node in the default water shader graph. See the HDRP documentation for more information about [the Water System](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/WaterSystem.html).
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| ---------------------- | ----------------------------------- | ------------------------------------------ |
| **Evaluate Refraction Data** | No | Yes |
## Ports
| **Name** | **Direction** | **Type** | **Description** |
|--- | --- | --- | --- |
| **NormalWS** | Input | Vector3 | The water surface normal in world space. |
| **LowFrequencyNormalWS** | Input | Vector3 | The low frequency normal of the water surface in world space. This is the normal of the water surface without high frequency details such as ripples. |
| **RefractedPositionWS** | Output | Vector3 | The refracted position of the water bed you observe through the water, in world space. |
| **DistortedWaterNDC** | Output | Vector2 | The screen space position of the refracted point. |
| **AbsorptionTint** | Output | Vector3 | An absorption factor that HDRP uses to blend between the water surface and the refracted underwater color. |

View File

@@ -0,0 +1,22 @@
# Evaluate Scattering Color
This node calculates the scattered diffuse color of water.
The High Definition Render Pipeline (HDRP) uses this node in the default water shader graph. See the HDRP documentation for more information about [the Water System](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/WaterSystem.html).
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| ---------------------- | ----------------------------------- | ------------------------------------------ |
| **Evaluate Scattering Color** | No | Yes |
## Ports
| **Name** | **Direction** | **Type** | **Description** |
|--- | --- | --- | --- |
| **AbsorptionTint** | Input | Vector3 | An absorption factor that HDRP uses to blend between the water surface and the refracted underwater color. |
| **LowFrequencyHeight** | Input | Float | The vertical displacement of the water surface. This doesn't include ripples. |
| **HorizontalDisplacement** | Input | Float | The horizontal displacement of the water surface. |
| **SSSMask** | Input | Float | Mask that defines where the water surface has subsurface scattering. |
| **DeepFoam** | Input | Float | The amount of foam under the water's surface. |
| **ScatteringColor** | Output | Vector3 | The diffuse color of the water. |

View File

@@ -0,0 +1,22 @@
# Evaluate Simulation Additional Data
This node provides access to Water's surface foam, surface gradient, and deep foam. You can also use this node to dampen the normals for each [water band](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/WaterSystem-simulation.html#simulation-bands).
The High Definition Render Pipeline (HDRP) uses this node in the default water shader graph to fetch data from the water simulation. Don't modify the settings of this node. See the HDRP documentation for more information about [the Water System](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/WaterSystem.html).
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| ---------------------- | ----------------------------------- | ------------------------------------------ |
| **Evaluate Simulation Additional Data** | No | Yes |
## Ports
| **Name** | **Direction** | **Type** | **Description** |
|--- | --- | --- | --- |
| **BandsMultiplier** | Input | Vector4 | The amount to dampen displacement for each water band. Bands are different wave frequencies that create swells, agitations or ripples on the water. |
| **SurfaceGradient** | Output | Vector3 | The perturbation of the normal, as a surface gradient.|
| **LowFrequencySurfaceGradient** | Output | Vector3 | The perturbation of the low frequency normal, as a surface gradient. The low frequency normal is the normal of the water surface without high frequency details such as ripples. |
| **SurfaceFoam** | Output | Float | The amount of foam. |
| **DeepFoam** | Output | Float | The amount of foam under the water's surface. |

View File

@@ -0,0 +1,26 @@
# Evaluate Simulation Caustics
This node calculates [water caustics](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/WaterSystem-caustics.html).
This node outputs caustics as monochrome in the red channel. If you connect the output of this node to a **Base Color** block, all the channels are red. To prevent this, split the output and use only the red channel. You can't apply a tint to caustics.
Caustics don't have an effect above the water unless you script this behavior. For example:
- If your scene contains a boat that sits in water, HDRP doesn't project caustics on the part of the boat's hull that's above water.
- A swimming pool inside a room doesn't bounce caustics off the walls or ceiling.
The High Definition Render Pipeline (HDRP) uses this node in the default water shader graph. See the HDRP documentation for more information about [the Water System](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/WaterSystem.html).
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| ---------------------- | ----------------------------------- | ------------------------------------------ |
| **Evaluate Simulation Caustics** | No | Yes |
## Ports
| **Name** | **Direction** | **Type** | **Description** |
|--- | --- | --- | --- |
| **RefractedPositionWS** | Input | Vector3 | The refracted position of the water bed you observe through the water, in world space. |
| **DistortedWaterNDC** | Input | Vector2 | The screen space position of the refracted point. |
| **Caustics** | Output | Float | The intensity of the caustics. |

View File

@@ -0,0 +1,21 @@
# Evaluate Water Simulation Displacement
This node calculates water surface displacement.
The High Definition Render Pipeline (HDRP) uses this node in the default water shader graph. See the HDRP documentation for more information about [the Water System](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/WaterSystem.html).
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| ---------------------- | ----------------------------------- | ------------------------------------------ |
| **Evaluate Water Simulation Displacement** | No | Yes |
## Ports
| **Name** | **Direction** | **Type** | **Description** |
|--- | --- | --- | --- |
| **PositionWS** | Input | Vector3 | The position of the water surface vertex in world space. |
| **BandsMultiplier** | Input | Vector4 | The amount to dampen displacement for each water band. Bands are different wave frequencies that create swells, agitations or ripples on the water. |
| **Displacement** | Output | Vector3 | The vertical and horizontal displacement of the water. |
| **LowFrequencyHeight** | Output | Float | The vertical displacement of the water surface. This doesn't include ripples. |
| **SSSMask** | Output | Float | Mask that defines where the water surface has subsurface scattering. |

View File

@@ -0,0 +1,19 @@
# Evaluate Tip Thickness
This node calculates the thickness of the water at the tips of waves.
The High Definition Render Pipeline (HDRP) uses this node in the default water shader graph. See the HDRP documentation for more information about [the Water System](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/WaterSystem.html).
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| ---------------------- | ----------------------------------- | ------------------------------------------ |
| **Evaluate Tip Thickness** | No | Yes |
## Ports
| **Name** | **Direction** | **Type** | **Description** |
|--- | --- | --- | --- |
| **LowFrequencyNormal** | Input | Vector3 | The low frequency normal of the water surface in world space. This is the normal of the water surface without high frequency details such as ripples. |
| **LowFrequencyHeight** | Input | Float | The vertical displacement of the water surface. This doesn't include ripples.|
| **TipThickness** | Output | Float | The thickness of the water in a wave tip. |

View File

@@ -0,0 +1,43 @@
# Exponential Node
## Description
Returns the exponential value of input **In**. The exponential base can be switched between base-e and base 2 from the **Base** dropdown on the node.
* **Base E** : Returns e to the power of input **In**
* **Base 2** : Returns 2 to the power of input **In**
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| Base | Dropdown | BaseE, Base2 | Selects the exponential base |
## Generated Code Example
The following example code represents one possible outcome of this node per **Base** mode.
**Base E**
```
void Unity_Exponential_float4(float4 In, out float4 Out)
{
Out = exp(In);
}
```
**Base 2**
```
void Unity_Exponential2_float4(float4 In, out float4 Out)
{
Out = exp2(In);
}
```

View File

@@ -0,0 +1,25 @@
# Exposure Node
The Exposure Node allows you to get the Camera's exposure value from the current or previous frame.
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| -------- | ----------------------------------- | ------------------------------------------ |
| Exposure | No | Yes |
## Ports
| name | **Direction** | type | description |
|--- | --- | --- | --- |
|**Output** |Output | float | The exposure value.|
## Exposure Type
You can use Exposure Type to select which exposure value to get.
| name | description |
|--- | ---|
| **CurrentMultiplier** | Gets the Camera's exposure value from the current frame. |
| **InverseCurrentMultiplier** | Gets the inverse of the Camera's exposure value from the current frame. |
| **PreviousMultiplier** | Gets the Camera's exposure value from the previous frame. |
| **InversePreviousMultiplier** | Gets the inverse of the Camera's exposure value from the previous frame. |

View File

@@ -0,0 +1,11 @@
# Eye Index Node
## Description
Provides access to the **Eye Index** when stereo rendering is enabled.
## Ports
| Name | Direction | Type | Binding | Description |
|:-------|:-----------|:------|:--------|:------------|
| Out | Output | Float | None | **Eye Index** for the camera of a stereo draw. |

View File

@@ -0,0 +1,20 @@
# Eye Surface Type Debug Node
Debug node that allows you to visually validate the current pupil radius.
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| ------------------------------- | ----------------------------------- | ------------------------------------------ |
| **Eye Surface Type Debug Node** | No | Yes |
## Ports
| name | **Direction** | type | description |
| ---------------- | ------------- | ------- | ------------------------------------------------------------ |
| **PositionOS** | Input | Vector3 | Position in object space of the current fragment to shade. |
| **EyeColor** | Input | Color | Final Diffuse color of the Eye. |
| **IrisRadius** | Input | float | The radius of the Iris in the used model. For the default model, this value should be **0.225**. |
| **Pupil Radius** | Input | float | Radius of the pupil in the iris texture as a percentage. |
| **IsActive** | Input | bool | Flag that defines if the node should be active. |
| **SurfaceColor** | Output | Color | Final Diffuse color of the Eye. |

View File

@@ -0,0 +1,34 @@
# Fade Transition Node
## Description
Fade Transition is a method of adding noise to add variation while a function transitions from on to off. This node takes in a fade value and remaps it using the noise value (usually from a texture). When FadeValue is 0, the output is always 0, and when FadeValue is 1, the output is always exactly 1. In between 0 and 1 the transition will follow the pattern in the noise.
This [Node](Node.md) is commonly used as an input to **Alpha** on a [Master Node](Master-Node.md) to provide an LOD transition.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Texture | Input | Texture 2D | None | Input value |
| Noise | Input | Float | None | The noise variation to apply to the fade function |
| FadeValue | Input | Float | None | The amount of transition to apply |
| FadeContrast | Input | Float | None | The contrast at which a single pixel goes from fully transparent to fully opaque. Higher values cause sharper edges in the transition |
| Fade | Output | Float | None | The resulting fade value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
float Unity_FadeTransitionNode_ApplyFade_float(float noise, float fadeValue, float fadeContrast)
{
float ret = saturate(fadeValue*(fadeContrast+1)+(noise-1)*fadeContrast);
return ret;
}
float Result = Unity_FadeTransitionNode_ApplyFade_float(
_NoiseValue,
_FadeValue,
_FadeContrast);
```

View File

@@ -0,0 +1,115 @@
# My first Shader Graph
Before you begin, make sure that your project is set up properly, and the graphs are loading correctly. See [Getting started with Shader Graph](Getting-Started.md) for more information.
## Create a New Graph
Use the Project Browser to create a new [Shader Graph Asset](Shader-Graph-Asset.md) in your project. The **Create > Shader Graph** will display the various creation options.
A **Blank Shader Graph** will create a Shader Graph with no selected active targets or [block nodes](Block-Node.md). You will need to select a target via the [Graph Settings Menu](Graph-Settings-Tab.md) to continue.
Certain integrations, like Render Pipelines, can also provide pre-configured options for Shader Graphs. For this example, a **Universal > Lit** Shader Graph has been created and opened.
## Create a new node
Use the **Create Node** menu to create new nodes. There are two ways to open the menu:
1. Right click, and select **Create Node** from the context menu.
2. Press the spacebar.
In the menu, you can type in the search bar to look for specific nodes, or browse all nodes in the library. In this example, we'll create a Color node. First, type "color" in the **Create Node** menu's search bar. Then, click **Color**, or highlight **Color** and press Enter to create a Color node.
![](images/MyFirstShaderGraph_01.png)
## Connect nodes
To build a graph, you need to connect nodes together. To do so, click the **Output Slot** of a node, and drag that connection into the **Input Slot** of another node.
Start by connecting the Color node to the **Base Color** block of our Fragment Stack.
![](images/MyFirstShaderGraph_02.png)
## Change node output
Notice that the connection updated the main preview, and the 3D Object in the **Main Preview** is now black, which is the color specified in the Color node. You can click on the color bar in that node, and use the color picker to change the color. Any changes you make on the node updates the object in the **Main Preview** in real time.
For example, if you pick red, the 3D Object immediately reflects this change.
![](images/MyFirstShaderGraph_03.png)
## Save the graph
Currently, Shader Graphs do not automatically save. There are two ways to save your changes:
1. Click the **Save Asset** button in the top left corner of the window.
3. Close the graph. If Unity detects any unsaved changes, a pop-up window appears, and asks if you want to save those changes.
![](images/MyFirstShaderGraph_04.png)
## Create a Material
After saving your graph, use the shader to create a new Material. The process of [creating a new Material](https://docs.unity3d.com/Manual/Materials.html) and assigning it a Shader Graph shader is the same as that for regular shaders. In either the main menu or the Project View context menu, select **Assets > Create > Material**. Select the Material you just created. In its Inspector window, select the **Shader** drop-down menu, click **Shader Graphs**, and choose the Shader Graph shader you wish to apply to the Material.
You can also right-click the Shader Graph shader, and select **Create > Material**. This method automatically assigns that Shader Graph shader to the newly created Material.
![](images/MyFirstShaderGraph_05.png)
A Material is also automatically generated as a subasset of the Shader Graph. You can assign it directly to an object in your scene. Modifying a property from the Blackboard on the Shader Graph will update this material in real time, which allows for quick visualization in the scene.
## Put the Material in the Scene
Now that you have assigned your shader to a Material, you can apply it to objects in the Scene. Drag and drop the Material onto an object in the Scene. Alternatively, in the object's Inspector window, locate **Mesh Renderer > Materials**, and apply the Material to the **Element**.
![](images/MyFirstShaderGraph_06.png)
## Use properties to edit the graph
You can also use properties to alter your shader's appearance. Properties are options that are visible from the Material's Inspector, which lets others change settings in your shader without the need to open the Shader Graph.
To create a new property, use the **Add (+)** button on the top right corner of the Blackboard, and select the type of property to create. In this example, we'll select **Color**.
![](images/MyFirstShaderGraph_07.png)
This adds a new property in the Blackboard with the following options in the **Node Settings** tab of the [Graph Inspector](Internal-Inspector.md) when the property is selected.
![](images/MyFirstShaderGraph_08.png)
| **Option** | **Description** |
| ------------------- | ------------------------------------------------------------ |
| **Property button** | To change the name of the property, right-click the button in the Blackboard, select **Rename**, then enter a new property name. To delete the property, right-click the button, and select **Delete**. |
| **Exposed** | Enable this checkbox to make the property visible from the Material's Inspector. |
| **Reference** | The property's name that appears in C# scripts. To change the **Reference** name, enter a new string. |
| **Default** | The default value of the property. |
| **Mode** | The mode of the property. Each property has different modes. For **Color**, you can select either **Default** or **HDR**. |
| **Precision** | The default [precision](Precision-Modes.md) of the property. |
| **Hybrid Instanced**| An experimental feature that enables this property to be instanced when using the Hybrid DOTS renderer. |
There are two ways to reference a property in your graph:
1. Drag the property from the Blackboard onto the graph.
2. Right-click and select **Create Node**. The property is listed in the **Properties** category.
![](images/MyFirstShaderGraph_09.png)
Try connecting the property to the **Base Color** block. The object immediately changes to black.
![](images/MyFirstShaderGraph_10.png)
Save your graph, and return to the Material's Inspector. The property now appears in the Inspector. Any changes you make to the property in the Inspector affects all objects that use this Material.
![](images/MyFirstShaderGraph_11.png)
## More Tutorials
Older tutorials use an outdated format of Shader Graph with master nodes. When looking at older tutorials, reference the [Upgrade Guide](Upgrade-Guide-10-0-x.md) for tips on how to convert the master node to a [Master Stack](Master-Stack.md).
To keep exploring how to use Shader Graph to author shaders, check out these blog posts:
- [Art That Moves: Creating Animated Materials with Shader Graph](https://blogs.unity3d.com/2018/10/05/art-that-moves-creating-animated-materials-with-shader-graph/)
- [Shader Graph Updates and Sample Project ](https://blogs.unity3d.com/2018/08/07/shader-graph-updates-and-sample-project/)
- [Custom Lighting in Shader Graph: Expanding Your Graphs in 2019](https://blogs.unity3d.com/2019/07/31/custom-lighting-in-shader-graph-expanding-your-graphs-in-2019/)
- [Unity 2018.3 Shader Graph Update: Lit Master Node](https://blogs.unity3d.com/2018/12/19/unity-2018-3-shader-graph-update-lit-master-node/)
- [Creating an Interactive Vertex Effect using Shader Graph](https://blogs.unity3d.com/2019/02/12/creating-an-interactive-vertex-effect-using-shader-graph/)
- [Introduction to Shader Graph: Build your shaders with a visual editor](https://blogs.unity3d.com/2018/02/27/introduction-to-shader-graph-build-your-shaders-with-a-visual-editor/)
You can also visit the [Unity YouTube Channel](https://www.youtube.com/channel/UCG08EqOAXJk_YXPDsAvReSg) and look for [video tutorials on Shader Graph](https://www.youtube.com/user/Unity3D/search?query=shader+graph), or head to our [user forum](https://forum.unity.com/forums/shader-graph.346/) to find the latest information and conversations about Shader Graph.

View File

@@ -0,0 +1,34 @@
# Flip Node
## Description
Flips the individual channels of input **In** selected by the [Node](Node.md)'s parameters. Positive values become negative values and vice versa.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| In | Input | Dynamic Vector | None | Input value |
| Out | Output | Dynamic Vector | None | Output value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| Red | Toggle | True, False | If true red channel will be flipped. |
| Green | Toggle | True, False | If true green channel will be flipped. Disabled if **In** is Float. |
| Blue | Toggle | True, False | If true blue channel will be flipped. Disabled if **In** is Vector 2 or smaller. |
| Alpha | Toggle | True, False | If true alpha channel will be flipped. Disabled if **In** is Vector 3 or smaller. |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
float2 _Flip_Flip = float4(Red, Green, Blue, Alpha);
void Unity_Flip_float4(float4 In, float4 Flip, out float4 Out)
{
Out = (Flip * -2 + 1) * In;
}
```

View File

@@ -0,0 +1,43 @@
# Flipbook Node
## Description
Creates a flipbook, or texture sheet animation, of the UVs supplied to input **UV**. The amount of tiles on the sheet are defined by the values of the inputs **Width** and **Height**. The index of the current tile is defined by the value of the input **Tile**.
This node can be used to create a texture animation functionality, commonly used for particle effects and sprites, by supplying [Time](Time-Node.md) to the input **Tile** and outputting to the UV input slot of a [Texture Sampler](Sample-Texture-2D-Node.md).
UV data is typically in the range of 0 to 1 starting from the bottom left of UV space. This can be seen by the black value at the bottom left corner of a UV preview. As flipbooks typically start from top left the parameter **Invert Y** is enabled by default, however you can change the direction of the Flipbook by switching the **Invert X** and **Invert Y** parameters.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| UV | Input | Vector 2 | UV | Input UV value |
| Width | Input | Float | None | Amount of horizontal tiles |
| Height | Input | Float | None | Amount of vertical tiles |
| Tile | Input | Float | None | Current tile index |
| Out | Output | Vector 2 | None | Output UV value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| Invert X | Toggle | True, False | If enabled tiles are iterated from right to left |
| Invert Y | Toggle | True, False | If enabled tiles are iterated from top to bottom |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
float2 _Flipbook_Invert = float2(FlipX, FlipY);
void Unity_Flipbook_float(float2 UV, float Width, float Height, float Tile, float2 Invert, out float2 Out)
{
Tile = fmod(Tile, Width * Height);
float2 tileCount = float2(1.0, 1.0) / float2(Width, Height);
float tileY = abs(Invert.y * Height - (floor(Tile * tileCount.x) + Invert.y * 1));
float tileX = abs(Invert.x * Width - ((Tile - Width * floor(Tile * tileCount.x)) + Invert.x * 1));
Out = (UV + float2(tileX, tileY)) * tileCount;
}
```

View File

@@ -0,0 +1,20 @@
# Float Node
## Description
Defines a **Float** value in the shader. If [Port](Port.md) **X** is not connected with an [Edge](Edge.md) this [Node](Node.md) defines a constant **Float**.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| X | Input | Float | None | Input x component value |
| Out | Output | Float | None | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
float _Vector1_Out = X;
```

View File

@@ -0,0 +1,23 @@
# Floor Node
## Description
Returns the largest integer value, or whole number, that is less than or equal to the value of input **In**.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Floor_float4(float4 In, out float4 Out)
{
Out = floor(In);
}
```

View File

@@ -0,0 +1,33 @@
# Fog Node
## Description
Provides access to the Scene's **Fog** parameters.
Note: The behavior of this [Node](Node.md) is undefined globally. Shader Graph does not define the function of the node. Instead, each Render Pipeline defines what HLSL code to execute for this [Node](Node.md).
Different Render Pipelines may produce different results. If you're building a shader in one Render Pipeline that you want to use in both, try checking it in both pipelines before production. A [Node](Node.md) might be defined in one Render Pipeline and undefined in the other. If this [Node](Node.md) is undefined, it returns 0 (black).
#### Unity Render Pipelines Support
- Universal Render Pipeline
The High Definition Render Pipeline does **not** support this Node.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Position | Output | Vector 3 | Position (object space) | Mesh vertex/fragment's position |
| Color | Output | Vector 4 | None | Fog color |
| Density | Output | Float | None | Fog density based on depth. Returns a value between 0 and 1, where 0 is no fog and 1 is full fog. |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Fog_float(float3 Position, out float4 Color, out float Density)
{
SHADERGRAPH_FOG(Position, Color, Density);
}
```

View File

@@ -0,0 +1,23 @@
# Fraction Node
## Description
Returns the fractional (or decimal) part of input **In**; which is greater than or equal to 0 and less than 1.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Fraction_float4(float4 In, out float4 Out)
{
Out = frac(In);
}
```

View File

@@ -0,0 +1,25 @@
# Fresnel Effect Node
## Description
**Fresnel Effect** is the effect of differing reflectance on a surface depending on viewing angle, where as you approach the grazing angle more light is reflected. The **Fresnel Effect** node approximates this by calculating the angle between the surface normal and the view direction. The wider this angle is, the greater the return value will be. This effect is often used to achieve rim lighting, common in many art styles.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| Normal | Input | Vector 3 | Normal direction. By default bound to World Space Normal |
| View Dir | Input | Vector 3 | View direction. By default bound to World Space View Direction |
| Power | Input | Float | Exponent of the power calculation |
| Out | Output | Float | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_FresnelEffect_float(float3 Normal, float3 ViewDir, float Power, out float Out)
{
Out = pow((1.0 - saturate(dot(normalize(Normal), normalize(ViewDir)))), Power);
}
```

View File

@@ -0,0 +1,61 @@
# Fresnel Equation Node
## Description
The Fresnel Equation Node adds equations that affect Material interactions to the Fresnel Component. You can select an equation in the **Mode** dropdown.
You can find Numerical values of refractive indices at [refractiveindex.info](https://refractiveindex.info/).
## Ports (Schlick)
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| f0 | Input | Vector{1, 2, 3} | None | Represente the reflection of the surface when we face typically 0.02-0.08 for a dielectric material. |
| DotVector | Input | Float | None | The dot product between the normal and the surface. |
| Fresnel | Output | same as f0 | None | Fresnel coefficient, which describe the amount of light reflected or transmitted. |
## Ports (Dielectric)
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| IOR Source | Input | Vector | None | The refractive index of the medium the light source originates in. |
| IOR Medium | Input | Vector | None | The refractive index of the medium that the light refracts into. |
| DotVector | Input | Float | None | The dot product between the normal and the surface. |
| Fresnel | Output | same as f0 | None | The fresnel coefficient, which describe the amount of light reflected or transmitted. |
## Ports (DielectricGeneric)
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| IOR Source | Input | Vector | None | The refractive index of the medium the light source originates in. |
| IOR Medium | Input | Vector | None | The refractive index of the medium that the light refracts into. |
| IOR MediumK | Input | Vector | None | The refractive index Medium (imaginary part), or the medium causing the refraction. |
| DotVector | Input | Float | None | The dot product between the normal and the surface. |
| Fresnel | Output | same as f0 | None | Fresnel coefficient, which describe the amount of light reflected or transmitted. |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| Mode | Dropdown | &#8226; **Schlick**: This mode produces an approximation based on [Schlick's Approximation](https://en.wikipedia.org/wiki/Schlick%27s_approximation). Use the Schlick mode for interactions between air and dielectric materials. <br/>&#8226; **Dielectric**: Use this mode for interactions between two dielectric Materials. For example, air to glass, glass to water, or water to air.<br/>&#8226; **DielectricGeneric**: This mode computes a [Fresnel equation](https://seblagarde.wordpress.com/2013/04/29/memo-on-fresnel-equations) for interactions between a dielectric and a metal. For example, clear-coat- to metal, glass to metal, or water to metal. <br/>**Note:** if the **IORMediumK** value is 0, **DielectricGeneric** behaves in the same way as the **Dielectric** mode. ||
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_FresnelEquation_Schlick(out float Fresnel, float cos0, float f0)
{
Fresnel = F_Schlick(f0, cos0);
}
void Unity_FresnelEquation_Dielectric(out float3 Fresnel, float cos0, float3 iorSource, float3 iorMedium)
{
FresnelValue = F_FresnelDielectric(iorMedium/iorSource, cos0);
}
void Unity_FresnelEquation_DielectricGeneric(out float3 Fresnel, float cos0, float3 iorSource, float3 iorMedium, float3 iorMediumK)
{
FresnelValue = F_FresnelConductor(iorMedium/iorSource, iorMediumK/iorSource, cos0);
}
```

View File

@@ -0,0 +1,73 @@
# Gather Texture 2D node
The Gather Texture 2D node samples the red channel of four neighboring pixels from a sample point. It returns a value of `RRRR`, and takes each `R` value from a different neighbor. Normal Texture sampling reads all four channels (RGBA) of a Texture.
This node is useful when you want to modify the bilinear interpolation between pixels, such as when you want to create custom blends.
![An image of the Graph window, with a Gather Texture 2D node.](images/sg-gather-Texture-2d-node.png)
This node uses the [Gather](https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-to-gather) HLSL intrinsic function. For platforms where this intrinsic function doesn't exist, Shader Graph uses an appropriate approximation, instead.
> [!NOTE]
> When you use the Metal graphics API, the `sample`, `sample_compare`, `gather`, and `gather_compare` intrinsics use an integer (int2) `offset` argument when sampling or gathering from a 2D Texture. The intrinsics apply this value to Texture coordinates before looking up each pixel. The `offset` value must be in the range of `-8` to `+7`, or the Metal API clamps the `offset` value.
The pixels that the Gather Texture 2D samples are always from the top mip level of the Texture, from a 2×2 block of pixels around the sample point. Rather than blending the 2×2 sample, it returns the sampled pixels in counter-clockwise order. It starts with the sample to the lower left of the query location:
![An image that shows 4 quadrants, numbered 1 to 4, to display the order that the Gather Texture 2D node collects its samples: (-,+), (+,+), (-,+), (-,-).](images/sg-gather-Texture-2d-node-sample-order.png)
## Create Node menu category
The Gather Texture 2D node is under the **Input** &gt; **Texture** category in the Create Node menu.
## Compatibility
The Gather Texture 2D [!include[nodes-compatibility-all](./snippets/nodes-compatibility-all.md)] <!-- ALL PIPELINES INCLUDE -->
The Gather Texture 2D [!include[nodes-fragment-only](./snippets/nodes-fragment-only.md)] <!-- FRAGMENT ONLY INCLUDE -->
## Inputs
The Gather Texture 2D [!include[nodes-inputs](./snippets/nodes-inputs.md)] <!-- MULTIPLE INPUT PORTS INCLUDE -->
| **Name** | **Type** | **Binding** | **Description** |
| :--- | :------ | :------ | :---------- |
| Texture | Texture 2D | None | The Texture to sample. |
| UV | Vector 2 | UV | The UV coordinates to use to take the sample. |
| Sampler | SamplerState | None | The Sampler State and its corresponding settings to use for the sample. |
| Offset | Vector 2 | None | The pixel offset to apply to the sample's UV coordinates. The **Offset** value is in pixels, not UV space. |
## Outputs
The Gather Texture 2D [!include[nodes-outputs](./snippets/nodes-outputs.md)] <!-- MULTIPLE OUTPUT PORTS INCLUDE -->
| **Name** | **Type** | **Description** |
| :------ | :------- | :------------- |
| RGBA | Vector 4 | The sample value. This is the red channels of the 4 neighboring pixels from the specified sample position on the given Texture. |
| R | Float | The first neighboring pixel's red channel. |
| G | Float | The second neighboring pixel's red channel. |
| B | Float | The third neighboring pixel's red channel. |
| A | Float | The fourth neighboring pixel's red channel. |
## Example graph usage
In the following example, a Gather Texture 2D node creates a blurred version of a Texture by averaging its 4 samples:
![An image of the Graph window, that displays a Gather Texture 2D node with its R & G ports connected to one Add node, its B port connected to another Add node, and its A port connected to another. The Add nodes add all the Gather Texture 2D node's ports together, then uses a Divide node to divide them by 4.](images/sg-gather-Texture-2d-node-example.png)
Then, the rest of the Shader Graph uses a Sample Texture 2D node to sample the Texture again, and uses a Lerp node to determine when to use the blurred Texture and when to use the regular Texture:
![An image of the Graph window, that displays a Sample Texture 2D node with its R port connected to the B port on a Lerp node. The Lerp node takes the result of the Divide node from the previous image and sends its Output port result to the Fragment Stage's Base Color and Emission nodes.](images/sg-gather-Texture-2d-node-example-2.png)
By changing the value provided to the T port on the Lerp node, you can change whether you want to blur or sharpen the Texture in your Shader Graph:
![An image of the Graph window, that displays the full graph from the previous two example images.](images/sg-gather-Texture-2d-node-example-3.png)
## Related nodes
[!include[nodes-related](./snippets/nodes-related.md)] Gather Texture 2D node:
- [Sample Texture 2D node](Sample-Texture-2D-Node.md)
- [Sample Texture 2D LOD node](Sample-Texture-2D-LOD-Node.md)
- [Sampler State node](Sampler-State-Node.md)
- [Texture 2D Asset node](Texture-2D-Asset-Node.md)

View File

@@ -0,0 +1,15 @@
# Getting started with Shader Graph
Use Shader Graph with either of the Scriptable Render Pipelines (SRPs) available in Unity version 2018.1 and later:
- The [High Definition Render Pipeline (HDRP)](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest)
- The [Universal Render Pipeline (URP)](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@latest)
As of Unity version 2021.2, you can also use Shader Graph with the [Built-In Render Pipeline](https://docs.unity3d.com/Documentation/Manual/built-in-render-pipeline.html).
> [!NOTE]
> Shader Graph support for the Built-In Render Pipeline is for compatibility purposes only. Shader Graph doesn't receive updates for Built-In Render Pipeline support, aside from bug fixes for existing features. It's recommended to use Shader Graph with the Scriptable Render Pipelines.
When you install HDRP or URP into your project, Unity also installs the Shader Graph package automatically. You can manually install Shader Graph for use with the Built-In Render Pipeline on Unity version 2021.2 and later with the Package Manager. For more information on how to install a package, see [Adding and removing packages](https://docs.unity3d.com/Manual/upm-ui-actions.html) in the Unity User Manual.
For more information about how to set up a Scriptable Render Pipeline, see [Getting started with HDRP](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Getting-started-with-HDRP.html) or [Getting started with URP](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@latest/index.html?subfolder=/manual/InstallingAndConfiguringURP.html).

View File

@@ -0,0 +1,50 @@
# Gradient Node
## Description
Defines a constant **Gradient** for use in [Shader Graph](Shader-Graph.md), although internally to the shader this is defined as a **struct**. To sample the **Gradient** it should be used in conjunction with a [Sample Gradient Node](Sample-Gradient-Node.md). When using a separate **Gradient Node**, you can sample a **Gradient** multiple times with different Time parameters.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| Out | Output | Gradient | Output value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| | Gradient Field | | Defines the gradient. |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
Gradient Unity_Gradient_float()
{
Gradient g;
g.type = 1;
g.colorsLength = 4;
g.alphasLength = 4;
g.colors[0] = 0.1;
g.colors[1] = 0.2;
g.colors[2] = 0.3;
g.colors[3] = 0.4;
g.colors[4] = 0;
g.colors[5] = 0;
g.colors[6] = 0;
g.colors[7] = 0;
g.alphas[0] = 0.1;
g.alphas[1] = 0.2;
g.alphas[2] = 0.3;
g.alphas[3] = 0.4;
g.alphas[4] = 0;
g.alphas[5] = 0;
g.alphas[6] = 0;
g.alphas[7] = 0;
return g;
}
Gradient _Gradient = Unity_Gradient_float();
```

View File

@@ -0,0 +1,54 @@
# Gradient Noise Node
## Description
Generates a gradient, or [Perlin](https://en.wikipedia.org/wiki/Perlin_noise), noise based on input **UV**. The scale of the generated noise is controlled by input **Scale**. In terms of performance cost, Gradient Noise node can be slightly more computationally intensive than sampling a texture map.
You can also choose to use two different hashing methods for calculating the noise. As of Unity version 2021.2, the Gradient Noise node defaults to the **Deterministic** hash, to ensure consistent results for noise generation across platforms. Because the **UV** value is used as the seed for the noise generation, you can offset, scale, or distort the **UV** value to generate different noise patterns.
## Ports
| Name | Direction | Type | Binding | Description |
|:------|:----------|:---------|:--------|:---------------|
| UV | Input | Vector 2 | UV | Input UV value |
| Scale | Input | Float | None | Noise scale |
| Out | Output | Float | None | Output value in the range 0.0 to 1.0 |
## Controls
| Name | Type | Options | Description |
|:----------|:---------|:-------------------------|:------------|
| Hash Type | Dropdown | Deterministic, LegacyMod | Selects the hash function used to generate random numbers for noise generation. |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
float2 unity_gradientNoise_dir(float2 p)
{
p = p % 289;
float x = (34 * p.x + 1) * p.x % 289 + p.y;
x = (34 * x + 1) * x % 289;
x = frac(x / 41) * 2 - 1;
return normalize(float2(x - floor(x + 0.5), abs(x) - 0.5));
}
float unity_gradientNoise(float2 p)
{
float2 ip = floor(p);
float2 fp = frac(p);
float d00 = dot(unity_gradientNoise_dir(ip), fp);
float d01 = dot(unity_gradientNoise_dir(ip + float2(0, 1)), fp - float2(0, 1));
float d10 = dot(unity_gradientNoise_dir(ip + float2(1, 0)), fp - float2(1, 0));
float d11 = dot(unity_gradientNoise_dir(ip + float2(1, 1)), fp - float2(1, 1));
fp = fp * fp * fp * (fp * (fp * 6 - 15) + 10);
return lerp(lerp(d00, d01, fp.y), lerp(d10, d11, fp.y), fp.x);
}
void Unity_GradientNoise_float(float2 UV, float Scale, out float Out)
{
Out = unity_gradientNoise(UV * Scale) + 0.5;
}
```

View File

@@ -0,0 +1,15 @@
# Graph Settings Tab
## Description
The **Graph Settings** tab on the **[Graph Inspector](Internal-Inspector.md)** make it possible to change settings that affect the Shader Graph as a whole.
![](images/GraphSettings_Menu.png)
### Graph Settings options
| Menu Item | Description |
|:----------|:------------|
| Precision | A [Precision Mode](Precision-Modes.md) drop-down menu that lets you set the default precision for the entire graph. You can override the Precision setting here at the node level in your graph.|
| Preview Mode | (Subgraphs only) Your options are **Inherit**, **Preview 2D**, and **Preview 3D**. |
| Active Targets | A list that contains the Targets you've selected. You can add or remove entries using the Add (**+**) and Remove (**-**) buttons. <br/>Shader Graph supports three targets: the [Universal Render Pipeline](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@12.0/manual/index.html), the [High Definition Render Pipeline](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@12.0/manual/index.html), and [Built-In Render Pipeline](https://docs.unity3d.com/2020.3/Documentation/Manual/render-pipelines.html). Target-specific settings appear below the standard setting options. The displayed Target-specific settings change according to which Targets you select. |

View File

@@ -0,0 +1,19 @@
# Graph Target
A Target determines the end point compatibility of a shader you generate using Shader Graph. You can select Targets for each Shader Graph asset, and use the [Graph Settings Menu](Graph-Settings-Tab.md) to change the Targets.
![image](images/GraphSettings_Menu.png)
Targets hold information such as the required generation format, and variables that allow compatibility with different render pipelines or integration features like [Visual Effect Graph](https://docs.unity3d.com/Packages/com.unity.visualeffectgraph@latest). You can select any number of Targets for each Shader Graph asset. If a Target you select isn't compatible with other Targets you've already selected, an error message that explains the problem appears.
Target Settings are specific to each Target, and can vary between assets depending on which Targets you've selected. Be aware that Universal Render Pipeline (URP) Target Settings and High Definition Render Pipeline (HDRP) Target Settings might change in future versions.
Typically, each Target you select generates a valid subshader from the graph. For example, a Shader Graph asset with both URP and HDRP Targets will generate two subshaders. When you use a graph that targets multiple render pipelines, you must reimport the Shader Graph asset if you change the active render pipeline. This updates the Material Inspector for any Materials that use your graph.
Shader Graph supports three targets: the [Universal Render Pipeline](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@12.0/manual/index.html), the [High Definition Render Pipeline](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@12.0/manual/index.html), and the [Built-In Render Pipeline](https://docs.unity3d.com/2020.3/Documentation/Manual/render-pipelines.html).
Not all blocks are compatible with all targets. If a block in your graph becomes inactive when you choose a target, that block is not compatible with that target.
The visual results of a graph are not the same in all render pipelines. This is because of the technical differences between URP, Built-In, and HDRP.
Shader Graphs that target the Built-In Render Pipeline replicate the results of shaders handwritten in ShaderLab, with the exception of normal maps. For mathematical correctness, normal maps created with Shader Graph behave as they do in URP even when your build targets the Built-In Render Pipeline.

View File

@@ -0,0 +1,27 @@
# Custom Color Node (HDRP)
The Custom Color Node accesses the custom pass color buffer allocated by HDRP.
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| -------------- | ----------------------------------- | ------------------------------------------ |
| Custom Color Node | No | Yes |
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| **UV** | Input | Vector 4 | Screen Position | Sets the normalized screen coordinates to sample. |
| **Output** | Output | Vector 4 | None | The value the custom pass color buffer contains at the sampled coordinates. |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_CustomDepth_LinearEye_float(float4 UV, out float Out)
{
Out = SampleCustomColor(UV.xy);
}
```

View File

@@ -0,0 +1,34 @@
# Custom Depth Node (HDRP)
The Custom Depth Node accesses the custom pass depth buffer allocated by HDRP.
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| -------------- | ----------------------------------- | ------------------------------------------ |
| Custom Depth Node | No | Yes |
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| **UV** | Input | Vector 4 | Screen Position | Sets the normalized screen coordinates that this node samples. |
| **Output** | Output | Vector 4 | None | The output value of this node. |
## Depth Sampling modes
| Name | Description |
|----------|------------------------------------|
| Linear01 | The linear depth value between 0 and 1. |
| Raw | The raw depth value. |
| Eye | The depth value converted to eye space units. |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_CustomDepth_LinearEye_float(float4 UV, out float Out)
{
Out = LinearEyeDepth(SampleCustomDepth(UV.xy), _ZBufferParams);
}
```

View File

@@ -0,0 +1,39 @@
# HD Sample Buffer Node
## Description
The HD Sample Buffer Node samples a buffer directly from the Camera.
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| -------------------- | ----------------------------------- | ------------------------------------------ |
| **HD Sample Buffer** | No | Yes |
## Ports
| **Name** | **Direction** | **Type** | **Binding** | **Description** |
| ----------- | ------------- | ------------ | ----------- | ------------------------------------------------------------ |
| **UV** | Input | Vector 2 | UV | Input UV value. |
| **Sampler** | Input | SamplerState | None | Determines the sampler that Unity uses to sample the buffer. |
| **Output** | Output | Float | None | Output value. |
## Controls
| **Name** | **Type** | **Options** | **Description** |
| ------------- | -------- | ------------------------------------------------------------ | ---------------------------------- |
| Source Buffer | Dropdown | World Normal, Roughness, Motion Vectors, PostProcess Input, Blit Source. | Determines which buffer to sample. |
## Generated Code Example
The following example code represents one possible outcome of this node:
```c#
float4 Unity_HDRP_SampleBuffer_float(float2 uv, SamplerState samplerState)
{
return SAMPLE_TEXTURE2D_X_LOD(_CustomPostProcessInput, samplerState, uv * _RTHandlePostProcessScale.xy, 0);
}
```

View File

@@ -0,0 +1,24 @@
# HD Scene Color Node
The HD Scene Color Node does the same thing as the Scene Color Node, but allows you to access the mips of the color buffer.
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| -------------- | ----------------------------------- | ------------------------------------------ |
| HD Scene Color | No | Yes |
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| **UV** | Input | Vector 4 | Screen Position | Sets the normalized screen coordinates to sample. |
| **Lod** | Input | float | None | Sets the mip level that the sampler uses to sample the color buffer. |
| **Output** | Output | Vector 3 | None | Output value |
## Notes
### Exposure
You can use the Exposure property to specify if you want to output the Camera color with exposure applied or not. By default, this property is disabled to avoid double exposure.
The sampler that this Node uses to sample the color buffer is in trilinear clamp mode. This allows the sampler to smoothly interpolate between the mip maps.

View File

@@ -0,0 +1,33 @@
# HD Scene Depth Node
## Description
The HD Scene Depth node uses a UV input to access the current Camera's depth buffer. Unity expects normalized screen coordinates for this value. You can also use this node to access the mipmaps in the depth buffer.
You can only use the HD Scene Depth node in the Fragment Shader Stage and with non-opaque materials.
## Render pipeline compatibility
| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| ------------------ | ----------------------------------- | ------------------------------------------ |
| **HD Scene Color** | No | Yes |
## Ports
| **Name** | **Direction** | **Type** | **Binding** | **Description** |
| ---------- | ------------- | -------- | --------------- | ------------------------------------------------------------ |
| **UV** | Input | Vector 4 | Screen Position | Sets the normalized screen coordinates to sample. |
| **Lod** | Input | float | None | Sets the mip level that the sampler uses to sample the depth buffer. |
| **Output** | Output | Vector 3 | None | Output value. |
## Depth Sampling modes
| Name | Description |
| ------------ | ---------------------------------- |
| **Linear01** | Linear depth value between 0 and 1 |
| **Raw** | Raw depth value |
| **Eye** | Depth converted to eye space units |
## Notes
To use the HD Scene Depth node in a Custom Render Pipeline, you need to explicitly define its behavior, otherwise it returns white.

View File

@@ -0,0 +1,74 @@
# Hue Node
## Description
Offsets the hue of input **In** by the amount of input **Offset**. The unit of the offset can be set with the parameter **Range**. **Offset** in **Degrees** is in the range -180 to 180. In **Radians** it is -Pi to Pi.
## Ports
| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| In | Input | Vector 3 | None | Input value |
| Offset | Input | Float | None | Amount to offset hue |
| Out | Output | Vector 3 | None | Output value |
## Controls
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| Range | Dropdown | Degrees, Radians | The unit used for the input **Offset** |
## Generated Code Example
The following example code represents one possible outcome of this node per **Base** mode.
**Degrees**
```
void Unity_Hue_Degrees_float(float3 In, float Offset, out float3 Out)
{
float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
float4 P = lerp(float4(In.bg, K.wz), float4(In.gb, K.xy), step(In.b, In.g));
float4 Q = lerp(float4(P.xyw, In.r), float4(In.r, P.yzx), step(P.x, In.r));
float D = Q.x - min(Q.w, Q.y);
float E = 1e-10;
float3 hsv = float3(abs(Q.z + (Q.w - Q.y)/(6.0 * D + E)), D / (Q.x + E), Q.x);
float hue = hsv.x + Offset / 360;
hsv.x = (hue < 0)
? hue + 1
: (hue > 1)
? hue - 1
: hue;
float4 K2 = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
float3 P2 = abs(frac(hsv.xxx + K2.xyz) * 6.0 - K2.www);
Out = hsv.z * lerp(K2.xxx, saturate(P2 - K2.xxx), hsv.y);
}
```
**Radians**
```
void Unity_Hue_Radians_float(float3 In, float Offset, out float3 Out)
{
float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
float4 P = lerp(float4(In.bg, K.wz), float4(In.gb, K.xy), step(In.b, In.g));
float4 Q = lerp(float4(P.xyw, In.r), float4(In.r, P.yzx), step(P.x, In.r));
float D = Q.x - min(Q.w, Q.y);
float E = 1e-10;
float3 hsv = float3(abs(Q.z + (Q.w - Q.y)/(6.0 * D + E)), D / (Q.x + E), Q.x);
float hue = hsv.x + Offset;
hsv.x = (hue < 0)
? hue + 1
: (hue > 1)
? hue - 1
: hue;
// HSV to RGB
float4 K2 = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
float3 P2 = abs(frac(hsv.xxx + K2.xyz) * 6.0 - K2.www);
Out = hsv.z * lerp(K2.xxx, saturate(P2 - K2.xxx), hsv.y);
}
```

View File

@@ -0,0 +1,23 @@
# Hyperbolic Cosine Node
## Description
Returns the hyperbolic cosine of input **In**.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_HyperbolicCosine_float4(float4 In, out float4 Out)
{
Out = cosh(In);
}
```

View File

@@ -0,0 +1,23 @@
# Hyperbolic Sine Node
## Description
Returns the hyperbolic sine of input **In**.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_HyperbolicSine_float4(float4 In, out float4 Out)
{
Out = sinh(In);
}
```

View File

@@ -0,0 +1,23 @@
# Hyperbolic Tangent Node
## Description
Returns the hyperbolic tangent of input **In**.
## Ports
| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| Out | Output | Dynamic Vector | Output value |
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_HyperbolicTangent_float4(float4 In, out float4 Out)
{
Out = tanh(In);
}
```

View File

@@ -0,0 +1,118 @@
# Input Nodes
## Basic
|[Boolean](Boolean-Node.md)|[Color](Color-Node.md)|
|:--------:|:------:|
|![Image](images/BooleanNodeThumb.png)|![](images/ColorNodeThumb.png)|
| Defines a constant Boolean value in the shader. | Defines a constant Vector 4 value in the shader using a Color field. |
|[**Constant**](Constant-Node.md)|[**Integer**](Integer-Node.md)|
|![Image](images/ConstantNodeThumb.png)|![Image](images/IntegerNodeThumb.png)|
|Defines a Float of a mathematical constant value in the shader.|Defines a constant Float value in the shader using an Integer field.|
|[**Slider**](Slider-Node.md)|[**Time**](Time-Node.md)|
|![Image](images/SliderNodeThumb.png)|![Image](images/TimeNodeThumb.png)|
|Defines a constant Float value in the shader using a Slider field.|Provides access to various Time parameters in the shader.|
|[**Float**](Float.md)|[**Vector 2**](Vector-2-Node.md)|
|![Image](images/Vector1NodeThumb.png)|![Image](images/Vector2NodeThumb.png)|
|Defines a Float value in the shader.|Defines a Vector 2 value in the shader.|
|[**Vector 3**](Vector-3-Node.md)|[**Vector 4**](Vector-4-Node.md)|
|![Image](images/Vector3NodeThumb.png)|![Image](images/Vector4NodeThumb.png)|
|Defines a Vector 3 value in the shader.|Defines a Vector 4 value in the shader.|
## Geometry
|[Bitangent Vector](Bitangent-Vector-Node.md)|[Normal Vector](Normal-Vector-Node.md)|
|:--------:|:------:|
|[![Image](images/BitangentVectorNodeThumb.png)](Combine-Node)|![](images/NormalVectorNodeThumb.png)|
| Provides access to the mesh vertex or fragment's Bitangent Vector. | Provides access to the mesh vertex or fragment's Normal Vector. |
|[**Position**](Position-Node.md)|[**Screen Position**](Screen-Position-Node.md)|
|![Image](images/PositionNodeThumb.png)|![Image](images/ScreenPositionNodeThumb.png)|
|Provides access to the mesh vertex or fragment's Position.|Provides access to the mesh vertex or fragment's Screen Position.|
|[**Tangent Vector**](Tangent-Vector-Node.md)|[**UV**](UV-Node.md)|
|![Image](images/TangentVectorNodeThumb.png)|![Image](images/UVNodeThumb.png)|
|Provides access to the mesh vertex or fragment's Tangent Vector.|Provides access to the mesh vertex or fragment's UV coordinates.|
|[**Vertex Color**](Vertex-Color-Node.md)|[**View Direction**](View-Direction-Node.md)|
|![Image](images/VertexColorNodeThumb.png)|![Image](images/ViewDirectionNodeThumb.png)|
|Provides access to the mesh vertex or fragment's Vertex Color value.|Provides access to the mesh vertex or fragment's View Direction vector.|
|[**Vertex ID**](Vertex-ID-Node.md)|
|![Image](images/VertexIDNodeThumb.png)|
|Provides access to the mesh vertex or fragment's Vertex ID value.|
## Gradient
|[Blackbody](Blackbody-Node.md)|[Gradient](Gradient-Node.md)|
|:--------:|:------:|
|![Image](images/BlackbodyNodeThumb.png)|![Image](images/GradientNodeThumb.png)|
| Samples a radiation based gradient from temperature input (in Kelvin). | Defines a constant Gradient in the shader. |
|[Sample Gradient](Sample-Gradient-Node.md)|
|![](images/SampleGradientNodeThumb.png)|
| Samples a Gradient given the input of Time. |
## Matrix
|[Matrix 2x2](Matrix-2x2-Node.md)|[Matrix 3x3](Matrix-3x3-Node.md)|
|:--------:|:------:|
|![Image](images/Matrix2x2NodeThumb.png)|![](images/Matrix3x3NodeThumb.png)|
| Defines a constant Matrix 2x2 value in the shader. | Defines a constant Matrix 3x3 value in the shader. |
|[**Matrix 4x4**](Matrix-4x4-Node.md)|[**Transformation Matrix**](Transformation-Matrix-Node.md)|
|![Image](images/Matrix4x4NodeThumb.png)|![Image](images/TransformationMatrixNodeThumb.png)|
|Defines a constant Matrix 4x4 value in the shader.|Defines a constant Matrix 4x4 value for a default Unity Transformation Matrix in the shader.|
## Mesh Deformation
| [Compute Deformation Node](Compute-Deformation-Node) | [Linear Blend Skinning Node](Linear-Blend-Skinning-Node) |
| :----------------------------------------------------------- | :----------------------------------------------------------- |
| ![Image](images/ComputeDeformationNodeThumb.png) | ![Image](images/LinearBlendSkinningNodeThumb.png) |
| Passes compute deformed vertex data to a vertex shader. Only works with the [DOTS Hybrid Renderer](https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@latest/). | Applies Linear Blend Vertex Skinning. Only works with the [DOTS Hybrid Renderer](https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@latest/). |
## PBR
| [**Dielectric Specular**](Dielectric-Specular-Node.md) | [**Metal Reflectance**](Metal-Reflectance-Node.md) |
| :----------------------------------------------------------: | :----------------------------------------------------------: |
| ![Image](images/DielectricSpecularNodeThumb.png) | ![](images/MetalReflectanceNodeThumb.png) |
| Returns a Dielectric Specular F0 value for a physically based material. | Returns a Metal Reflectance value for a physically based material. |
## Scene
|[Ambient](Ambient-Node.md)|[Camera](Camera-Node.md)|
|:--------:|:------:|
|![Image](images/AmbientNodeThumb.png)|![](images/CameraNodeThumb.png)|
| Provides access to the Scene's Ambient color values. | Provides access to various parameters of the current Camera. |
|[**Fog**](Fog-Node.md)|[**Baked GI**](Baked-GI-Node.md)|
|![Image](images/FogNodeThumb.png)||
|Provides access to the Scene's Fog parameters.|Provides access to the Baked GI values at the vertex or fragment's position.|
|[**Object**](Object-Node.md)|[**Reflection Probe**](Reflection-Probe-Node.md)|
|![Image](images/ObjectNodeThumb.png)|![Image](images/ReflectionProbeNodeThumb.png)|
|Provides access to various parameters of the Object.|Provides access to the nearest Reflection Probe to the object.|
|[**Scene Color**](Scene-Color-Node.md)|[**Scene Depth**](Scene-Depth-Node.md)|
|![Image](images/SceneColorNodeThumb.png)|![Image](images/SceneDepthNodeThumb.png)|
|Provides access to the current Camera's color buffer.|Provides access to the current Camera's depth buffer.|
|[**Screen**](Screen-Node.md)|[**Eye Index**](Eye-Index-Node.md)|
|![Image](images/ScreenNodeThumb.png)|![Image](images/EyeIndexNodeThumb.png)|
|Provides access to parameters of the screen.|Provides access to the Eye Index when stereo rendering.|
## Texture
|[**Cubemap Asset**](Cubemap-Asset-Node.md)|[**Sample Cubemap**](Sample-Cubemap-Node.md)|
|:--------:|:------:|
|[![Image](images/CubemapAssetNodeThumb.png)](Combine-Node)|![](images/SampleCubemapNodeThumb.png)|
| Defines a constant Cubemap Asset for use in the shader. | Samples a Cubemap and returns a Vector 4 color value for use in the shader. |
|[**Sample Reflected Cubemap Node**](Sample-Reflected-Cubemap-Node.md)|[**Sample Texture 2D**](Sample-Texture-2D-Node.md)|
|![Image](images/SampleReflectedCubemapThumb.png)|![Image](images/SampleTexture2DNodeThumb.png)|
|Samples a Cubemap with reflected vector and returns a Vector 4 color value for use in the shader.|Samples a Texture 2D and returns a color value for use in the shader.|
|[**Sample Texture 2D Array**](Sample-Texture-2D-Array-Node.md)|[**Sample Texture 2D LOD**](Sample-Texture-2D-LOD-Node.md)|
|![Image](images/SampleTexture2DArrayNodeThumb.png)|![Image](images/SampleTexture2DLODNodeThumb.png)|
|Samples a Texture 2D Array at an Index and returns a color value for use in the shader.|Samples a Texture 2D at a specific LOD and returns a color value for use in the shader.|
|[**Sample Texture 3D**](Sample-Texture-3D-Node.md)| [**Sample Virtual Texture**](Sample-Virtual-Texture-Node.md) |
|![Image](images/SampleTexture3DNodeThumb.png)| ![image](images/SampleVirtualTextureNodeThumb.png) |
|Samples a Texture 3D and returns a color value for use in the shader.| Samples a Virtual Texture and returns color values for use in the shader.|
|[**Sampler State**](Sampler-State-Node.md)|[**Texture Size**](Texture-Size-Node.md)|
|![Image](images/SamplerStateNodeThumb.png)|![Image](images/TexelSizeNodeThumb.png) <!-- Add updated image -->|
|Defines a Sampler State for sampling textures.|Returns the Width and Height of the texel size of Texture 2D input.|
|[**Texture 2D Array Asset**](Texture-2D-Array-Asset-Node.md)|[**Texture 2D Asset**](Texture-2D-Asset-Node.md)|
|![Image](images/Texture2DArrayAssetNodeThumb.png)|![Image](images/Texture2DAssetNodeThumb.png)|
|Defines a constant Texture 2D Array Asset for use in the shader.|Defines a constant Texture 2D Asset for use in the shader.|
|[**Texture 3D Asset**](Texture-3D-Asset-Node.md)| |
|![Image](images/Texture3DAssetNodeThumb.png)| |
|Defines a constant Texture 3D Asset for use in the shader.| |

Some files were not shown because too many files have changed in this diff Show More