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

Why can't we properly render a material with alpha?

Discussion in 'General Discussion' started by Rodolfo-Rubens, Jan 15, 2014.

  1. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,196
    A normal alpha make the depth messed, alpha clip doesn't allow translucency, nowadays pcs are capable of amazing things but the technology used for alphas it's... primitive and precarious!
    I think will study computer graphics and create a new algorythm for alpha calculation!
     
  2. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,029
    if you can come up with something that can sort the alpha test it would be great. the only way to have something almost decent is using the cut out alpha. but then it's opaque, and you can 't play with transparent layers within a single geometry.
     
  3. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,519
    If you show us what you're trying to do and what it's doing incorrectly I'm sure we can help.

    Alpha is a tricky thing. Getting it right requires a good understanding of how the graphics pipeline works with regards to depth sorting, blending, and so on. Unity most certainly can render alpha properly, but you need to tell it how you want it handled in various cases (as you do with other renderers, too) because while it may seem obvious to us what we want the computer has no way of telling.

    You absolutely can do cut-out with blending, alpha with a depth pre-pass, etc. etc. with the tools already in Unity, they just can't pre-package shaders for every single possible use of alpha. (Well... I guess they could, but there'd be a lot, and chances are that you'd need to tweak them anyway.)
     
    Last edited: Jan 15, 2014
  4. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,196
    I wasn't talking about unity itself, but anything related to graphics rendering, the alpha calculation used by every software and etc is sad!

    Anyway, I was trying to make a good looking tree for mobile, no sucess, no matter what I try (alpha blended, cutout, etc) I can't push those shaders into mobile without lagging (or glitch look in case of alpha blend), after a long time trying shader by shader (including simple unlit) on all renderers at once, just to check what shader is the most heavy, then I realized that the dynamic directional light is also expensive to render, so... I guess my game can't be on mobile devices because the directional light weigh too much and I need the directional light to simulate the time passage, it's a lose-lose situtation for me, I need a good look vegetation and also the a dynamic directional light, and both of them it's heavy! :(

    any idea?
     
  5. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,519
    Well, again, images of what you're trying to achieve would be good. "Tree", "mobile" and "dynamic light" alone aren't enough for anyone to be particularly helpful.
     
  6. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,196
    Ok, so, that's my scene:


    a wire (as you can see, the trees is very low poly!)


    And the overdraw. (as a side note, the waterfall region is one of the parts where the game runs faster, so I don't think overdraw is the problem)


    that's what the camera usually render:


    the stats on the exact same spot above:


    On both my devices (sony tablet s and samsung galaxy s) I get a very bad fps (~20).

    I think alpha is my worst enemy right now... There is no way to know without the profiler. :/
     
  7. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Considering how very low-poly your scene is and there's not many triangles in the camera view, I'm surprised you're seeing such low framerates. I think even a Ouya would be running this at 60hz and that's only half the performance of an iPad2.

    How is it that you have 175 draw calls in this little scene? Are the ground tiles individual objects or something?
     
  8. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,196
    Yes, they are, I'm using, a tile atlas (8x8 tiles, 512x512px) and 1 material for the entire scene geography... Is that a better approach or nay?
     
  9. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's why you're getting low fps; way too many draw calls. All that should be combined into a few meshes.

    --Eric
     
  10. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,196
    But I'm using that combine children script...
     
  11. JamesArndt

    JamesArndt

    Unity Technologies

    Joined:
    Dec 1, 2009
    Posts:
    2,916
    Atlas those textures together as well. I would suggest just grouping this world into chunks you can hide and unhide. Your view area at any given point appears pretty small so any kind of culling would work very well with these chunks of geometry.
     
  12. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,196
    Hi JamesArndt! Thanks for the advice, I will do that! One more thing, a shader that is just flat and only receive ambient light would be faster than the VertexLits? (I'm not using lights anymore, only ambient light to simulate day/night mood)
     
  13. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    The Ouya is capped at 30FPS though?
     
  14. multivac

    multivac

    Joined:
    Oct 27, 2009
    Posts:
    133
    Try to switch those trees to alpha blend, not cutout. Cutout can cause worse performance than alpha blend on mobile devices.
     
  15. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Ouya is capped at 60