Pretty straightforward; I set a mesh object to not cast shadows and it still does. Latest full version of Unity 5.3.5f1. This pertains to building Lightmaps, Directional setting, for iOS games. Object needs to receive a lightmap but not cast any shadows as it gets turned on and off depending on certain situations.
Anyone experience this sometimes?
I’ve had this happen sometimes, in some scenes but not in others. It’s very inconsistent but there doesn’t seem to be anything that’s different between the meshes and scenes. It also seems like the direct light rays are passing through but indirect ones are not, as the shadows appear more prominently in areas that get a lot of bounce light as opposed to direct light.
Is there some setting that will directly influence this? Something in LightParameters that may have something to do with this oversight? This is driving me a little crazy… When setting an object to NOT cast shadows, I expect it to NOT CAST SHADOWS! Including Indirect light!
This is perplexing and I haven’t gotten into Unity lighting as much as I should have at this point so my suggestions might seem simplistic.
Could you manipulate the layers with these meshes so the mesh you want to receive but not cast can be on one layer separately, then on another layer have other meshes you want to receive shadows from all but the one mesh on the other layer?
I know this isn’t specifically how layers work, but I remember reading you can control some settings for lighting by layering.
Hope you find the solution.
Did you say build(bake) lightmaps? once you build a lightmap, turning on/off shadow will have no effect, the shadow is already baked, unless the object is dynamic…
2 months later and I’ve tried searching more for this problem and I can’t believe I didn’t find more relevant stuff than my own old thread. Here we go again, months later and the same thing keeps happening over and over again.
What I am talking about here is baked lighting, not realtime, lightmaps, as most mobile devs re using. More specifically, Indirect Shadows, maybe AO, but stuff getting stored in Lightmap textures.
Objects that are set to not cast shadows do indeed correctly not cast shadow from direct light, but indirect, bounce light (heck maybe even Ambient light is bugged I have not tested this yet) still casts shadows from these objects set to NOT cast shadows.
Simple outline; I have a scene, it has lights in it. There’s a plane with 3 cubes on it. One cube is set to not cast shadows. I bake lighting. Go back to the scene, turn off (hide) the “no cast shadows” cube and it STILL has a shadow in its space because the indirect light was not correctly ignored by the “lighting engine”. I know it’s caused by indirect light because if I DO leave shadows on for that cube, the shadows it leaves behind are totally black, as expected, instead of muted, almost AO shadows. Actually, it could also be AO that is causing this… even though it shouldn’t be.
I can drown out these splotches by shining direct light on them, making sure the area these objects are in is brightly lit, but that defeats the purpose of having good lighting! That’s not a workaround.
“Did you say build(bake) lightmaps? once you build a lightmap, turning on/off shadow will have no effect, the shadow is already baked, unless the object is dynamic…”
Yes, and the expected result of an object not casting shadows, is for that object to not leave a shadow in the lightmap that just baked, whether that object is turned on or off…
Please, if you are seeing this problem as well, at least leave a bump on here… this stuff is driving me crazy.
I had a similar problem with 3rd party lighting extensions (namely the Valve Realtime Light for the Unity VR development). It even ignores the “cast Shadows = off” setting. :-(((
My ideas:
- maybe you also have additional light scripts attached to the light that override shadow settings?
- maybe you can use a “Culling Mask” as proposed above (see light settings) This trick worked for me, I let the light ignore the objects via the layer. I haven’t tried with baking and indirect light though, as I need real time shadows for the other objects.
so I had like 30 some objects with shadow on and I didn’t want to click 1 by 1 to disable them…
so I disable them at runtime.
essentially, all these objects have the same parent, so I just use childcount and loop through each object and disable each property of meshrenderer.
void disableShadows ()
for (int i = 0; i < this.transform.childCount; i++) {
if (this.transform.GetChild(i).GetComponent() != null) {
this.transform.GetChild(i).GetComponent().receiveShadows = false;
this.transform.GetChild(i).GetComponent().shadowCastingMode =
ShadowCastingMode.Off;
this.transform.GetChild(i).GetComponent().lightProbeUsage =
UnityEngine.Rendering.LightProbeUsage.Off;
this.transform.GetChild(i).GetComponent().reflectionProbeUsage =
ReflectionProbeUsage.Off;
Bump. EXACTLY the same problem, do anyone have a solution ?
Hey guys, i had the same problem but i might have a fix for u.
At first i thought it might be micro shadows from my global volume but it wasnt. When u Turn off ur shadows in the mesh renderer it is turning off the shadows , BUT there are still contact shadows.
U can deactivate contact shadows in ur HDRP render settings. Just head to ur project Settings > HDRP Default Settings > Contact Shadows and deactivate those. Worked for me.