Facebook

Unity Shader Graph: Split Vector3

by Michael Sacco Published August 31, 2023

Introduction

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

  1. To split a Vector3, use the Split Node.
  2. To create the Split Node, open Shader Graph, Right Click > Create Node > Channel > Split.
  3. 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.

  1. To create a Vector2, use the Vector2 node.
  2. To create the Vector2 Node, open Shader Graph, Right Click > Create Node > Input > Basic > Vector2
  3. To assign the components of the Vector2, drag the Split node’s Out ports to the Vector2 node’s X and Y ports.

Conclusion

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.

Free download: Indie Game Marketing Checklist

Download now

Category

unity basics

Don't forget to share this post!

Popular assets for Unity

See all assets ->
    Cutting-edge volumetric fog and volumetric lighting with support for transparent materials.
    Volumetric clouds, day night cycles, dynamic skies, global lighting, weather effects, and planets and moons.
    A lightweight procedural skybox ideal for semi-stylized projects.
    Image-based Outlines for 2D and 3D games with variable line weight, color, and displacement options.
    Per-pixel gaussian blur on your entire screen, part of the UI, or in-scene objects.
    Drag-and-drop ready-to-use ambient, impact, and spell particle effects.

Free Indie Game Marketing Checklist

Learn how to make your game successful with this handy checklist.

Download for free