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.

Real Time Shadow Casting Help

Discussion in 'Editor & General Support' started by Monkey_of_Doom, Oct 4, 2011.

  1. Monkey_of_Doom

    Monkey_of_Doom

    Joined:
    May 9, 2011
    Posts:
    24
    I am having a bit of a problem with my real time shadows. I have a helicopter that is full scale. The shadows do not cast unless the directional light is at a 90 degree angle to the helicopter. Basically, the light has to be completely perpendicular for the shadows to cast correctly. The further I rotate the light away from 90 degrees, the more the shadow breaks up and disappears. See the pictures below.


    Light at 90 degrees, straight down on helicopter


    Light rotated to 75 degress


    Light rotated to 60 degrees


    Any ideas what's going on here? I should be able to cast shadows correctly at any angle shouldn't I? Also, in this next picture I have the light still rotated to 60 degrees, but I have now raised the rotor blades up from 2.77 to 3.77 and their shadow now shows up correctly. What's going on here?

     
    Last edited: Oct 5, 2011
  2. Monkey_of_Doom

    Monkey_of_Doom

    Joined:
    May 9, 2011
    Posts:
    24
    Has no one had this issue before? It seems everything that comes out of Max has the same issue with the shadows. Even a simple cube and plane.

    Anyone?
     
  3. MADmarine

    MADmarine

    Joined:
    Aug 31, 2010
    Posts:
    627
    What shadow configuration are you using in your quality settings?

    Am I correct to assume this is using a directional light with forward rendering as well?
     
  4. i3DTutorials

    i3DTutorials

    Joined:
    Aug 26, 2010
    Posts:
    564
    Check your shadow bias, this is most likely what's throwing you off. Adjust it until your shadows look the way you want. Shadow Bias is not 0 by default, which is prob what's confusing you. Setting it to something small, like 0.01 or something might "fix" your issue.
     
  5. Monkey_of_Doom

    Monkey_of_Doom

    Joined:
    May 9, 2011
    Posts:
    24
    Directional light with forward rendering, yes. Shadow quality is turned to highest settings. If I turn all the quality settings up, I get no change.

    I've adjusted shadow bias, shadow distance, changed the scaled of the model, with no change to the shadows.

    This seems to only be a problem with models I am bringing in from Max. If I create a simple box and plane in Unity, the shadows work correctly. But importing a simple box and plane from Max, the shadows break the same way. I have tried using Max 9 with most current FBX exporter and switched over to Max 2012 with it's most current FBX exporter, and no change.

    I've changed the import options from Import Normals and tangents to calculating one or the other or both, and still no change.
     
  6. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,325
    Very odd and it seems like you've tried the usual culprits. Would you mind posting a Unity Package here with a simple scene that exhibits this issue?
     
  7. i3DTutorials

    i3DTutorials

    Joined:
    Aug 26, 2010
    Posts:
    564
    Yeah this is a weird one, new to me.

    Have you tried importing a sample asset (box or something) from another 3d package, could be anything- Blender, Maya, Softimage, Modo, etc. and see if it exhibits the same problem?
     
  8. Monkey_of_Doom

    Monkey_of_Doom

    Joined:
    May 9, 2011
    Posts:
    24
    OK, I think I've got it figured out now. Since you asked me to make you a simple package, I made a new project and everything magically worked. So, I poked around in a few other areas, and it turns out when I turn the Water layer off, everything works. We were using a script in the water layer to generate a floor reflection. Here is a link to the script we were using:

    http://www.unifycommunity.com/wiki/index.php?title=MirrorReflection2

    Thanks for the help. Without the suggestion to make a new package, I would have completely skipped the obvious solution of using a default scene. Thanks again!
     
  9. i3DTutorials

    i3DTutorials

    Joined:
    Aug 26, 2010
    Posts:
    564
    Good stuff, I know the great feeling when you solve a nasty issue that bugs you for days!
     
  10. Monkey_of_Doom

    Monkey_of_Doom

    Joined:
    May 9, 2011
    Posts:
    24
    Thanks for the help. That was really bugging me. Now we just have to figure out how to correct it, or find another script for reflections.
     
unityunity