Unity Shader Graph: Split Vector3
As a new game developer, Shader Graph can be a tough nut to crack. As a Shader Graph pro, I wanted to put together this super short guide on how to use Shader Graph nodes to split a Vector3 into the x, y, z components.
How to Split a Vector3 in Shader Graph
- To split a Vector3, use the Split Node.
- To create the Split Node, open Shader Graph, Right Click > Create Node > Channel > Split.
- To attach the Vector3, drag the Vector3 node’s Out port to the Split node’s In port.
Unity has more documentation on the Split node.
Great, so you’ve split the Vector3. Now you want to put it back together again to make a Vector2. Ruh roh!
Just kidding, I got you. In the section section, I will show you how to make a new Vector2 from individual float ports from the Split node.
How to make a Vector2 using the Split node
Here’s how to use the Split node to create a new Vector2 from the X/Z components of the Vector3.
- To create a Vector2, use the Vector2 node.
- To create the Vector2 Node, open Shader Graph, Right Click > Create Node > Input > Basic > Vector2
- To assign the components of the Vector2, drag the Split node’s Out ports to the Vector2 node’s X and Y ports.
As you can see, it’s easy to deconstruct and reconstruct vectors in Unity’s Shader Graph. By using Split and Vector nodes, you can tear down and build up any vector you want.
To continue building your shader and math skills, you should read my comprehensive guide to HLSL’s Step function. Then, get comfortable using linear interpolation with my Lerp essentials guide.
65+ Tips: How to improve a Unity Game's Performance
65+ tips to help you improve your Unity game's performance.
The basics of arrays in C#. Declaring, initializing, assigning values, accessing elements, and using foreach loops.
Low Poly Trees
This article outlined the world of low poly trees. You learned how to make low poly trees. You also learned where to use low poly trees.