Problems with shadows after parenting and unparenting a light to a camera/transform

We are getting some problems after parenting and unparenting a directional light to a camera. In this playground I’ve reproduced the issue:

It seems that after parenting and unparenting the light, the shadow is not being calculated properly. Also notice that light.shadowMinZ and light.shadowMaxZ are changed after unparenting the light.
Is there a way to recalculate the original shadow after unparenting the light?

You will need to reset the light.transformedDirection to null (as well as transformedPosition even if this one is not strictly necessary for your PG to work) after you unparent to make it work because ShadowLight.getShadowDirection is returning transformedDirection if it is not null, which is wrong when the light has been unparented:

I guess resetting transformedDirection / transformedPosition should be done automatically by the light class at some point… Maybe in ShadowLight.computeTransformedInformation? Overriding the Node.parent setter does not seem a good idea as it is doing a lot of things that would need to be rewritten as we can’t call a base setter from an overriden setter. I will let @Deltakosh / @sebavan have a look at that one.


Will be fixed in the next nightly :slight_smile:

1 Like

Thank you very much! Resetting light.transformedDirection and light.transformedPostion as @Evgeni_Popov sugested saved our day :slight_smile:

1 Like