Search Unity

Downgrading from HDRP?

Discussion in 'General Graphics' started by zhuchun, Oct 28, 2018.

  1. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, wondering if it's possible to make a game in HDRP and then downgrade it to LDRP for cross-platform someday? My best guess is there will be some script like the Unity updator to help you change the whole project, but leave tons of pink materials to be fixed yourself, and of crouse, some feature will be lost.
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I do not think there is any provision made for this scenario because Unity not support this use-case as far as I know. They don't give support for people swapping SRP's, only very minimal support for built in to HDRP via standard shader to lit conversion, and this only works on the basic standard shader.

    So to downgrade you will do it all by yourself. You will remove HDRP via package manager. You then go and replace all your materials and fix all your reflection probes. You adjust all the lighting etc. And so on. You'll also be having to change textures where necessary.

    If you just sit down and do the work, it really doesn't take more than a week for any project, writing the occasional script where required to automate things.
     
    zhuchun likes this.
  3. LM031

    LM031

    Joined:
    Jul 16, 2017
    Posts:
    10
    Not checked it myself, but on THIS unity blog post they use a sample project, they mention:

    "On the Readme inspector, you’ll find buttons to switch between Lightweight and High Definition Render Pipelines. This is mainly to allow you to author assets and test compatibility between pipelines — for production, we recommend using only one render pipeline."

    So check it out.
     
    zhuchun likes this.
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    zhuchun likes this.
  5. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Thank you guys, it seems feasible as long as we keep substance source files. Also, as @hippocoder suggested, perhaps a few more automated scripts and some short-term hard work ;)
     
  6. Carterryan1990

    Carterryan1990

    Joined:
    Dec 29, 2016
    Posts:
    79
    Just want to say after reading this forum I didn’t feel I had a week and almost didn’t do it but went ahead anyways. My project is small in size, around 5gb’s. I have to say it was extremely easy and took less then 5 minutes. Only pain in the butt was changing the materials back but rather easy since I have them sorted together in my projects folder. All I did was go to package manger, removed hdsrp. Fixed materials. Good to go. What a relief, I was running into brick walls left and right in the HD pipeline. It’s still way to early in my opinion to be used by a mid level user.
     
  7. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Would you be willing to share a bit more on your specific brick walls? Maybe even on its own topic. I'm considering migrating to SRP but I'm on the fence and leaning to not migrating at all.
     
  8. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    I've used HDRP for a few months, here' are some experiences.

    1. Regarding HDRP/LWRP migration, pipeline differences cannot be ignored. Say if you're using HDRP, probably you are targeting top-notch graphics, which LWRP might not support. AFAICS, HDRP is not designed for the multi-platform purpose.

    2. Packages like PostProcessing has been integrated into HDRP in Unity2019, some implementation of effects has been changed a lot and I've to re-authoring all PostProcessing effects in Volume, vice versa. It could be a trend, only Unity Tech can explain this.
     
    FM-Productions, fuzzy3d and SugoiDev like this.
  9. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    I created this script to fix the material, if someone is interested:


    Code (CSharp):
    1. [MenuItem("Tools/Fix materials")]
    2.     static void Do()
    3.     {
    4.         var standardShader = Shader.Find("Standard");
    5.         var materialsGuids = AssetDatabase.FindAssets($"t:{nameof(Material)}");
    6.         EditorUtility.DisplayProgressBar("Fixing materials", "", 0);
    7.         var counter = 0;
    8.         foreach (var materialGuid in materialsGuids)
    9.         {
    10.             var materialPath = AssetDatabase.GUIDToAssetPath(materialGuid);
    11.             var material = AssetDatabase.LoadAssetAtPath<Material>(materialPath);
    12.             EditorUtility.DisplayProgressBar("Fixing materials", material.name, counter++ / (float)materialsGuids.Length);
    13.             try
    14.             {
    15.                 var shader = material.shader;
    16.                 if (shader.name == "Hidden/InternalErrorShader")
    17.                 {
    18.                     Debug.Log(material.name, material);
    19.                     material.shader = standardShader;
    20.                     EditorUtility.SetDirty(material);
    21.                     AssetDatabase.SaveAssetIfDirty(material);
    22.                 }
    23.             }
    24.             catch (Exception e)
    25.             {
    26.                 Debug.LogError(e.ToString(), material);
    27.                 break;
    28.             }
    29.             finally
    30.             {
    31.                 EditorUtility.DisplayProgressBar("Fixing materials", "", counter / (float)materialsGuids.Length);
    32.             }
    33.         }
    34.         EditorUtility.ClearProgressBar();
    35.     }
     
    eyupunity likes this.
  10. unity_9902699141a

    unity_9902699141a

    Joined:
    Jun 13, 2020
    Posts:
    1
    what does this script does. ?
     
  11. Ottonello

    Ottonello

    Joined:
    Oct 17, 2019
    Posts:
    1
    How do i make this script work? I'm not great at scripting, so where do i place the script, what should I copy in the Csharp?
     
  12. Cerberus_team

    Cerberus_team

    Joined:
    Apr 9, 2014
    Posts:
    43
    Here's a little script i made, it's from HDRP/Lit --->Standard shader but you can easily modify it to fit your needs.

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UnityEditor;
    4. using System.Collections.Generic;
    5.  
    6. public class DowngradeMaterials : EditorWindow
    7. {
    8.     [MenuItem("Tools/HDRP to Built-in/Lit --> Standard")]
    9.     static void DowngradeLitMaterials()
    10.     {
    11.         Undo.RegisterCompleteObjectUndo(Selection.objects, "UndoDowngrade");
    12.  
    13.         Object[] selectedObjects = Selection.objects;
    14.  
    15.         List<Material> hdMaterials = new List<Material>();
    16.  
    17.         for (int i = 0; i < selectedObjects.Length; i++)
    18.         {
    19.             if (selectedObjects[i] is Material)
    20.             {
    21.                 hdMaterials.Add(selectedObjects[i] as Material);
    22.             }
    23.         }
    24.  
    25.         for (int i = 0; i < hdMaterials.Count; i++)
    26.         {
    27.             //Get render type Opaque = 0, Transparent = 1
    28.             float surfaceType = hdMaterials[i].GetFloat("_SurfaceType");
    29.  
    30.             //Get Normal map
    31.             Texture normalMap = hdMaterials[i].GetTexture("_NormalMap");
    32.  
    33.             //Get Mask Map - Metallic(R) - Ambient Occlusion(G) - Detail Mask(B) - Smoothness(A)
    34.             Texture maskMap = hdMaterials[i].GetTexture("_MaskMap");
    35.  
    36.             //Get Emission Map
    37.             Texture emissionMap = hdMaterials[i].GetTexture("_EmissiveColorMap");
    38.  
    39.             //Get Detail Map
    40.             Texture detailMap = hdMaterials[i].GetTexture("_DetailMap");
    41.  
    42.             //Get main texture tiling and offset
    43.             Vector2 first_UV_Tiling = hdMaterials[i].GetTextureScale("_BaseColorMap");
    44.             Vector2 first_UV_OffSet = hdMaterials[i].GetTextureOffset("_BaseColorMap");
    45.  
    46.             //Get detail texture tiling and offset
    47.             Vector2 second_UV_Tiling = hdMaterials[i].GetTextureScale("_DetailMap");
    48.             Vector2 second_UV_OffSet = hdMaterials[i].GetTextureOffset("_DetailMap");
    49.  
    50.  
    51.             hdMaterials[i].shader = Shader.Find("Standard");
    52.  
    53.  
    54.             //Set render type
    55.             if (surfaceType == 1)
    56.             {
    57.                 //Opaque = 0, Cutout = 1, Fade = 2, Transparent = 3
    58.                 hdMaterials[i].SetFloat("_Mode", 3.0f);
    59.             }
    60.  
    61.             //Set Normal map
    62.             hdMaterials[i].SetTexture("_BumpMap", normalMap);
    63.  
    64.             //Set Metallic map
    65.             hdMaterials[i].SetTexture("_MetallicGlossMap", maskMap);
    66.  
    67.             //Set Occlusion map
    68.             hdMaterials[i].SetTexture("_OcclusionMap", maskMap);
    69.  
    70.             if (emissionMap != null)
    71.             {
    72.                 //Set Occlusion map
    73.                 hdMaterials[i].SetTexture("_EmissionMap", emissionMap);
    74.  
    75.                 hdMaterials[i].globalIlluminationFlags = MaterialGlobalIlluminationFlags.BakedEmissive;
    76.  
    77.                 hdMaterials[i].EnableKeyword("_EMISSION");
    78.             }
    79.  
    80.  
    81.             //Set Detail Map
    82.             hdMaterials[i].SetTexture("_DetailAlbedoMap", detailMap);
    83.  
    84.             //Set main texture tiling and offset
    85.             hdMaterials[i].SetTextureScale("_MainTex", first_UV_Tiling);
    86.             hdMaterials[i].SetTextureOffset("_MainTex", first_UV_OffSet);
    87.  
    88.             //Set detail texture tiling and offset
    89.             hdMaterials[i].SetTextureScale("_DetailAlbedoMap", second_UV_Tiling);
    90.             hdMaterials[i].SetTextureOffset("_DetailAlbedoMap", second_UV_OffSet);
    91.         }
    92.     }
    93. }
    94.  
     
    Last edited: Mar 20, 2022
  13. SMART-LE

    SMART-LE

    Joined:
    Mar 23, 2020
    Posts:
    3
    Can you please provide an upgraded link? The one you have hear is 404!