0
Under review

Wind affecting leaves, but not branches + weird shadow flicker in wind

miklelottesen 6 years ago updated by Aaron Brown 6 years ago 7

I'm having a bit of problems with wind. Only leaves seem to be affected by wind zones, while the branches aren't affected at all, neither by main wind nor turbulance. This is unfortunate, because it makes the leaves appear disjointed when there's wind.


Another problem I'm having is that the shadows in the leaves are flickering a lot as they move in the wind, more notacible from certain angles. The flickering gets worse as the wind speed declines (though completely stops when there's no wind at all).


I'm using instantiated trees, not hand placed, so I had to modify the script a bit (we worked on this in a whole other thread) and therefore no baked shadows, only realtime. I've tried everything, including disabling ambient occlusion on the trees before converting them, but nothing seems to work. Any ideas what might be causing these issues?

Under review

Just a quick off the top of my head answers for now....


1) The way my converted trees move in the wind should be identical to the way the tree moved in the wind before it was converted into a LushLOD tree. So if the converted tree isn't moving correctly in the wind, then the same incorrect behavior should also be happening in the original Unity tree prior to conversion into LushLOD. I will say though, I believe I'm using a copy of the windzone code from like Unity 5.6 or earlier, and so hopefully windzones haven't changed since then. But check to see that the tree is moving correctly prior to conversion, because it should behave the same after conversion.


2) As for the shadows...flicker in the leaves... the shadows in the HQ leaves shouldn't flicker. It could be caused by duplicate verticies in your tree. You can try editing my HQ tree shader, and comment out both occurrences of the line "Cull Off" and see if that makes the flickering go away.

PS: if you're gonna try to comment out the cull off lines, you need to edit the shader that's being used by the leaves of the high quality lushLOD tree models. The exact shader depends on your manager settings, so I don't know which shader your scene is using. But you can select one of the HQ tree models, and see what shader it is using for the leaves. Edit that shader and comment out the "Cull Off" lines, should be two of those lines, and see if the flickering goes away. That's not a permanent fix though, so you shouldn't leave the shader that way, it's just a test to see if that's where the problem is.

Something must definitely have changed in the wind system. I made a fresh scene, added a plane and a wind zone, then added the following trees:


  • Alder (converted to LushLOD, shipped with asset, unmodified)
  • Alder (converted to LushLOD by me, from "Unoptimized trees")
  • Alder (unconverted, from "Unoptimized trees")
  • Birch (made by be, converted to LushLOD)
  • Birch (same, but unconverted)

I then tested out how they react to varying levels of wind (main wind, no turbulence):



As you can see, especially from the last picture, only the unconverted trees are affected by wind. For the converted trees, only leaves and some of the smaller branches are affected.


I'm using Unity 2017.3.0f3, by the way.


I'll look into the shadow issues immediately, and let you know what I find.

Update: uncommeting the two Cull off lines in the shader does indeed eliminate the flicker problem. Also, I forgot to add that the flicker problem also happens for the trees that came with the asset.

It does look like they updated the wind zones. My branches used to slide around horizontally a bit, but if they aren't moving at all anymore, then that's probably what happened, they made a breaking change to the wind zones.


I will add this to the to-do list to get this fixed. In the mean time, if the leaves are still moving in the wind, you might just have to turn down the wind quite a bit so that it's less noticeable that the branches aren't moving.


As for the flickering happening with the trees that came with the asset, that's not what I expected to hear. My trees should all have single-sided polygons. I'm pretty sure the issue has something to do with the way Unity 2017 is handling the thing called "ambient occlusion" in the leaves....


Anyway I will take a look at both these issues soon and try to get a fix for you soon.

Sounds good :)


I did notice something weird; all the (unoptimized) trees that came with the asset were different in that they didn't have certain settings in the inspector (for the tree's root node), that my own trees has - I think some of them had to do with ambient occlusion, but I don't quite remember. Anyway, I actually did try to convert the trees with ambient occlusion disabled, but it didn't affect the flickering.


Also, just remembered that I found two minor bugs that I meant to tell you about:


  1. Converting trees that has no leaf nodes will cause the converter to crash before finishing (because it's looking for the tree's (missing) leaf material). A quick and dirty fix for this is to add a single leaf with an invisible material to the tree's root node.
  2. Converting trees that has leaves of the "billboard" type will create a bad LOD billboard for the tree, because the leaf texture for some reason stretches and takes up the entire altas square for that tree.

I just wanted to drop in to say that I'm currently uploading LushLOD version 0.8, which will be the first update for Unity 2018.1+. In this update, I don't think the issue with the wind zones has been addressed. But the problem with the flickering *may* be fixed. I do know that significant improvements and changes were made to the way the trees handle lighting, including ambient occlusion. If the flickering had anything to do with ambient occlusion, there's a chance it may be fixed. The update should appear on the asset store within the next few days, once it is approved.