I have a scene with 3 cubes, Blue, White, Red. In the middle the white is covering up a section of the red cube. When I toggle on off the white cube, the shadow gets affected on the red cube side. I need to export from Blender each individual object the way it appears in the render, but when I turn off the objects, the shadow and lights also disappear from the rendered image. So is there a way to hide objects without losing the the way its influencing other objects in the scene?
Maybe you can get away with this: create a material using Transparent BSDF
set its color's alpha to zero leave the RGB values full white (thx @GordonBrinkmann) and enable alpha blending under Material Properties > Settings > Blend Mode. Leave the Shadow Mode as Opaque. This gives a completely invisible object which still throws shadows.