Difference between revisions of "Reference:Pattern"

From POV-Wiki
Jump to navigation Jump to search
m (link correction)
m (1 revision: link repair)
 
(3 intermediate revisions by the same user not shown)
Line 35: Line 35:
 
the particles or gasses.</p>
 
the particles or gasses.</p>
 
<p>
 
<p>
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>,
+
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 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>pigment_map</code>, <code>normal_map</code>, <code>slope_map</code>, <code>texture_map</code>, <code>density</code>, and <code>density_map</code>.</p>
 
<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>
  
Line 57: Line 57:
 
</ul>
 
</ul>
  
==General Patterns==
+
<p>See the following sections for more <em>pattern</em> and <em>pattern related topics</em>:</p>
<p>Many patterns can be used in textures, normals and media. These patterns are <code>agate</code>, <code>boxed</code>, <code>bozo</code>, <code>brick</code>, <code>bumps</code>, <code>cubic</code>, <code>cylindrical</code>, <code>density_file</code>, <code>dents</code>, <code>facets</code>, <code>fractal</code>, <code>function</code>, <code>gradient</code>, <code>granite</code>, <code>hexagon</code>,
 
<code>leopard</code>, <code>marble</code>, <code>onion</code>, <code>pavement</code>, <code>pigment_pattern</code>, <code>planar</code>, <code>quilted</code>, <code>radial</code>, <code>ripples</code>, <code>spherical</code>, <code>spiral1</code>, <code>spiral2</code>,
 
<code>spotted</code>, <code>square</code>, <code>tiling</code>, <code>waves</code>, <code>wood</code>, and <code>wrinkles</code>.</p>
 
 
 
==Discontinuous Patterns==
 
<p>Some patters are discontinuous, meaning their slope is infinite. These patters are not suitable for use as object normals, as objects with discontinuous normals may look odd. These patters work best for textures and media. They are <code>cells</code>, <code>checker</code>, <code>crackle</code>, <code>object</code>, and <code>triangular</code>.</p>
 
 
 
==Normal-Dependent Patterns==
 
<p>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 <code>aoi</code> and <code>slope</code>.</p>
 
 
 
==Special Patterns==
 
<p>Some patters are no &quot;real&quot; patterns, but behave like patters and are used in the same location as a regular pattern. They are <code>average</code> and <code>image</code>.</p>
 
 
 
{{#indexentry:pattern modifiers}}
 
 
 
==Pattern Modifiers==
 
<p>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:</p>
 
<pre>
 
PATTERN_MODIFIER:
 
  BLEND_MAP_MODIFIER | AGATE_MODIFIER | DENSITY_FILE_MODIFIER |
 
  QUILTED_MODIFIER | BRICK_MODIFIER | SLOPE_MODIFIER |
 
  noise_generator Number| turbulence &lt;Amount&gt; |
 
  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:
 
  &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>
 
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 <code>
 
gradient</code> or <code>onion</code> generate a groove or slot that looks
 
like a ramp that drops off sharply. This is called a <code>ramp_wave</code>
 
wave type and it is the default wave type for most patterns. However the
 
<code>wood</code> and <code>marble</code> 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 <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>
 
Now any pattern that takes a map can have the default wave type overridden.
 
For example:</p>
 
<pre>
 
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>
 
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.</p>
 
<p>
 
Wave type modifiers have no effect on block patterns <code>checker</code>,
 
<code>brick</code>, <code>object</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>, <code>ripples</code>, <code>
 
waves</code>, or <code>wrinkles</code> because these normal patterns cannot
 
use <code>normal_map</code> or <code>slope_map</code>.</p>
 
{{#indexentry:noise_generator, pattern modifier}}
 
{{#indexentry:pattern modifier, noise_generator}}
 
===Noise Generators===
 
<p> There are three noise generators implemented. Changing the <code>noise_generator</code> will change
 
the appearance of noise based patterns, like bozo and granite.</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>
<p>The default is <code>noise_generator 2</code></p>
 
<p class="Note"><strong>Note:</strong> The noise_generator can also be set in <code>global_settings</code></p>
 

Latest revision as of 19:27, 23 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: