Create a simple Animation using shader graph

In our last tutorial, we saw how to get started with shader graph in Unity. If you are totally new to shader graph then I will suggest you read our getting started with shader graph tutorial before going ahead with this.

In this tutorial, we will create a sun texture with noise and color and also make it rotate with shader graph. Making animations using shaders is less performance expensive compared to the regular animation in Unity.

Here is how our final output will look like

Normally to create something like in the image above you will need a texture and a rotation animation. But using a shader this can be done with just noise and offset.

Create a new shader graph by right clicking on the project window>create>shader>Universal Renderpipeline> Unlit shader graph.

Right click the shader graph and create>material. Add a sphere to the scene and apply this material to the sphere.

Double click on the shader graph to open the shader graph editor.

Add a new simple noise node by right clicking on the shader graph editor> Add node.

Create the following parameter by clicking on the plus sign on the blackboard.

  1. Color of type color.
  2. Float Noise_level.
  3. vector 2 offset.
  4. Float Rotation_speed.

Add a new Time node. Multiple the Rotation_speed with the output of time node and connect the output to a multiplier node.

Drag and drop the offset variable into the graph editor and connect it to the second into of the multiplier.

Add a tiling and offset node to the graph. Connect the output of your offset multiplier to the offset input.

Connect the output of the tiling and offset node to the UV input of your Simple noise node.

Connect the Noise_level parameter to the scale input of your Simple noise node.

Connect the noise node output to a divide node. Also connect your color parameter to the divide node.

Connect the output of the divide node to the base color of the shader master.

Save the asset.

Select the material you created in this tutorial earlier and play around with the values in the inspector window until you get your desired result.

If you have any other questions leave it in the comment box below.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.