It is possible to create richer architectural volumes by combining several simple volumes like boxes. The resulting volumes can be quite complex, which is in part what we wanted but it also brings some complications.
In the following image you can see the result of three boxes intersecting each other:
To show this I will use the same grammar language as in the earlier post. If you feel lost in the code there are some comments in that post that may help.
This is the code that produced these three boxes. It will be our starting point:
The module "angletest" is the one that produces the three rotated box volumes. Each box has its sides covered by wall panels.
The first half of the trick is to hide those panels that appear inside a volume. The occlusion query can do that. It would take only a few lines to add it:
The "volume" module now occludes. Also there is a new definition for the "panel" module that should be picked when the panel is occluded. Just to visualize which ones should be hidden I chose to render them as lines on the floor. You can see the results here:
This is already better, but there are still some holes in the corners. This is because an entire panel is hidden even if only one part of it is occluded.
Snap planes can help with this. If each volume defines a set of planes, the intersecting panels will match their size to the near volume. This is how you would write it:
Now each wall introduces a snap plane, then the panel repetition is snapped to those planes. Panels are aligned to wall intersections. They can be entirely removed and no holes will appear:
It wasn't so bad. Again, this alone won't be enough to create interesting buildings, but it is a technique you may want to remember.
Here is how it would look if you replaced the panels by windows. I also added some random rotation to the three boxes.