In a previous article (Truchet Tilings) I showed a way to represent labyrinths in a sphere and at the end, in a plane. In this one I'm going to show a way to represent infinite labyrinths in a plane.
Usually these labyrinths are finite sets of triangles. One of the problems in this type of representations is that you can see boundings.
One way to solve this is replicating the figure. Sooner or later you'll be able to see a periodic shape, noticing an artificial behaviour.
So, if you want to show infinite labyrinths, you'll have to find a method that satisfy these conditions:
- Covers all the visible domain.
- Absence of periodicity in the image.
- Split the plane (in an algorithmic manner) in square regions of unit size (a grid of infinite squares, each one with one unit of side length).
- Asign to each square region a tridimensional figure (for example, a wall in a side).
Here I show a sample using always the same shape.
This method presents a set of decissions:
- How many types of shape should I use.
- How I assign to each region a concrete shape.
The first point is chosen by the user. For example, my set of shapes will be:
- A wall of 0.1 units width and 1 unit length arranged in a north face of the region.
- Another similar wall arranged in the west face.
The generator will be a LCM (Linear Congruent Method) generator. We run the risk of having the Marsaglia effect. It will appear, and the user might see a certain periodicity but will be very dificutl to distinguish.
Each shape has a certain probability for appearing (for example: 1/number_of_figures). It will choose the figure using the method of the Russian roulette depending on the generated random number. As the number is pseudorandom and depends on the input paramaters, it always return the same value for the same input parameters.
The results are these:
And with a different probability distribution:
As you can see, choosing this kind of figures, as the norwest corner is always occupied, the aspect seems to be a growing figures in the same direction.
It can be resolved by adding another figure that is a double wall south and east. So using this way the distribution of corners is uniform and doesn't seem to grow in any direction. Althoug this adds more holes and makes the maze looks more closed.
This is with a figure with a column in the middle of the region:
Making simplier walls appears problems of double corners and doesn't seems very well.
Finaly there is a more complex method than the previous one. Consists on chosing figures randomly only in pair coordinates (i,j) which sum i+j are even (from this point, even regions). That yields a checker pattern. In the even regions we assign one shape selected by the pseudorandom generator. In the other hand, in the odd regions the shape is assigned by a shape that matchs with the shapes that are sharing each face. That is, if the north face of the figure that I have in the south has a wall, my south face should have a wall. So, both walls match together.
Choosing correctly the shapes and with a little extra programming we can achieve these images:
Using non linear cameras:
Using some procedural textures and phong materials:
If we use the first proposed method the labyrinth looks like this:
That's wrong but nice to test global illumination.
Obviously changing slightly the hashing function (adding a sum operation, in example) we can make labyrinths totaly indistinguishable ones with each others. We have graphically represented the hashing function.