Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Use Per Renderer Data in UI

Discussion in 'Shaders' started by Le_Tai, Oct 28, 2016.

  1. Le_Tai

    Le_Tai

    Joined:
    Jun 20, 2014
    Posts:
    364
    Unity default UI shader use [PerRendererData] for Sprite Texture, so you can use one shader for all your sprite and render them in one draw call. But I can't seem to find a API call for setting those anywhere, so I decompile Unity dll just to find that they use an Internal call to set the sprite.

    On the asset store I see a lot of package about normal mapped UI, so there must be a way to pass in per renderer data to the Canvas Renderer, right?
     
  2. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    886
  3. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    665
    Also struggling with this. The only solution I found so far is cloning the materials on runtime, which creates more drawcalls in the end.

    Code (CSharp):
    1. Material instancedMat;
    2. ...
    3. instancedMat = Instantiate(image.material);
    4. image.material = instancedMat;
    Also took a look at the decompiled unity version, but didn't get any smarter. I fear as for now (5.6), there is no solution to this problem.
     
unityunity