Shader Graph Conversion Catchup : Swaying Grass & Shattered Moving & Growing Flowers

(For those waiting for a new Standard RP-based tutorial, I've got a Thermal Vision effect post coming up next week :) )

In this post I"m explaining how to set up the position based movement effect from the Bastion and Position Effects posts in ShaderGraph and the LWRP/URP .

The graph files are attached to this post!

The script : PasteBin Link 

Here's the script you will need, it's the same as from the Position Effects post, but one addition: I added an extra random range option so effects don't trigger all at the same time.

The important parts from this script we need to add to the Shader Graphs :

_Moved (goes to 1 when the target is near)
_PositionMoving (position of target for texture blending)
_RandomOffset (random offset for blocks offset)

The _Moved value and the _RandomOffset will be set individually for all objects you want to interact with. _PositionMoving is a global variable.

Before setting up the growing flowers, I never explained a grass swaying effect in Shader Graph, let's set that up first.

Swaying Grass

To make swaying grass we need to convert this code into nodes.

"float4 wpos" is easy, just the Position node set to "World"

Break the others into parts. Do the X axis first.

First Split the World Position Node, only using the .r(x) value.
Then Divide this by the _Rigidness exposed Vector1.
Add Time multiplied by _Speed exposed Vector1.

Now put this whole block through a Sine wave node, you should see the preview animate if you set your "Move Speed" default to something other than 0

Add a falloff on the local Y axis, by adding a Position node set to Object, splitting to the g(y), and subtracting a Y-Offset variable from it.

Multiply the falloff with the result of the Sine Node, and multiply that result with a Sway Max Vector1

 That's the X axis done, do the same for the Z axis, and put these two vectors into a new Vector3, leaving the middle option G(Y) at 0. 

Finally , create step of the Y-falloff and multiply with the new Vector3, then add the result to the full Position-Object node and add a texture and you're done!

Here's a link to the full graph: Imgur Link 

And the graph file is attached

Growing Flowers

Copy the swaying part of the Swaying Grass effect into this graph, don't forget to convert to property and name the _YOffset, _Rigidness, SwayMax, MoveSpeed variables.

Here's the code we need to convert

Add a Vector1 with Reference "_Moved" (And don't forget to untick Exposed, we are providing the value via script)

Also add new Vector1 for Shrink XZ axis, and Shrink whole mesh 

XZ Shrinking first, a cheap illusion of a closed flower

Add the Moved and Shrink XZ together and saturate the result. 

Multiply this result with the Swaying final "Add" node, and create a new Vector3 by splitting the XZ(RB) of the shrink result and adding the Y of a Position - Object node.

Now shrink the whole mesh

Add the Moved and Shrink variables together, saturate, then multiply by the XZ result.

The output of this goes into the PBR Master. Add a texture and you're done.

Here's a link to the full graph: Imgur Link  

And the graph file is attached

Shattered Moving Back

Pretty big block of code to convert this time. 

Add a Vector1 for the Moving value with reference "_Moved",

And a Vector1 for the Random Offset with reference "_RandomOffset". Not exposed for both.

Let's start with the AwayFromPlayer value, this time we only want to move things when the target is away, so invert the Moved value with a OneMinus node. All vertex movement will be multiplied by this number


Just like with the swaying effect, create a sine function based on time.

Multiply with the AwayFromTarget value, a new BobbingAmount vector1.

This will be added to the Vertex.y


Multiply a new Vector1 slider Offset with the RandomOffset from script. Multiply by AwayFromTarget and then add to the Bobbing Result vector3.


Randomise the angle for both Y and X by multiplying an exposed Vector1 for AngleY and AngleX with the RandomOffset from script.

Multiply both with the AwayFromTarget value so that if they target is in radius, the angle value will be 0.

Use these values as the degrees for a Rotate About Axis node set to Degrees.

For the Y rotation, feed in the Offset Result Vector3, and as the Axis set it to 0,1,0., add in the Randomised Angle Y as Degrees

For the X rotation, feed in the result of the Y Rotate About Axis node, with the Axis set to 1,0,0, and add the Randomised Angle X value as Degrees.

And that's the vertex manipulation done!


If you want to add texture swapping, grab the effect from This Post , it's explained there how it works, just paste it into the file, and expose and name the parts you need.

The Position vector3 from that post should be refenced as"_PositionMoving" to work with what the script provides by default

Here's the full graph: Imgur Link 

and the shader graph file is linked.

That's it for today, have fun!

Become a patron to

Unlock 141 exclusive posts
Be part of the community
Connect via private message