Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Passing Vector3 Arrays to ShaderGraph

Discussion in 'Shader Graph' started by marcosbiagi, May 4, 2022.

  1. marcosbiagi

    marcosbiagi

    Joined:
    Mar 22, 2019
    Posts:
    6
    Hello, I have been trying to convert my shaders from Amplify to ShaderGraph.

    On Amplify we were sending our shader an array of 100 Vector3's with

    Shader.SetGlobalVectorArray("objectPosition", vectorPositions);


    Is there something like this for ShaderGraph, where I can send an array of Vector3's representing positions.

    The idea is to have our floor vertex go down when any character or actor is on top of it. Like this:

    Any help will be greatly appreciated!
     

    Attached Files:

  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,574
    If I am correct, shader graph has an array of floats. Or maybe even array of float3.
    However, not sure if you can use it with Unity inspector. Last time I remember, which was while ago, there was some problems with it. But now maybe all works fine. I haven't been really using it.

    Shader Graph has input properties.
     
  3. marcosbiagi

    marcosbiagi

    Joined:
    Mar 22, 2019
    Posts:
    6
    Shader Graph doesn't have a Property for float arrays. It only has texture2D array.

    Amplify has global variables and one of those can be an array of vectors. I'm finding no way of sending 100 vectors to Shader Graph.
     

    Attached Files:

    Antypodish likes this.
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,574
    Yeah, you are right.
    Sorry, my memory failed :D
    Yes it is texture 2D array, which I most likely confused.

    However, could you consider using Matrix4, which is 4x4.
    16 elements multiply 19, that is 304 floats,
    Or 101 + 1/3 vector3 :p
    I don't know if that helpful anyhow, as it is not ideal solution.
    Otherwise, you may need to write custom shader.