Skip to content

Commit 25cc3f7

Browse files
Internal/2022.3/staging
Internal/2022.3/staging
2 parents 62027b9 + cb1186f commit 25cc3f7

File tree

17 files changed

+206
-178
lines changed

17 files changed

+206
-178
lines changed

Packages/com.unity.render-pipelines.core/Editor/MaterialUpgrader.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class KeywordFloatRename
7272
public float setVal, unsetVal;
7373
}
7474
List<KeywordFloatRename> m_KeywordFloatRename = new List<KeywordFloatRename>();
75+
Dictionary<string, (string, System.Func<float, bool>)> m_ConditionalFloatRename;
7576

7677
/// <summary>
7778
/// Type of property to rename.
@@ -220,6 +221,20 @@ public virtual void Convert(Material srcMaterial, Material dstMaterial)
220221

221222
dstMaterial.SetFloat(t.property, srcMaterial.IsKeywordEnabled(t.keyword) ? t.setVal : t.unsetVal);
222223
}
224+
225+
// Handle conditional float renaming
226+
if (m_ConditionalFloatRename != null)
227+
{
228+
foreach (var (oldName, (newName, condition)) in m_ConditionalFloatRename)
229+
{
230+
if (srcMaterial.HasProperty(oldName) &&
231+
condition(srcMaterial.GetFloat(oldName)) &&
232+
dstMaterial.HasProperty(newName))
233+
{
234+
dstMaterial.SetFloat(newName, 1.0f);
235+
}
236+
}
237+
}
223238
}
224239

225240
/// <summary>
@@ -316,6 +331,17 @@ public void RenameKeywordToFloat(string oldName, string newName, float setVal, f
316331
m_KeywordFloatRename.Add(new KeywordFloatRename { keyword = oldName, property = newName, setVal = setVal, unsetVal = unsetVal });
317332
}
318333

334+
/// <summary>
335+
/// Rename a float property conditionally based on its value
336+
/// </summary>
337+
/// <param name="oldName">Old property name</param>
338+
/// <param name="newName">New property name</param>
339+
/// <param name="condition">Condition function that takes the float value and returns true if renaming should occur</param>
340+
protected void RenameFloat(string oldName, string newName, System.Func<float, bool> condition)
341+
{
342+
(m_ConditionalFloatRename ??= new Dictionary<string, (string, System.Func<float, bool>)>())[oldName] = (newName, condition);
343+
}
344+
319345
static MaterialUpgrader GetUpgrader(List<MaterialUpgrader> upgraders, Material material)
320346
{
321347
if (material == null || material.shader == null)

Packages/com.unity.render-pipelines.high-definition/Documentation~/Atmospheric-Scattering.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ HDRP implements an exponential fog, where density varies exponentially with dist
1111
Instead of using a constant color, fog can use the background sky as a source for color. In this case, HDRP samples the color from different mipmaps of the cubemap generated from the current sky settings. The chosen mip varies linearly between the lowest resolution and the highest resolution mipmaps, depending on the distance from the Camera and the values in the fog component’s **Mip Fog** properties. You can also choose to limit the resolution of the highest mip that HDRP uses. Doing this adds a volumetric effect to the fog and is less resource intensive to use than actual volumetric fog.
1212

1313
Optionally, you can enable volumetric fog for GameObjects close to the camera. It realistically simulates the interaction of lights with fog, which allows for physically plausible rendering of glow and crepuscular rays, which are beams of light that stream through gaps in objects like clouds and trees from a central point.
14+
15+
**Note:** Volumetric fog doesn't support [light rendering layers](Light-Layers).

Packages/com.unity.render-pipelines.universal/Editor/2D/LightBatchingDebugger/LightBatchingDebugger.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,18 +457,17 @@ private void Update()
457457

458458
private bool IsDirty()
459459
{
460+
if (lightCullResult == null)
461+
return false;
462+
460463
bool isDirty = false;
461464

462465
// Refresh if layers are added or removed
463466
isDirty |= Light2DManager.GetCachedSortingLayer().Count() != batchList.Sum(x => x.LayerNames.Count());
464467
isDirty |= cachedSceneHandle != SceneManager.GetActiveScene().handle;
465468
isDirty |= cachedCamPos != Camera.main?.transform.position;
466-
467-
if (lightCullResult != null)
468-
{
469-
isDirty |= totalLightCount != lightCullResult.visibleLights.Count();
470-
isDirty |= totalShadowCount != lightCullResult.visibleShadows.Count();
471-
}
469+
isDirty |= totalLightCount != lightCullResult.visibleLights.Count();
470+
isDirty |= totalShadowCount != lightCullResult.visibleShadows.Count();
472471

473472
return isDirty;
474473
}

Packages/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineMaterialUpgrader.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ public StandardUpgrader(string oldShaderName)
551551
}
552552

553553
RenameFloat("_Mode", "_Surface");
554+
RenameFloat("_Mode", "_AlphaClip", renderingMode => renderingMode == 1.0f);
554555
RenameTexture("_MainTex", "_BaseMap");
555556
RenameColor("_Color", "_BaseColor");
556557
RenameFloat("_GlossyReflections", "_EnvironmentReflections");

Packages/com.unity.shadergraph/Documentation~/Branch-Node.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# Branch Node
1+
# Branch node
22

3-
## Description
3+
The Branch node adds a dynamic branch to the shader, which outputs a different value depending on whether the input is true or false.
44

5-
Provides a dynamic branch to the shader. If input **Predicate** is true, this node returns input **True**, otherwise it returns input **False**. The **Branch Node** evaluates the **Predicate** per vertex or per pixel depending on shader stage. Both sides of the branch are evaluated in the shader, and the branch not used is discarded.
5+
Both sides of the branch are evaluated in the shader, and the output from the unused path is discarded.
66

77
## Ports
88

9-
| Name | Direction | Type | Binding | Description |
9+
| **Name** | **Direction** | **Type** | **Binding** | **Description** |
1010
|:----------|:----------|:---------------|:--------|:------------|
11-
| Predicate | Input | Boolean | None | Determines which input to return. |
12-
| True | Input | Dynamic Vector | None | Returned if **Predicate** is true. |
13-
| False | Input | Dynamic Vector | None | Returned if **Predicate** is false. |
14-
| Out | Output | Dynamic Vector | None | Output value |
11+
| **Predicate** | Input | Boolean | None | The input to test the value of. If you input a float, all values are evaluated as `true` except `0`. |
12+
| **True** | Input | Dynamic Vector | None | The value to output as **Out** if **Predicate** is true. |
13+
| **False** | Input | Dynamic Vector | None | The value to output as **Out** if **Predicate** is false. |
14+
| **Out** | Output | Dynamic Vector | None | Outputs either **True** or **False**. |
1515

1616
## Generated Code Example
1717

Packages/com.unity.shadergraph/Documentation~/Circle-Pupil-Animation-Node.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ This node applies a deformation to a normalized IrisUV coordinate to simulate th
1212

1313
| name | **Direction** | type | description |
1414
| -------------------------- | ------------- | ------- | ------------------------------------------------------------ |
15-
| **IrisUV** | Input | Vector2 | Position of the fragment to shade in object space. |
16-
| **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. |
17-
| **Maximal Pupil Aperture** | Input | float | The normal of the eye surface in object space. |
18-
| **Minimal Pupil Aperture** | Input | float | The index of refraction of the eye (**1.333** by default). |
19-
| **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** |
20-
| **IrisUV** | Output | Vector2 | Position of the refracted point on the iris plane in object space. |
15+
| **Iris UV** | Input | Vector2 | Normalized UV coordinates that can be used to sample either a texture or procedurally generate an Iris Texture. |
16+
| **Pupil Radius** | Input | float | Radius of the pupil in the iris texture as a percentage. |
17+
| **Pupil Aperture** | Input | float | Set the current diameter of the pupil opening. |
18+
| **Maximal Pupil Aperture** | Input | float | Define the largest size the pupil opening can reach. |
19+
| **Minimal Pupil Aperture** | Input | float | Define the smallest size the pupil opening can reach. |
Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,53 @@
1-
# Custom Interpolators
1+
# Add a custom interpolator
22

3-
## Description
3+
To pass custom data from the vertex shader to the fragment shader, add a custom interpolator to the vertex context of the Master Stack.
44

5-
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.
6-
7-
There are two target audiences for Custom Interpolators:
5+
There are two target audiences for custom interpolators:
86

97
* Technical Directors and Lead Technical Artists setting up environments for their teams.
108
* Graphics programmers helping artists to optimize content performance.
119

10+
**Note:** If you use the Built-In Render Pipeline, refer to [Input vertex data into a shader](https://docs.unity3d.com/Manual/SL-VertexProgramInputs.html) instead.
1211

1312
## Supported data types
14-
Custom interpolators support float, vec2, vec3, and vec4 options.
13+
14+
Custom interpolators support float, vector 2, vector 3, and vector 4 types.
1515

1616
## Channel limits
17-
The Custom Interpolator feature supports a maximum of 32 channels. A channel is equivalent to four floats. Each float is an interpolator variable.
18-
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.
19-
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.
2017

21-
## How to use
22-
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.
23-
These instructions include a contextual example illustrating the process of using a Custom Interpolator to fetch per-vertex data from a texture.
24-
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**.
18+
A custom interpolator supports a maximum of 32 channels. A channel is equivalent to four floats. Each float is an interpolator variable.
2519

26-
### Creating channel warnings and errors
20+
Different platforms and GPUs may have different limits, which might prevent your shaders compiling. Test your custom interpolators on your build targets to make sure your shaders compile properly. For more information, refer to the **Interpolator count limits** section in [Input vertex data into a shader](https://docs.unity3d.com/Manual/SL-VertexProgramInputs.html).
2721

28-
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.
29-
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.
30-
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**.
22+
You can't limit the number of channels another user creates in a shader graph. However, to warn users about the limits, go to [Project Settings](https://docs.unity3d.com/Manual/comp-ManagerGroup.html) and set the following:
3123

32-
### Adding a Custom Interpolator block to the Master Stack
24+
- **Warning Threshold** to tell users when they approach the channel limit. The range is 8 to 32 channels.
25+
- **Error Threshold** to tell users when they reach or exceed the channel limit. The minimum value is 8 channels, and it must be higher than the **Warning Threshold**.
3326

34-
![](images/custom-interpolators-3.gif) ![](images/custom-interpolators-2.png)
27+
## Add a custom interpolator block to the Master Stack
3528

36-
1. Right-click in the **Vertex** contex to create a block node.
29+
1. Right-click in the **Vertex** context to create a block node.
3730
2. Select **Custom Interpolator**.
38-
3. Select a data type.
39-
4. Enter a name for this interpolator.
31+
3. In the **Node Settings** tab of the **Graph Inspector** window, select a data type, for example **Vector 4**.
32+
4. In the same tab, enter a name for the interpolator.
4033

41-
In the illustrated example, you use the Vector 4 (vec4) data type.
34+
## Write data to the interpolator
4235

43-
### Writing data to the interpolator
36+
1. Right-click in your graph to create a node.
37+
2. Select the type, for example **Vertex ID**.
4438

45-
![](images/custom-interpolators-1.png)
39+
Custom interpolator blocks support many types of data, so you can connect the data from many other nodes including UV nodes and color nodes.
4640

47-
1. Right-click in your graph to create a node.
48-
2. Select the type **Vertex ID**.
49-
3. Connect this node to the Custom Interpolator block.
41+
3. Connect the node to the custom interpolator block.
5042

51-
In the example, you write Vertex ID values from your graph into the Custom Interpolator.
43+
The graph now writes Vertex ID values into the custom interpolator.
5244

53-
### Reading data from the interpolator
45+
## Read data from the interpolator
5446

5547
1. Right-click in your graph to create a node.
5648
2. Select **Custom Interpolator**.
57-
3. Connect the Custom Interpolator node to the relevant block in the Fragment context.
58-
59-
![](images/custom-interpolators-4.png)
60-
61-
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.
49+
3. Connect the **Custom Interpolator** node to the relevant block in the **Fragment** context, for example **Base Color** to use the Vertex ID as color output.
6250

63-
### Deleting the block from the Master Stack
51+
## Delete a custom interpolator
6452

65-
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.
53+
If you delete a custom interpolator that's 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 the nodes with it. This prevents the alert from appearing.

Packages/com.unity.shadergraph/Documentation~/Dither-Node.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
# Dither Node
1+
# Dither node
22

3-
## Description
3+
The Dither node adds a structured form of noise to the input. Use the Dither node to reduce the color bands that might appear if you move from a high number of colors to a low number (quantizing), or to simulate transparency by adding random alpha pixels to an opaque object.
44

5-
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**.
5+
The Dither node applies dithering in screen space to ensure a uniform distribution of the pattern. To change the space the node uses, connect another node to the **Screen Position** input, such as a [UV node](UV-Nodes.md).
66

7-
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.
7+
To use a dither pattern for transparency, connect the Dither node to the **Alpha Clip Threshold** input in the [Master Stack](Master-Stack.md). As a result, when you adjust the overall alpha value of the material, some pixels are discarded because the alpha value is lower than their alpha clip threshold. This technique is useful for creating geometry that appears to be transparent but has the advantages of rendering as opaque, such as writing to the depth buffer or rendering using a deferred [rendering path](https://docs.unity3d.com/Manual/built-in-rendering-paths.html).
88

99
## Ports
1010

11-
| Name | Direction | Type | Binding | Description |
11+
| **Name** | **Direction** | **Type** | **Binding** | **Description** |
1212
|:------------ |:-------------|:-----|:---|:---|
13-
| In | Input | Dynamic Vector | None | Input value |
14-
| Screen Position | Input | Vector 4 | Screen Position | Coordinates used to apply dither pattern |
15-
| Out | Output | Dynamic Vector | None | Output value |
13+
| **In** | Input | Dynamic vector | None | The input to dither. The noise stays within the overall minimum and maximum range of the input values. |
14+
| **Screen Position** | Input | Vector 4 | Screen Position | The coordinates Unity uses to calculate the dither pattern. For more information about the options, refer to the [Screen Position node](Screen-Position-Node.md). |
15+
| **Out** | Output | Dynamic vector | None | The dithered output. |
1616

17-
## Generated Code Example
17+
## Generated code example
1818

1919
The following example code represents one possible outcome of this node.
2020

@@ -33,3 +33,4 @@ void Unity_Dither_float4(float4 In, float4 ScreenPosition, out float4 Out)
3333
Out = In - DITHER_THRESHOLDS[index];
3434
}
3535
```
36+

0 commit comments

Comments
 (0)