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

Adding material to SpriteRenderer messes up sprite

Discussion in '2D' started by timppaonboss, Nov 15, 2022.

  1. timppaonboss

    timppaonboss

    Joined:
    Apr 5, 2020
    Posts:
    2
    Hi,
    Im trying to create a shader for my player character but every time I assign a material it messes up my sprite

    Default material: 66032B40-57E2-41E5-BAFD-27E2707024C7.jpeg

    Any other material: 4A634ED1-0E4C-4C4C-843F-3BC58451E376.jpeg

    on the images it looks pixelated and not so obvious but when playing its super noticeable

    the top and bottom are not round, top left of eyemask is box shaped instead of round
     
    Last edited: Nov 15, 2022
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,323
    Without information about the material/shader we're guessing in the dark.

    First guess: this is a sampling thing. It's forces Point instead of Bilinear when you mean to use Bilinear sampling.

    Second guess: this is an alpha thing. Your material isn't treating alpha the same as the Sprite Lit material. Perhaps - if this is shader graph - it's not connected correctly?

    edit: what does it look like if the GameView zoom is a power-of-two (7.6x in pic)? That might be a surprising source of the compressed/artifact look it produces.
     
    Last edited: Nov 16, 2022
    timppaonboss likes this.
  3. timppaonboss

    timppaonboss

    Joined:
    Apr 5, 2020
    Posts:
    2
    It was an alpha thing since it got fixed when I changed the Surface type of the material to transparent and enabled alpha clipping. I have no idea what those things mean but thank you a lot I was getting super frustrated because of this.
     
  4. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,323
    It sounds like this material is using a standard Universal RP material lit or unlit? What the alpha clipping does is pretend to be transparent, when really you're removing pixels if the alpha is below the clipping threshold.

    If you need real transparency as is typical for sprites, you may instead want to create a material/shader that uses Sprite Lit or Sprite Unlit as its template in Shader Graph.

    Here's what I mean: https://blog-api.unity.com/sites/default/files/2021/02/GraphInspector.mp4

    Sprite Lit is the template for shaders that behave similarly to Sprite-Lit-Default, responding to Light2Ds.
     
    timppaonboss likes this.