Search Unity

DrawMeshInstanced and material property blocks

Discussion in 'General Graphics' started by Culzean, Sep 22, 2017.

  1. Culzean

    Culzean

    Joined:
    Jan 25, 2014
    Posts:
    48
    I'm trying to assign an instanced property to my shader. This is rendered 128 times using DrawMeshInstanced and each position is indeed unique. However I wish to update a vector4 values each time I am rendering this, which I am trying to do via a material property block.


    I access the property via:

    UNITY_INSTANCING_CBUFFER_START(propertyBlock)
    UNITY_DEFINE_INSTANCED_PROP(float4, _AnimatonFrame)
    UNITY_INSTANCING_CBUFFER_END

    and in the vertex shader like so UNITY_ACCESS_INSTANCED_PROP(_AnimatonFrame);

    The property block is updated using .SetVectorArray("_AnimationFrame", vecList);

    yet it appears no property is getting send to the shader, does anyone have any ideas why this would be?
     

    Attached Files:

  2. jknight-nc

    jknight-nc

    Joined:
    Jun 10, 2014
    Posts:
    52
    I have my instanced property declared like this:
    UNITY_INSTANCING_CBUFFER_START(Props)
    UNITY_DEFINE_INSTANCED_PROP(fixed4, _Color) // Make _Color an instanced property (i.e. an array)
    UNITY_INSTANCING_CBUFFER_END
     
  3. Culzean

    Culzean

    Joined:
    Jan 25, 2014
    Posts:
    48
    @jknight-nc I have my instanced property defined as _AnimatonFrame ("AnimationFrame", Vector) = (1, 1, 1, 1)
    I don't see the difference. Any thoughts?
     
  4. Culzean

    Culzean

    Joined:
    Jan 25, 2014
    Posts:
    48
    I have fixed it now, working as intended. I have a spelling mistake between my shader property and what was set in my property block. damn dyslexia
     
  5. jknight-nc

    jknight-nc

    Joined:
    Jun 10, 2014
    Posts:
    52
    I thought the "UNITY_INSTANCING_CBUFFER_START(Props)" being different from "UNITY_INSTANCING_CBUFFER_START(propertyBlock)" was going to be the problem