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

RGBA Crunched DXT5 (WebGL) weirdly cuts part of my sprites

Discussion in 'General Graphics' started by JZ_CGL, May 27, 2020.

  1. JZ_CGL

    JZ_CGL

    Joined:
    Jun 12, 2017
    Posts:
    9
    Hey guys,

    I'm working on a 2D game running in WebGL. I have a Spritesheet of my 2D character idleing, one row facing left, the other facing right. If I set my Import Settings for that Sprite to RGBA Crunched DXT5 (Compression rate 50, but the problem occurs with any compression rate). The crunched spritesheet looks fine, but the sliced sprites by Unity feature a cut in the leg of every left-facing frame of the Animation. Check this:



    I've attached a small part of my spritesheet for you to test for yourself. The issue is reproducable on a different device. The full spritesheet has 16 Idle states, this issue only affects the left-looking sprites. Any ideas? :)


    Unity Version

    2019.2.0f1 (Edit: Happens also in 2019.3.14f1)
    Platform
    WebGL (Edit: Happens also in PC, Mac & Linux Standalone)
    Import Settings
    Sprite (2D and UI)
    Multiple
    Generate Physics Shape: Off
    Clamp
    Bilinear
    Override for WebGL: On

    MaxSize: 2048
    Algorithm: Mitchell
    Format: RGBA Crunched DXT5
    Quality: 50

     

    Attached Files:

    Last edited: May 28, 2020
    Vivien_Lynn likes this.
  2. JZ_CGL

    JZ_CGL

    Joined:
    Jun 12, 2017
    Posts:
    9
    Steps I've tried so far:
    • Reimporting
    • Creating a copy / Renaming the file
    • Adjusting the crunch quality
    • Reslicing
    • Redrawing the sliced parts in Photoshop
    • Export the Image as JPG, create Layermask from PNG, Apply to JPG and save the result as a new PNG
    • Using another Photoshop PNG-Export Format (I normally use "Smallest")

    This issue is driving me nuts. I shouldn't put so much time into this, but I'm really curious why this happens.

    I've checked the Alpha Channel in the Sprite Editor:


    Looking fine, not the slightest shade of grey.
    Help me solve this mystery or I won't be able to sleep, haha. This' gonna haunt me.
     
  3. JZ_CGL

    JZ_CGL

    Joined:
    Jun 12, 2017
    Posts:
    9
    Currently crunching all of the other spritesheets now, so far I don't see any similiar issues there. While this is a good thing, I kind of hoped to find another instance where this bug occurs. If someone could reassure me that they were able to reproduce my bug using the sprite I've attached, that would be great.
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,022
    i briefly tested that sprite here in same unity version, didn't see anything (although didn't have webgl as platform)

    i'd certainly report as a bug in any case. (especially if you can include that project where it happens)
     
  5. JZ_CGL

    JZ_CGL

    Joined:
    Jun 12, 2017
    Posts:
    9
    Thanks for trying, mgear. I will report the bug now. Just tested in 2019.3.14 and the same problem.
    Did you slice the sprite using the Sprite Editor? The missing piece is only present in the sliced sub-sprite. You can just use the Auto Slicing option, it results in the same outcome.

    Edit: It also happens using Windows build platform.
     
  6. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,022
    oh yeah, it is visible (in the individual sprite, not in the main asset)

    if selected "full rect" its not visible, with "tight" it is there, some kind of mesh generation issue?
    upload_2020-5-28_17-23-31.png
     
    JZ_CGL likes this.
  7. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,864
    looks like the triangle UVs are incorrect
    please report a bug :)
     
  8. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,022
    seems to work fine in 2020.1.0b8
    upload_2020-5-28_17-27-56.png
     
  9. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,864
    but produces a completely different mesh... and it doesn't look like a good tri density to me
     
  10. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,022
    sorry extrude edges value was 0 in that screenshot (but no issues with other values either)

    here is with default: extrude edges = 1
    upload_2020-5-28_17-30-46.png
     
  11. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,864
    still looks too dense for me :)
     
  12. JZ_CGL

    JZ_CGL

    Joined:
    Jun 12, 2017
    Posts:
    9
    Thanks guys! I've reported a bug (Case 1251241).

    I was actually always ignoring the mesh type dropwdown. And definitely never set the Shading Mode in a 2D game to Shaded Wireframe. I was greeted with this view:



    I can't believe this should be more efficient than full rect, but I guess "Tight" is set to Default because of a reason. The documentation doesn't tell me what the better solution would be. I assume "Tight" is also needed for Polygon Collider creation? Or is it actually reducing the draw calls by getting rid of transparent Pixels? What's the best practice here?

    Edit:
    Okay, I just had an interesting dive into 2D Sprite Optimization, Overdraws and Geometry Optimization. This was a good read: learn.unity.com/tutorial/fixing-performance-problems#5c7f8528edbc2a002053b596
     
    Last edited: May 28, 2020
  13. unity_EDH7Los5SCXZxQ

    unity_EDH7Los5SCXZxQ

    Joined:
    Dec 24, 2020
    Posts:
    1
    Before compression Image size is 5MB.Iam using "RGBA Crunched DXT5" compression for webgl build. In Unity editor it is showing size of the texture:481KB after applying compression.But In webgl build i cross checked in memory profiler it showing 5MB. Compression is not happening in webgl build, only compression happening in editor. Screenshot 2020-12-24 at 11.33.02 AM.png