Difference between revisions of "Reference:Pattern"

From POV-Wiki
Jump to navigation Jump to search
m (moved some sub-sections to separate files)
m (my bad pasted wrong cotent)
Line 1: Line 1:
{{#indexentry:pattern modifiers}}
+
{{DISPLAYTITLE:Patterns}}
==Pattern Modifiers==
+
[[Category:Patterns]]
<p>Pattern modifiers are statements or parameters which modify how a pattern
+
<p>POV-Ray uses a method called <em>three-dimensional solid texturing</em> to
is evaluated or tells what to do with the pattern. The complete syntax
+
define the color, bumpiness and other properties of an object. You specify
is:</p>
+
the way that the texture varies over a surface by specifying a <em>
<pre>
+
pattern</em>. Patterns are used in pigments, normals and texture maps as well
PATTERN_MODIFIER:
+
as media density.</p>
  BLEND_MAP_MODIFIER | AGATE_MODIFIER | DENSITY_FILE_MODIFIER |
+
<p>
  QUILTED_MODIFIER | BRICK_MODIFIER | SLOPE_MODIFIER |
+
All patterns in POV-Ray are three dimensional. For every point in space,
  noise_generator Number| turbulence &lt;Amount&gt; |
+
each pattern has a unique value. Patterns do not wrap around a surface like
  octaves Count | omega Amount | lambda Amount |
+
putting wallpaper on an object. The patterns exist in 3d and the objects are
  warp { [WARP_ITEMS...] } | TRANSFORMATION
+
carved from them like carving an object from a solid block of wood or
BLEND_MAP_MODIFIER:
+
stone.</p>
  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:
 
  &lt;Altitude&gt;
 
  &lt;Lo_slope,Hi_slope&gt;
 
  &lt;Lo_alt,Hi_alt&gt;
 
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 }
 
</pre>
 
 
 
{{#indexentry:default values, pattern modifiers}}
 
<p>Default values for pattern modifiers:</p>
 
<pre>
 
dist_exp        : 0
 
falloff        : 2.0
 
frequency      : 1.0
 
lambda          : 2.0
 
major_radius    : 1
 
map_type        : 0
 
noise_generator : 2
 
octaves        : 6
 
omega          : 0.5 
 
orientation    : &lt;0,0,1&gt;
 
phase          : 0.0
 
poly_wave      : 1.0
 
strength        : 1.0
 
turbulence      : &lt;0,0,0&gt;
 
</pre>
 
 
 
<p>The modifiers <em>PIGMENT_LIST</em>, <code>quick_color</code>, and <code>pigment_map</code> apply only to pigments. See the section [[Reference:Pigment|:Pigment|Pigment]] for details on these pigment-specific pattern modifiers.</p>
 
<p>The modifiers <em> COLOR_LIST</em> and <code>color_map</code> apply only to pigments and densities. See the sections [[Reference:Pigment|:Pigment|Pigment]] and [[Reference:Density File Pattern|:Density|:Density_File|Density]] for details on these pigment-specific pattern modifiers.</p>
 
<p>The modifiers <em> NORMAL_LIST</em>, <code>bump_size</code>, <code>slope_map</code> and <code>normal_map</code> apply only to normals. See the section [[Reference:Normal|:Normal|Normal]] for details on these normal-specific pattern
 
modifiers.</p>
 
<p>The <em>TEXTURE_LIST</em> and <code>texture_map</code> modifiers can only be used with patterned textures. See the section <!--<linkto "Texture Maps">Texture Maps</linkto>--->[[Reference:Patterned Textures#Texture Maps|Texture Maps]] for details.</p>
 
<p>The <em> DENSITY_LIST</em> and <code>density_map</code> modifiers only work with <code>media{density{..}}</code> statements. See the section [[Reference:Density File Pattern|:Density|:Density_File|Density]] for details.</p>
 
 
 
{{#indexentry:agate_turb, pattern modifier}}
 
{{#indexentry:pattern modifier, agate_turb}}
 
{{#indexentry:brick_size, pattern modifier}}
 
{{#indexentry:pattern modifier, brick_size}}
 
{{#indexentry:mortar, pattern modifier}}
 
{{#indexentry:pattern modifier, mortar}}
 
{{#indexentry:control0, pattern modifier}}
 
{{#indexentry:pattern modifier, control0}}
 
{{#indexentry:control1, pattern modifier}}
 
{{#indexentry:pattern modifier, control1}}
 
{{#indexentry:warp, pattern modifier}}
 
{{#indexentry:pattern modifier, warp}}
 
<p>The <code>agate_turb</code> modifier can only be used with the <code>agate</code> pattern. See the section [[Reference:Agate Pattern|:Agate|Agate]] for details.</p>
 
<p>The <code>brick_size</code> and <code>mortar</code> modifiers can only be used with the <code>brick</code> pattern. See the section [[Reference:Brick Pattern|:Brick|Brick]] for details.</p>
 
<p>The <code>control0</code> and <code>control1</code> modifiers can only be used with the <code>quilted</code> pattern. See the section [[Reference:Quilted Pattern|:Quilted|Quilted]] for details.</p>
 
<p>The <code>interpolate</code> modifier can only be used with the <code>density_file</code> pattern. See the section [[Reference:Density File Pattern|:Density File|Density File]] for details.</p>
 
<p>The general purpose pattern modifiers in the following sections can be used with <code>pigment</code>, <code>normal</code>, <code>texture</code>, or <code>density</code> patterns.</p>
 
 
 
===Transforming Patterns===
 
<p>The most common pattern modifiers are the transformation modifiers <code>translate</code>, <code>rotate</code>, <code>scale</code>, <code>transform</code>, and <code>matrix</code>. For details on these commands see the section [[Reference:Transformations|:Transformations|Transformations]].</p>
 
<p>These modifiers may be placed inside pigment, normal, texture, and density
 
statements to change the position, size and orientation of the patterns.</p>
 
<p>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 <code>turbulence</code>, <code>color_map</code> 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 <code>warp</code> statements is important. See the section [[Reference:Warp|Warps]] for details.</p>
 
 
 
{{#indexentry:frequency, pattern modifier}}
 
{{#indexentry:pattern modifiers, frequency}}
 
{{#indexentry:phase, pattern modifier}}
 
{{#indexentry:pattern modifiers, phase}}
 
 
 
===Frequency and Phase===
 
<p>The <code>frequency</code> and <code>phase</code> 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 <code>color_map</code>,
 
<code>pigment_map</code>, <code>normal_map</code>, <code>slope_map</code>,
 
<code>density_map</code>, and <code>texture_map</code>. This discussion uses
 
a color map as an example but the same principles apply to the other blend
 
map types.</p>
 
<p>The <code>frequency</code> keyword adjusts the number of times that a color
 
map repeats over one cycle of a pattern. For example <code>gradient</code> covers color map values 0 to 1 over the range from x=0 to x=1. By adding <code>frequency 2.0</code> the color map repeats twice over that same range. The same effect can be achieved using <code>scale 0.5*x</code> so the frequency keyword is not that useful for patterns like gradient.</p>
 
<p>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 <code>frequency 2.0</code> causes the color map to be
 
used twice per revolution. Try this:</p>
 
<pre>
 
pigment {
 
  radial
 
  color_map{
 
    [0.5 color Red]
 
    [0.5 color White]
 
    }
 
  frequency 6
 
  }
 
</pre>
 
 
 
<p>The result is six sets of red and white radial stripes evenly spaced
 
around the object.</p>
 
<p>The float after <code>frequency</code> 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.</p>
 
<p>The <code>phase</code> 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 <code>phase 0</code> then <code>phase 0.1</code>, <code>phase 0.2</code>, etc. you could create an animation that rotates the stripes. The same effect can be easily achieved by rotating the <code>radial</code> pigment using <code>rotate y*Angle</code> but there are other uses where phase can be handy.</p>
 
<p>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 <code>mandel</code> pigment for a color
 
palette rotation effect.</p>
 
<p>These values work by applying the following formula</p>
 
<p><em> New_Value = fmod ( Old_Value * Frequency + Phase, 1.0 ). </em></p>
 
<p>The <code>frequency</code> and <code>phase</code> modifiers have no effect on block patterns <code>checker</code>, <code>brick</code>, and <code>hexagon</code> nor do they effect <code>image_map</code>, <code>bump_map</code> or <code>material_map</code>. They also have no effect in normal statements when used with <code>bumps</code>, <code>dents</code>, <code>quilted</code> or <code>wrinkles</code> because these normal patterns cannot use <code>normal_map</code> or <code>slope_map</code>.</p>
 
<p>They can be used with normal patterns <code>ripples</code> and <code>waves</code> even though these two patterns cannot use <code>normal_map</code> or <code>slope_map</code> either. When used with <code>ripples</code> or <code>waves</code>, <code>frequency</code> adjusts the space between features and <code>phase</code> 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.</p>
 
 
 
{{#indexentry:ramp_wave, pattern modifier}}
 
{{#indexentry:pattern modifiers, ramp_wave}}
 
===Waveforms===
 
<p>POV-Ray allows you to apply various wave forms to the pattern function
 
before applying it to a blend map. Blend maps are <code>color_map</code>,
 
<code>pigment_map</code>, <code>normal_map</code>, <code>slope_map</code>,
 
<code>density_map</code>, and <code>texture_map</code>.</p>
 
 
<p>
 
<p>
Most of the patterns which use a blend map, use the entries in the map in
+
Consider a block of wood. It contains light and dark bands that are
order from 0.0 to 1.0. The effect can most easily be seen when these patterns
+
concentric cylinders being the growth rings of the wood. On the end of the
are used as normal patterns with no maps. Patterns such as <code>
+
block you see these concentric circles. Along its length you see lines that
gradient</code> or <code>onion</code> generate a groove or slot that looks
+
are the veins. However the pattern exists throughout the entire block. If you
like a ramp that drops off sharply. This is called a <code>ramp_wave</code>
+
cut or carve the wood it reveals the pattern inside. Similarly an onion
wave type and it is the default wave type for most patterns. However the
+
consists of concentric spheres that are visible only when you slice it.
<code>wood</code> and <code>marble</code> patterns use the map from 0.0 to
+
Marble stone consists of wavy layers of colored sediments that harden into
1.0 and then reverses it and runs it from 1.0 to 0.0. The result is a wave
+
rock.</p>
form which slopes upwards to a peak, then slopes down again in a <code>
 
triangle_wave</code>. 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.</p>
 
 
<p>
 
<p>
Now any pattern that takes a map can have the default wave type overridden.
+
These solid patterns can be simulated using mathematical functions. Other
For example:</p>
+
random patterns such as granite or bumps and dents can be generated using a
<pre>
+
random number system and a noise function.</p>
pigment { wood color_map { MyMap } ramp_wave }
 
</pre>
 
 
 
{{#indexentry:sine_wave, pattern modifier}}
 
{{#indexentry:pattern modifiers, sine_wave}}
 
{{#indexentry:scallop_wave, pattern modifier}}
 
{{#indexentry:pattern modifiers, scallop_wave}}
 
{{#indexentry:cubic_wave, pattern modifier}}
 
{{#indexentry:pattern modifiers, cubic_wave}}
 
{{#indexentry:poly_wave, pattern modifier}}
 
{{#indexentry:pattern modifiers, poly_wave}}
 
<p>Also available are <code>sine_wave</code>, <code>scallop_wave</code>,
 
<code>cubic_wave</code> and <code>poly_wave</code> types. These types are of
 
most use in normal patterns as a type of built-in slope map. The <code>
 
sine_wave</code> takes the zig-zag of a ramp wave and turns it into a gentle
 
rolling wave with smooth transitions. The <code>scallop_wave</code> 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 <code>cubic_wave</code>
 
is a gentle cubic curve from 0.0 to 1.0 with zero slope at the start and end.
 
The <code>poly_wave</code> is an exponential function. It is followed by an
 
optional float value which specifies exponent. For example <code>poly_wave
 
2</code> starts low and climbs rapidly at the end while <code>poly_wave
 
0.5</code> 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 <code>ramp_wave</code>.</p>
 
 
<p>
 
<p>
Although any of these wave types can be used for pigments, normals,
+
In each case, the x, y, z coordinate of a point on a surface is used to
textures, or density the effect of many of the wave types are not as
+
compute some mathematical function that returns a float value. When used with
noticeable on pigments, textures, or density as they are for normals.</p>
+
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.</p>
 
<p>
 
<p>
Wave type modifiers have no effect on block patterns <code>checker</code>,
+
The following sections describe each pattern. See the sections [[Reference:Pigment|:Pigment|Pigment]], [[Reference:Normal|:Normal|Normal]], <!--<linkto "Patterned Textures">Patterned Textures</linkto>--->[[Reference:Patterned Textures|Patterned Textures]] and [[Reference:Density File Pattern|:Density|:Density_File|Density]] for more details on how to use patterns. Unless mentioned otherwise, all patterns use the <code>ramp_wave</code> wave type by default but may use any wave type and may be used with <code>color_map</code>,
<code>brick</code>, <code>object</code> and <code>hexagon</code> nor do they effect <code>
+
<code>pigment_map</code>, <code>normal_map</code>, <code>slope_map</code>, <code>texture_map</code>, <code>density</code>, and <code>density_map</code>.</p>
image_map</code>, <code>bump_map</code> or <code>material_map</code>. They
+
 
also have no effect in normal statements when used with <code>bumps</code>,
+
<p class="Note"><strong>Note:</strong> Some patterns have a built in default color_map that does not result in a
<code>dents</code>, <code>quilted</code>, <code>ripples</code>, <code>
+
grey-scale pattern. This may lead to unexpected results  when one of these
waves</code>, or <code>wrinkles</code> because these normal patterns cannot
+
patterns is used without a user specified color_map, for example in
use <code>normal_map</code> or <code>slope_map</code>.</p>
+
functions or media.</p>
{{#indexentry:noise_generator, pattern modifier}}
+
<p> These patterns are:</p>
{{#indexentry:pattern modifier, noise_generator}}
+
<ul>
===Noise Generators===
+
<li><code>agate</code></li>
<p> There are three noise generators implemented. Changing the <code>noise_generator</code> will change
+
<li><code>bozo</code></li>
the appearance of noise based patterns, like bozo and granite.</p>
+
<li><code>brick</code></li>
 +
<li><code>checker</code></li>
 +
<li><code>hexagon</code></li>
 +
<li><code>mandel</code></li>
 +
<li><code>marble</code></li>
 +
<li><code>radial</code></li>
 +
<li><code>square</code></li>
 +
<li><code>triangular</code></li>
 +
<li><code>wood</code></li>
 +
</ul>
 +
 
 +
<p>See the following sections for more <em>pattern</em> and <em>pattern related topics</em>:</p>
 
<ul>
 
<ul>
<li><code>noise_generator 1</code> the noise that was used in POV_Ray 3.1</li>
+
  <li>[[Reference:General Patterns|General Patterns]]</li>
<li><code>noise_generator 2</code> <em>range corrected</em> version of the old noise, it does not show
+
  <li>[[Reference:Discontinuous Patterns|Discontinuous Patterns]]</li>
the plateaus seen with <code>noise_generator 1</code> </li>
+
  <li>[[Reference:Normal-Dependent Patterns|Normal-Dependent Patterns]]</li>
<li><code>noise_generator 3</code> generates Perlin noise</li>
+
  <li>[[Reference:Special Patterns|Special Patterns]]</li>
 +
  <li>[[Reference:Pattern Modifiers|Pattern Modifiers]]</li>
 
</ul>
 
</ul>

Revision as of 22:10, 18 July 2012

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

See the following sections for more pattern and pattern related topics: