imagico.de
imagico.de

imagico.de

Tutorials and Tables

Warps

This tutorial describes the use of Povray's warp statement. It is a pattern modifier that was introduced in Povray 3.1 in addition to existing turbulence. The external linkPovray 3.1 documentation gives a quite complete description about it's possibilities, but it is not very easy to understand for the beginner. Furthermore i will also describe the new warp types introduced with external linkMegaPOV.

turbulence warps

Before Povray 3.1 the only possibility to modify a external linkpattern was the external linkturbulence keyword. It added some randomness to the pattern and could be modified with the additional keywords octaves, omega and lambda.

turbulence 0.4

turbulence

A similar effect is possible with the warp statement, namely the turbulence warp.

It works just like turbulence and has the same optional keywords. Anyway the effect is not identical although it is similar.

warp { turbulence 0.4 }

turbulence warp

The main difference is the influence of external linktransformations like rotate, scale and translate. While turbulence has the same effect no matter where you place it in your pattern definition, warps are applied in the order they are written.

Example:

pigment {
  marble
  color_map { ... }

  scale 5
  warp { turbulence 0.4 }
  scale 0.2
}

turbulence warp scaled

pigment {
   marble
   color_map { ... }

   scale 0.2
   warp { turbulence 0.4 }
   scale 5
}

turbulence warp scaled

That are the main things about turbulence warps, of course you can use several of them in one pattern definition, also remember that turbulence can also take a vector so you can specify different amounts for different directions.

repeat warps

The repeat warp repeats a certain part of the pattern with a frequency and a direction specified with the vector that follows the repeat keyword. The vector has to lie in one of the axes.

warp { repeat x }

no repeat warp with repeat warp

Changing the length of the repeat vector changes the size of the repeated part.

warp { repeat x*0.5 }

scaled repeat warps

You can of course combine several repeat warps:

warp { repeat x }
warp { repeat y }

two repeat warps

You can slightly change the repeated section with the optional offset keyword. The vector following that keyword specifies the direction and amount the pattern is moved with each repeat step.

warp { repeat x*0.5 offset y*0.25 }

repeat warp with offset

The last thing about the repeat warp is the flip keyword. It is also followed by a vector, but this vector must only have components either 1 or 0. 1 means the every second repeated section is flipped around that axis. The fist section in positive direction is not flipped, while the first one in negative direction is.

warp { repeat x flip x }
warp { repeat y flip y }

repeat warp with flip

black_hole warps

Another warp type is the black_hole warp. It distorts the pattern around a certain point towards this point.

The first parameter following the black_hole keyword is the point the black hole is located at. The second is the radius.

warp { black_hole <0.00.00.0>0.8 }

black_hole warp

With the optional inverse keyword, you can invert the effect of the warp, meaning that it pushes away the pattern from the center.

warp {
  black_hole <000>0.8
  inverse
}

black_hole warp inverse

For seeing the effect of strength and falloff have a look at some tabulated pictures.

You can also place several black holes without using several warps with help of the repeat keyword.

warp {
  black_hole <0.30.30>0.25
  strength 3
  inverse
  repeat x*0.7
}

black_hole repeat

If the repeat vector is not parallel to one of the axes, the black hole is repeated in several directions.

warp {
  black_hole <0.30.30>0.25
  strength 3
  inverse
  repeat <0.710>
}

black_hole repeat

Finally you can also vary the position of the repeated warps using turbulence.

warp {
  black_hole <0.30.30>0.25
  strength 3
  inverse
  repeat <0.710>
  turbulence <0.150.40>
}

black_hole repeat with turbulence

When using repeated black hole warps, the warp has to be completely within one repeat segment. This also applies for turbulence meaning that the turbulated warp must have a correct position.

This picture illustrates this requirement, for details consult the documentation.

black_hole repeat limitations

displace warps

This warp type requires external linkMegaPOV.

The displace warp uses a pigment for specifying the distortion. There are two different types, type 0, which is the default, uses the red, green and blue value of the pigment to determine the displacement in x, y and z direction.

This is a first very simple example, on the left is the pigment used for displacement, on the right the displaced pigment.

warp {
  displace {
    pigment {
      gradient y
      color_map {
        [0.5 color rgb <000> ]
        [0.5 color rgb <100> ]
      }
      scale 2
      translate -1.5*y
    }
  }
}

displace warp type 0

Using also other colors adds displacement in the other directions.

warp {
  displace {
    pigment {
      gradient y
      pigment_map {
        [0.5
          gradient x
          color_map {
            [0.0 color rgb <00,   0> ]
            [1.0 color rgb <000.7> ]
          }
        ]
        [0.5 color rgb <100> ]
      }
      scale 2
      translate -1.5*y
    }
  }
}

displace warp type 0

The type 1 displace warp uses the gradient of the pigment to determine displacement. The pattern is pushed away from dark areas and towards bright areas.

The object on the left is an isosurface with the brightness of the displace pigment as height. The warp displaces horizontally in the uphill direction.

warp {
  displace {
    pigment {
      cylindrical
      poly_wave 2
      color_map {
        [0.0 color rgb 0]
        [1.0 color rgb 1]
      }
      rotate 90*x
    }
    type 1
  }
}

displace warp type 0

Also note, that when using pigments for displace warps, any color values including negative and larger than 1 can be useful.

Similar to the black hole warp I have some tabulated pictures for the displace warp.


That's all for now about warps, in megapov there are remaining cylindrical, spherical, toroidal and planar warps i will maybe write about later.

If you have any suggestions for improvements or find errors, feel free to contact me.

Christoph Hormann February 3, 2000