Download

Disable CastDynamicShadows runtime

Hi,

Is it possible to disable/enable a ULightComponent’s CastDynamicShadows at runtime?

I can see a function SetCastShadows but i don’t want to disable the Static Shadows only the Dynamic. Not sure if i’m going down the correct route with this so here is my use case… My game is an outdoor nightime scene with a directional light (moon) casting Dynamic and Static Baked Shadows; it’s very dark. All is fine and i’m hitting frame rate just about (32ms). I have now implemented a lantern that the player holds. If this doesn’t cast any shadows all is still well, but it looks so much nicer if it does (but the frame time jumps to 50ms). So my thinking was when you are using the lantern disable the dynamic casting off the moon but keep the static baked shadows there to keep the scene dark. If i SetCastShadows to false on the moon everything goes ‘south’ and it looks flat and bright. Any ideas?

Best Regards,
Matt.