Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Pixel Perfect - problem with rotation

Discussion in '2D' started by sly_88, Jun 5, 2018.

Thread Status:
Not open for further replies.
  1. sly_88

    sly_88

    Joined:
    May 8, 2018
    Posts:
    25
    hi guys,

    I making 2d game (pixel perfect) when I must rotate camera and object and I have some problem with it. the corners not looking good when I rotate camera and objects. I tried anti-aliasing and etc and still result is not perfect. Do you have any ideas/solutions how handle camera and object rotation in a pixel-art game?

    I attached the image to show my problem.
     

    Attached Files:

  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Hmm, well the short (and obvious) answer is, you can't. True pixel art doesn't rotate except in 90-degree increments.

    Old pixel-based games with rotating spaceships or whatever had pre-rotated (usually in 8, 12, or 16 different angles) versions of the sprites, and just switched to the appropriate one for whatever way the thing is facing. And they never rotated the entire camera (as if there were a camera! ;) ).

    If you really need to arbitrarily rotate the camera and objects, while achieving a pixel-perfect look (as if the game were made with infinite variations of all sprites etc), then I think maybe you'll need to use a 2-step process: render your scene to a smaller RenderTexture (however many pixels wide and high you want your display to be), and then render that texture to the display (enlarged to the actual display size).
     
  3. sly_88

    sly_88

    Joined:
    May 8, 2018
    Posts:
    25
    so you mean render the scene to texture and then rotate textures?
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    No. Render the scene (including rotated elements) to a texture, and then display the (unrotated) texture.
     
  5. sly_88

    sly_88

    Joined:
    May 8, 2018
    Posts:
    25
    so the first camera will render all elements to texture included rotation, right?
     
    JoeStrout likes this.
  6. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Yes. You're simply using the RenderTexture as a little screen, one pixel per pixel. Then you blow this up to the actual screen, at (say) 4 pixels per pixel or whatever you want.
     
  7. sly_88

    sly_88

    Joined:
    May 8, 2018
    Posts:
    25
    or I misunderstand something or it doesn't work. I still have the same effect.
    what I did
    - render texture from first camera (rotated objects and etc.) (texture size 600x600)
    - show rendered texture
     
  8. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Then perhaps I don't understand what the issue is. The screen shot at the top of the thread shows rotated pixels, but that's impossible with this technique. Can you post a screen shot of what you're getting now, and explain how it differs from what you want?
     
  9. sly_88

    sly_88

    Joined:
    May 8, 2018
    Posts:
    25
    hi :)

    I have the same result because I render from the camera which displays rotated objects, so perhaps I don't understand in 100% your ideas
     
Thread Status:
Not open for further replies.