Search Unity

Changing URP Asset Render Scale affects decal's rendering

Discussion in 'Universal Render Pipeline' started by Zepir, Oct 20, 2021.

  1. Zepir

    Zepir

    Joined:
    Dec 16, 2016
    Posts:
    18
    Changing the render scale of a Universal Render Pipeline Asset changes the position of the new decals renderer feature introduced in Unity 2021.2.

    It's pretty easy to reproduce, just add the new decals to a scene and change the slider "Render Scale" to a value different than 1, the decals completely disappear at some point. Already sent a bug report.
     
    zhuchun, Claytonious and CaseyHofland like this.
  2. CaseyHofland

    CaseyHofland

    Joined:
    Mar 18, 2016
    Posts:
    613
  3. Zepir

    Zepir

    Joined:
    Dec 16, 2016
    Posts:
    18
    I really needed this to work or else I'll have to find another Decal solution for URP, still have no reply on the bug report, I don't know how long they usually take to acknowledge a bug.
     
  4. CaseyHofland

    CaseyHofland

    Joined:
    Mar 18, 2016
    Posts:
    613
    I would probably wait for 2021.2 to go out of beta before looking for a different solution.

    Alternatively you might be able to change the Decal Shader Graph to include this yourself (if that's possible).
     
  5. Zepir

    Zepir

    Joined:
    Dec 16, 2016
    Posts:
    18
    I'm releasing a new game soon so I need it solved or have a different solution, which I have but they are not as performant.

    I know I shouldn't use a beta Unity version for a production build but I really liked some changes they introduced in 2021.2 and the only problem that I found was this one.

    I also tried changing the Decal's Shader Graph but couldn't fix the problem, I think it's something to do internally with the way they made Decals work in URP. But if someone has a hack for it I would really appreciate it!
     
  6. AydinDeveloper

    AydinDeveloper

    Joined:
    Sep 8, 2017
    Posts:
    92
    i was having the same problem. Then I saw that it was actually fixed on github, but it was kept waiting.

    com.unity.render-pipelines.universal\Runtime\ScriptableRenderer.cs

    line 221.
    cmd.SetGlobalVector(ShaderPropertyId.screenSize, new Vector4(cameraWidth, cameraHeight, 1.0f / cameraWidth, 1.0f / cameraHeight));

    fix
    cmd.SetGlobalVector(ShaderPropertyId.screenSize, new Vector4(scaledCameraWidth, scaledCameraHeight, 1.0f / scaledCameraWidth, 1.0f / scaledCameraHeight));



    The problem is that the wrong screen pixel value is sent to the camera. This is a bug that is found in too many places. Lens flare is broken, for example, due to the same error.
     
    Evar155, ATate, adamgolden and 5 others like this.
  7. Zepir

    Zepir

    Joined:
    Dec 16, 2016
    Posts:
    18
    Thank you so much, it worked!

    I had to do some small changes to make it work, first was copying the com.unity.render-pipelines.universal package from Library\PackageCache\ to Packages\ and making sure it didn't have the @version number at the end. After that and making the changes to the "ScriptableRenderer.cs" there was an error appearing when changing the Render Scale on "DecalRendererFeature.cs" saying that the m_DecalEntityManager was null, so I had to add a new line on the method "OnCameraPreCull"
    Code (CSharp):
    1. if (m_DecalEntityManager == null)
    2.             {
    3.                 m_DecalEntityManager = sharedDecalEntityManager.Get();
    4.             }
    For some reason the m_DecalEntityManager gets null when you change the renderer scale so had to do this little hack for now.
     
    MadMonkey119 and CaseyHofland like this.
  8. projectorgames_unity

    projectorgames_unity

    Joined:
    Oct 15, 2018
    Posts:
    107
    Claytonious likes this.
  9. Zarod

    Zarod

    Joined:
    Jan 20, 2016
    Posts:
    60
    still broken ... but to be honest, I welcome the 0.2 fps gain ... rather have a "high fidelity" mode and a "low, just performance" and build the levels with that limitation/quirk in mind.

    It's not just decals, special effects are affected as well.

    So much for the "cross platform compatability", but I understand it's insanely hard what you are doing, so thank you for your effort.
     
  10. AydinDeveloper

    AydinDeveloper

    Joined:
    Sep 8, 2017
    Posts:
    92
    Claytonious and flogskin like this.
  11. flogskin

    flogskin

    Joined:
    Apr 18, 2018
    Posts:
    5
    I have the same problem.
    2021.1, 2021.2, and 2021.3 LTS.
     
  12. projectorgames_unity

    projectorgames_unity

    Joined:
    Oct 15, 2018
    Posts:
    107
    Tunmix likes this.
  13. LukasCh

    LukasCh

    Unity Technologies

    Joined:
    Mar 9, 2015
    Posts:
    102
    Hey, seems like it was a bit oversight as the bug fix refers to VFX decals, but as you see the problems is with ShaderPropertyId.screenSize in general.
    So it is safe to use proposed wokraround and we will try to fix the bug as soon as we can.
    This bug can be used for tracking https://issuetracker.unity3d.com/is...-value-of-the-universal-render-pipeline-asset.

    I actually can not reproduce on latest unity version. As I understand changing render scale causes m_DecalEntityManager to be null?
     
    Claytonious likes this.
  14. projectorgames_unity

    projectorgames_unity

    Joined:
    Oct 15, 2018
    Posts:
    107
    It's quite easy to reproduce; have more than 1 profile, and drag the resolution scale slider up and down on one of them that's not active.
     
  15. florentsteiner

    florentsteiner

    Joined:
    Apr 13, 2021
    Posts:
    8
    It's still broken in 2021.3.2 and 2022.1.0
     
    gyx920820 likes this.
  16. projectorgames_unity

    projectorgames_unity

    Joined:
    Oct 15, 2018
    Posts:
    107
    And 2022.1.1 in URP 13. I know this as I just downloaded it fresh and am having to apply my bandaid again. Do I take it that literally no-one has released a URP game with decals since Oct 20, 2021?
     
  17. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Same. Still waiting for the fix. Hope it will be fixed as well in 2022.1.
     
  18. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    That is a smaller issue which still exists, yes, but the bigger issue is the original one that started this thread - decals are positioned incorrectly whenever render scale is not 1.0.

    https://issuetracker.unity3d.com/is...-is-affected-when-changing-render-scale-value has been in a status of "Fix in Review" for a very long time.
     
  19. djarcas

    djarcas

    Joined:
    Nov 15, 2012
    Posts:
    246
  20. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    Users have reported the exact line number of the problem and how to fix it (such as in this post, as one example). But it has been broken for a year and we're still forced to embed custom versions of the URP package in our projects to workaround it to this day.

    I submitted a minimalist repro project that demonstrates the bug without any extraneous noise with bug report IN-9027, but still nothing has happened.

    https://forum.unity.com/threads/cha...ffects-decals-rendering.1188094/#post-8387190 still shows "Fix in Review" after a long, long time.

    We would all like for this bug to be fixed, but there's a bigger question here about what the process is inside of Unity for dealing with these things? The community is baffled that this bug is still here after so long. Can anyone from Unity elaborate on the process and how this kind of thing stays broken for so long? I think it might help us all come together better and be more productive if we better understood what is preventing Unity from just changing the one line of code and merging it into the appropriate branches for RC sweeps and release. That would be so appreciated!
     
  21. projectorgames_unity

    projectorgames_unity

    Joined:
    Oct 15, 2018
    Posts:
    107
    I thought this was the POINT of packages - so you can shove out a tiny patch without having to update the main engine. I just find it hard to believe that the decals are *so* broken no-one has shipped a URP game with decals for the last... what.. 8 months?
     
    gyx920820 and Claytonious like this.
  22. gyx920820

    gyx920820

    Joined:
    Oct 8, 2015
    Posts:
    35
    Finally ,I copy URP package into local 'Packages' after so long wating
     
    Claytonious likes this.
  23. LukasCh

    LukasCh

    Unity Technologies

    Joined:
    Mar 9, 2015
    Posts:
    102
    For 2023.1.0a10 fixes landed. 2022.2 and 2021.3 is currently in the queue.

    Recently we experienced many changes in our internal process, that unfortunately slowed down our development velocity quite a lot temporary. Things should improve in the future. There is very detailed post about changes for those who curious https://forum.unity.com/threads/important-upcoming-changes-to-the-graphics-repository.1239826/.
     
  24. LukasCh

    LukasCh

    Unity Technologies

    Joined:
    Mar 9, 2015
    Posts:
    102
    Good news finally backports landed. This includes 2022.2.0b10 and 2021.3.10f1.
     
  25. projectorgames_unity

    projectorgames_unity

    Joined:
    Oct 15, 2018
    Posts:
    107
  26. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
  27. projectorgames_unity

    projectorgames_unity

    Joined:
    Oct 15, 2018
    Posts:
    107
    Er, no it hasn't.

    Code (CSharp):
    1. cmd.SetGlobalVector(ShaderPropertyId.screenSize, new Vector4(cameraWidth, cameraHeight, 1.0f / cameraWidth, 1.0f / cameraHeight));
    Still in the 12.7 URP available in 2021.3.10f1.
     
    Claytonious likes this.
  28. Zepir

    Zepir

    Joined:
    Dec 16, 2016
    Posts:
    18
    The fix finally landed with 2021.3.11f1.

    It took almost a year to fix something so simple, at least there was a quick fix.

    I hope things are better now after Unity's internal process changes.
     
    Jackrabbit82 and hippocoder like this.
  29. kruskal21

    kruskal21

    Joined:
    May 17, 2022
    Posts:
    68
    Thank you to the devs for fixing this bug! I know it has been a while and all, but very glad to have this solved!
     
  30. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    Using Unity 2022.1.9.f1 and URP 13.1.8

    I don't know what's fixed and what's not but i just tried to simply place a decal in a URP project and i got this...

    looking from the left i got this effect

    upload_2022-10-19_10-38-35.png

    and looking from top right i got this. Decal is not projected correctly.

    upload_2022-10-19_10-38-46.png
     
    st_Drunks and juanCastano like this.