Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Runtime Upgrade Material to URP

Discussion in 'Universal Render Pipeline' started by NightKotGames, May 3, 2022.

  1. NightKotGames

    NightKotGames

    Joined:
    Dec 14, 2020
    Posts:
    8
    How to upgrade Standard (Spectacular Setup) materials to URP Universal Render Pipeline\Lit in Runtime? With C#
    The problem is that the Perception (AI Camera) functionality requires a URP (Universal Render Pipeline). The standard materials of the imported .obj model are not displayed in it.
     
    ErkanAkin likes this.
  2. ErkanAkin

    ErkanAkin

    Joined:
    Oct 26, 2019
    Posts:
    7
    I am looking for the same thing, we have more than 50 asset bundles with standart render pipeline and we must upgrade these bundles to urp in runtime in our main project.
     
  3. mittalash

    mittalash

    Joined:
    May 11, 2023
    Posts:
    3
    Hi @ErkanAkin and @NightKotGames ,

    I am also looking for the solution to change the shaders of 50+ assets at runtime from standard shaders to URP shaders for WebGL build. if you have any solution please post here.

    Thanks
     
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,456
    1. Get the current material
    2. Cache all used textures
    3. Change the shader to URP (Simple) Lit or your custom URP shader (there is no 1 way to upgrade the BiRP shader to URP)
    4. Add the textures back to the material
     
    mittalash likes this.
  5. mittalash

    mittalash

    Joined:
    May 11, 2023
    Posts:
    3
    Thanks for your quick response @DevDunk

    I have 50+ assets and 1 Render button, when i click on the render button all the material shader's attached to mesh renderer needs to change at one time from standard shaders to urp shaders. it is working in editor but not on WebGL platform. it is giving white screen and no errors.

    Do you have any idea about this?
     
  6. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,456
    I suggest to first try on an non WebGL build (windows, macos, whatever you're developing on). This way you can see if it's a build issue, or WebGL issue.
    Make sure to get the latest possible lts bugfix version as well, and make sure that URP is setup properly (switching BiRP to URP as a whole at runtime works very poorly)
     
  7. mittalash

    mittalash

    Joined:
    May 11, 2023
    Posts:
    3
    yes @DevDunk , i tried and it's working on editor but it is not working on WebGL and there are no any errors just whole white screen is coming on converting standard shaders to URP. But when i am converting back from urp to standard then it is working fine on Editor and also WebGL.

    I don't know if it is not supporting the URP textures or why the white screen is coming only.
     
  8. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,456
    Again, try on a non webgl build as well