- Home /
Realtime tree shadows disappear on camera movement
I searched the internet about this issue for countless hours with no results. So here's the situation:
I have a classic terrain setup, 2000 x 2000, trees, one directional light as sunlight, graphics on fantastic, average tree rendering settings...
Now here's the point, I have a pretty low position of the sun so that it makes long shadows of the trees and gives the scene the mood I'd like to achieve. The problem I have with this is that if I rotate my camera view some trees behind my frustum don't render anymore (which is the normal frustum culling behaviour I guess?) and therefore their shadows disappear even if they should be visible in the camera view.
Here are two screenshots with slightly different camera rotation:
I played arround with all kind of tree, quality and shadow settings with no result and I just can't believe that no one ever made a scenery with long shadows and came across this problem...
Are you using the free version of unity? They recently launched shadows for free which were previously only accesable from the pro version. Anyways, On 2 different computers with another unity editor free, the shadows are very buggy. They dissapear as you said, I hope there's a solution, and not a unity bug.
Hi, just an idea: if it's really due to the culling and there is nothing to tune/fix it, maybe you can increase the bounding box of the trees by adding some vertices or faces to the geometry (vertex without face or faces with only 2 vertices so it's not rendered). There would be a small performance cost though as the culling would be less effective.
I just found out some things by messing around:
It definitly only happens with trees placed by the terrain system
It's always a hole chunk of shadows that pop up or disappear and not individual ones
It does not just depend on whether I look at those trees but also on my distance to them. I can look at the opposite direction but if I'm close enough, the shadows don't disappear
So this brought me to the theory, that the culling or the shadows of terrain trees are calculated in some kind of groups based on camera distance AND rotation.
So I tested if I can somehow "extend" or at least fake to extend this group or the distance. I have some fern which I loaded as a tree ins$$anonymous$$d of detail mesh and if I place only one little fern where no shadow is rendered, exactly this extension happens. So it basically extends the "render border" or what ever.
The shadow chunk disappears now, if I get far enough from the fern. I can work around this issue this way, but it doesn't make me happy...
If it has to do with the distance from the camera to the trees it might be the LOD of the trees. When they are enough far away, they are probably being switched to the billboard versions, and those probably don't cast shadow.
Answer by team_eden · Dec 16, 2014 at 07:55 PM
I am having the same problem. When trees get to close to the camera field of view, they suddenly disappear when the trunk of the tree gets out of view. All of a sudden, the leaves disappear, just because the trunk is gone. This is a poor attempt at culling, simply because the position of the object is not directly in camera view, does not mean, the rest of the object is out of view.
So far this applies only to trees on the terrain system.
BUMP This is annoying, watching trees suddenly disappear on a mobile game, where it is glaringly obvious because there are only few trees in the scene.
Answer by danielrugu · Feb 20, 2017 at 09:38 AM
Change the shadow distance to a higher number, my case 500 worked
Answer by skymeson · Jun 24, 2020 at 06:07 PM
Changing shadow distnace did not work in my case. Still having issues with shadows being culled from trees in Unity 2018.4. Hoping someone has a solution to this.
Answer by OTRegashi · Aug 30, 2020 at 11:16 AM
I changed "Shadow Near Plane" to a higher value. Fixed in my case.
Your answer
Follow this Question
Related Questions
How do I get lightmap shadows working for trees? 1 Answer
Shadows in terrains 1 Answer
Tree shadow problem / billboard trees 3 Answers
Lightmapping shows lighter areas cast by tree shadows 1 Answer
Trees have no shadows (baked shadow) 1 Answer