Skip to content

Commit 17d2476

Browse files
sebastienduverneEvergreen
authored andcommitted
[Port] [6000.5] DOCG-7573 - Shader Graph documentation for Custom Material Property Drawers sample
1 parent 8629989 commit 17d2476

20 files changed

Lines changed: 149 additions & 75 deletions

Packages/com.unity.shadergraph/Documentation~/Property-Types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ All properties have the following common parameters in addition to those specifi
2121
| **Preview Value** | Sets a value to use for preview in the Shader Graph window, only when you set **Scope** to **Global**. |
2222
| **Show In Inspector** | Displays the property in the material Inspector when enabled.<br/>If you disable this option, it includes an `[HideInInspector]` attribute to the material property (refer to [Properties block reference in ShaderLab](https://docs.unity3d.com/Manual/SL-Properties.html#material-property-attributes) for more details). |
2323
| **Read Only** | Marks the property as non-editable in the material Inspector by adding the [`PerRendererData`](https://docs.unity3d.com/ScriptReference/Rendering.ShaderPropertyFlags.html) attribute. |
24-
| **Custom Attributes** | Enables attachment of custom scripted drawers or decorators to extend the material property UI, such as adding static headers or complex controls.<br/>The **Custom Material Property Drawers** sample, available in the Package Manager among other [Shader Graph samples](ShaderGraph-Samples.md), shows how to display a Vector2 as a min/max slider, for example.<br/><br/>**Note**: When you declare the custom functions in the script, make sure to suffix their names with `Drawer` or `Decorator`.<br/><br/>In the list, use **+** or **-** to add or remove entries. Each entry corresponds to a function call which requires the following parameters:<ul><li>**Name**: A shorthened version of the function name, without its `Drawer` or `Decorator` suffix.</li><li>**Value**: The input values for the function as the script expects them.</li></ul>**Note**: A property can only have one drawer at any given time. |
24+
| **Custom Attributes** | Enables attachment of custom scripted drawers or decorators to extend the material property UI, such as adding static headers or complex controls.<br/>The [Custom Material Property Drawers](Shader-Graph-Sample-Custom-Material-Property-Drawers.md) sample shows how to display a Vector2 as a min/max slider, for example.<br/><br/>**Note**: When you declare the custom functions in the script, make sure to suffix their names with `Drawer` or `Decorator`.<br/><br/>In the list, use **+** or **-** to add or remove entries. Each entry corresponds to a function call which requires the following parameters:<ul><li>**Name**: A shortened version of the function name, without its `Drawer` or `Decorator` suffix.</li><li>**Value**: The input values for the function as the script expects them.</li></ul>**Note**: A property can only have one drawer at any given time. |
2525
| **Use Custom Binding** | Turns the property into a bound input port for connection to the [**Branch On Input Connection**](Branch-On-Input-Connection-Node.md) node. 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.<br/>This property is available only in sub graphs. |
2626

2727
## Float

Packages/com.unity.shadergraph/Documentation~/Shader-Graph-Sample-Custom-Lighting-Get-Started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Use the templates and sub graphs included in the **Custom Lighting** sample to get started with lighting model customization in Shader Graph.
44

55
> [!NOTE]
6-
> To use the **Custom Lighting** templates and sub graphs, you first need to [import the sample in your project](ShaderGraph-Samples.md#add-samples).
6+
> To use the **Custom Lighting** templates and sub graphs, you first need to [import the sample in your project](ShaderGraph-Samples-Import.md).
77
88
## Start from a shader graph template
99

Packages/com.unity.shadergraph/Documentation~/Shader-Graph-Sample-Custom-Lighting.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# Custom Lighting
2-
3-
![An example scene with custom lighting effects.](images/CustomLightingSample.png)
1+
# Custom Lighting sample
42

53
Use the additional templates and sub graphs provided in the **Custom Lighting** sample to get started with lighting model customization in Shader Graph.
64

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
## Custom Material Property Drawers sample
2+
3+
Learn how to use custom attributes in Shader Graph to improve the display and usability of property controls in the material's Inspector window.
4+
5+
The Custom Material Property Drawers sample includes a shader graph based material set up for adjustable color gradient and noise. This example shows how to achieve the following in the material Inspector UI with Shader Graph:
6+
7+
* Hide or display a basic material color property.
8+
* Display a Vector2 property as a min/max slider.
9+
* Display a help box for a property.
10+
11+
## Before you start
12+
13+
To access the Custom Material Property Drawers sample, follow these steps:
14+
15+
1. [Import](ShaderGraph-Samples-Import.md) the Custom Material Property Drawers sample in your project.
16+
17+
1. In the Project window, open the `Assets/Samples/Shader Graph/<your version>/Custom Material Property Drawers` folder.
18+
19+
1. Open the `RemapDrawerExample` shader graph asset.
20+
21+
## Hide or display a property in the material Inspector UI
22+
23+
To hide or display a material property from the shader graph in the material Inspector UI, follow these steps:
24+
25+
1. In the [Shader Graph window](Shader-Graph-Window.md), in the [Blackboard](Blackboard.md), select a property, for example **InnerColor**.
26+
27+
1. In the [Graph Inspector](Internal-Inspector.md), in the **Node Settings** tab, disable **Show in Inspector**.
28+
29+
1. Save the graph.
30+
31+
1. In the Project window, select the `RemapDrawerExample` material variant asset.
32+
33+
1. In the Inspector window, notice that the **InnerColor** property isn't displayed, contrarily to the other properties of the graph.
34+
35+
1. In the [Shader Graph window](Shader-Graph-Window.md), re-enable **Show in Inspector** for the **InnerColor** property.
36+
37+
1. Save the graph.
38+
39+
1. In the Inspector window, notice that the **InnerColor** property is now displayed.
40+
41+
## Display a material property as a min/max range slider
42+
43+
To learn how to display a material property as a min/max range slider in the material Inspector UI, follow these steps:
44+
45+
1. In the [Shader Graph window](Shader-Graph-Window.md), in the [Blackboard](Blackboard.md), select the **Range** property.
46+
47+
1. In the [Graph Inspector](Internal-Inspector.md), in the **Node Settings** tab, notice the following:
48+
49+
* The **Custom Attributes** include an entry named **Remap**, which modifies the **Range** property's appearance in the material UI based on a script provided with the sample.
50+
* The attribute includes no parameter values for the called function. For more information, refer to the sticky note besides the **Range** property instance in the graph.
51+
52+
1. In the Project window, open the `Editor` subfolder.
53+
54+
1. Select the `RemapDrawer` C# file.
55+
56+
1. In the Inspector window, notice the following:
57+
58+
* The C# file includes a set of custom functions named `RemapDrawer` to display a Vector2 as a min/max slider.
59+
* The function names include a `Drawer` suffix while in the shader graph the **Range** property excludes this suffix to call the functions.
60+
61+
## Display a help box in the material Inspector UI
62+
63+
To learn how to display a help box in the material Inspector UI, follow these steps:
64+
65+
1. In the [Shader Graph window](Shader-Graph-Window.md), in the [Blackboard](Blackboard.md), select the **NoiseRange** property.
66+
67+
1. In the [Graph Inspector](Internal-Inspector.md), in the **Node Settings** tab, notice the following:
68+
69+
* The **Custom Attributes** include an entry named **Remap** (previously described) and a second one named **HelpBox**, which adds a help box to the **NoiseRange** property in the material UI based on a second script provided with the sample.
70+
* The two attributes include specific parameter values for the called functions. For more information, refer to the sticky note under the **NoiseRange** property instance in the graph.
71+
72+
1. In the Project window, still in the `Editor` subfolder, select the `HelpBoxDecorator` C# file.
73+
74+
1. In the Inspector window, notice the following:
75+
76+
* The C# file includes a set of custom functions named `HelpBoxDecorator` to draw a message box in the material UI.
77+
* The function names include a `Decorator` suffix while in the shader graph the **NoiseRange** property excludes this suffix to call the functions.
78+
79+
## Additional resources
80+
81+
* [Property attribute reference](Property-Types.md)

Packages/com.unity.shadergraph/Documentation~/Shader-Graph-Sample-Feature-Examples.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# Feature Examples
1+
# Feature Examples sample
22

33
The Shader Graph Feature Examples sample content is a collection of Shader Graph assets that demonstrate how to achieve common techniques and effects in Shader Graph. The goal of this sample pack is to help users see what is required to achieve specific effects and provide examples to make it easier for users to learn.
44

5+
Each sample contains notes that describe what the shader does. Most of the shaders have their core functionality in a subgraph, so you can copy and paste them into your own shader graphs.
6+
57
The sample content is broken into the following categories:
68

79
- **Blending Masks** - these samples generate masks based on characteristics of the surface - such as height, facing angle, or distance from the camera.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Node Reference sample
2+
3+
This set of Shader Graph assets provides reference material for the nodes available in the Shader Graph node library.
4+
5+
Each graph contains a description for a specific node, examples of how it can be used, and useful tips. Some example assets also show a break-down of the math that the node is doing. You can use these samples along with the documentation to learn more about the behavior of individual nodes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Procedural Patterns sample
2+
3+
This collection of Assets showcases various procedural techniques possible with Shader Graph. Use them directly in your Project, or edit them to create other procedural patterns.
4+
5+
This collection includes the following patterns:
6+
7+
* Bacteria
8+
* Brick
9+
* Dots
10+
* Grid
11+
* Herringbone
12+
* Hex Lattice
13+
* Houndstooth
14+
* Smooth Wave
15+
* Spiral
16+
* Stripes
17+
* Truchet
18+
* Whirl
19+
* Zig Zag

Packages/com.unity.shadergraph/Documentation~/Shader-Graph-Sample-Production-Ready.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# Production Ready Shaders
1+
# Production Ready Shaders sample
22

3-
The Shader Graph Production Ready Shaders sample is a collection of Shader Graph shader assets that are ready to be used out of the box or modified to suit your needs. You can take them apart and learn from them, or just drop them directly into your project and use them as they are. The sample also includes a step-by-step tutorial for how to combine several of the shaders to create a forest stream environment.
4-
5-
The sample content is broken into the following categories:
3+
The Shader Graph Production Ready Shaders sample is a collection of Shader Graph shader assets that are ready to be used out of the box or modified to suit your needs. You can take them apart and learn from them, or just drop them directly into your project and use them as they are. The sample includes the Shader Graph versions of the HDRP and URP Lit shaders. It also includes a step-by-step tutorial for how to combine several of the shaders to create a forest stream environment.
64

75
| Topic | Description |
86
|:------|:--------------|

Packages/com.unity.shadergraph/Documentation~/Shader-Graph-Sample-Terrain.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Terrain Shaders
1+
# Terrain Shaders sample
22

33
The Terrain Shaders sample shows you how to design your own terrain material solutions and customize them to fit your specific goals and performance budgets. Possibilities include high quality tile repetition break-up solutions, detail mapping, smooth blending with the distant material, parallax mapping, auto materials, triplanar projection, and more.
44

Packages/com.unity.shadergraph/Documentation~/Shader-Graph-Sample-UGUI-Shaders.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# UGUI Shaders
2-
![The Shader Graph UGUI Shaders: A collection of Shader Graph subgraphs that serve as building blocks for building user interface elements.](images/UIToolsSample.png)
1+
# UGUI Shaders sample
32

4-
The Shader Graph UGUI Shaders sample is a collection of Shader Graph subgraphs that serve as building blocks for building user interface elements. They speed up the process of building widgets, buttons, and backgrounds for the user interface of your project. Using these tools, you can build dynamic, procedural UI elements that don’t require any texture memory and scale correctly for any resolution screen.
3+
The Shader Graph UGUI Shaders sample is a collection of Shader Graph subgraphs that you can use to build user interface elements. They speed up the process of building widgets, buttons, and backgrounds for the user interface of your project. With these tools, you can build dynamic, procedural UI elements that don’t require any texture memory and scale correctly for any resolution screen.
54

65
In addition to the subgraphs, the sample also includes example buttons, indicators, and backgrounds built using the subgraphs. The examples show how the subgraphs function in context and help you learn how to use them.
76

8-
We have two main objectives with this sample set:
7+
This sample set covers two main objectives:
98

109

1110
- Demonstrate Shader Graph’s ability to create dynamic, resolution-independent user interface elements in a wide variety of shapes and styles.

0 commit comments

Comments
 (0)