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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Render Order custom material doesn't work?

Discussion in 'UGUI & TextMesh Pro' started by rorakin3, Sep 1, 2014.

  1. rorakin3


    Jan 2, 2013
    I've been adding support for UGUI last couple days for my Graph Maker package (link in my sig). So far it has been going great. I've managed to reproduce line graphs, bar graphs, pie graphs, custom events, tooltips, animations, etc. without any issues. The only issue I've run into that I can't solve is render order for Image with custom material.

    Basically, to create a stacked line graph, I have a custom shader that I created in Shader Forge. This shader handles alpha clipping based on various shader properties that I pass in via code.

    I have it working in NGUI, and Daikon Forge (screenshots on asset store product page). For those, I create and set a material on UITexture (NGUI) / dfTextureSprite (Daikon). For UGUI, I'm using Image (tried raw image as well), and I'm basically just setting Image.material = new Material().

    Everything seems to work (alpha clipping, color, etc), except for the render order. The render order does not seem to respect ordering of the transform siblings. I have attached a screenshot attempting too show this. In the hierarchy, the series2 object represents the line series with the orange squares, and for this series there should be green rectangles below overlaying the blue rectangles (refer to asset store product screenshot for stacked line graph for what the final result should look like).

    So, I do have the series 1 before series 2 in the transform hierarchy, but series 2 is rendering below series 1. If I drag out the position of series 2, I do see the green rectangles.

    Attached Files:

    Last edited: Sep 1, 2014
  2. Tim-C


    Unity Technologies

    Feb 6, 2010
    Not sure why this would be happening without seeing a repro project. can you log a bug>
  3. rorakin3


    Jan 2, 2013
    Ooo, I've never logged a bug before, yea I can do that later tonight. I played around with it a bit more, and it looks like it works with another shader forge shader I created. Pretty much the only difference between the shaders is the shader that works uses the Alpha node:

    Alpha controls the transparency of the final pixel. Note that partial transparency is generally finicky to get right, especially when using deferred rendering.

    The shader that doesn't work uses the Alpha Clip node instead of Alpha node:

    Alpha Clip
    Alpha Clip is a way of controlling if the current pixel/fragment should draw or not. Always use alpha clip for objects that need transparency, but not partial transparency, as Alpha Clip is easily sorted, which Alpha is not.