• RuntimesUnity
  • Having white edges while using Pixel Lit shader

I want my character receive shadow so I'm using pixel lit shader, and this happens:

Also happning in shadow:

Any way to fix?

  • Misaki ha risposto a questo messaggio
    Related Discussions
    ...

    KarenArushi I'm sorry to hear that you're having trouble. Unfortunately, I cannot determine the cause of the problem from these screenshots. Could you please email us a minimal Unity project that can reproduce the problem?: contact@esotericsoftware.com
    Please briefly mention the URL of this forum thread in the email so that we know the context. Then we can take a look at what's going wrong.

    Sended. Looking forward to your reply.

    • Misaki ha risposto a questo messaggio
    • Misaki ha messo mi piace.
      • Modificato

      KarenArushi Thank you for sending us the repro project!

      The texture of the skeleton that was exported with Premultiply Alpha seems to be enabled, but the texture settings in Unity were the settings for straight alpha textures, so you should fix them according to this section of the documentation: Advanced - Premultiplied vs Straight Alpha Import

      However, for the issue of artifacts on the edges, it seems to be due to Write to Depth. Harald's answer in the following thread may be helpful: https://esotericsoftware.com/forum/d/17645-spine-2d-shaders-trouble-with-unity-visual-effects/3

      When having Write to Depth enabled you will need to increase the Depth alpha cutoff value as it's currently set to the very low value of 0.001. Semi-transparency combined with depth-write will however always be a tradeoff between cutting off too much (higher Depth alpha cutoff) and cutting off too little (your current state, low Depth alpha cutoff value) while still setting the depth value with a semi-transparent pixel which mostly shows the darker background and blocks subsequent overlaid pixels.


      In your case, it seemed to me that setting the Depth Alpha Cutoff and Shadow Alpha Cutoff to around 0.9-0.95 for the material using the Spine/Sprite/Pixel Lit shader would give good results. However, as Harald explained, there will be areas that will have too much cutoff.

      Harald may be able to offer you better advice, but is currently on vacation. So please wait for a while for his response.

      @KarenArushi As Misaki already mentioned, your export and import settings don't match up. If you intended to use Straight Alpha workflow, you should enable Bleed at the export options and disable Premultiply Alpha.

      Regarding the white outline:
      I'm afraid there is no optimal solution with enabled ZWrite of the Spine/Sprite/Pixel Lit shader (which is necessary unfortunately with the Built-In Render Pipeline and can't simply be disabled). As Misaki recommended, you should increase Depth Alpha Cutoff to get a better looking cutoff threshold.

      A different solution would be to switch your project to using Universal Render Pipeline, also called URP (with a 3D Renderer, not a 2D Renderer). See the documenation here for more details on the Spine URP Shaders package. The lit Spine URP Shaders have ZWrite disabled (since it's not required with Universal RP), while still being able to receive shadows, which would get rid of the problem altogether.

        Harald I'll give URP a try. Thanks a lot.

        Harald There are still some adaptation job on UPR, but it works totally fine now. Thanks again.

        @KarenArushi Glad to hear, thanks for letting us know.