Patterns

POV-Ray uses a method called three-dimensional solid texturing to define the color, bumpiness and other properties of an object. You specify the way that the texture varies over a surface by specifying a pattern. Patterns are used in pigments, normals and texture maps as well as media density.

All patterns in POV-Ray are three dimensional. For every point in space, each pattern has a unique value. Patterns do not wrap around a surface like putting wallpaper on an object. The patterns exist in 3d and the objects are carved from them like carving an object from a solid block of wood or stone.

Consider a block of wood. It contains light and dark bands that are concentric cylinders being the growth rings of the wood. On the end of the block you see these concentric circles. Along its length you see lines that are the veins. However the pattern exists throughout the entire block. If you cut or carve the wood it reveals the pattern inside. Similarly an onion consists of concentric spheres that are visible only when you slice it. Marble stone consists of wavy layers of colored sediments that harden into rock.

These solid patterns can be simulated using mathematical functions. Other random patterns such as granite or bumps and dents can be generated using a random number system and a noise function.

In each case, the x, y, z coordinate of a point on a surface is used to compute some mathematical function that returns a float value. When used with color maps or pigment maps, that value looks up the color of the pigment to be used. In normal statements the pattern function result modifies or perturbs the surface normal vector to give a bumpy appearance. Used with a texture map, the function result determines which combinations of entire textures to be used. When used with media density it specifies the density of the particles or gasses.

The following sections describe each pattern. See the sections Pigment, Normal, Patterned Textures and Density for more details on how to use patterns. Unless mentioned otherwise, all patterns use the `ramp_wave` wave type by default but may use any wave type and may be used with `color_map`, `pigment_map`, `normal_map`, `slope_map`, `texture_map`, `density`, and `density_map`.

Note: Some patterns have a built in default color_map that does not result in a grey-scale pattern. This may lead to unexpected results when one of these patterns is used without a user specified color_map, for example in functions or media.

These patterns are:

• `agate`
• `bozo`
• `brick`
• `checker`
• `hexagon`
• `mandel`
• `marble`
• `radial`
• `square`
• `triangular`
• `wood`

General Patterns

Many patterns can be used in textures, normals and media. These patterns are `agate`, `boxed`, `bozo</code, <code>brick`, `bumps`, `cubic`, `cylindrical`, `density_file`, `dents`, `facets`, `fractal`, `function`, `gradient`, `granite`, `hexagon`, `leopard`, `marble`, `onion`, `pavement`, `pigment_pattern`, `planar`, `quilted`, `radial`, `ripples`, `spherical`, `spiral1`, `spiral2`, `spotted`, `square`, `tiling`, `waves`, `wood`, and `wrinkles`.

Discontinuous Patterns

Some patters are discontinuous, meaning their slope is infinite. These patters are not suitable for use as object norms, as objects with discontinuous norms may look odd. These patters work best for textures and media. They are `cells`, `checker`, `crackle`, `object`, and `triangular`.

Normal-Dependent Patterns

Some patters depend on the normal vector in addition to a position vector. As such, these patters are suitable for object normals only. They are `aoi` and `slope`.

Special Patterns

Some patters are no "real" patterns, but behave like patters and are used in the same location as a regular pattern. They are `average` and `image`.

Pattern Modifiers

Pattern modifiers are statements or parameters which modify how a pattern is evaluated or tells what to do with the pattern. The complete syntax is:

```PATTERN_MODIFIER:
BLEND_MAP_MODIFIER | AGATE_MODIFIER | DENSITY_FILE_MODIFIER |
QUILTED_MODIFIER | BRICK_MODIFIER | SLOPE_MODIFIER |
noise_generator Number| turbulence <Amount> |
octaves Count | omega Amount | lambda Amount |
warp { [WARP_ITEMS...] } | TRANSFORMATION
BLEND_MAP_MODIFIER:
frequency Amount | phase Amount | ramp_wave | triangle_wave |
sine_wave | scallop_wave | cubic_wave | poly_wave [Exponent]
AGATE_MODIFIER:
agate_turb Value
BRICK_MODIFIER:
brick_size Size | mortar Size
DENSITY_FILE_MODIFIER:
interpolate Type
SLOPE_MODIFIERS:
<Altitude>
<Lo_slope,Hi_slope>
<Lo_alt,Hi_alt>
QUILTED_MODIFIER:
control0 Value | control1 Value
PIGMENT_MODIFIER:
PATTERN_MODIFIER | COLOR_LIST | PIGMENT_LIST |
color_map { COLOR_MAP_BODY } | colour_map { COLOR_MAP_BODY } |
pigment_map{ PIGMENT_MAP_BODY } | quick_color COLOR |
quick_colour COLOR
COLOR NORMAL_MODIFIER:
PATTERN_MODIFIER | NORMAL_LIST |
normal_map { NORMAL_MAP_BODY } | slope_map{ SLOPE_MAP_BODY } |
bump_size Amount
TEXTURE_PATTERN_MODIFIER:
PATTERN_MODIFIER | TEXTURE_LIST |
texture_map{ TEXTURE_MAP_BODY }
DENSITY_MODIFIER:
PATTERN_MODIFIER | DENSITY_LIST | COLOR_LIST |
color_map { COLOR_MAP_BODY } | colour_map { COLOR_MAP_BODY } |
density_map { DENSITY_MAP_BODY }
```

Default values for pattern modifiers:

```dist_exp        : 0
falloff         : 2.0
frequency       : 1.0
lambda          : 2.0
map_type        : 0
noise_generator : 2
octaves         : 6
omega           : 0.5
orientation     : <0,0,1>
phase           : 0.0
poly_wave       : 1.0
strength        : 1.0
turbulence      : <0,0,0>
```

The modifiers PIGMENT_LIST, `quick_color`, and `pigment_map` apply only to pigments. See the section Pigment for details on these pigment-specific pattern modifiers.

The modifiers COLOR_LIST and `color_map` apply only to pigments and densities. See the sections Pigment and Density for details on these pigment-specific pattern modifiers.

The modifiers NORMAL_LIST, `bump_size`, `slope_map` and `normal_map` apply only to normals. See the section Normal for details on these normal-specific pattern modifiers.

The TEXTURE_LIST and `texture_map` modifiers can only be used with patterned textures. See the section Texture Maps for details.

The DENSITY_LIST and `density_map` modifiers only work with `media{density{..}}` statements. See the section Density for details.

The `agate_turb` modifier can only be used with the `agate` pattern. See the section Agate for details.

The `brick_size` and `mortar` modifiers can only be used with the `brick` pattern. See the section Brick for details.

The `control0` and `control1` modifiers can only be used with the `quilted` pattern. See the section Quilted for details.

The `interpolate` modifier can only be used with the `density_file` pattern. See the section Density File for details.

The general purpose pattern modifiers in the following sections can be used with `pigment`, `normal`, `texture`, or `density` patterns.

Transforming Patterns

The most common pattern modifiers are the transformation modifiers `translate`, `rotate`, `scale`, `transform`, and `matrix`. For details on these commands see the section Transformations.

These modifiers may be placed inside pigment, normal, texture, and density statements to change the position, size and orientation of the patterns.

Transformations are performed in the order in which you specify them. However in general the order of transformations relative to other pattern modifiers such as `turbulence`, `color_map` and other maps is not important. For example scaling before or after turbulence makes no difference. The turbulence is done first, then the scaling regardless of which is specified first. However the order in which transformations are performed relative to `warp` statements is important. See the section Warps for details.

Frequency and Phase

The `frequency` and `phase` modifiers act as a type of scale and translate modifiers for various blend maps. They only have effect when blend maps are used. Blend maps are `color_map`, `pigment_map`, `normal_map`, `slope_map`, `density_map`, and `texture_map`. This discussion uses a color map as an example but the same principles apply to the other blend map types.

The `frequency` keyword adjusts the number of times that a color map repeats over one cycle of a pattern. For example `gradient` covers color map values 0 to 1 over the range from x=0 to x=1. By adding `frequency 2.0` the color map repeats twice over that same range. The same effect can be achieved using `scale 0.5*x` so the frequency keyword is not that useful for patterns like gradient.

However the radial pattern wraps the color map around the +y-axis once. If you wanted two copies of the map (or 3 or 10 or 100) you would have to build a bigger map. Adding `frequency 2.0` causes the color map to be used twice per revolution. Try this:

```pigment {
color_map{
[0.5 color Red]
[0.5 color White]
}
frequency 6
}
```

The result is six sets of red and white radial stripes evenly spaced around the object.

The float after `frequency` can be any value. Values greater than 1.0 causes more than one copy of the map to be used. Values from 0.0 to 1.0 cause a fraction of the map to be used. Negative values reverses the map.

The `phase` value causes the map entries to be shifted so that the map starts and ends at a different place. In the example above if you render successive frames at `phase 0` then `phase 0.1`, `phase 0.2`, etc. you could create an animation that rotates the stripes. The same effect can be easily achieved by rotating the `radial` pigment using `rotate y*Angle` but there are other uses where phase can be handy.

Sometimes you create a great looking gradient or wood color map but you want the grain slightly adjusted in or out. You could re-order the color map entries but that is a pain. A phase adjustment will shift everything but keep the same scale. Try animating a `mandel` pigment for a color palette rotation effect.

These values work by applying the following formula

New_Value = fmod ( Old_Value * Frequency + Phase, 1.0 ).

The `frequency` and `phase` modifiers have no effect on block patterns `checker`, `brick`, and `hexagon` nor do they effect `image_map`, `bump_map` or `material_map`. They also have no effect in normal statements when used with `bumps`, `dents`, `quilted` or `wrinkles` because these normal patterns cannot use `normal_map` or `slope_map`.

They can be used with normal patterns `ripples` and `waves` even though these two patterns cannot use `normal_map` or `slope_map` either. When used with `ripples` or `waves`, `frequency` adjusts the space between features and `phase` can be adjusted from 0.0 to 1.0 to cause the ripples or waves to move relative to their center for animating the features.

Waveforms

POV-Ray allows you to apply various wave forms to the pattern function before applying it to a blend map. Blend maps are `color_map`, `pigment_map`, `normal_map`, `slope_map`, `density_map`, and `texture_map`.

Most of the patterns which use a blend map, use the entries in the map in order from 0.0 to 1.0. The effect can most easily be seen when these patterns are used as normal patterns with no maps. Patterns such as ``` gradient``` or `onion` generate a groove or slot that looks like a ramp that drops off sharply. This is called a `ramp_wave` wave type and it is the default wave type for most patterns. However the `wood` and `marble` patterns use the map from 0.0 to 1.0 and then reverses it and runs it from 1.0 to 0.0. The result is a wave form which slopes upwards to a peak, then slopes down again in a ``` triangle_wave```. In earlier versions of POV-Ray there was no way to change the wave types. You could simulate a triangle wave on a ramp wave pattern by duplicating the map entries in reverse, however there was no way to use a ramp wave on wood or marble.

Now any pattern that takes a map can have the default wave type overridden. For example:

```pigment { wood color_map { MyMap } ramp_wave }
```

Also available are `sine_wave`, `scallop_wave`, `cubic_wave` and `poly_wave` types. These types are of most use in normal patterns as a type of built-in slope map. The ``` sine_wave``` takes the zig-zag of a ramp wave and turns it into a gentle rolling wave with smooth transitions. The `scallop_wave` uses the absolute value of the sine wave which looks like corduroy when scaled small or like a stack of cylinders when scaled larger. The `cubic_wave` is a gentle cubic curve from 0.0 to 1.0 with zero slope at the start and end. The `poly_wave` is an exponential function. It is followed by an optional float value which specifies exponent. For example ```poly_wave 2``` starts low and climbs rapidly at the end while ```poly_wave 0.5``` climbs rapidly at first and levels off at the end. If no float value is specified, the default is 1.0 which produces a linear function identical to `ramp_wave`.

Although any of these wave types can be used for pigments, normals, textures, or density the effect of many of the wave types are not as noticeable on pigments, textures, or density as they are for normals.

Wave type modifiers have no effect on block patterns `checker`, `brick`, `object` and `hexagon` nor do they effect ``` image_map```, `bump_map` or `material_map`. They also have no effect in normal statements when used with `bumps`, `dents`, `quilted`, `ripples`, ``` waves```, or `wrinkles` because these normal patterns cannot use `normal_map` or `slope_map`.

Noise Generators

There are three noise generators implemented. Changing the `noise_generator` will change the appearance of noise based patterns, like bozo and granite.

• `noise_generator 1` the noise that was used in POV_Ray 3.1
• `noise_generator 2` range corrected version of the old noise, it does not show the plateaus seen with `noise_generator 1`
• `noise_generator 3` generates Perlin noise

The default is `noise_generator 2`

Note: The noise_generator can also be set in `global_settings`