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

Resolved Weird 2D texture spikes (pixel out of place)

Discussion in '2D' started by Adesnada, Mar 10, 2021.

  1. Adesnada

    Adesnada

    Joined:
    Oct 14, 2020
    Posts:
    12
    Can anyone tell me what this is? It's driving me crazy...

    At first I thought it was anti-aliasing, V-sync or Pixel Perfect Camera.

    This was taking with V-sync turned on to cap framerate, pixel perfect camera turned off and anti-aliasing turned off.

    Pixel perfect camera makes this problem appear on the character, whereas now it isn't.

    20210308_225517.jpg
     
  2. Drahedron

    Drahedron

    Joined:
    Apr 17, 2020
    Posts:
    20
    Hi, I also had many problems with the pixel perfect so I will do my best to help you even if I am a beginner.

    Some questions:

    - Is pixel snaping turned on? If it isn't you need to turn it on
    - how did you set your camera's ortographic size?
    - Have you tried to build the game to see if this isnt just caused by the Game tab resolution?
     
  3. Adesnada

    Adesnada

    Joined:
    Oct 14, 2020
    Posts:
    12
    Hi there,

    - Pixel snap is off and I want it to be off cause I dont like how if feels when it's on

    - My camera size is set up with cinemachine

    - Actually, this only happens when I build the game. Not seen in the editor.
     
  4. Drahedron

    Drahedron

    Joined:
    Apr 17, 2020
    Posts:
    20
    But did you calculated the right value to the orthographic size? Basically you need to set a value like this

    Orthographic size = your Y resolution/ (2* your ppu)

    Example: If you set your camera to 640x360 and your sprites are 32 pixels per unit then your orthographic size will be:

    Orthographic size = 360/2*32 = 5.625
     
  5. Drahedron

    Drahedron

    Joined:
    Apr 17, 2020
    Posts:
    20
    Also, you need to set pixel perfect on, I didn't get it...is it turned off?
     
  6. Adesnada

    Adesnada

    Joined:
    Oct 14, 2020
    Posts:
    12
    Im currently not using the pixel perfect camera component because that would cause the problem to appear on my character. So there's no pixel snap turned on nor there is a reference resolution set.
    And actually, when I looked up tutorials on setting up pixel perfect, they would tell you to set the reference resolution to whatever your targeting your game to have, in other words, if you want your game to have 1920x1080 resolution then set that as your reference resolution. In that case that rule of calculating my camera size wouldn't work... perhaps that's where the problem might be but idk
     
  7. Drahedron

    Drahedron

    Joined:
    Apr 17, 2020
    Posts:
    20
    Yeah, you can set reference resolution to whatever you want, but in this case your Orthographic size would be:

    OS = 1080/ (2* your sprites ppu)

    Also, are you using PoT on your sprites right? Remember your sprites must have always a Power of 2 x Power of 2 dimensions. Example: 8x16 or 16x16 or 32x128 and so on.

    Also, you need to set your sprites pixel per unit to the same and it also needs to be a PoT.
     
  8. Adesnada

    Adesnada

    Joined:
    Oct 14, 2020
    Posts:
    12
    Yes, all the sprites I'm using follow that rule (16x16) and yeah I set all of them to 16 pixel per unity so they all have the same resolution and match as well

    If i apply this OS = 1080/ (2* your sprites ppu), that would give me a camera size of 33.75, which is insanely big and cant barely see anything.
     
  9. Drahedron

    Drahedron

    Joined:
    Apr 17, 2020
    Posts:
    20
    So try to adjust your reference resolution, use 640x360 and calculate the OS, just to see if it will fix your problem.
     
  10. Adesnada

    Adesnada

    Joined:
    Oct 14, 2020
    Posts:
    12
    I set it to 320x180 (5.625 cam size) and toggled the pixel perfect camera component. The problem seems to have disappeared... idk why because I had these exact same settings a couple of days ago and the problem was there, so chances are that it will happen again and I still won't know what caused it or what solved it.

    Anyway, thanks for your help mate. I didn't know about that OS rule. Although, I realised that the camera does that calculation for you, when i set the resolution to 320x180, the camera size changed to 5.625 automatically, what is the actual result of that math rule. Idk if this was supposed to happen or I had to manually calculate the cam size myself and I didn't get it :p
     
    Drahedron likes this.
  11. Adesnada

    Adesnada

    Joined:
    Oct 14, 2020
    Posts:
    12
    Btw, one thing I noticed is that because I'm using the URP, the standard pixel perfect camera component doesn't work (a unity warning appears on the component telling you it isn't compatible with URP). I had to use the one pixel perfect camera component that says "experimental".
     
  12. Drahedron

    Drahedron

    Joined:
    Apr 17, 2020
    Posts:
    20
    Good to know man, I had enough problems with pixel perfect camera to let someone facing the same problems alone. Maybe in the past you did this change but some other mistakes were still there and you kept solving them until now that the only problem was the OS, I don't think this problem will comeback.

    Never used URP, but I've seen some videos and it looks pretty cool. Good to know that, when I use it I will go for this experimental version.
     
    Adesnada likes this.