r/UnityHelp • u/moduspwnens9k • May 03 '26
How to pass array data to Unity Shader Graph
I need to pass an array of arbitrary length to Unity Shader Graph to iterate over each item in the array (Vector3s) and process them. I know you can't iterate in Shader Graph directly, so I am trying to make use of Shader Graph's Custom Function node. The problem is I can't figure out how to pass an array of data to the node. Shader Graph has no Vector3[] data type to pass as input, and global variables don't seem to be working either.
What is the correct approach for handling arrays of data in unity shader graph? Or is it simply not possible and i have to write the whole thing in HLSL?
2
u/AbominableScience May 04 '26
Shader Graph cannot directly expose a Vector3[] as an input port. You need to use HLSL within a Custom Function Node, using either:
SetVectorArray for a small, simple array.
ComputeBuffer / GraphicsBuffer + StructuredBuffer for a dynamic array or a GPU-side array.
1
u/digimbyte May 05 '26
if you are clever enough you pipe it in as a texture, a texture is a 2d vector3 (RGB)or vector4 (RGBA)
there are other options but require custom nodes, but this does get into data blobs but the easiest approach is to handle it as a texture.