Skip to content

Commit ca67aa3

Browse files
Cleanup Render Pipeline menu script entry (#993)
* Cleanup script in Edit menu * Update Render-Pipeline-Wizard.md
1 parent bd80b94 commit ca67aa3

File tree

8 files changed

+67
-447
lines changed

8 files changed

+67
-447
lines changed

com.unity.render-pipelines.high-definition/Documentation~/Material-Upgrade.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ Please note that if a version control system that requires check out operations
1818
In case the above process fails and a material is not working as expected when upgrading HDRP version, it is suggested to run the upgrade process manually. To do so, you can either:
1919

2020
- Open the [Render Pipeline Wizard](Render-Pipeline-Wizard.html) and under the **Project Migration Quick-links** click on the Upgrade HDRP Materials to Latest Version button. Or:
21-
- Select **Edit > Render Pipelines > Upgrade HDRP Materials to Latest Version**
21+
- Select **Edit > Render Pipelines > HD Render Pipeline > Upgrade from Previous Version > Upgrade HDRP Materials to Latest Version**

com.unity.render-pipelines.high-definition/Documentation~/Render-Pipeline-Wizard.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ Note that every **Fix** will be deactivated if your Hardware or OS do not suppor
9393

9494
## Project Migration Quick-links
9595

96-
When upgrading a project from the built-in render pipeline to HDRP, you need to do upgrade your Lights and your Materials. Use the following utility functions to help with the upgrade process:
96+
When upgrading a project from the built-in render pipeline to HDRP, you need to do upgrade your Materials. Use the following utility functions to help with the upgrade process:
9797

9898
- **Upgrade Project Materials to High Definition Materials**: Upgrades every Material in your Unity Project to HDRP Materials.
9999
- **Upgrade Selected Materials to High Definition Materials**: Upgrades every Material currently selected to HDRP Materials.
100-
- **Multiply Unity Builtin Directional Light Intensity to match High Definition**: Multiply intensity of each Directional Light in the current Scene to match HDRP compatible intensity values. Caution: This script should be executed only once.
101100

101+
The lighting will not match as HDRP use a different attenuation function than built-in and use correct math to handle lighting model. There is no function that can convert the look. Thus the lighting will require to be redone.

com.unity.render-pipelines.high-definition/Editor/PostProcessing/TonemappingEditor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public override void OnInspectorGUI()
125125

126126
PropertyField(m_LutContribution, EditorGUIUtility.TrTextContent("Contribution"));
127127

128-
EditorGUILayout.HelpBox("Use \"Edit > Render Pipeline > Render Selected Camera to Log EXR\" to export a log-encoded frame for external grading.", MessageType.Info);
128+
EditorGUILayout.HelpBox("Use \"Edit > Render Pipeline > HD Render Pipeline > Render Selected Camera to Log EXR\" to export a log-encoded frame for external grading.", MessageType.Info);
129129
}
130130
}
131131

@@ -142,7 +142,7 @@ void CheckCurveRT(int width, int height)
142142

143143
sealed class ExrExportMenu
144144
{
145-
[MenuItem("Edit/Render Pipeline/Render Selected Camera to Log EXR %#&e", priority = CoreUtils.editMenuPriority3)]
145+
[MenuItem("Edit/Render Pipeline/HD Render Pipeline/Render Selected Camera to Log EXR %#&e")]
146146
static void Export()
147147
{
148148
var camera = Selection.activeGameObject?.GetComponent<Camera>();

com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineMenuItems.cs

Lines changed: 57 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using UnityEngine.SceneManagement;
99
using UnityEditor.SceneManagement;
1010
using UnityEngine.Rendering;
11+
using UnityEngine.Assertions;
1112

1213
namespace UnityEditor.Rendering.HighDefinition
1314
{
@@ -45,7 +46,7 @@ static void RemoveTessellationMaterials()
4546
}
4647
}
4748

48-
[MenuItem("Edit/Render Pipeline/Export Sky to Image", priority = CoreUtils.editMenuPriority3)]
49+
[MenuItem("Edit/Render Pipeline/HD Render Pipeline/Export Sky to Image")]
4950
static void ExportSkyToImage()
5051
{
5152
var renderpipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline;
@@ -95,160 +96,11 @@ static void CreateSceneSettingsGameObject(MenuCommand menuCommand)
9596
volume.sharedProfile = profile;
9697
}
9798

98-
[MenuItem("Edit/Render Pipeline/Upgrade Fog Volume Components", priority = CoreUtils.editMenuPriority2)]
99-
static void UpgradeFogVolumeComponents(MenuCommand menuCommand)
99+
[MenuItem("Edit/Render Pipeline/HD Render Pipeline/Upgrade from Previous Version /Upgrade HDRP Materials to Latest Version")]
100+
internal static void UpgradeMaterials()
100101
{
101-
void OverrideCommonParameters(AtmosphericScattering input, Fog output)
102-
{
103-
if (input.colorMode.overrideState)
104-
output.colorMode.Override(input.colorMode.value);
105-
if (input.color.overrideState)
106-
output.color.Override(input.color.value);
107-
if (input.maxFogDistance.overrideState)
108-
output.maxFogDistance.Override(input.maxFogDistance.value);
109-
if (input.mipFogMaxMip.overrideState)
110-
output.mipFogMaxMip.Override(input.mipFogMaxMip.value);
111-
if (input.mipFogNear.overrideState)
112-
output.mipFogNear.Override(input.mipFogNear.value);
113-
if (input.mipFogFar.overrideState)
114-
output.mipFogFar.Override(input.mipFogFar.value);
115-
if (input.tint.overrideState)
116-
output.tint.Override(input.tint.value);
117-
}
118-
119-
Fog CreateFogComponentIfNeeded(VolumeProfile profile)
120-
{
121-
Fog fogComponent = null;
122-
if (!profile.TryGet(out fogComponent))
123-
{
124-
fogComponent = VolumeProfileFactory.CreateVolumeComponent<Fog>(profile, false, false);
125-
}
126-
127-
return fogComponent;
128-
}
129-
130-
if (!EditorUtility.DisplayDialog(DialogText.title, "This will upgrade all Volume Profiles containing Exponential or Volumetric Fog components to the new Fog component. " + DialogText.projectBackMessage, DialogText.proceed, DialogText.cancel))
131-
return;
132-
133-
var profilePathList = AssetDatabase.FindAssets("t:VolumeProfile", new string[]{ "Assets" });
134-
135-
int profileCount = profilePathList.Length;
136-
int profileIndex = 0;
137-
foreach (string guid in profilePathList)
138-
{
139-
var assetPath = AssetDatabase.GUIDToAssetPath(guid);
140-
profileIndex++;
141-
if (EditorUtility.DisplayCancelableProgressBar("Upgrade Fog Volume Components", string.Format("({0} of {1}) {2}", profileIndex, profileCount, assetPath), (float)profileIndex / (float)profileCount))
142-
break;
143-
144-
VolumeProfile profile = AssetDatabase.LoadAssetAtPath(assetPath, typeof(VolumeProfile)) as VolumeProfile;
145-
146-
if (profile.TryGet<VisualEnvironment>(out var visualEnv))
147-
{
148-
if (visualEnv.fogType.value == FogType.Exponential || visualEnv.fogType.value == FogType.Volumetric)
149-
{
150-
var fog = CreateFogComponentIfNeeded(profile);
151-
fog.enabled.Override(true);
152-
}
153-
}
154-
155-
156-
if (profile.TryGet<ExponentialFog>(out var expFog))
157-
{
158-
var fog = CreateFogComponentIfNeeded(profile);
159-
160-
// We only migrate distance because the height parameters are not compatible.
161-
if (expFog.fogDistance.overrideState)
162-
fog.meanFreePath.Override(expFog.fogDistance.value);
163-
164-
OverrideCommonParameters(expFog, fog);
165-
EditorUtility.SetDirty(profile);
166-
}
167-
168-
if (profile.TryGet<VolumetricFog>(out var volFog))
169-
{
170-
var fog = CreateFogComponentIfNeeded(profile);
171-
172-
fog.enableVolumetricFog.Override(true);
173-
if (volFog.meanFreePath.overrideState)
174-
fog.meanFreePath.Override(volFog.meanFreePath.value);
175-
if (volFog.albedo.overrideState)
176-
fog.albedo.Override(volFog.albedo.value);
177-
if (volFog.baseHeight.overrideState)
178-
fog.baseHeight.Override(volFog.baseHeight.value);
179-
if (volFog.maximumHeight.overrideState)
180-
fog.maximumHeight.Override(volFog.maximumHeight.value);
181-
if (volFog.anisotropy.overrideState)
182-
fog.anisotropy.Override(volFog.anisotropy.value);
183-
if (volFog.globalLightProbeDimmer.overrideState)
184-
fog.globalLightProbeDimmer.Override(volFog.globalLightProbeDimmer.value);
185-
186-
OverrideCommonParameters(volFog, fog);
187-
EditorUtility.SetDirty(profile);
188-
}
189-
190-
if (profile.TryGet<VolumetricLightingController>(out var volController))
191-
{
192-
var fog = CreateFogComponentIfNeeded(profile);
193-
if (volController.depthExtent.overrideState)
194-
fog.depthExtent.Override(volController.depthExtent.value);
195-
if (volController.sliceDistributionUniformity.overrideState)
196-
fog.sliceDistributionUniformity.Override(volController.sliceDistributionUniformity.value);
197-
198-
EditorUtility.SetDirty(profile);
199-
}
200-
}
201-
202-
AssetDatabase.SaveAssets();
203-
AssetDatabase.Refresh();
204-
EditorUtility.ClearProgressBar();
205-
}
206-
207-
[MenuItem("Edit/Render Pipeline/Upgrade Sky Intensity Mode", priority = CoreUtils.editMenuPriority2)]
208-
static void UpgradeSkyIntensityMode(MenuCommand menuCommand)
209-
{
210-
if (!EditorUtility.DisplayDialog(DialogText.title, "This will upgrade all Volume Profiles containing Sky components with the new intensity mode paradigm. " + DialogText.projectBackMessage, DialogText.proceed, DialogText.cancel))
211-
return;
212-
213-
var profilePathList = AssetDatabase.FindAssets("t:VolumeProfile", new string[] { "Assets" });
214-
215-
int profileCount = profilePathList.Length;
216-
int profileIndex = 0;
217-
foreach (string guid in profilePathList)
218-
{
219-
var assetPath = AssetDatabase.GUIDToAssetPath(guid);
220-
profileIndex++;
221-
if (EditorUtility.DisplayCancelableProgressBar("Upgrade Sky Components", string.Format("({0} of {1}) {2}", profileIndex, profileCount, assetPath), (float)profileIndex / (float)profileCount))
222-
break;
223-
224-
VolumeProfile profile = AssetDatabase.LoadAssetAtPath(assetPath, typeof(VolumeProfile)) as VolumeProfile;
225-
226-
List<SkySettings> m_VolumeSkyList = new List<SkySettings>();
227-
if (profile.TryGetAllSubclassOf<SkySettings>(typeof(SkySettings), m_VolumeSkyList))
228-
{
229-
foreach (var sky in m_VolumeSkyList)
230-
{
231-
// Trivial case where multiplier is not used we ignore, otherwise we end up with a multiplier of 0.833 for a 0.0 EV100 exposure
232-
if (sky.multiplier.value == 1.0f)
233-
continue;
234-
else if (sky.skyIntensityMode.value == SkyIntensityMode.Exposure) // Not Lux
235-
{
236-
// Any component using Exposure and Multiplier at the same time must switch to multiplier as we will convert exposure*multiplier into a multiplier.
237-
sky.skyIntensityMode.Override(SkyIntensityMode.Multiplier);
238-
}
239-
240-
// Convert exposure * multiplier to multiplier and reset exposure for all non trivial cases.
241-
sky.multiplier.Override(sky.multiplier.value * ColorUtils.ConvertEV100ToExposure(-sky.exposure.value));
242-
sky.exposure.Override(0.0f);
243-
244-
EditorUtility.SetDirty(profile);
245-
}
246-
}
247-
}
248-
249-
AssetDatabase.SaveAssets();
250-
AssetDatabase.Refresh();
251-
EditorUtility.ClearProgressBar();
102+
// Force reimport of all materials, this will upgrade the needed one and save the assets if needed
103+
MaterialReimporter.ReimportAllMaterials();
252104
}
253105

254106
class DoCreateNewAsset<TAssetType> : ProjectWindowCallback.EndNameEditAction where TAssetType : ScriptableObject
@@ -364,11 +216,12 @@ static void SynchronizeAllLayeredMaterial()
364216
}
365217
}
366218

219+
// We now do this automatically when upgrading Material version, so not required anymore - keep it in case you want to manually do it
367220
// The goal of this script is to help maintenance of data that have already been produced but need to update to the latest shader code change.
368221
// In case the shader code have change and the inspector have been update with new kind of keywords we need to regenerate the set of keywords use by the material.
369222
// This script will remove all keyword of a material and trigger the inspector that will re-setup all the used keywords.
370223
// It require that the inspector of the material have a static function call that update all keyword based on material properties.
371-
[MenuItem("Edit/Render Pipeline/Reset All Loaded High Definition Materials Keywords", priority = CoreUtils.editMenuPriority3)]
224+
// [MenuItem("Edit/Render Pipeline/HD Render Pipeline/Reset All Loaded High Definition Materials Keywords")]
372225
static void ResetAllMaterialKeywords()
373226
{
374227
try
@@ -382,7 +235,7 @@ static void ResetAllMaterialKeywords()
382235
}
383236

384237
// Don't expose, ResetAllMaterialKeywordsInProjectAndScenes include it anyway
385-
//[MenuItem("Edit/Render Pipeline/Reset All Material Asset's Keywords (Materials in Project)", priority = CoreUtils.editMenuPriority3)]
238+
//[MenuItem("Edit/Render Pipeline/HD Render Pipeline/Reset All Material Asset's Keywords (Materials in Project)")]
386239
static void ResetAllMaterialAssetsKeywords()
387240
{
388241
try
@@ -395,7 +248,8 @@ static void ResetAllMaterialAssetsKeywords()
395248
}
396249
}
397250

398-
[MenuItem("Edit/Render Pipeline/Reset All Project and Scene High Definition Materials Keywords", priority = CoreUtils.editMenuPriority3)]
251+
// We now do this automatically when upgrading Material version, so not required anymore - keep it in case you want to manually do it
252+
// [MenuItem("Edit/Render Pipeline/HD Render Pipeline/Reset All Project and Scene High Definition Materials Keywords")]
399253
static void ResetAllMaterialKeywordsInProjectAndScenes()
400254
{
401255
var openedScenes = new string[EditorSceneManager.loadedSceneCount];
@@ -520,7 +374,7 @@ public void LogException(Exception exception, UnityObject context)
520374
}
521375
}
522376

523-
[MenuItem("Edit/Render Pipeline/Check Scene Content for Ray Tracing", priority = CoreUtils.editMenuPriority4)]
377+
[MenuItem("Edit/Render Pipeline/HD Render Pipeline/Check Scene Content for Ray Tracing")]
524378
static void CheckSceneContentForRayTracing(MenuCommand menuCommand)
525379
{
526380
// Flag that holds
@@ -610,5 +464,50 @@ static void CheckSceneContentForRayTracing(MenuCommand menuCommand)
610464
Debug.Log("No errors were detected in the process.");
611465
}
612466
}
467+
468+
[MenuItem("Edit/Render Pipeline/HD Render Pipeline/Upgrade from Previous Version/Fix Warning 'referenced script in (Game Object 'SceneIDMap') is missing' in loaded scenes")]
469+
static public void FixWarningGameObjectSceneIDMapIsMissingInLoadedScenes()
470+
{
471+
var rootCache = new List<GameObject>();
472+
for (var i = 0; i < SceneManager.sceneCount; ++i)
473+
FixWarningGameObjectSceneIDMapIsMissingFor(SceneManager.GetSceneAt(i), rootCache);
474+
}
475+
476+
static void FixWarningGameObjectSceneIDMapIsMissingFor(Scene scene, List<GameObject> rootCache)
477+
{
478+
Assert.IsTrue(scene.isLoaded);
479+
480+
var roots = rootCache ?? new List<GameObject>();
481+
roots.Clear();
482+
scene.GetRootGameObjects(roots);
483+
bool markSceneAsDirty = false;
484+
for (var i = roots.Count - 1; i >= 0; --i)
485+
{
486+
if (roots[i].name == "SceneIDMap")
487+
{
488+
if (roots[i].GetComponent<SceneObjectIDMapSceneAsset>() == null)
489+
{
490+
// This gameObject must have SceneObjectIDMapSceneAsset
491+
// If not, then Unity can't find the component.
492+
// We can remove it, it will be regenerated properly by rebaking
493+
// the probes.
494+
//
495+
// This happens for scene with baked probes authored before renaming
496+
// the HDRP's namespaces without the 'Experiemental' prefix.
497+
// The serialization used this path explicitly, thus the Unity serialization
498+
// system lost the reference to the MonoBehaviour
499+
UnityEngine.Object.DestroyImmediate(roots[i]);
500+
501+
// If we do any any modification on the scene
502+
// we need to dirty it, otherwise, the editor won't commit the change to the disk
503+
// and the issue will still persist.
504+
if (!markSceneAsDirty)
505+
markSceneAsDirty = true;
506+
}
507+
}
508+
}
509+
if (markSceneAsDirty)
510+
SceneManagement.EditorSceneManager.MarkSceneDirty(scene);
511+
}
613512
}
614513
}

0 commit comments

Comments
 (0)