Skip to content

Commit 1b1ffe1

Browse files
authored
Merge pull request #8274 from Unity-Technologies/internal/6000.0/staging
Mirror Internal/6000.0/staging
2 parents 8cce35d + 03aaff5 commit 1b1ffe1

File tree

81 files changed

+6326
-823
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+6326
-823
lines changed

Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct UnityTexture2D
2323
SAMPLER(samplerstate);
2424
float4 texelSize;
2525
float4 scaleTranslate;
26+
float4 hdrDecode;
2627

2728
// these functions allows users to convert code using Texture2D to UnityTexture2D by simply changing the type of the variable
2829
// the existing texture macros will call these functions, which will forward the call to the texture appropriately
@@ -61,15 +62,16 @@ float4 tex2D(UnityTexture2D tex, float2 uv) { return SAMPLE_TEXT
6162
float4 tex2Dlod(UnityTexture2D tex, float4 uv0l) { return SAMPLE_TEXTURE2D_LOD(tex.tex, tex.samplerstate, uv0l.xy, uv0l.w); }
6263
float4 tex2Dbias(UnityTexture2D tex, float4 uv0b) { return SAMPLE_TEXTURE2D_BIAS(tex.tex, tex.samplerstate, uv0b.xy, uv0b.w); }
6364

64-
#define UnityBuildTexture2DStruct(n) UnityBuildTexture2DStructInternal(TEXTURE2D_ARGS(n, sampler##n), n##_TexelSize, n##_ST)
65-
#define UnityBuildTexture2DStructNoScale(n) UnityBuildTexture2DStructInternal(TEXTURE2D_ARGS(n, sampler##n), n##_TexelSize, float4(1, 1, 0, 0))
66-
UnityTexture2D UnityBuildTexture2DStructInternal(TEXTURE2D_PARAM(tex, samplerstate), float4 texelSize, float4 scaleTranslate)
65+
#define UnityBuildTexture2DStruct(n) UnityBuildTexture2DStructInternal(TEXTURE2D_ARGS(n, sampler##n), n##_TexelSize, n##_ST, float4(0, 0, 0, 0))
66+
#define UnityBuildTexture2DStructNoScale(n) UnityBuildTexture2DStructInternal(TEXTURE2D_ARGS(n, sampler##n), n##_TexelSize, float4(1, 1, 0, 0), float4(0, 0, 0, 0))
67+
UnityTexture2D UnityBuildTexture2DStructInternal(TEXTURE2D_PARAM(tex, samplerstate), float4 texelSize, float4 scaleTranslate, float4 hdrDecode)
6768
{
6869
UnityTexture2D result;
6970
result.tex = tex;
7071
result.samplerstate = samplerstate;
7172
result.texelSize = texelSize;
7273
result.scaleTranslate = scaleTranslate;
74+
result.hdrDecode = hdrDecode;
7375
return result;
7476
}
7577

@@ -78,6 +80,7 @@ struct UnityTexture2DArray
7880
{
7981
TEXTURE2D_ARRAY(tex);
8082
SAMPLER(samplerstate);
83+
float4 hdrDecode;
8184

8285
// these functions allows users to convert code using Texture2DArray to UnityTexture2DArray by simply changing the type of the variable
8386
// the existing texture macros will call these functions, which will forward the call to the texture appropriately
@@ -94,12 +97,13 @@ struct UnityTexture2DArray
9497
float4 Load(int4 pixel) { return LOAD_TEXTURE2D_ARRAY(tex, pixel.xy, pixel.z); }
9598
};
9699

97-
#define UnityBuildTexture2DArrayStruct(n) UnityBuildTexture2DArrayStructInternal(TEXTURE2D_ARRAY_ARGS(n, sampler##n))
98-
UnityTexture2DArray UnityBuildTexture2DArrayStructInternal(TEXTURE2D_ARRAY_PARAM(tex, samplerstate))
100+
#define UnityBuildTexture2DArrayStruct(n) UnityBuildTexture2DArrayStructInternal(TEXTURE2D_ARRAY_ARGS(n, sampler##n), float4(0, 0, 0, 0))
101+
UnityTexture2DArray UnityBuildTexture2DArrayStructInternal(TEXTURE2D_ARRAY_PARAM(tex, samplerstate), float4 hdrDecode)
99102
{
100103
UnityTexture2DArray result;
101104
result.tex = tex;
102105
result.samplerstate = samplerstate;
106+
result.hdrDecode = hdrDecode;
103107
return result;
104108
}
105109

@@ -108,6 +112,7 @@ struct UnityTextureCube
108112
{
109113
TEXTURECUBE(tex);
110114
SAMPLER(samplerstate);
115+
float4 hdrDecode;
111116

112117
// these functions allows users to convert code using TextureCube to UnityTextureCube by simply changing the type of the variable
113118
// the existing texture macros will call these functions, which will forward the call to the texture appropriately
@@ -128,12 +133,13 @@ struct UnityTextureCube
128133
float4 texCUBE(UnityTextureCube tex, float3 dir) { return SAMPLE_TEXTURECUBE(tex.tex, tex.samplerstate, dir); }
129134
float4 texCUBEbias(UnityTextureCube tex, float4 dirBias) { return SAMPLE_TEXTURECUBE_BIAS(tex.tex, tex.samplerstate, dirBias.xyz, dirBias.w); }
130135

131-
#define UnityBuildTextureCubeStruct(n) UnityBuildTextureCubeStructInternal(TEXTURECUBE_ARGS(n, sampler##n))
132-
UnityTextureCube UnityBuildTextureCubeStructInternal(TEXTURECUBE_PARAM(tex, samplerstate))
136+
#define UnityBuildTextureCubeStruct(n) UnityBuildTextureCubeStructInternal(TEXTURECUBE_ARGS(n, sampler##n), float4(0, 0, 0, 0))
137+
UnityTextureCube UnityBuildTextureCubeStructInternal(TEXTURECUBE_PARAM(tex, samplerstate), float4 hdrDecode)
133138
{
134139
UnityTextureCube result;
135140
result.tex = tex;
136141
result.samplerstate = samplerstate;
142+
result.hdrDecode = hdrDecode;
137143
return result;
138144
}
139145

@@ -142,6 +148,7 @@ struct UnityTexture3D
142148
{
143149
TEXTURE3D(tex);
144150
SAMPLER(samplerstate);
151+
float4 hdrDecode;
145152

146153
// these functions allows users to convert code using Texture3D to UnityTexture3D by simply changing the type of the variable
147154
// the existing texture macros will call these functions, which will forward the call to the texture appropriately
@@ -155,12 +162,13 @@ struct UnityTexture3D
155162

156163
float4 tex3D(UnityTexture3D tex, float3 uvw) { return SAMPLE_TEXTURE3D(tex.tex, tex.samplerstate, uvw); }
157164

158-
#define UnityBuildTexture3DStruct(n) UnityBuildTexture3DStructInternal(TEXTURE3D_ARGS(n, sampler##n))
159-
UnityTexture3D UnityBuildTexture3DStructInternal(TEXTURE3D_PARAM(tex, samplerstate))
165+
#define UnityBuildTexture3DStruct(n) UnityBuildTexture3DStructInternal(TEXTURE3D_ARGS(n, sampler##n), float4(0, 0, 0, 0))
166+
UnityTexture3D UnityBuildTexture3DStructInternal(TEXTURE3D_PARAM(tex, samplerstate), float4 hdrDecode)
160167
{
161168
UnityTexture3D result;
162169
result.tex = tex;
163170
result.samplerstate = samplerstate;
171+
result.hdrDecode = hdrDecode;
164172
return result;
165173
}
166174

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

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ public static void ShowExample()
4343
// Variables used for refresh view
4444
private bool doRefresh;
4545
private int cachedSceneHandle;
46+
private Vector3 cachedCamPos;
4647
private int totalLightCount;
4748
private int totalShadowCount;
48-
private Vector3 cachedCamPos;
49+
private string[] cachedLightNames;
50+
private string[] cachedShadowCasterNames;
4951

5052
ILight2DCullResult lightCullResult
5153
{
@@ -118,6 +120,9 @@ private VisualElement MakePill(UnityEngine.Object obj)
118120
var bubble = new Button();
119121
bubble.AddToClassList("Pill");
120122
bubble.text = obj.name;
123+
bubble.style.maxWidth = 200;
124+
bubble.style.overflow = Overflow.Hidden;
125+
bubble.style.textOverflow = TextOverflow.Ellipsis;
121126

122127
bubble.clicked += () =>
123128
{
@@ -469,8 +474,20 @@ private bool IsDirty()
469474

470475
if (lightCullResult.IsGameView())
471476
{
477+
var visibleShadows = lightCullResult.visibleShadows.SelectMany(x => x.GetShadowCasters()).ToList();
478+
472479
isDirty |= totalLightCount != lightCullResult.visibleLights.Count();
473-
isDirty |= totalShadowCount != lightCullResult.visibleShadows.Count();
480+
isDirty |= totalShadowCount != visibleShadows.Count();
481+
482+
// Account for name changes
483+
if (!isDirty)
484+
{
485+
for (int i = 0; i < totalLightCount; ++i)
486+
isDirty |= !lightCullResult.visibleLights.Exists(x => x != null && x.name == cachedLightNames[i]);
487+
488+
for (int i = 0; i < totalShadowCount; ++i)
489+
isDirty |= !visibleShadows.Exists(x => x != null && x.name == cachedShadowCasterNames[i]);
490+
}
474491
}
475492

476493
return isDirty;
@@ -485,8 +502,27 @@ private void ResetDirty()
485502

486503
if (lightCullResult != null)
487504
{
505+
var visibleShadows = lightCullResult.visibleShadows.SelectMany(x => x.GetShadowCasters());
506+
488507
totalLightCount = lightCullResult.visibleLights.Count();
489-
totalShadowCount = lightCullResult.visibleShadows.Count();
508+
totalShadowCount = visibleShadows.Count();
509+
510+
cachedLightNames = new string[totalLightCount];
511+
cachedShadowCasterNames = new string[totalShadowCount];
512+
513+
for (int i = 0; i < totalLightCount; ++i)
514+
{
515+
var light = lightCullResult.visibleLights[i];
516+
if (light != null)
517+
cachedLightNames[i] = light.name;
518+
}
519+
520+
for (int i = 0; i < totalShadowCount; ++i)
521+
{
522+
var shadowCaster = visibleShadows.ElementAt(i);
523+
if (shadowCaster != null)
524+
cachedShadowCasterNames[i] = shadowCaster.name;
525+
}
490526
}
491527

492528
doRefresh = false;

Packages/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineAsset/UniversalRenderPipelineAssetUI.Skin.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ internal static class Styles
5555
public static readonly GUIContent lightProbeSystemContent = EditorGUIUtility.TrTextContent("Light Probe System", "What system to use for Light Probes.");
5656
public static readonly GUIContent probeVolumeMemoryBudget = EditorGUIUtility.TrTextContent("Memory Budget", "Determines the width and height of the 3D textures used to store lighting data from probes. Depth is fixed.");
5757
public static readonly GUIContent probeVolumeBlendingMemoryBudget = EditorGUIUtility.TrTextContent("Blending Memory Budget", "Determines the width and height of the 3D textures used to store light scenario blending data from probes. Depth is fixed.");
58-
public static readonly GUIContent supportProbeVolumeGPUStreaming = EditorGUIUtility.TrTextContent("Enable GPU Streaming", "Enable steaming of Cells for Adaptive Probe Volumes.");
59-
public static readonly GUIContent supportProbeVolumeDiskStreaming = EditorGUIUtility.TrTextContent("Enable Disk Streaming", "Enable steaming of Cells from disk for Adaptive Probe Volumes.");
58+
public static readonly GUIContent supportProbeVolumeGPUStreaming = EditorGUIUtility.TrTextContent("Enable GPU Streaming", "Enable streaming of Cells for Adaptive Probe Volumes.");
59+
public static readonly GUIContent supportProbeVolumeDiskStreaming = EditorGUIUtility.TrTextContent("Enable Disk Streaming", "Enable streaming of Cells from disk for Adaptive Probe Volumes.");
6060
public static readonly GUIContent supportProbeVolumeScenarios = EditorGUIUtility.TrTextContent("Enable Lighting Scenarios", "Enable Lighting Scenario Baking for Adaptive Probe Volumes.");
6161
public static readonly GUIContent supportProbeVolumeScenarioBlending = EditorGUIUtility.TrTextContent("Enable Lighting Scenario Blending", "Enable Lighting Scenario Blending for Adaptive Probe Volumes.\nNote: Lighting Scenario Blending requires Compute Shader support.");
6262
public static readonly GUIContent probeVolumeSHBands = EditorGUIUtility.TrTextContent("SH Bands", "The number of Spherical Harmonic bands used by Adaptive Probe Volumes to store lighting data. Choosing L2 provides better quality but with higher memory and runtime costs.");

Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,21 +1954,39 @@ internal enum URPProfileId
19541954
internal static class PlatformAutoDetect
19551955
{
19561956
/// <summary>
1957-
/// Detect and cache runtime platform information. This function should only be called once when creating the URP.
1957+
/// Detect and cache runtime platform information.
1958+
/// Lazy initialized for situations where platform detection is required before URP is initialized (UUM-134298)
19581959
/// </summary>
1959-
internal static void Initialize()
1960+
private sealed class PlatformDetectionCache
19601961
{
1961-
bool isRunningMobile = false;
1962-
#if ENABLE_VR && ENABLE_VR_MODULE
1963-
#if PLATFORM_WINRT || PLATFORM_ANDROID
1964-
isRunningMobile = IsRunningXRMobile();
1962+
public readonly bool isXRMobile;
1963+
public readonly bool isShaderAPIMobileDefined;
1964+
public readonly bool isSwitch;
1965+
public readonly bool isSwitch2;
1966+
public readonly bool isRunningOnPowerVRGPU;
1967+
1968+
public PlatformDetectionCache()
1969+
{
1970+
bool isRunningMobile = false;
1971+
#if ENABLE_VR && ENABLE_VR_MODULE
1972+
#if PLATFORM_WINRT || PLATFORM_ANDROID
1973+
isRunningMobile = IsRunningXRMobile();
1974+
#endif
19651975
#endif
1966-
#endif
19671976

1968-
isXRMobile = isRunningMobile;
1969-
isShaderAPIMobileDefined = GraphicsSettings.HasShaderDefine(BuiltinShaderDefine.SHADER_API_MOBILE);
1970-
isSwitch = Application.platform == RuntimePlatform.Switch;
1971-
isSwitch2 = Application.platform == RuntimePlatform.Switch2;
1977+
isXRMobile = isRunningMobile;
1978+
isShaderAPIMobileDefined = GraphicsSettings.HasShaderDefine(BuiltinShaderDefine.SHADER_API_MOBILE);
1979+
isSwitch = Application.platform == RuntimePlatform.Switch;
1980+
isSwitch2 = Application.platform == RuntimePlatform.Switch2;
1981+
isRunningOnPowerVRGPU = SystemInfo.graphicsDeviceName.Contains("PowerVR");
1982+
}
1983+
}
1984+
1985+
private static readonly Lazy<PlatformDetectionCache> platformCache = new(() => new PlatformDetectionCache(), true);
1986+
1987+
internal static void Initialize()
1988+
{
1989+
_ = platformCache.Value;
19721990
}
19731991

19741992
#if ENABLE_VR && ENABLE_VR_MODULE
@@ -1997,19 +2015,21 @@ private static bool IsRunningXRMobile()
19972015
/// <summary>
19982016
/// If true, the runtime platform is an XR mobile platform.
19992017
/// </summary>
2000-
internal static bool isXRMobile { get; private set; } = false;
2018+
internal static bool isXRMobile => platformCache.Value.isXRMobile;
20012019

20022020
/// <summary>
20032021
/// If true, then SHADER_API_MOBILE has been defined in URP Shaders.
20042022
/// </summary>
2005-
internal static bool isShaderAPIMobileDefined { get; private set; } = false;
2023+
internal static bool isShaderAPIMobileDefined => platformCache.Value.isShaderAPIMobileDefined;
20062024

20072025
/// <summary>
20082026
/// If true, then the runtime platform is set to Switch.
20092027
/// </summary>
2010-
internal static bool isSwitch { get; private set; } = false;
2028+
internal static bool isSwitch => platformCache.Value.isSwitch;
20112029

2012-
internal static bool isSwitch2 { get; private set; } = false;
2030+
internal static bool isSwitch2 => platformCache.Value.isSwitch2;
2031+
2032+
internal static bool isRunningOnPowerVRGPU => platformCache.Value.isRunningOnPowerVRGPU;
20132033

20142034
/// <summary>
20152035
/// Gives the SH evaluation mode when set to automatically detect.
@@ -2028,7 +2048,5 @@ internal static ShEvalMode ShAutoDetect(ShEvalMode mode)
20282048

20292049
return mode;
20302050
}
2031-
2032-
internal static bool isRunningOnPowerVRGPU = SystemInfo.graphicsDeviceName.Contains("PowerVR");
20332051
}
20342052
}

Packages/com.unity.shadergraph/Documentation~/Blackboard.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Description
44
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.
55

6-
![image](images/blackboardcategories1.png)
6+
![The blackboard layout with properties, keywords, and categories.](images/blackboardcategories1.png)
77

88
## Accessing the Blackboard
99
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.
@@ -42,8 +42,6 @@ To make the properties in your shader more discoverable, organize them into cate
4242
### Adding, removing, and reordering properties and keywords
4343
* 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.
4444

45-
![image](images/blackboardcategories2.png)
46-
4745
* To remove a property or keyword, select it and press **Delete**, or right-click and select **Delete**.
4846
* To re-order properties or keywords, drag and drop them within a category or move them into other categories.
4947

@@ -66,9 +64,6 @@ To copy a specific set of properties:
6664
### Using categories in the Material Inspector
6765
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.
6866

69-
![image](images/blackboardcategories3.png)
70-
71-
7267
#### Working with Streaming Virtual Textures
7368
[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.
7469

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,4 @@ If you disable **Automatically Add or Remove Blocks**, Shader Graph doesn't auto
2626

2727
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.
2828

29-
![image](images/Active-Inactive-Blocks.png)
30-
3129
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.

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ Defines a constant **Boolean** value in the [Shader Graph](index.md), although i
66

77
## Ports
88

9-
| Name | Direction | Type | Binding | Description |
10-
|:------------ |:-------------|:-----|:---|:---|
11-
| Out | Output | Boolean | None | Output value |
9+
| Name | Direction | Type | Binding | Description |
10+
|:--- |:---|:---|:---|:---|
11+
| Out | Output | Boolean | None | Output value |
1212

1313
## Controls
1414

15-
| Name | Type | Options | Description |
16-
|:------------ |:-------------|:-----|:---|
17-
| | Toggle | | Defines the output value. |
15+
| Control | Description |
16+
|:---|:---|
17+
| (Checkbox) | Defines the output value. |
1818

1919
## Generated Code Example
2020

Packages/com.unity.shadergraph/Documentation~/Channel-Mixer-Node.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ Controls the amount each of the channels of input **In** contribute to each of t
66

77
## Ports
88

9-
| Name | Direction | Type | Binding | Description |
10-
|:------------ |:-------------|:-----|:---|:---|
11-
| In | Input | Vector 3 | None | Input value |
12-
| Out | Output | Vector 3 | None | Output value |
9+
| Name | Direction | Type | Binding | Description |
10+
|:---|:---|:---|:---|:---|
11+
| In | Input | Vector 3 | None | Input value |
12+
| Out | Output | Vector 3 | None | Output value |
1313

1414
## Controls
1515

16-
| Name | Type | Options | Description |
17-
|:------------ |:-------------|:-----|:---|
18-
| | Toggle Button Array | R, G, B | Selects the output channel to edit. |
19-
| R | Slider | | Controls contribution of input red channel to selected output channel. |
20-
| G | Slider | | Controls contribution of input green channel to selected output channel. |
21-
| B | Slider | | Controls contribution of input blue channel to selected output channel. |
16+
| Control | Description |
17+
|:---|:---|
18+
| **R**, **G**, **B** (toggle buttons) | Selects the output channel to edit with the sliders. |
19+
| **R** (slider) | Controls the contribution of the input red channel to the selected output channel. |
20+
| **G** (slider) | Controls the contribution of the input green channel to the selected output channel. |
21+
| **B** (slider) | Controls the contribution of the input blue channel to the selected output channel. |
2222

2323
## Shader Function
2424

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ NOTE: In versions prior to 10.0, Shader Graph assumed that HDR colors from the C
88

99
## Ports
1010

11-
| Name | Direction | Type | Binding | Description |
12-
|:------------ |:-------------|:-----|:---|:---|
13-
| Out | Output | Vector 4 | None | Output value |
11+
| Name | Direction | Type | Binding | Description |
12+
|:--- |:---|:---|:---|:---|
13+
| Out | Output | Vector 4 | None | Output value |
1414

1515
## Controls
1616

17-
| Name | Type | Options | Description |
18-
|:------------ |:-------------|:-----|:---|
19-
| | Color | | Defines the output value. |
20-
| Mode | Dropdown | Default, HDR | Sets properties of the Color field |
17+
| Control | Description |
18+
|:---|:---|
19+
| (Color) | Defines the output value. |
20+
| **Mode** | Sets properties of the Color field. The options are:<ul><li>**Default**</li><li>**HDR**</li></ul> |
2121

2222
## Generated Code Example
2323

0 commit comments

Comments
 (0)