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

Question Rotate scene positions uv stretches output?

Discussion in 'Shaders' started by Pheonix14, Sep 1, 2022.

  1. Pheonix14

    Pheonix14

    Joined:
    Mar 24, 2015
    Posts:
    2
    I'm having trouble making a very basic shader. I was hoping someone might be able to help me understand what I'm doing wrong. I hope this is the right place to ask for help.

    The shader I'm trying to do copies whatever is underneath it and then rotates it.
    Not sure if it's relevant but I'm trying to apply this effect to sprites.
    This is the current shader graph:
    unknown.png

    On my scene, I just have a circle, which is correctly copied and not stretched without the rotation.
    However, with rotation, I get this weird stretching.
    After seeing this I thought that maybe I needed to align the shader's center with the object's center, but that didn't work either.
    Unity_OPu2XjNp2k.gif
    Any idea as to what I'm doing wrong?

    Thank you.
     
  2. Pheonix14

    Pheonix14

    Joined:
    Mar 24, 2015
    Posts:
    2
    I got help from someone outside the forum. The reason the stretching was happening was because I'm working with a 16:9 ratio when the UV map is made for 1:1.
    Not taking that into consideration caused the stretch.
    To fix it I just had to multiply the screen position and the center by the screen width and height, and then after the rotation divide it by the screen width and height.