Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

How to use new MaterialPropertyBlock uniform API with DrawProceduralIndirect

Discussion in '5.4 Beta' started by obviousjim, Mar 18, 2016.

  1. obviousjim

    obviousjim

    Joined:
    Oct 11, 2009
    Posts:
    29
    Hi,

    I'm excited about the support for uniform arrays in MaterialPropertyBlocks. However I think there may be a gap left in the new API that I have fallen into.

    I'm using Graphics.DrawProceduralIndirect with a shader using uniform arrays. Previously I was able to pass the uniform array through:

    material.SetVector("_MyUniform" + i, myVectorArray);

    However, this stopped working which makes sense based on the updated description from 5.4b10 release notes:

    Shader uniform array support. Uniform arrays can be set by new array APIs on MaterialPropertyBlock. The old way of setting array elements by using number-suffixed names is deprecated


    But there does not seem to be a way to pass a material property block to a material when it's drawn through Graphics.DrawProceduralIndirect. So now it seems that I'm stuck without being able to use the new API, and a broken shader using the old API number-suffix approach.

    Any advice would be helpful, thank you!
     
  2. zeroyao

    zeroyao

    Unity Technologies

    Joined:
    Mar 28, 2013
    Posts:
    169
    Oops yeah it indeed is something we should fix. I'll do it in a future beta.
     
  3. obviousjim

    obviousjim

    Joined:
    Oct 11, 2009
    Posts:
    29
    Thank you!