Search code examples
unity-game-engine2dspriteshader-graph

How to set direction of arrows in shadergraph


I'm pretty new to shader graph and shaders in general. I'm working on a 2D project and I'm trying to make a shader that rotates an arrow to make a flow-like material and use it on a sprite shape.

Basically what I want to do is make a proper version of this:

current arrow

What I'm currently doing is multiplying the Y position of the position node by an exposed vector 1 and using it in Rotate node (which I know is pretty hacky and won't work if the shape is not an arc.)

shader


Solution

  • Aligning UV with arbitrary mesh seems bit hard. Why not bend pre-made mesh instead? Graph below bends vertex positions around axis Z at given point and strength (0 makes mesh invisible tho), but, you can easily replace that Position node with UV and plug results into Sample Texture 2D. I just guess bending a mesh will give you better/easier results.


    • Create a subdivided and well UV-mapped rectangle plane
    • Bend that plane with a vertex shader (attached graph bends around Z axis) bend mesh vertices unity shader graph

    graph is based on code from Blender source