Search Unity

Question My sprite gets a polygonal shape when I add a material

Discussion in 'Shader Graph' started by Rventima, Jan 1, 2022.

  1. Rventima

    Rventima

    Joined:
    Oct 16, 2021
    Posts:
    8
    Hello.
    I want to add a material to a sprite, but it gets a polygonal shape:
    upload_2022-1-1_12-46-33.png
    Its original shape is a flame.
    I'm using the URP and working in 2D. With other materials like Sprite-Unlit-Default this doesn't happen. It's the first time I get this problem.
     
  2. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    Alpha clip threshold maybe ?
     
  3. Rventima

    Rventima

    Joined:
    Oct 16, 2021
    Posts:
    8
    The problem was in the shader graph node editor, I needed to connect the alpha channel even if the RGBA was connected.
     
  4. Sinterklaas

    Sinterklaas

    Joined:
    Jun 6, 2018
    Posts:
    93
    By the by, the weird polygonal shape in your picture happened due to the "mesh type" option in the sprite's import settings being set to "tight" instead of "full rect". This basically makes Unity cut away certain parts of the sprite that are fully transparent, particularly near the corners of the image, as an optimization. If you had used the "full rect" option, you would've seen a fully opaque, rectangular image instead of the weird polygonal one.

    As for the coloring of pixels that should've been transparent, that happens when the rgb values of transparent pixels in your source image contain non-zero values. Photoshop, for example, often leaves color in the rgb channels of transparent pixels instead of clearing them, which can lead to some pretty weird results when you then read those pixels in a shader without checking for transparency.