Terrain Shadow bug.

Currently, shadows of objects do not land on terrain, but are shown through the terrain on themselves. This is on 5.0.2.

Same problem as this:

Quick timeline of how this happened:

  • Project was on 5.0.1, everything was perfect.
  • Upgraded to 5.1, Hinge Joint changes wrecked game (different subject, unrelated), but no shadow bug.
  • Downgraded back to 5.0.1 using a backup of the project and uninstalling 5.1 and reinstalling 5.0.1
  • Shadow bug now appears on all maps.
  • Upgraded to 5.0.3
  • Shadow bug still present and will not go away.

Details of project:

  • This bug ONLY occurs in the build, not the Editor.
  • Single sun Directional light causes issues. Soft Shadows.
  • Legacy Deferred long distance camera paired with a Deferred short camera.
  • dx11 enabled.
  • Standard Terrain Material.
  • This didnt happen until I reinstalled 5.0.1 after a failed 5.1 attempt.

So far I have tried to solve by:

  • Reimporting all assets
  • adding a cube or some object to the scene
  • reinstalling Unity
  • Purging GI cache
  • rebuilding all scripts
  • altering the terrain, rebaking
  • renaming the terrain
  • changing material type

Shadow bug DOES go away under the following conditions:

  • Change Terrain Material from 5.0 Standard to Legacy Diffuse

or

  • Exclude 1 particular scene out of 10 from the build.

I would rather not convert all my scenes to Legacy Diffuse, it does not look as nice as the standard shader.
Excluding the 1 scene in the build doesnt always work.

Ive spent 2 days in agony over this. Any insight would be really great.
-Ryan

A followup question that might help is:
If you have a unity version, upgrade it, then uninstall/downgrade it back to the original, what persists on a windows machine that might scramble the shaders? Do they need to recompiled? What residue is left over from changing the unity version that would have a persistent effect? I have reinstalled the same unity version and the exact same project, what could possibly be different after the upgrade/downgrade that would effect rendering and how can I fix that?

So, after much tinkering, I think I found the problem. As some other posts have shown, if you have standard “cube” primitives in your scene, those can somehow mess with the terrain shaders. Most of those posts have been about cubes in that particular scene.

I deleted a set of cubes in an entirely different scene and now its fine. I dont know what you put in your cubes Unity, but they are potent. I hope others find this answer useful if they run into this. Just say no to Unity Cubes.

Haha its still there. FML.

I have same problem.

I also have the same problem.

I eventually upgraded to Unity 5.1 and the shadow bug went away. I think it has to do with Unity doing a complete rebuild of your project, purging old temp files, rebuilding meta files, etc.

Spoke too soon, Back again. I just upgraded to F1 and thats not fixing it. I have tried forcing unity to do a complete update rebuild by deleting temp files, caches, altering version .txt files within the project. It will rebuild the project in its entirety but still have the shadows showing through the terrain. It only happens in the build, not the editor.

Im really hoping someone can help shed some light on this.

Does anybody know how to force rebuild the Shader cache without deleting it?