Doesn't this only work because the square is a uniform color?
However, in theory, the technique and code can be extended to handle those cases. It's just more demanding computationly-wise.
Adding overlapping objects of different colours is somewhat easier (but still hard) than adding textures.
See here: http://www.gamedev.net/topic/622099-representing-interval-se...
It's the same technique that can be used to achieve Order Independent Transparency.