Shadow map is also calculated for hidden them

My editor uses auxiliary sections that are hidden if they are synchronized with the main model, but if you turn on the light, then a shadow map is also calculated for them, this can be seen by the sharp increase in triangles.

meshInstance.visibleThisFrame = false;
meshInstance.visible = false;

After studying the code for some time, I determined what the problem was.


I make my own decision to show this mesh or not.

1 Like

When adding a meshInstance with a changed castShadow value, it is overwritten in the render component.

I don’t think there’s a way for you to mark mesh instances as visible/invisible each frame, specifically for the shadows. Your best option is to use MeshInstance.visible to mark mesh instances as visible, and this applies to both the main camera and also the shadow camera.