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. Dismiss Notice

White lines appear on PNGs with shader Sprite-Lit-Default after upgrading to to URP 10.7.0

Discussion in 'Universal Render Pipeline' started by jtiret, Jan 4, 2022.

  1. jtiret

    jtiret

    Joined:
    Nov 11, 2020
    Posts:
    63
    Hello there,

    I upgraded Unity to 2020.3.25, which led to automatically upgrade the Universal RP package to 10.7.0 which introduced an issue with PNGs in my project (the issue also appears after upgrading Universal RP to 10.8.1).

    Here is the issue: every sprite that has the Sprite-Lit-Default shader now shows white lines, only when running on an iOS device (works fine on Android), the issue doesn't appear in the Editor.

    The game view still appears normally in the Editor:
    Screenshot 2022-01-04 at 12.48.39.png

    When running the build on the target (iOS/Android), it appears this way:
    IMG_2410.PNG

    There are white lines around trees, around items, on the ground, and more generally around every PNG for which the sprite component has the URP>2D>Sprite-Lit-Default shader selected. When I select the Sprite-Default shader, the sprite appears correctly without white lines but is no longer affected by lighting which is a problem.

    I have searched for this issue and I couldn't find any solution. Downgrading to the previous Unity version and downgrading URP to 10.6.0 fixes the issue but this is not a sustainable solution.

    Do you have any idea what change introduced in the new version of the URP package and/or Unity could have led to this issue and how to fix it?

    Thanks a lot!
     
    Last edited: Jan 4, 2022
  2. jtiret

    jtiret

    Joined:
    Nov 11, 2020
    Posts:
    63
    I can reproduce the issue on a minimalist project in Unity Editor, here is how it looks.
    I created a project with URP settings and a 2D renderer (default settings for both).

    The sprite on the left has Sprite-Default-Lit and the one on the right Sprites-Default. Global light intensity is 0.17.

    Here is how it looks in the Editor (clean):
    Screenshot 2022-01-04 at 15.51.34.png

    Here is how it looks on the iOS device (white artifacts around the sprite on the left):
    IMG_202079CC3F00-1.jpeg
     
  3. jtiret

    jtiret

    Joined:
    Nov 11, 2020
    Posts:
    63
    For those of you who may have the same issue, I fixed it by putting DisplayP3 as the first choice in the "Color Gamut" list (Project Settings > Player > iOS > Other Settings > Rendering > Color Gamut).
     
    damelin likes this.
  4. damelin

    damelin

    Joined:
    Jul 3, 2012
    Posts:
    64
    Oh my.. thanks a lot! I had the same issue + a 2d light issue with sprite with transparency. This color settings fixed everything!

    (The light issue I had before changing the setting)
    URP.jpg
     
    Last edited: Jan 8, 2022
  5. kjyv

    kjyv

    Joined:
    Feb 20, 2018
    Posts:
    53
    Did any of you guys report this as an issue with Unity? Switching to DisplayP3 permanently is not an option for us because it does not work on some Android devices.
    I would also create one but I we only get the same issue when using the Procedural UI Image, although the same workaround helps. Not sure if Unity would simply say it's an issue in that asset.
    @jtiret Do you still have your repro project?
     
  6. damelin

    damelin

    Joined:
    Jul 3, 2012
    Posts:
    64
    I haven't reported this as an issue no.

    What kind of issues are you having with DisplayP3 on Android? It wouldn't be a proper solution if I have theses same issues too. Are you on URP v10.x?

    Edit: I have just tried URP 12 (which comes with 2021.2), and it doesn't have theses issues on iOS. But I'm not sure that I want to use a non-LTS version.
     
    Last edited: Jan 11, 2022
  7. kjyv

    kjyv

    Joined:
    Feb 20, 2018
    Posts:
    53
    We are only seeing this issues since URP 12 with 2021.2, it was all working fine with 2020.3 LTS.
    On Android with Gamma Color space and DisplayP3, we're getting exceptions like this:
    Code (CSharp):
    1. OverrideNativeWindowFormat: Unable to find a format in sRGB colorspace for EGI format: 85
    2. Create: Initialize Talled
    3. [EGL] Failed to create window surface: EGL_BAD_MATCH: Arguments inconsistent (for example a valid context requires buffers not supplied by a valid surface).
    And nothing is rendered, only a black screen.
     
  8. jtiret

    jtiret

    Joined:
    Nov 11, 2020
    Posts:
    63
  9. jtiret

    jtiret

    Joined:
    Nov 11, 2020
    Posts:
    63
    Hello there,

    I also had issues on some Android devices by switching to DisplayP3. The screen was dark, almost unreadable for some of my users, see the screenshot:
    Screenshot_20220118-194721476.jpg

    Unfortunately, the Color Gamut setting is a shared setting that can't be differentiated between iOS and Android. So I decided to create a PreBuild script that would change this setting automatically depending on the target right before the build. Here again, unfortunately, there's no public API to modify the Color Gamut setting in the PlayerSettings class. So I had to update the PlayerSettings.asset file directly. I don't like this solution (especially the way of modifying the file), but this is the only one I found for the moment.

    For those of you interested, here is the script to be placed within an "Editor" folder (e. g. Scripts/Editor) :

    Code (CSharp):
    1. using UnityEngine;
    2. using System;
    3. using UnityEditor.Build;
    4. using UnityEditor.Build.Reporting;
    5. using System.IO;
    6. using System.Text.RegularExpressions;
    7.  
    8. #if UNITY_IOS || UNITY_ANDROID
    9.  
    10. /**
    11. * This preprocessor will run before any build with iOS or Android as
    12. * target in order to modify the Project Settings' Color Gamut value.
    13. * This value cannot be changed once and for all via Project Settings
    14. * because this is a shared setting, which needs different values for
    15. * iOS and Android, because both platforms have different issues with
    16. * different settings. On iOS, everything works fine with DisplayP3 as
    17. * the first choice in the list, but this leads to dark, unreadable screens
    18. * on some Android devices.
    19. * On the other hand, everything works fine with sRGB on Android devices,
    20. * but this leads to white lines around PNGs on iOS devices
    21. * (this issue started to appear from a certain version
    22. * of the URP package (around 10.8) and a certain version of Unity, which
    23. * may indicate that this behaviour is a bug that may be fixed in the future.
    24. * As a result, it may be worth trying again in the future whether this issue
    25. * is fixed by disabling this script.
    26. * Discussion on the Unity forums: https://forum.unity.com/threads/white-lines-appear-on-pngs-with-shader-sprite-lit-default-after-upgrading-to-to-urp-10-7-0.1220019
    27. */
    28. public class ColorGamutBuildPreprocessor : IPreprocessBuildWithReport
    29. {
    30.  
    31. #if UNITY_IOS
    32.     // The value below represents the following order: DisplayP3, sRGB
    33.     private const string kColorGamutSetting = "0300000000000000";
    34.  
    35. #elif UNITY_ANDROID
    36.     // The value below represents the following order: sRGB, DisplayP3
    37.     private const string kColorGamutSetting = "0000000003000000";
    38.  
    39. #endif
    40.  
    41.     public int callbackOrder => 0;
    42.  
    43.     public void OnPreprocessBuild(BuildReport report)
    44.     {
    45.         var settingsFilePath = Path.Combine(Application.dataPath, "..", "ProjectSettings", "ProjectSettings.asset");
    46.  
    47.         if (File.Exists(settingsFilePath))
    48.         {
    49.             var currentSettingsContent = File.ReadAllText(settingsFilePath);
    50.             var updatedSettingsContent = Regex.Replace(currentSettingsContent, @"m_ColorGamuts: ([0-9]+)", "m_ColorGamuts: " + kColorGamutSetting);
    51.             File.WriteAllText(settingsFilePath, updatedSettingsContent);
    52.  
    53.             Debug.Log("ColorGamutBuildPreprocessor: updated color gamut setting to " + kColorGamutSetting);
    54.         }
    55.  
    56.         else
    57.         {
    58.             throw new Exception("ColorGamutBuildPreprocessor: couldn't change color gamut setting, ProjectSettings file couldn't be found at " + settingsFilePath);
    59.         }
    60.     }
    61. }
    62.  
    63. #endif
     
  10. kjyv

    kjyv

    Joined:
    Feb 20, 2018
    Posts:
    53
    We had issues on Google Pixel 4 and 5 phones. We were able to switch back to sRGB and Linear color space now as apparently Unity 2021.2.8 fixed the issue causing white outlines for us. DisplayP3 causes also issues with transparent videos on iOS (black instead of transparent), so we won't follow this further.
     
    jtiret likes this.