Given a 3D space and a light source, I use ray casting to determine the shadows generated in the scene. If I'm to store the shadow data (boundary of the shadow, object which cast the shadow, etc.) what is an efficient way to go about it?
Its basically for an application where I want to be able to move the shadow around manually to see the change in the 3d objects position. Say I apply a force to the shadow of a ball, I can actually see the ball move and also the change in the shadow. So I need to be able to set up colliders for the shadow and hence need a way to be able to store the boundary of the shadow and information about the object that cast it to carry out the actions.
If the goal is mouse interactivity, you can do with a simple "shadow buffer", i.e. an image that holds the identity of the occluding object (if any) on every rendered pixel. You will compute this map during the casting process as you shoot the rays to the source.
In case there are several occluding objects, it is up to you to choose which one to consider (or keep a linked list of all occluding objects). If there are several sources, you can keep one map per source.
You might want to look into signed distance field textures. They are very efficient and high quality for monochromatic images like shadows. They work by storing a clamped, signed distance from the pixel to the shape. Working this way, the distances play nicely with the bilinear interpolation of texture sampling, so you can have very nice results for very low resolution. You can also give them a soft edge to have a soft shadow look.