Search Unity

Rotate sprite using shader graph

Discussion in '2D' started by vambier, Aug 4, 2021.

  1. vambier

    vambier

    Joined:
    Oct 1, 2012
    Posts:
    102
    I'm trying to rotate the texture on a sprite using shader graph. The rotation is only part of a bigger shader I'm creating, and everything works but the rotation. When I try to rotate a single square sprite it works fine. But when that sprite is part of a spritesheet it doesn't work anymore. When I to rotate the texture it rotates the whole sheet, at 0 degrees rotation it's fine, but once it starts rotating it rotates the whole sheet.
    Another problem I see is rotating a rectangular sprite. When I rotate a rectangular sprite to 90 degrees the texture becomes deformed. I added screenshots for clarification.

    This is a rectangular sprite, 64x128 pixels:
    alienPink_front.png


    Rotated 90 degrees in game it looks like this, really flattened:

    upload_2021-8-4_13-16-47.png

    The other problem is with spritesheets, for example this one:

    ExtraJump.png

    Looks like this in game:

    upload_2021-8-4_13-19-6.png

    But when rotated for example 20 degrees:

    upload_2021-8-4_13-20-3.png

    It looks like it rotates the whole sheet and tries to squish them into a single sprite.

    Anyone got any ideas what could be the problem and how to fix it?
     
  2. vambier

    vambier

    Joined:
    Oct 1, 2012
    Posts:
    102
    I forgot to add my shader graph:

    upload_2021-8-4_13-24-6.png
     
  3. vambier

    vambier

    Joined:
    Oct 1, 2012
    Posts:
    102
    Noone?
     
  4. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    vambier likes this.
  5. vambier

    vambier

    Joined:
    Oct 1, 2012
    Posts:
    102
    MousePods likes this.
  6. GareGames

    GareGames

    Joined:
    May 12, 2022
    Posts:
    2