How to calculate shadow area

Hi all,

I am involved in a photovoltaic project and I thought it would be useful to optimize the positions of the single panels, so that they shadow each other as little as possible over the whole year. While finding and adapting the code for the irradiation and the sun position in the sky has been trivial, I am having some problems with the shadowing stuff.

Is it possible to use some function in Panda3D to easily calculate the area of the shadowed surface on an arbitrary plane (i.e. solar panel)? Or at least where do the objects store the information which triangle of the mesh is in shadow?

It might sound relatively easy at first, but when you consider shadows from different sources that project on the same surface, as well as arbitrary positions of the objects, then the whole calculation gets really messy. So I would really appreciate any help in this direction.

  1. Create an orthographic display in the direction of the lightsource that captures the entire shadow and has a known coverage area.

  2. render the shadow casters with a fixed color (say pure red), ignoring depth testing.

  3. if you need to determine the area hit and not just the area of the shadow, render the hit object into a different color channel (say green) with color masks set so that green pixels do not overwrite red pixels.

  4. calculate the areas of shadow and receiver by counting pixels in each color channel and dividing by the total number of pixels and multiplying by the area of the ortho camera (this probably requires copying to a texture and using Panda’s image manipulation functions).

I’m not sure of all of the panda specific details on how to set the correct objects colors and masks, but the basic algorithm should work well.