Need help with bending effect on sprites

Hello, I am making a shader that displaces the UV coordinates on a sprite to achieve the bending effect. What I need to do is to make object bend according to the parameter _BendFactor. The shader itself kind of works allright. The problem is, that the Sprite Renderer does not use quads, it generates a kind of 2D mesh (I don’t know why this feature is even there. Performance maybe?). Anyway, the thing is that the mesh is optimized for initial texture, however, when I displace the UV coordinates, a part of the object goes outside of the generated mesh and is clipped (as in the screenshot). So, my question is, is it possible to force SpriteRenderer to use a single quad instead of a fancy generated mesh? And if not, how can I possibly work around it? (I tried adding a plane object, however the problem is that I need all the animation features and the sprite animations didn’t seem to work with the 3D setup). I also attach a shader file just in case, although I don’t think it i necessary.

2623088–184233–BendShader.shader (1.48 KB)

Actually, never mind. I already found a solution.

@codemakeris
I would actually be interested in hearing about the solution you found. :wink:

I bet he found the Mesh Type pop-up in the Advanced import settings. :slight_smile:

Setting this to Full Rect instead of Tight gets you a simple quad for the sprite instead of a more complex shape.

Actually, I didn’t know about that setting. I’ll keep this in mind if I need this in the future, thanks for bringing that into my attention. However, I don’t know if that solution would have been sufficient, since I needed the sprite to bend quite a lot and it is possible that it would go out of bounds anyway.So I modeled a mesh consisting of a column of quads an then used the vertex shader to change the vertex positions. As for the animation, I have written a script which translates the UV coordinates. This may not be optimal, but worked well for my purposes. As for the shader file I added earlier - just ignore it, I wrote something completely different.

1 Like