How to Create a Shader for Stretching a 2D Sprite Based on Cursor or Touch Movement?

Hi everyone,

I’m trying to create a shader for a 2D Sprite Renderer that stretches the sprite based on the direction of mouse cursor movement or touch gestures on the screen.

Here’s the functionality I’m aiming for:

  • When the user interacts with the sprite by touching or clicking within its collider (e.g., at point A (1, 0, 0)) and moves their hand or cursor to point B (3, 0, 0), the sprite should stretch in the direction of vector AB.
  • This stretching behavior should work for any direction in which the user moves their gesture.

I have some experience with creating shaders, but my attempts so far haven’t produced the desired results.

If anyone has encountered a similar problem, I would greatly appreciate your help. Specifically, if you could share guidance, examples, or keywords I can use to research this further, it would be really helpful.

Thank you in advance!