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 Pixel Sprite Rotation Goes Wonky

Discussion in '2D' started by walruscake, Jun 19, 2023.

  1. walruscake

    walruscake

    Joined:
    Dec 19, 2022
    Posts:
    7
    I created a spritesheet with Piskel and imported it to Unity, but when I rotate the sprite the image itself starts to appear weird. Also, when the sprite is along a 0, 90, 180, or 360 degree angle the sprite is perfect. Also I have a filter mode of Point, and no compression. Any ideas(I tried the pixel perfect camera in Unity)? One final thing too, the edges are weirdly outstretched in some places, if anyone knows how to fix that. Attached files down below will show the weird appearance.
     

    Attached Files:

  2. Zonlib

    Zonlib

    Joined:
    Apr 15, 2014
    Posts:
    39
    I think the reason is you have set scale of the game view too big
     

    Attached Files:

  3. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    put the scale of your game window to x1

    you arent giving enough pixels to the screen for the rotation to be smooth
     
  4. walruscake

    walruscake

    Joined:
    Dec 19, 2022
    Posts:
    7
    @karderos
    @Zonlib

    You can still see the affect at 1x even though it might be slightly less, but i just zoomed in to show the effect better. I have a screen recording with a window at 1x scale, but I am having trouble uploading it. I get the error "The uploaded file does not have an allowed extension.". Do I have to make and link a youtube video, or can I do something else to fix this error?
     
    Last edited: Jun 19, 2023
  5. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    u are supposed to put the scale at 1x

    and after that increase the scale of the sprite so it isnt small on the screen, by using transform.scale or PPU

    you should upload to youtube yes
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,708
    That's kinda how pixel art works... if you rotate pixel art and you keep the point filtering, you WILL get wonkiness. It's not possible for a single pixel to be smoothly shared between two output pixels in point mode.

    If you want to rotate in pixel art, you create a different sprite that has been "hand pixelized" to the new rotation and show that in lieu of the non-rotated one.

    Obviously 0, 90, 180, 270 works fine because... those are pixel-perfect!
     
  7. walruscake

    walruscake

    Joined:
    Dec 19, 2022
    Posts:
    7
    @Kurt-Dekker

    Are you saying I should turn the pixel art into a different type of sprite, or are you saying I should make my own in between rotation pixel art?
     
  8. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,708
    I am not saying you should or should not do anything.

    I am pointing out that pixel art, when rotated slightly, will ALWAYS have aliasing artifacts.

    This is often why custom frames are made when trying to rotate stuff. But it certainly isn't a "must."

    If you want to see what I mean, simply make an 8x8 texture that is black / white like a checkerboard, put it in your game and start rotating it by small amounts to see what happens to the pixels.
     
  9. papapari319

    papapari319

    Joined:
    Jun 24, 2023
    Posts:
    2
    Any ideas(I tried the pixel perfect camera in Unity)? One final thing too, the edges are weirdly outstretched in some places, if anyone knows how to fix that. Attached files down below will show the weird appearance.
     
  10. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    theres nothing to fix, what is happening is normal, you just having trouble to understand why

    it happens because there arent enough pixels
     
  11. walruscake

    walruscake

    Joined:
    Dec 19, 2022
    Posts:
    7
    @Kurt-Dekker
    @karderos

    Well, if this will happen to pixel art no matter what, can I do anything different to change the pixel art so it works smoothly rotating, like take a screenshot of my pixel art and turn it into a normal image? And if that would work, would I have to change my filter mode?
     
  12. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    for it to rotate smoother, scale up the sprite, its too small on the screen

    you could change it to bilinear filter but it will be blurry you probably wont like it
     
  13. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,131
    You hand draw the rotation images
    You use a shader to smoothen things a bit
     
  14. walruscake

    walruscake

    Joined:
    Dec 19, 2022
    Posts:
    7
    @Kurt-Dekker
    @karderos
    @sngdan

    I've already try scaling it up, which I stated in a different comment, and it still gives me that weird pixelated look (In added files)
    Also, how can I hand make the in between sprites if I let the car rotate 360 degrees?
     

    Attached Files:

  15. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,131
  16. walruscake

    walruscake

    Joined:
    Dec 19, 2022
    Posts:
    7
    I just realized that scaling the sprite up does work, but I also have to scale up the camera size. But while doing that, I encountered a new bug (Yay!). Whenever I enter Play Mode, the camera snaps back to a size of 7.25, and I have no control over it. Anyone know why?
     
  17. walruscake

    walruscake

    Joined:
    Dec 19, 2022
    Posts:
    7
    @karderos

    I have everything working now, but how do I set the thread as complete or remove it?