Global visibility

The short explanation about the visibility calculations is that I calculated vision shadows for the buildings. If a point, being tested for visibility, was in a vision shadow, then it was not visible.

A "vision shadow" can best be described by thinking of the observer as a light, and the buildings as casting shadows from this light. If some other point is in one of these shadows, then it cannot be seen by the observer. I first calculate the silhouette of the building. Based on that, I calculate a shadow as defined by three lines. One from the observer to the left side of the silhouette, one from the the right side of the silhouette to the observer and one from the right side of the silhouette to the left side. The a point was tested by seeing if its position was above all the three line equations. 

To test how visible a given point is, it is tested for visibility by a large number of random observation points.

Two simple rectangular buildings and a Monte Carlo being used as opposed to using all positions. 


A third building has been added and the three of them are now extending each others shadows. 



By addning a fourth building, a low visibility area has been created in between them. This white area has quite lov visibility. It will be good for sneaking arround when you don't know exactly where all the enemies are. 


A more complex scene with perfect calculation. Perfect meaning that every point is used as an observer point, rather than using only a random sub set of points.


An even more complex scene. Still with perfect calculation.