Search Unity

Convert HDRP to LWRP

Discussion in 'High Definition Render Pipeline' started by whidzee, Aug 8, 2019.

  1. whidzee

    whidzee

    Joined:
    Nov 20, 2012
    Posts:
    166
    Is there an easy and automated way of converting a project from HDRP to LWRP?

    I started my project in HDRP and now that it's getting further along i have realised i don't quite need HDRP and LWRP will suit my needs better, but there doesn't seem to be a way to convert from one to the other.

    I've tried just changing my renderer to lwrp and now everything is pink. I can't even seem to find a way to convert my terrain shaders from hdrp to lwrp.

    I'm stuck

    Any ideas?
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    There is no way to do this other than manually recreating all materials and custom shaders.
     
  3. whidzee

    whidzee

    Joined:
    Nov 20, 2012
    Posts:
    166
    How would I go about recreating the terrain materials and applying them to the terrain? I tried and I couldn't work out a way it seemed that terrains had their material and I couldn't change it.

    For manually recreating all materials. I'm up for that. Any tips on going through this?

    Also, is this something you guys are working on? An automated process of switching between the two?
     
    Lars-Steenhoff likes this.
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    I don't know. I suppose you can try asking this question in a separate thread :)
    AFAIK no, we're not. The choice of the render pipe affects too much on the asset side of things, so I think the promise was that there won't be any automatic conversion between SRPs.
     
  5. whidzee

    whidzee

    Joined:
    Nov 20, 2012
    Posts:
    166
    is it possible to revert from HDRP to the standard unity renderer. because from there i could install the lwrp and go from there.
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    No, going backwards (SRP->Builtin) is also not possible in automated way.
     
  7. whidzee

    whidzee

    Joined:
    Nov 20, 2012
    Posts:
    166
    so it seems that it's possible, but just not automated. it's a long process of reverting it to have no render pipeline then convert it to lwrp
     
  8. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    I think it's a loss not to be able to go between Render pipelines, as Unity targets multiple platforms and some would be best off with LW and other with HD. If most materials are the same just for example HD needs raytracing you could make and Hd version with as the only extra raytracing.
     
  9. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Yeah I guess the marketing days of "write once run everywhere" for Unity has long gone past it seems to me....
     
  10. manutoo

    manutoo

    Joined:
    Jul 13, 2010
    Posts:
    523
    From my HDRP experience, it seems possible to write an automatic converter from HDRP materials to Built-in ones. You'll have to specify in it what shader replaces what shader, and convert the texture & color names, but it seems technically possible, with all the limitations on the missing extra stuff that HDRP offers, of course ; ie: you can cut off ~90% of the manual work.

    Writing the converter might take some time, though.
     
    Last edited: Sep 3, 2019
    Lars-Steenhoff likes this.
  11. Chrisad

    Chrisad

    Joined:
    Mar 12, 2013
    Posts:
    55
    I agree with this.

    For sure, there will be people starting a project using one render pipeline and at some point wanting to change. Look at all the games released on PC and consoles and now getting a switch version. Or mobile games getting a PC version.

    Even if the converter cannot convert 100% of the settings, Unity should provide something for the developer. Otherwise I dont see how using RPs will be more convenient than the built-in pipeline. And if I had to upgrade, in the future, one of my projects to URP or HDRP without any way to make it easy and without the possibility to change the render pipeline, clearly it feels like a huge downgrade. Cross-platform game will become a huge nightmare in Unity.
     
    Last edited: Oct 15, 2020
  12. soleron

    soleron

    Joined:
    Apr 21, 2013
    Posts:
    580
    One way is completely manual. The other way is use Shadergraph shaders. They seem to convert much easier than the standard ones that do not. Give it a try with one material and see what happens. Create a basic Shadergraph shader similar to the standard and then switch to URP/LWRP.
     
    RoughSpaghetti3211 likes this.
  13. manutoo

    manutoo

    Joined:
    Jul 13, 2010
    Posts:
    523
    I had a look at the Unity Built-in -> HDRP material converter.

    Like I thought, it's relatively trivial. It'd take literally less than 1 hour for the Unity Dev who wrote it to make it work in the other way.

    I guess a good coder knowing well the Unity material system can get a 1st working draft in a couple hours, by checking what has been done in the Unity converter. The average coder might need a couple of days. And the beginner coder who doesn't know Unity well might not want to try to do that... :p
     
    newguy123 likes this.
  14. xDavidLeon

    xDavidLeon

    Joined:
    Jun 9, 2014
    Posts:
    123
    One of the main complaints about the new SRP model is how it asks you to commit to one of these render pipelines when none of them are even feature complete and it may take years for them to become production ready. So it makes me wonder why Unity devs don't spend some effort to make it easier to transition from one render pipeline to the other.

    Anyway, it took me a couple of hours to create a HDRP to Universal RP material converter. It's not perfect by far, but it makes it way easier to 'downgrade' from HDRP to URP after months of waiting for HDRP to be production ready and finally giving up and converting to URP. /rant

    You need to have both URP and HDRP packages installed, then go to Edit/Render Pipeline and there will be 2 new options to convert HDRP to URP materials. Tested it with HDRP/Lit to URP/Lit.
     

    Attached Files:

    odavy, nnimarca, jeromeWork and 16 others like this.
  15. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    This is a major design flaw IMO, and one that keeps a lot of people from even bothering with the SRPs due to the gigantic commitment.

    Basic shaders shouldn't be so deeply tied to the selected pipeline, since all their do is output renderer-agnostic data like albedo, normals, etc, where the renderers should consume into their own internal shader generation process.

    But of course, nobody makes actual games at Unity, so nobody there is aware of how harmful this is, specially when that other engine can use the same shaders all the way from mobile to ray-tracing.
     
    Xain, mowax74, keypax and 6 others like this.
  16. FiveXGames

    FiveXGames

    Joined:
    Apr 27, 2016
    Posts:
    43
    Thanks for the converter @xDavidLeon, would it be hard to get the converter to go from hdrp to the built-in?
     
  17. xDavidLeon

    xDavidLeon

    Joined:
    Jun 9, 2014
    Posts:
    123
    Probaby not. Here's the script that converts from built-in to HDRP Lit:

    https://github.com/Unity-Technologi...erial/Lit/StandardsToHDLitMaterialUpgrader.cs

    It is called by this:

    https://github.com/Unity-Technologi...r/Upgraders/UpgradeStandardShaderMaterials.cs

    So you should be able to do the inverse of the first script, and call it from an editor function similar to what is being done in the second script.
     

    Attached Files:

    Last edited: Apr 14, 2022
  18. FiveXGames

    FiveXGames

    Joined:
    Apr 27, 2016
    Posts:
    43
    Many thanks @xDavidLeon !

    I wish the HDRP is more production ready, but since we need to release during this year I don't feel that it will be stable enough, so I need to test the 3 render methods to see which one is a better fit.

    Normally with these changes I use a copy of the project that later on I discard and just copy the asset folder, input manager and other project files in a fresh Unity project. It has the downside of the import time, but apart from it, it normally works as expected.
     
  19. JohnKP-Mindshow

    JohnKP-Mindshow

    Joined:
    Oct 25, 2017
    Posts:
    56
    Have you tried deleting the library folder and reimporting the project? At least for my shadergraph shaders, this is the only way to get them to actually successfully compile (I also have to open each one individually once by hand :mad:


    I also recently ended up making basically the same conversion tool you made as I was getting frustrated being "stuck" on a render pipeline when I ran into a new issue after upgrading. I want to target HDRP, but having the option to "easily" fallback to URP when I hit a roadblock has been a comforting safety net.

    The only issues I really encountered were needing to rebake the lighting, otherwise the light probes don't work.

    When they said that it wasn't possible to switch between URP and HDRP with the same assets, I assumed it was some sort of technical limitation. But when I started digging into each render pipeline and understanding the differences, I kept facepalming because of how similar the two actually are. Its mostly just slight naming differences :rolleyes: (and HDRP has some extra features)

    the Render Pipeline teams could really use a joint meeting where they agree to certain terms (bump vs normal, emissive vs emission, baseMap vs unlitColorMap, etc. Its pretty braindead code to actually get it converted between the two, surprised they haven't done that as a nice safetey net for their users.
     
    _sequel_, JoeStrout, milox777 and 2 others like this.
  20. xDavidLeon

    xDavidLeon

    Joined:
    Jun 9, 2014
    Posts:
    123
    I believe copying the full Assets folder to a new Unity project to replace the old one would break Source Control.. as "all files" would change in the project. It's also not feasible when working with big teams working on the same codebase.

    Honestly, I'm only trying to create an empty project with URP and convert it to HDRP, or the other way around. Had no success so far.. so that means that every developer is locked onto a single Render Pipeline when starting a project? You can't ever change to a different Render Pipeline? Sounds like a huge issue.. let's say I'm working on a project for PS5 with HDRP, but in a year or two I want to downgrade the game to URP to port it to mobile or Switch.. you are telling me there's no way to do it?
     
    newguy123 likes this.
  21. JohnKP-Mindshow

    JohnKP-Mindshow

    Joined:
    Oct 25, 2017
    Posts:
    56
    I didn't say to copy the full assets folder to a new unity project. Switching render pipelines in a project is very doable (I've done it a handful of a times now since the SRP started production). The project I'm using this technique for is a professional one used by a whole team (not just a test project on my machine). I've only recently started to automate it to get rid of some of the lift of doing so. Not sure what hiccup you are running into.

    1) Make sure HDRP and URP packages are included.
    2) Make an asset for the render pipeline you want to switch to.
    3) Switch the render pipeline in the graphics settings to the new pipeline
    4) Run any material converters
    5) Close Unity
    6) Delete 'Library' folder that is next to the 'Assets' folder in the project in File Explorer.
    7) Open the project. It will reimport (but this time, set up the library folder with the render pipeline you set in the graphics settings).
    8) Open each shader graph by hand (worst step....)
    9) Run Unity and it should be using the new pipeline.
     
  22. xDavidLeon

    xDavidLeon

    Joined:
    Jun 9, 2014
    Posts:
    123
    I managed to convert the project to URP by following your steps. Shader Graphs are completely broken though.. opening a shader graph with a HDLit master node in URP freezes the shader graph editor. Enabling the HDRP package let's you open it, but it freezes anyway.
     
  23. JohnKP-Mindshow

    JohnKP-Mindshow

    Joined:
    Oct 25, 2017
    Posts:
    56
    My shadergraphs were initially constructed in URP which may explain their easier portability....

    The shadergraph files seem to just be JSON, so you could potentially make a shadergraph with URP Lit master node and one with the HDRP Lit master node, analyze the difference between them, and write another converter.
     
  24. JohnKP-Mindshow

    JohnKP-Mindshow

    Joined:
    Oct 25, 2017
    Posts:
    56
    I do have one shadergraph shader that compiles in URP but with HDRP gives me an error saying "maximum ps_5_0 sampler register index (16) exceeded"

    It's a pretty complex graph, so I'm assuming with the render pipeline swap the generated code is just more...complex? Its on my todo to file a ticket for that or at least better understand why its happening.

    So not all shadergraphs will work it seems
     
  25. FiveXGames

    FiveXGames

    Joined:
    Apr 27, 2016
    Posts:
    43
    @JohnKP-Mindshow Not sure if you used it, but the sampler limit sometimes could be solved if you share the sampler of some of the sampler textures in the shadergraph (Just drop the "sampler state" node and set the output into multiple texture samplers inputs).

    @xDavidLeon I'm not sure but I normally use a source control (git) that is not file aware, but content aware, that means that as far as I don't touch any of the content inside the source control files It will keep the track correctly, even if I move then (keeping the folder and file hierarchy) . You have to copy the source control (git) files also, Unity don't change the metafiles or the files itself, just the ones that normally changes through render pipelines (e.g Shaders or materials)

    Also you can have a separate source control for the materials shaders and the render pipeline aware contents so you can keep source control for mostly all the files and work in both render pipelines sharing the main source control (The one with the no render pipeline aware content) Anyway since the illumination, materials and shaders behaves somehow different in each Render pipeline its tolerable to have them separated.(Unity ignores the files starting with dot (.) e.g ".git" so the source control folder is ignored.)

    Anyway I agree that it should be a easy way to keep working with the different render pipelines, e.g. if you want to work in a project for Xbox, PS and Switch you may want HDRP for the first two and URP for the third one,.
     
  26. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    I can understand the needs to switch between the Render Pipelines but it is clearly stated by Unity that there is no automatic way to convert backwards at the moment so I don't understand the rants and surprises by people. Perhaps people should read the instruction manual before going to new tech.

    Also there should be no reason to switch because if your game will be published on high end and low end then stick to URP, switching settings and features and if only targeting high end pcs and high end consoles go with HDRP (if photorealismn is needed). And why would you suddenly decide: Oh, actually I don't need refraction, hair, coat, fabric shader, gpu particles and raytracing. You know that before.
    That seems to be an unprofessional planning.
     
    Last edited: Jan 26, 2020
    hickna and Skaster87 like this.
  27. xDavidLeon

    xDavidLeon

    Joined:
    Jun 9, 2014
    Posts:
    123
    I started my current project in 2017. Since my project has a 2021 release date with support planned through 2022, in 2018 I had to choose between:
    1. Sticking with a soon to be deprecated pipeline (built-in)
    2. Move to a pipeline marketed towards low-end devices (lwrp)
    3. Move to a piepline marketed towards current and next gen devices (hdrp).
    So no, I didn't know HDRP would be still in preview 3 years later, with LWRP being repurposed as a universal pipeline to replace built-in, out of preview and with most of the support from Asset Store devs. It's my own fault that I entered production with a 'in preview' render pipeline, but hdrp seemed like the obvious choice at the time.
     
    Kundelstein and manutoo like this.
  28. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    To be fair, cannot Unity blame for that asset store creators do not support HDRP at the moment. Some very kind creators support it even despite the preview state, but most will only support HDRP once it is fully finished.
     
  29. JohnKP-Mindshow

    JohnKP-Mindshow

    Joined:
    Oct 25, 2017
    Posts:
    56
    Well first off, most of the render pipelines have been in various states of being completely undocumented. Its a bit better now than it was before, but the information is still sparser than it should be for something out of preview (in the case of URP)

    The issue is the supported features of each RP keep changing without much of a notice. VR support has been working in one RP, then broken in the same RP with a new Unity update, forcing a pipeline switch. LWRP supported custom post process effects, then URP swapped out the post process stack for a new implementation without much notice, and without custom post processing. URP used to only support a handful of realtime lights at a time by some arbitrarily set limit, whereas it now doesn't. The list could keep going. Its not easy to pick a RP at the beginning of a project and stick with it, because games and their needs evolve as you develop them.

    And again, after digging into the issue myself, it seems providing a basic/generic RP converter for materials is entirely doable. I am just one person tackling the issue on my project and have made significant process with easing the burden of switching render pipelines. They could be doing a lot more to lessen the pain of the developers trying to navigate their currently tricky rendering setup
     
    mowax74, Lars-Steenhoff and JoeStrout like this.
  30. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    But the process of changing the API and features is part of "preview" state of the render pipelines.
    Unity self posted a nice long chart of what each pipeline is supporting and will be added later. So you could make decisions on that. The other alternative is waiting for them to be production ready or stick with the build-in pipeline.

    And I think if it is easy to convert all the stuff for switching the pipelines, Unity would have done it and provided converter scripts.
    Perhaps they don't have the ressources for that.
     
  31. JohnKP-Mindshow

    JohnKP-Mindshow

    Joined:
    Oct 25, 2017
    Posts:
    56
    URP was out of preview when the post processing stack (and even the name) changed. Camera stacking was also removed without much notice either close to the out of preview state of LWRP or when it was out of preview.

    When you need 2 features in one pipeline and 3 in another, the decision isn't cut and dry. Add VR to the mix and it gets even more hairy. Its not as clean cut as you are making it out to be.
     
    Ryuuguu and mowax74 like this.
  32. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    I'm sure you can track all features changes in the public package change log files of URP.
    In general it is better to do your own researches about Unity techs rather believe PR speaking.
    Often you will find out yourself what does work for your specific project.
     
    Last edited: Jan 27, 2020
  33. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    755
    I was under the impression it still did not, because unlimited lights requires deferred rendering, which URP does not have.
    Hence me jumping over to HDRP. I just love free point lights too much.

    BTW, my few URP shadergraphs survived transfer to HDRP, and still work. Everything else will have to be converted. But this bodes well for at least some amount of uniform SRP shader grammar.
     
    Last edited: Jan 29, 2020
  34. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    @JohnKP-Mindshow , have you considered polishing up your conversion tools and making them available as an Asset (or perhaps a GitHub repo)?

    It sounds like this would be a valuable service to the community, and could possibly compensate you somewhat for the your effort.
     
  35. JohnKP-Mindshow

    JohnKP-Mindshow

    Joined:
    Oct 25, 2017
    Posts:
    56
    I don't own the code personally (wrote it for a company), so my hands may be a little tied here. I can talk to some folks there to see if I could publish the code to help out the community. It's a little specific to our project right now but doesn't need to be.

    Really wish unity hadan offfical solution for porting between render pipelines. My solution still has it's quirks but is better than converting a project by hand
     
  36. maewionn

    maewionn

    Joined:
    Jan 18, 2016
    Posts:
    38
  37. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,349
    From what i have seen is nearly impossible to make such tool, is probably too complex to even think of try, as a custom shader can have so many aspects that depend on the pipeline and its specific libraries that complexity is exponential to handle.

    Of course everything can be done, but if is something that takes as much time as making the pipelines themselves, we may never see it. The only way this could be handled is if Unity had from start unified the libraries and used same libraries all around, so at least there would be a chance to make a converter, sadly this is not the case and everything is totally different in the 3 pipelines, is like having 3 different engines to handle.

    And on top they are still changing, HDRP in my mind is not even in pre-Beta state yet, there is nothing production ready about it yet and changing radically all the time, even between minor Unity versions.

    Personally i would only ever use HDRP in a serious project at least in one year from now.
     
  38. Ghosthowl

    Ghosthowl

    Joined:
    Feb 2, 2014
    Posts:
    228
    Since this is one of the first Google results I will share how I managed to better overcome this. I bought some assets on the Asset Store for the HDRP but needed to convert them to the URP.

    First download XnConvert. Here is a link to some presets you can use that I made.

    Now you can drag and drop the root folder from Windows Explorer into the drop zone and use the filter buttons to remove all files that aren't labeled MaskMap as well as all files that are .meta. From there open the present with the folder icon next to 'Presets' and select one of the maps. Then click the convert button and wait. This will extract all the specific channels from the mask map and name them appropriately. So for example, all red channels in the mask maps will be exported to a PNG with the same file name + _Metallic. You can change this in the Output settings. Doing this once for each channel will give you all the textures you need. Now just convert your pink shaders to URP ones and Unity will bring over the Albedo and Normals. You now just need to assign all the new maps you exported.

    For renaming you can use Bulk Rename Utility. You can also use the scripts here to rename the files. In this case since the MaskMap is still present, you can have those replaced to just be Metallic for instance.

    I also made a small script (not editor window) that will match all files with the same prefixed name and combine them together. Simply place this in a scene, add the path to your textures (starts looking in Assets folder) and then right click the script header to reveal the context menu and use the 'Get All Matches' method to see in the console all the matches it has found. Use this to make sure your options are correct. Once this is done and confirmed, use the 'Save All Matches' method to save the matches. This can take quite a while depending on file amount and size, so be patient.

    This allows for separate Metallic and Smoothness maps to be combined into the file that Unity is looking for. (Metallic in RGB channels, Smoothness in alpha channel) The results I see for the RGB channels wasn't as I was expecting (getting a value of .8 for all black metallic, instead of 1) but so far it seems to be working for my eyes at least. Maybe time will tell but feel free to modify or fix this if it isn't the case. Script attached below. I included tooltips for the various options. You can also use this for any sort of merging as in the merge options. (different channels to different channel destinations) The invert option allows you to change a smoothness to a roughness map if needing this somewhere else.

    Still a lot of work involved, but drastically reduced compared to without it. Hope this helps someone.
     

    Attached Files:

    Last edited: Apr 4, 2022
  39. mattiapompita

    mattiapompita

    Joined:
    Mar 16, 2022
    Posts:
    9
    Thanks for the converter and also the script for convert the MaskMap. After I did it how can utilize them? BatchProcessor it's useful for automate this process? How can I run that code?
     
  40. LuiBroDood

    LuiBroDood

    Joined:
    Mar 13, 2019
    Posts:
    84
    Ghosthowl real MVP
     
  41. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    342
    I don't care about my mats. I just want to go from HDRP to URP.

    When I click CREATE->Rendering-> There are no URP options

    How do I remedy this?

    upload_2023-6-15_17-30-6.png
     
  42. Uninstall HDRP and install URP in the Package Manager. As of today URP and HDRP can't live in the same project.
     
  43. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    342
    I uninstalled HDRP in package manager and installed URP, HDRP is still in all my options, URP in none of them.
    I'll just do this later when my game is mature I think...
     
  44. THE2FUN

    THE2FUN

    Joined:
    Aug 25, 2015
    Posts:
    63
    Can we make for URP > HDRP materials?