From 7b1dd75ac9a8cd01a84d25e56b4a471468137954 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Fri, 19 Jun 2020 19:08:05 +0200 Subject: [PATCH 1/2] Cleanup script in Edit menu --- .../Documentation~/Material-Upgrade.md | 2 +- .../PostProcessing/TonemappingEditor.cs | 4 +- .../HDRenderPipelineMenuItems.cs | 215 ++++----------- .../Editor/Upgraders/UpgradeMenuItem.cs | 247 ------------------ .../Editor/Upgraders/UpgradeMenuItem.cs.meta | 11 - .../UpgradeStandardShaderMaterials.cs | 27 +- .../Editor/Wizard/HDWizard.Window.cs | 4 +- 7 files changed, 65 insertions(+), 445 deletions(-) delete mode 100644 com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeMenuItem.cs delete mode 100644 com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeMenuItem.cs.meta diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Material-Upgrade.md b/com.unity.render-pipelines.high-definition/Documentation~/Material-Upgrade.md index bee7ef5fdd7..1e256c621e8 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Material-Upgrade.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Material-Upgrade.md @@ -18,4 +18,4 @@ Please note that if a version control system that requires check out operations 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: - 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: -- Select **Edit > Render Pipelines > Upgrade HDRP Materials to Latest Version** \ No newline at end of file +- Select **Edit > Render Pipelines > HD Render Pipeline > Upgrade from Previous Version > Upgrade HDRP Materials to Latest Version** diff --git a/com.unity.render-pipelines.high-definition/Editor/PostProcessing/TonemappingEditor.cs b/com.unity.render-pipelines.high-definition/Editor/PostProcessing/TonemappingEditor.cs index 6df51c75676..256ffd2bcc5 100644 --- a/com.unity.render-pipelines.high-definition/Editor/PostProcessing/TonemappingEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/PostProcessing/TonemappingEditor.cs @@ -125,7 +125,7 @@ public override void OnInspectorGUI() PropertyField(m_LutContribution, EditorGUIUtility.TrTextContent("Contribution")); - EditorGUILayout.HelpBox("Use \"Edit > Render Pipeline > Render Selected Camera to Log EXR\" to export a log-encoded frame for external grading.", MessageType.Info); + 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); } } @@ -142,7 +142,7 @@ void CheckCurveRT(int width, int height) sealed class ExrExportMenu { - [MenuItem("Edit/Render Pipeline/Render Selected Camera to Log EXR %#&e", priority = CoreUtils.editMenuPriority3)] + [MenuItem("Edit/Render Pipeline/HD Render Pipeline/Render Selected Camera to Log EXR %#&e")] static void Export() { var camera = Selection.activeGameObject?.GetComponent(); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineMenuItems.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineMenuItems.cs index 106f326c19d..37c74e1f310 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineMenuItems.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineMenuItems.cs @@ -8,6 +8,7 @@ using UnityEngine.SceneManagement; using UnityEditor.SceneManagement; using UnityEngine.Rendering; +using UnityEngine.Assertions; namespace UnityEditor.Rendering.HighDefinition { @@ -45,7 +46,7 @@ static void RemoveTessellationMaterials() } } - [MenuItem("Edit/Render Pipeline/Export Sky to Image", priority = CoreUtils.editMenuPriority3)] + [MenuItem("Edit/Render Pipeline/HD Render Pipeline/Export Sky to Image")] static void ExportSkyToImage() { var renderpipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline; @@ -95,160 +96,11 @@ static void CreateSceneSettingsGameObject(MenuCommand menuCommand) volume.sharedProfile = profile; } - [MenuItem("Edit/Render Pipeline/Upgrade Fog Volume Components", priority = CoreUtils.editMenuPriority2)] - static void UpgradeFogVolumeComponents(MenuCommand menuCommand) + [MenuItem("Edit/Render Pipeline/HD Render Pipeline/Upgrade from Previous Version /Upgrade HDRP Materials to Latest Version")] + internal static void UpgradeMaterials() { - void OverrideCommonParameters(AtmosphericScattering input, Fog output) - { - if (input.colorMode.overrideState) - output.colorMode.Override(input.colorMode.value); - if (input.color.overrideState) - output.color.Override(input.color.value); - if (input.maxFogDistance.overrideState) - output.maxFogDistance.Override(input.maxFogDistance.value); - if (input.mipFogMaxMip.overrideState) - output.mipFogMaxMip.Override(input.mipFogMaxMip.value); - if (input.mipFogNear.overrideState) - output.mipFogNear.Override(input.mipFogNear.value); - if (input.mipFogFar.overrideState) - output.mipFogFar.Override(input.mipFogFar.value); - if (input.tint.overrideState) - output.tint.Override(input.tint.value); - } - - Fog CreateFogComponentIfNeeded(VolumeProfile profile) - { - Fog fogComponent = null; - if (!profile.TryGet(out fogComponent)) - { - fogComponent = VolumeProfileFactory.CreateVolumeComponent(profile, false, false); - } - - return fogComponent; - } - - 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)) - return; - - var profilePathList = AssetDatabase.FindAssets("t:VolumeProfile", new string[]{ "Assets" }); - - int profileCount = profilePathList.Length; - int profileIndex = 0; - foreach (string guid in profilePathList) - { - var assetPath = AssetDatabase.GUIDToAssetPath(guid); - profileIndex++; - if (EditorUtility.DisplayCancelableProgressBar("Upgrade Fog Volume Components", string.Format("({0} of {1}) {2}", profileIndex, profileCount, assetPath), (float)profileIndex / (float)profileCount)) - break; - - VolumeProfile profile = AssetDatabase.LoadAssetAtPath(assetPath, typeof(VolumeProfile)) as VolumeProfile; - - if (profile.TryGet(out var visualEnv)) - { - if (visualEnv.fogType.value == FogType.Exponential || visualEnv.fogType.value == FogType.Volumetric) - { - var fog = CreateFogComponentIfNeeded(profile); - fog.enabled.Override(true); - } - } - - - if (profile.TryGet(out var expFog)) - { - var fog = CreateFogComponentIfNeeded(profile); - - // We only migrate distance because the height parameters are not compatible. - if (expFog.fogDistance.overrideState) - fog.meanFreePath.Override(expFog.fogDistance.value); - - OverrideCommonParameters(expFog, fog); - EditorUtility.SetDirty(profile); - } - - if (profile.TryGet(out var volFog)) - { - var fog = CreateFogComponentIfNeeded(profile); - - fog.enableVolumetricFog.Override(true); - if (volFog.meanFreePath.overrideState) - fog.meanFreePath.Override(volFog.meanFreePath.value); - if (volFog.albedo.overrideState) - fog.albedo.Override(volFog.albedo.value); - if (volFog.baseHeight.overrideState) - fog.baseHeight.Override(volFog.baseHeight.value); - if (volFog.maximumHeight.overrideState) - fog.maximumHeight.Override(volFog.maximumHeight.value); - if (volFog.anisotropy.overrideState) - fog.anisotropy.Override(volFog.anisotropy.value); - if (volFog.globalLightProbeDimmer.overrideState) - fog.globalLightProbeDimmer.Override(volFog.globalLightProbeDimmer.value); - - OverrideCommonParameters(volFog, fog); - EditorUtility.SetDirty(profile); - } - - if (profile.TryGet(out var volController)) - { - var fog = CreateFogComponentIfNeeded(profile); - if (volController.depthExtent.overrideState) - fog.depthExtent.Override(volController.depthExtent.value); - if (volController.sliceDistributionUniformity.overrideState) - fog.sliceDistributionUniformity.Override(volController.sliceDistributionUniformity.value); - - EditorUtility.SetDirty(profile); - } - } - - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); - EditorUtility.ClearProgressBar(); - } - - [MenuItem("Edit/Render Pipeline/Upgrade Sky Intensity Mode", priority = CoreUtils.editMenuPriority2)] - static void UpgradeSkyIntensityMode(MenuCommand menuCommand) - { - 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)) - return; - - var profilePathList = AssetDatabase.FindAssets("t:VolumeProfile", new string[] { "Assets" }); - - int profileCount = profilePathList.Length; - int profileIndex = 0; - foreach (string guid in profilePathList) - { - var assetPath = AssetDatabase.GUIDToAssetPath(guid); - profileIndex++; - if (EditorUtility.DisplayCancelableProgressBar("Upgrade Sky Components", string.Format("({0} of {1}) {2}", profileIndex, profileCount, assetPath), (float)profileIndex / (float)profileCount)) - break; - - VolumeProfile profile = AssetDatabase.LoadAssetAtPath(assetPath, typeof(VolumeProfile)) as VolumeProfile; - - List m_VolumeSkyList = new List(); - if (profile.TryGetAllSubclassOf(typeof(SkySettings), m_VolumeSkyList)) - { - foreach (var sky in m_VolumeSkyList) - { - // 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 - if (sky.multiplier.value == 1.0f) - continue; - else if (sky.skyIntensityMode.value == SkyIntensityMode.Exposure) // Not Lux - { - // Any component using Exposure and Multiplier at the same time must switch to multiplier as we will convert exposure*multiplier into a multiplier. - sky.skyIntensityMode.Override(SkyIntensityMode.Multiplier); - } - - // Convert exposure * multiplier to multiplier and reset exposure for all non trivial cases. - sky.multiplier.Override(sky.multiplier.value * ColorUtils.ConvertEV100ToExposure(-sky.exposure.value)); - sky.exposure.Override(0.0f); - - EditorUtility.SetDirty(profile); - } - } - } - - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); - EditorUtility.ClearProgressBar(); + // Force reimport of all materials, this will upgrade the needed one and save the assets if needed + MaterialReimporter.ReimportAllMaterials(); } class DoCreateNewAsset : ProjectWindowCallback.EndNameEditAction where TAssetType : ScriptableObject @@ -364,11 +216,12 @@ static void SynchronizeAllLayeredMaterial() } } + // We now do this automatically when upgrading Material version, so not required anymore - keep it in case you want to manually do it // 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. // 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. // This script will remove all keyword of a material and trigger the inspector that will re-setup all the used keywords. // It require that the inspector of the material have a static function call that update all keyword based on material properties. - [MenuItem("Edit/Render Pipeline/Reset All Loaded High Definition Materials Keywords", priority = CoreUtils.editMenuPriority3)] + // [MenuItem("Edit/Render Pipeline/HD Render Pipeline/Reset All Loaded High Definition Materials Keywords")] static void ResetAllMaterialKeywords() { try @@ -382,7 +235,7 @@ static void ResetAllMaterialKeywords() } // Don't expose, ResetAllMaterialKeywordsInProjectAndScenes include it anyway - //[MenuItem("Edit/Render Pipeline/Reset All Material Asset's Keywords (Materials in Project)", priority = CoreUtils.editMenuPriority3)] + //[MenuItem("Edit/Render Pipeline/HD Render Pipeline/Reset All Material Asset's Keywords (Materials in Project)")] static void ResetAllMaterialAssetsKeywords() { try @@ -395,7 +248,8 @@ static void ResetAllMaterialAssetsKeywords() } } - [MenuItem("Edit/Render Pipeline/Reset All Project and Scene High Definition Materials Keywords", priority = CoreUtils.editMenuPriority3)] + // We now do this automatically when upgrading Material version, so not required anymore - keep it in case you want to manually do it + // [MenuItem("Edit/Render Pipeline/HD Render Pipeline/Reset All Project and Scene High Definition Materials Keywords")] static void ResetAllMaterialKeywordsInProjectAndScenes() { var openedScenes = new string[EditorSceneManager.loadedSceneCount]; @@ -520,7 +374,7 @@ public void LogException(Exception exception, UnityObject context) } } - [MenuItem("Edit/Render Pipeline/Check Scene Content for Ray Tracing", priority = CoreUtils.editMenuPriority4)] + [MenuItem("Edit/Render Pipeline/HD Render Pipeline/Check Scene Content for Ray Tracing")] static void CheckSceneContentForRayTracing(MenuCommand menuCommand) { // Flag that holds @@ -610,5 +464,50 @@ static void CheckSceneContentForRayTracing(MenuCommand menuCommand) Debug.Log("No errors were detected in the process."); } } + + [MenuItem("Edit/Render Pipeline/HD Render Pipeline/Upgrade from Previous Version/Fix Warning 'referenced script in (Game Object 'SceneIDMap') is missing' in loaded scenes")] + static public void FixWarningGameObjectSceneIDMapIsMissingInLoadedScenes() + { + var rootCache = new List(); + for (var i = 0; i < SceneManager.sceneCount; ++i) + FixWarningGameObjectSceneIDMapIsMissingFor(SceneManager.GetSceneAt(i), rootCache); + } + + static void FixWarningGameObjectSceneIDMapIsMissingFor(Scene scene, List rootCache) + { + Assert.IsTrue(scene.isLoaded); + + var roots = rootCache ?? new List(); + roots.Clear(); + scene.GetRootGameObjects(roots); + bool markSceneAsDirty = false; + for (var i = roots.Count - 1; i >= 0; --i) + { + if (roots[i].name == "SceneIDMap") + { + if (roots[i].GetComponent() == null) + { + // This gameObject must have SceneObjectIDMapSceneAsset + // If not, then Unity can't find the component. + // We can remove it, it will be regenerated properly by rebaking + // the probes. + // + // This happens for scene with baked probes authored before renaming + // the HDRP's namespaces without the 'Experiemental' prefix. + // The serialization used this path explicitly, thus the Unity serialization + // system lost the reference to the MonoBehaviour + UnityEngine.Object.DestroyImmediate(roots[i]); + + // If we do any any modification on the scene + // we need to dirty it, otherwise, the editor won't commit the change to the disk + // and the issue will still persist. + if (!markSceneAsDirty) + markSceneAsDirty = true; + } + } + } + if (markSceneAsDirty) + SceneManagement.EditorSceneManager.MarkSceneDirty(scene); + } } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeMenuItem.cs b/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeMenuItem.cs deleted file mode 100644 index b3c47bae415..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeMenuItem.cs +++ /dev/null @@ -1,247 +0,0 @@ -using System.IO; -using UnityEngine; -using UnityEngine.Rendering.HighDefinition; -using System.Collections.Generic; -using UnityEditor.Rendering; -using UnityEngine.Rendering; -using UnityEditor.ShaderGraph; - -// Include material common properties names -using static UnityEngine.Rendering.HighDefinition.HDMaterialProperties; -using UnityEngine.SceneManagement; -using UnityEngine.Assertions; - -namespace UnityEditor.Rendering.HighDefinition -{ - class UpgradeMenuItems - { - // Version 3 - - // Added RenderStates for shader graphs, we need to ovewrite the material prperties used for the rendering - // in these materials and synch them with the master node values (which are the shader default values, that's - // why we create a new material in this script). - - // List of the render state properties to sync - static readonly string[] floatPropertiesToReset = { - kStencilRef, kStencilWriteMask, - kStencilRefDepth, kStencilWriteMaskDepth, - kStencilRefMV, kStencilWriteMaskMV, - kStencilRefDistortionVec, kStencilWriteMaskDistortionVec, - kStencilRefGBuffer, kStencilWriteMaskGBuffer, kZTestGBuffer, - kSurfaceType, kBlendMode, "_SrcBlend", "_DstBlend", "_AlphaSrcBlend", "_AlphaDstBlend", - kZWrite, "_CullMode", "_CullModeForward", kTransparentCullMode, - kZTestDepthEqualForOpaque, - kAlphaCutoffEnabled, - kTransparentSortPriority, "_UseShadowThreshold", - kDoubleSidedEnable, kDoubleSidedNormalMode, - kTransparentBackfaceEnable, kReceivesSSR, kUseSplitLighting - }; - - static readonly string[] vectorPropertiesToReset = { - "_DoubleSidedConstants", - }; - - // This upgrade functioncopy all the keywords needed for the BlendStates - // to be synced with their master node values, then it calls the HDRP material keyword reset function and finally - // it set the render queue of the material to match the one on the shader graph. - // It's required to sync the shader default properties with the material because when you create a new material, - // by default the Lit shader is assigned to it and so write all his properties into the material. It's a problem - // because now that the shader graphs uses these properties, the material properties don't match the shader settings. - // This function basically fix this. - static bool UpdateMaterial_ShaderGraphRenderStates(string path, Material mat) - { - // We only need to upgrade shadergraphs materials - if (GraphUtil.IsShaderGraph(mat.shader)) - { - var defaultProperties = new Material(mat.shader); - - foreach (var floatToReset in floatPropertiesToReset) - if (mat.HasProperty(floatToReset)) - mat.SetFloat(floatToReset, defaultProperties.GetFloat(floatToReset)); - foreach (var vectorToReset in vectorPropertiesToReset) - if (mat.HasProperty(vectorToReset)) - mat.SetVector(vectorToReset, defaultProperties.GetVector(vectorToReset)); - - HDShaderUtils.ResetMaterialKeywords(mat); - - mat.renderQueue = mat.shader.renderQueue; - - defaultProperties = null; - - return true; - } - - return false; - } - - delegate bool UpdateMaterial(string path, Material mat); - delegate void UpdateMaterialFile(string path); - - static void ProcessUpdateMaterial(string caption, float scriptVersion, UpdateMaterial updateMaterial, UpdateMaterialFile updateMaterialFile = null) - { - bool VCSEnabled = (UnityEditor.VersionControl.Provider.enabled && UnityEditor.VersionControl.Provider.isActive); - var matIds = AssetDatabase.FindAssets("t:Material"); - List materialFiles = new List(); // Contain the list dirty files - - try - { - for (int i = 0, length = matIds.Length; i < length; i++) - { - var path = AssetDatabase.GUIDToAssetPath(matIds[i]); - var mat = AssetDatabase.LoadAssetAtPath(path); - - EditorUtility.DisplayProgressBar( - "Update material " + caption + "...", - string.Format("{0} / {1} materials updated.", i, length), - i / (float)(length - 1)); - - if (HDShaderUtils.IsHDRPShader(mat.shader)) - { - // We don't handle embed material as we can't rewrite fbx files - if (Path.GetExtension(path).ToLower() == ".fbx") - { - continue; - } - - bool dirty = updateMaterial(path, mat); - - // Checkout the file and tag it as dirty - if (dirty) - { - CoreEditorUtils.CheckOutFile(VCSEnabled, mat); - EditorUtility.SetDirty(mat); - materialFiles.Add(path); - } - } - } - } - finally - { - EditorUtility.ClearProgressBar(); - // Save all dirty assets - AssetDatabase.SaveAssets(); - } - - if (updateMaterialFile == null) - return; - - // Now that all the asset have been modified and save, we can safely update the .mat file and remove removed property - try - { - for (int i = 0, length = materialFiles.Count; i < length; i++) - { - string path = materialFiles[i]; - - EditorUtility.DisplayProgressBar( - "Update .mat files...", - string.Format("{0} / {1} materials .mat file updated.", i, length), - i / (float)(length - 1)); - - // Note: The file is supposed to be checkout by the previous loop - updateMaterialFile(path); - } - } - finally - { - EditorUtility.ClearProgressBar(); - // No need to save in this case - } - } - - // This function go through all loaded materials so it can be used to update any materials that is - // not serialized as an asset (i.e materials saved in scenes) - static void UpgradeSceneMaterials() - { -#pragma warning disable 618 - var hdAsset = HDRenderPipeline.currentAsset; - // For each loaded materials - foreach (var mat in Resources.FindObjectsOfTypeAll()) - { - DiffusionProfileSettings.UpgradeMaterial(mat, hdAsset.diffusionProfileSettings); - } -#pragma warning restore 618 - } - - [MenuItem("Edit/Render Pipeline/Upgrade all Materials to newer version", priority = CoreUtils.editMenuPriority3)] - static public void UpdateMaterialToNewerVersion() - { - // TODO: We need to handle material that are embed inside scene! + How to handle embed material in fbx? - - // Add here all the material upgrade functions - // Note: This is a slow path as we go through all files for each script + update the version number after each script execution, - // but it is the safest way to do it currently for incremental upgrade - // Caution: When calling SaveAsset, Unity will update the material with latest addition at the same time, so for example - // unity can add a supportDecal when executing script for version 1 whereas they only appear in version 2 because it is now part - // of the shader. Most of the time this have no consequence, but we never know. - - // Caution: Version of latest script and default version in all HDRP shader must match - - UpgradeSceneMaterials(); - } - - [MenuItem("Edit/Render Pipeline/Reset All ShaderGraph Materials BlendStates (Project)")] - static public void UpgradeAllShaderGraphMaterialBlendStatesProject() - { - ProcessUpdateMaterial("(ShaderGraphRenderStates_3)", 3.0f, UpdateMaterial_ShaderGraphRenderStates); - } - - [MenuItem("Edit/Render Pipeline/Reset All ShaderGraph Materials BlendStates (Scene)")] - static public void UpgradeAllShaderGraphMaterialBlendStatesScene() - { - var materials = Resources.FindObjectsOfTypeAll(); - - foreach (var mat in materials) - { - string path = AssetDatabase.GetAssetPath(mat); - - if (!string.IsNullOrEmpty(path)) - UpdateMaterial_ShaderGraphRenderStates(path, mat); - } - } - - [MenuItem("Edit/Render Pipeline/Fix Warning 'referenced script in (Game Object 'SceneIDMap') is missing' in loaded scenes")] - static public void FixWarningGameObjectSceneIDMapIsMissingInLoadedScenes() - { - var rootCache = new List(); - for (var i = 0; i < SceneManager.sceneCount; ++i) - FixWarningGameObjectSceneIDMapIsMissingFor(SceneManager.GetSceneAt(i), rootCache); - } - - static void FixWarningGameObjectSceneIDMapIsMissingFor(Scene scene, List rootCache) - { - Assert.IsTrue(scene.isLoaded); - - var roots = rootCache ?? new List(); - roots.Clear(); - scene.GetRootGameObjects(roots); - bool markSceneAsDirty = false; - for (var i = roots.Count - 1; i >= 0; --i) - { - if (roots[i].name == "SceneIDMap") - { - if (roots[i].GetComponent() == null) - { - // This gameObject must have SceneObjectIDMapSceneAsset - // If not, then Unity can't find the component. - // We can remove it, it will be regenerated properly by rebaking - // the probes. - // - // This happens for scene with baked probes authored before renaming - // the HDRP's namespaces without the 'Experiemental' prefix. - // The serialization used this path explicitly, thus the Unity serialization - // system lost the reference to the MonoBehaviour - Object.DestroyImmediate(roots[i]); - - // If we do any any modification on the scene - // we need to dirty it, otherwise, the editor won't commit the change to the disk - // and the issue will still persist. - if (!markSceneAsDirty) - markSceneAsDirty = true; - } - } - } - if(markSceneAsDirty) - SceneManagement.EditorSceneManager.MarkSceneDirty(scene); - } - } -} diff --git a/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeMenuItem.cs.meta b/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeMenuItem.cs.meta deleted file mode 100644 index cab43d30f34..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeMenuItem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9ba0cef4d0966574ab013f1cb2972ba3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs b/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs index e474ad3aa5c..a0d1dd2c185 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs @@ -24,26 +24,26 @@ static List GetHDUpgraders() return upgraders; } - [MenuItem("Edit/Render Pipeline/Upgrade Project Materials to High Definition Materials", priority = CoreUtils.editMenuPriority2)] + [MenuItem("Edit/Render Pipeline/HD Render Pipeline/Upgrade from Builtin pipeline/Upgrade Project Materials to High Definition Materials")] internal static void UpgradeMaterialsProject() { MaterialUpgrader.UpgradeProjectFolder(GetHDUpgraders(), "Upgrade to HD Material"); } - [MenuItem("Edit/Render Pipeline/Upgrade Selected Materials to High Definition Materials", priority = CoreUtils.editMenuPriority2)] + [MenuItem("Edit/Render Pipeline/HD Render Pipeline/Upgrade from Builtin pipeline/Upgrade Selected Materials to High Definition Materials")] internal static void UpgradeMaterialsSelection() { MaterialUpgrader.UpgradeSelection(GetHDUpgraders(), "Upgrade to HD Material"); } - [MenuItem("Edit/Render Pipeline/Upgrade Scene Terrains to High Definition Terrains", priority = CoreUtils.editMenuPriority2)] + [MenuItem("Edit/Render Pipeline/HD Render Pipeline/Upgrade from Builtin pipeline/Upgrade Scene Terrains to High Definition Terrains")] static void UpgradeSceneTerrainsToHighDefinitionTerrains(MenuCommand menuCommand) { var LegacyDefaultTerrainMat = AssetDatabase.GetBuiltinExtraResource("Default-Terrain-Standard.mat"); var HDRPTerrainMat = AssetDatabase.LoadAssetAtPath("Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDTerrainMaterial.mat"); var terrainArray = UnityEngine.GameObject.FindObjectsOfType(); - if(terrainArray.Length == 0) + if (terrainArray.Length == 0) { Debug.LogWarning("No terrains were found in the scene."); return; @@ -57,24 +57,5 @@ static void UpgradeSceneTerrainsToHighDefinitionTerrains(MenuCommand menuCommand } } } - - - [MenuItem("Edit/Render Pipeline/Multiply Unity Builtin Directional Light Intensity to match High Definition", priority = CoreUtils.editMenuPriority2)] - internal static void UpgradeLights() - { - Light[] lights = Light.GetLights(LightType.Directional, 0); - foreach (var l in lights) - { - Undo.RecordObject(l, "Light intensity x PI"); - l.intensity *= Mathf.PI; - } - } - - [MenuItem("Edit/Render Pipeline/Upgrade HDRP Materials to Latest Version", priority = CoreUtils.editMenuPriority2)] - internal static void UpgradeMaterials() - { - // Force reimport of all materials, this will upgrade the needed one and save the assets if needed - MaterialReimporter.ReimportAllMaterials(); - } } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Window.cs b/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Window.cs index 11816e93f55..f9c1ff1fed5 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Window.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Window.cs @@ -41,7 +41,6 @@ static class Style public const string migrateAllButton = "Upgrade Project Materials to High Definition Materials"; public const string migrateSelectedButton = "Upgrade Selected Materials to High Definition Materials"; - public const string migrateLights = "Multiply Unity Builtin Directional Light Intensity to match High Definition"; public const string migrateMaterials = "Upgrade HDRP Materials to Latest Version"; public const string hdrpVersionLast = "You are using High-Definition Render Pipeline lastest {0} version."; //{0} will be replaced when displayed by the version number. @@ -337,8 +336,7 @@ private void OnEnable() container.Add(CreateTitle(Style.migrationTitle)); container.Add(CreateLargeButton(Style.migrateAllButton, UpgradeStandardShaderMaterials.UpgradeMaterialsProject)); container.Add(CreateLargeButton(Style.migrateSelectedButton, UpgradeStandardShaderMaterials.UpgradeMaterialsSelection)); - container.Add(CreateLargeButton(Style.migrateLights, UpgradeStandardShaderMaterials.UpgradeLights)); - container.Add(CreateLargeButton(Style.migrateMaterials, UpgradeStandardShaderMaterials.UpgradeMaterials)); + container.Add(CreateLargeButton(Style.migrateMaterials, HDRenderPipelineMenuItems.UpgradeMaterials)); container.Add(CreateWizardBehaviour()); From 4e4c58aba2c1d0a61b69fd02a9895a837c190229 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Fri, 19 Jun 2020 19:13:17 +0200 Subject: [PATCH 2/2] Update Render-Pipeline-Wizard.md --- .../Documentation~/Render-Pipeline-Wizard.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Render-Pipeline-Wizard.md b/com.unity.render-pipelines.high-definition/Documentation~/Render-Pipeline-Wizard.md index eecbef60ef6..53753e37fa2 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Render-Pipeline-Wizard.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Render-Pipeline-Wizard.md @@ -93,9 +93,9 @@ Note that every **Fix** will be deactivated if your Hardware or OS do not suppor ## Project Migration Quick-links -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: +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: - **Upgrade Project Materials to High Definition Materials**: Upgrades every Material in your Unity Project to HDRP Materials. - **Upgrade Selected Materials to High Definition Materials**: Upgrades every Material currently selected to HDRP Materials. -- **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. +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.