- Home /
How to whirl effect in shader graphs?
Whirl effect controlled by a float/int on a 2D sprite with shadergraphs and c#.
Like my picture:
Answer by Bunny83 · May 05, 2020 at 08:08 PM
Well, here you go. Here's the actual shadergraph file. It should be quite obvious that "Angle" is the angle and "Center" the center of the swirl. The center is specified in texture coordinates, so in the range between 0 and 1. The "Area" multiplies is a bit tricky to explain ^^. It essentially allows you to specify the area / size of the swirl, though it's hard to explain. A value of 0 will not swirl at all but just rotate the whole image. A value between 0 and 1.414 (==sqrt(2)) will essentially unwind the outer part of the image. A value greater than 1.414 essentially limits the outer radius of the swirl.
I might should mention that shader graph actually has a "Twirl" node which does a very similar thing. However it keeps the center fixed and swirls the outer part around. This effect can be combined with the rotate around node to undo the rotation to achieve a similar effect what we want. However you have less control over the area of effect. Such a shader might looks like this. Here's the shadergraph file
I just quickly clicked this shader together. However it should put you on the right track.
Note that my first swirl shader currently uses an angle in degrees while the second one uses an angle in radians. The "rotate about axis" node can be switched between degrees and radians, the Twirl node does not have such a setting. Of course you can simply add a multiply node to convert between degrees and radians.
ps: I created and tested this shader with the lightweight pipeline.
Your answer
![](https://koobas.hobune.stream/wayback/20220612233350im_/https://answers.unity.com/themes/thub/images/avi.jpg)