- Home /
Realtime shadows don't always render
As you can see on the screenshot below, some of my walls are rendering realtime shadows, others are not. I know it's better to use lightmapping for static objects and I do intend to bake it later, but I was wondering why that happened. It also happened with a couple of other objects in my scene.
They are all using a Diffuse shader, have a BoxCollider (they actually have mesh colliders, but I already tried replacing them for boxcolliders, nothing different happened), have both Cast and Receive shadows marked on the renderer component, and I already tried switching from 'static' to 'not static'. Unity Pro.
There's only one directional light in my scene and I'm using forward rendering.
Why is it happening?
Additional info: Using the same building model on a totally new scene (without any other objects in the scene) seems to work. I have not touched the colliders/renderers/materials, but I have changed the layers and set the walls to static.
I was wondering if there was perhaps a "shadow count limit" for realtime shadowed objects (it's the only explanation I could come up with, seeing the only thing different here are the layers and static option - which I already tried changing).
Is it possible that some of your walls are set to layers that are excluded from the real time lights? All lights have a Culling $$anonymous$$ask in the inspector, if the objects you want to cast shadows are on a layer not ticked in the culling mask of the light they wont cast shadows. As far as I know there isn't a limit to the amount of objects casting real time shadows.
All walls are in the same layer, and the Directional Light culling mask is set to "Everything". :(
$$anonymous$$ore additional info: it works fine if I switch my Rendering Path from forward rendering to deferred lighting.
Answer by Kryptos · Jul 19, 2012 at 06:14 PM
There might be something wrong with the normals on your wall mesh. The shadows from the trees should be stopped by the walls.
What happens when you rotate the walls that are not casting shadow by 180 degrees around the y-axis?
edit: obviously, normals are not the issue here. I keep this answer because of the comments above.
Nothing happens when I rotate my walls...
Since the normals are generated from importing the model (and I can change its configurations on the FBXImporter), it shouldn't work on a different scene if that was the case, should it? If I add the exact same model on another scene, it works :(
Also, changing from the Normals from "Import" to "Calculate" on the FBXImporter doesn't fix the problem. Changing from "Import" to "None" makes everything dark (duh!). Is there anywhere else I can experiment with normals without editing the model inside 3DS $$anonymous$$AX?
I did a small test with point lights casting shadows on either side of a plane with only normals on one side. Both lights cast shadows, so I don't think that normals are the problem in this case.
Point lights shouldn't cast shadows in forward rendering, should they? I have a lot of point lights in my scene (I just hid the gizmos on the screenshots above - sorry I forgot to mention that)... should it interfere with the shadows?
Ah, no point lights dont cast shadows in forward rendering, but I checked it again with a directional light and the normal had no effect on casting shadows in that case either. I had my scene in Deffered Rendering before so I didnt notice it at first sorry.
Edit: Speaking of which, if you change it to Deffered for a moment, are the shadows the same?