Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Shader.SetGlobalVectorArray I have a problem

Discussion in 'Shaders' started by Little_Time, Oct 29, 2020.

  1. Little_Time

    Little_Time

    Joined:
    Sep 25, 2019
    Posts:
    4
    Shader.SetGlobalVectorArray("PointLightPos",PointLightPos);
    float4 colro=PointLightPos;
    if i>0, I can't get the right value

    So, am I using the wrong syntax, or how should I use the values in this array?
     
  2. Little_Time

    Little_Time

    Joined:
    Sep 25, 2019
    Posts:
    4
    I need help. Thank you
     

    Attached Files:

  3. grizzly

    grizzly

    Joined:
    Dec 5, 2012
    Posts:
    357
    Use SetGlobalVector if PointLightPos isn't an array, otherwise you'll need to change the shader to float4 colro[8]; where 8 is the maximum size of the array passed to the shader, for example.
     
    Little_Time likes this.
  4. Little_Time

    Little_Time

    Joined:
    Sep 25, 2019
    Posts:
    4
    thank you very much for your help
    statement:
    float4 PointLightPos[2];
    float4 _fAttenuationValue[2];
    float4 PointLightColors[2];

    The above values are in a include file

    I want to get the parameters of a particular Light by passing in the index but only array[0] is correct array[0+n] is wrong