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
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Terrain trees sparkle in deferred rendering

Discussion in 'Unity 5 Pre-order Beta' started by Jaimi, Nov 8, 2014.

  1. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,204
    When I enable deferred rendering, the trees that display where the sky is (whether or not I have a skybox, or clear the sky to black) sparkle with white dots. It's only where the sky would be. is this a known issue? It's just a standard tree on a terrain...

    Since a picture is worth a thousand words:

     
  2. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    did you rebuild the tree? or you made it with Unity 5?
     
  3. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    I have the same issue. How do yo rebuild it? I would grab the standard asset tree and it would do that
     
  4. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,204
    Its happening with a lot of trees, and I didn't rebuild it. The trees work great in every mode except deferred rendering. In one scene I was able to fix it by playing with the camera "clear" color (even though it was set to clear to the skybox). But that trick didn't work on any other scene. I think something is just broken in the deferred renderer.
     
  5. Sabathius

    Sabathius

    Joined:
    Jul 13, 2013
    Posts:
    55
    I had the same issue, just for the record.
     
    Gua likes this.
  6. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    report the bug please, and post the report code here so unity developers can see it
     
  7. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    Sorry if i ask in this thread but how do you get textures on your terrain?
    If i try it i only can see them from the far but when i come near, in the editor or in game, everything gets white meaning the textures disappear. In beta 21.
     
  8. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    I think you should ask that in the 4.6 beta forums not the 5.0 beta
     
  9. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    Sorry, i mean beta 12 so it is right here.
     
  10. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Argh, I remember being happy when this was finally fixed in Unity 4, but now it is broken again. Trees work in Legacy Deferred mode but not the new Deferred mode.
     
  11. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Ok, so the problem is that when the "shadow caster" pass happens after the regular albedo pass, the alpha clip causes it to leave a "hole" anywhere that the shadow texture would render but the albedo would not, I guess because it's writing to the depth buffer but then not actually rendering anything, so you just get the skybox showing up instead of whatever is behind it. Because the shadow texture and the albedo texture are usually two different sizes and don't quite line up, you get shimmer. I've figured out two different ways to fix it by modifying the TreeCreatorLeavesOptimized shader code.

    1) In the initial surface shader, change the alpha clip in the pragma to an alpha blend. This looks the nicest but I'm guessing it's probably slow to do a blend instead of a clip on lots of trees.

    or

    2) In the shadow caster pass, change the clip to "clip (alpha - _Cutoff - 0.1);" or something greater than .1. This makes sure that the clip cuts more of the texture away and leaves a smaller area than the albedo pass. But, you need to make sure your "Shadow Caster Res" for the tree is somewhat high to make sure you won't have any jagged edges in the clip, at least 1/4 resolution. I'm guessing this is faster than method 1, but maybe not, since with method 1 you can use a very small shadow texture.
     
  12. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Here is a replacement shader with the thinner shadow clip. And make sure on the leaves you choose "Tree Creator Leaves" not "Tree Creator Leaves Fast" and make the "Shadow Caster Res" somewhat high.

    Edit: I actually just figured out that the alpha blending version doesn't work, because though it gets rid of the shimmer it was only because it was blocking leaf shadows entirely. But this smaller clip version will work. You can edit the subtraction in the clip to subtract more than 0.1 if you need to. The more you subtract, the less chance of shimmer, but your leaf shadows will become smaller.
     

    Attached Files:

    Last edited: Feb 17, 2015
  13. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    What would be ideal is if there was a way to only write to the shadow buffer or something during that shadow caster pass instead of writing to the actual z buffer and causing holes. I've noticed the holes are actually there in Forward Rendering as well, just much harder to notice because in Forward they'll just show you what's directly behind the leaves as normal, instead of in Deferred where you usually get the skybox through the holes.
     
    hopeful likes this.
  14. Roni92

    Roni92

    Joined:
    Nov 29, 2013
    Posts:
    225
    Ideal would be if devs would be occupied with game developing, instead of trying to fix something that Unity should. ;)
     
  15. chargedneuron

    chargedneuron

    Joined:
    Jan 12, 2013
    Posts:
    21
    Has someone bug reported this yet? I have the same issue and was about to report it.
     
  16. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,204
    I thought I had, but reviewing my submitted bugs, it appears I did not. Go ahead and report it, doesn't hurt. :)
     
  17. chargedneuron

    chargedneuron

    Joined:
    Jan 12, 2013
    Posts:
    21
    Case 674542
     
  18. chargedneuron

    chargedneuron

    Joined:
    Jan 12, 2013
    Posts:
    21
    The reply was to update. And low and behold - RC3 is now out.
     
  19. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,204
    Unfortunately, RC3 does not appear to fix this:

    TheySparkle.jpg
     
  20. chargedneuron

    chargedneuron

    Joined:
    Jan 12, 2013
    Posts:
    21
    Ticket is Open, same case number. It appears to be under review.