Showing posts with label infinite. Show all posts
Showing posts with label infinite. Show all posts

Sunday, August 22, 2010

Infinite Pipes

English    Spanish

Today I'm going to show a set of renders that extends the model of infinite labyrinths.

To represent them it has been slightly modified the algorithm that represents the type of shape that a ray will encounter in a space region.



The operation of this algoritm is very similar to the previously described to generate infinite labyrinths. It's presented now: We began with an object composed of two infinite planes separated by a arbitrary distance, let it be, for example a unit length. When a ray which its origin is outside the space contained between the two planes intersects with any of these two planes, an intersection position is computed. This position is a real vector. It's possible to take the X and Y coordinates (assuming that both planes cover a constant Z value) and covert it into integer coordinates (from now, j and i respectively). If the sum of this integer numbers is an even value one algorithm will be applied, if it's an odd value another algorithm will be applied. This is made in order to avoid adyacent regions share the same algorithm.
The algorithm of the even regions is simple, a LCG type random number generator will use the j and i values in order to generate a boolean value. This boolean value will determinate if a straigt tube is place along X or Y direction. So if we randomly fill even regions with straight tubes that moves along random directions X or Y we got a constraint in order to choose a shape to fill the odd regions. So if the adjacent regions (sharing an edge) of an odd region got straight tubes in the Y direction, the shape of that odd region will be a Y direction tube. If the up and down region got a Y direction tube, and the left got another Y direction and the right a X direction tube, the shape will be a T.

In order to achieve the effect of rusty it has been used a Perlin noise as a mask and then another configuration of Perlin noise for bumpmapping and color. To get the effect of water/ice it have been used a cellular fractal noise generator.

Here we can see the same image without bumpmapping and color:



Another view using a cylindrical camera:



The same with texture and bumpmapping:



Finaly here, we can see another view from a high Z value. The shape reminds quite well a maze:





Sunday, August 2, 2009

Spherical Renders of Labyrinths

English    Spanish

Recently I was thinking about how one of the mazes that I programmed would it seen using a spherical lens. Spherical lens deform parts of the images that are away from center, so the things that are far away looks like further away indeed. So more things "fits" inside the image.
When the deformation is low the result is similar to a wide angle lens. When the deformation is high we get images more dificult to achieve in reality. When the deformation is very high the images are imposible to obtain in reality.
The code that generates a particular ray for a pixel can be coded like this:


Ray RayGenerator::GenerateRay(int pixel_x, int pixel_y)
{
Ray ray;
double u,v;

ConvertPixel_to_Unit(pixel_x,pixel_y,u,v);

ray.orig=From;
ray.dir=-Normalize3d(-i + u*tanFov*aspect*j + v*tanFov*k);

return ray;
}

This code generates rays that advance in the negative direction of the X axis

Slightly modifying the code we can obtain our new spherical camera:

Ray SphericalRayGenerator::GenerateRay(int pixel_x, int pixel_y)
{
Ray ray;
double u,v;

ConvertPixel_to_Unit(pixel_x,pixel_y,u,v);

u*=fishEyeFactor*aspect;
v*=fishEyeFactor;

Vector V;
double r=sqrt(u*u+v*v);

double a=atan2(v,u);
V.y=sin(a)*(1-cos(r));
V.z=-cos(a)*(1-cos(r));
V.x=sin(r);
V=Normalize3d(V);

Matrix matrix=Construct4d(i,j,k,VECTOR3D(0,0,0));
V=TransformVector3d(V,matrix);

ray.orig=From;
ray.dir=Normalize3d(V);

return ray;
}

This type of projection generates a pole (or singularity) in the positive direction of the X axis. This generates images wery similar to the ones that Escher made in Circle Limit. As we aproach to the horizon we go to infinity.
With the value 'fishEyeFactor' we replicate the plane several times over the sphere reaching infinity as concentrical circular shapes.

This image is a normal render of an infinite labyrinth:


As we increase the spherical factor we slightly deform the image:


If we increase too much the factor we reach infinity several times:


We can make a render looking "down" obtaining an image that remainds quite well to the ones of M.C.Escher:


Likewise it's possible to increase the spherical factor:

Thursday, February 5, 2009

Infinite Labyrinths

English    Spanish

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.
The way that I present here in order to do this task is the next one:
  • 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).
When a ray step inside a region, it will intersect with the associated shape in that region. When, by reflexion or traversing, it changes the region, a new intersection will be computed with the new form associated to the new region.

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.
For the second point we have to think a bit. To each coordinate (integer) of the space I have to assign a random number. The function will be f(i,j)->n. Being i and j integer numbers and n a real number from 0 to 1. This function has to return values highly distinct of 'n' using slight variations of i and j. This is either a hashing function or a pseudorandom generator. Esentially are the same.
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.