I figured out a method. On the layer which contains the light and shadows, a Canvas is placed at the bottom of each wall which is as wide as the wall and 1 pixel high. In the events the layer is pasted to the Canvas and is then the hight is stretched to be the hight of the wall.
Basically you get what you see in image 2 except now if there is a shadow below the wall then it will be vertically stretched up the wall, turning it into image 1!