1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470
|
<!-- This file copyright Persistence of Vision Raytracer Pty. Ltd. 2003-2004 -->
<html>
<head>
<!-- NOTE: In order to users to help find information about POV-Ray using -->
<!-- web search engines, we ask you to *not* let them index documentation -->
<!-- mirrors because effectively, when searching, users will get hundreds -->
<!-- of results containing the same information! For this reason, the two -->
<!-- meta tags below disable archiving and indexing of this page by all -->
<!-- search engines that support these meta tags. -->
<meta content="noarchive" name="robots">
<meta content="noindex" name="robots">
<meta content="no-cache" http-equiv="Pragma">
<meta content="0" http-equiv="expires">
<title>3.5.5 Patterned Textures</title>
<link href="povray35.css" rel="stylesheet" type="text/css">
</head>
<body>
<table class="NavBar" width="100%">
<tr>
<td align="left" nowrap="" valign="middle" width="32">
<a href="s_118.html"><img alt="previous" border="0" src="prev.png"></a>
</td>
<td align="left" valign="middle" width="30%">
<a href="s_118.html">3.5.4 Halo</a>
</td>
<td align="center" valign="middle">
<strong class="NavBar">POV-Ray 3.6 for UNIX documentation</strong><br> <strong>3.5.5
Patterned Textures</strong>
</td>
<td align="right" valign="middle" width="30%">
<a href="s_120.html">3.5.6 Layered Textures</a>
</td>
<td align="right" nowrap="" valign="middle" width="32">
<a href="s_120.html"><img alt="next" border="0" src="next.png"></a>
</td>
</tr>
</table>
<h3><a name="s03_05_05">3.5.5 </a>Patterned Textures</h3>
<p>
Patterned textures are complex textures made up of multiple textures. The component textures may be plain textures
or may be made up of patterned textures. A plain texture has just one pigment, normal and finish statement. Even a
pigment with a pigment map is still one pigment and thus considered a plain texture as are normals with normal map
statements.
</p>
<p>
Patterned textures use either a <code>texture_map</code> statement to specify a blend or pattern of textures or
they use block textures such as <code>checker</code> with a texture list or a bitmap similar to an image map called a <em>material
map</em> specified with a <code>material_map</code> statement.
</p>
<p>
The syntax is...
</p>
<pre>
PATTERNED_TEXTURE:
texture
{
[PATTERNED_TEXTURE_ID]
[TRANSFORMATIONS...]
} |
texture
{
PATTERN_TYPE
[TEXTURE_PATTERN_MODIFIERS...]
} |
texture
{
tiles TEXTURE tile2 TEXTURE
[TRANSFORMATIONS...]
} |
texture
{
material_map
{
BITMAP_TYPE "bitmap.ext"
[BITMAP_MODS...] TEXTURE... [TRANSFORMATIONS...]
}
}
TEXTURE_PATTERN_MODIFIER:
PATTERN_MODIFIER | TEXTURE_LIST |
texture_map { TEXTURE_MAP_BODY }
</pre>
<p>
There are restrictions on using patterned textures. A patterned texture may not be used as a default texture (see
section "<a href="s_98.html#s03_02_02_04">The #default Directive</a>"). A patterned texture cannot be used
as a layer in a layered texture however you may use layered textures as any of the textures contained within a
patterned texture.
</p>
<h4><a name="s03_05_05_01">3.5.5.1 </a>Texture Maps</h4>
<a name="s03_05_05_01_i1"><a name="texture_map"></a>
<p>
In addition to specifying blended color with a color map or a pigment map you may create a blend of textures using <code>texture_map</code>.
The syntax for a texture map is identical to the pigment map except you specify a texture in each map entry.
</p>
<p>
The syntax for <code>texture_map</code> is as follows:
</p>
<pre>
TEXTURE_MAP:
texture_map { TEXTURE_MAP_BODY }
TEXTURE_MAP_BODY:
TEXTURE_MAP_IDENTIFIER | TEXTURE_MAP_ENTRY...
TEXTURE_MAP_ENTRY:
[ Value TEXTURE_BODY ]
</pre>
<p>
Where <em><code>Value</code></em> is a float value between 0.0 and 1.0 inclusive and each <em>TEXTURE_BODY</em> is
anything which can be inside a <code>texture{...}</code> statement. The <code>texture</code> keyword and <code>{}</code>
braces need not be specified.
</p>
<p class="Note">
<strong>Note:</strong> the <code>[]</code> brackets are part of the actual <em> TEXTURE_MAP_ENTRY</em>.
They are not notational symbols denoting optional parts. The brackets surround each entry in the texture map.
</p>
<p>
There may be from 2 to 256 entries in the map.
</p>
<p>
For example:
</p>
<pre>
texture {
gradient x //this is the PATTERN_TYPE
texture_map {
[0.3 pigment{Red} finish{phong 1}]
[0.3 T_Wood11] //this is a texture identifier
[0.6 T_Wood11]
[0.9 pigment{DMFWood4} finish{Shiny}]
}
}
</pre>
<p>
When the <code>gradient x</code> function returns values from 0.0 to 0.3 the red highlighted texture is used. From
0.3 to 0.6 the texture identifier <code>T_Wood11</code> is used. From 0.6 up to 0.9 a blend of <code> T_Wood11</code>
and a shiny <code>DMFWood4</code> is used. From 0.9 on up only the shiny wood is used.
</p>
<p>
Texture maps may be nested to any level of complexity you desire. The textures in a map may have color maps or
texture maps or any type of texture you want.
</p>
<p>
The blended area of a texture map works by fully calculating both contributing textures in their entirety and then
linearly interpolating the apparent colors. This means that reflection, refraction and lighting calculations are done
twice for every point. This is in contrast to using a pigment map and a normal map in a plain texture, where the
pigment is computed, then the normal, then reflection, refraction and lighting are calculated once for that point.
</p>
<p>
Entire textures may also be used with the block patterns such as <code> checker</code>, <code>hexagon</code> and <code>brick</code>.
For example...
</p>
<pre>
texture {
checker
texture { T_Wood12 scale .8 }
texture {
pigment { White_Marble }
finish { Shiny }
scale .5
}
}
}
</pre>
<p class="Note">
<strong>Note:</strong> that in the case of block patterns the <code>texture</code> wrapping is
required around the texture information. Also note that this syntax prohibits the use of a layered texture however you
can work around this by declaring a texture identifier for the layered texture and referencing the identifier.
</p>
<p>
A texture map is also used with the <code> average</code> texture type. See "Average" for details.
</p>
<p>
You may declare and use texture map identifiers but the only way to declare a texture block pattern list is to
declare a texture identifier for the entire texture.
</p>
<h4><a name="s03_05_05_02">3.5.5.2 </a>Tiles</h4>
<a name="s03_05_05_02_i1"><a name="tile2"></a><a name="s03_05_05_02_i2"><a name="tiles"></a>
<p>
Earlier versions of POV-Ray had a patterned texture called a <em>tiles texture</em>. It used the <code>tiles</code>
and <code>tile2</code> keywords to create a checkered pattern of textures.
</p>
<pre>
TILES_TEXTURE:
texture
{
tiles TEXTURE tile2 TEXTURE
[TRANSFORMATIONS...]
}
</pre>
<p>
Although it is still supported for backwards compatibility you should use a <code>checker</code> block texture
pattern described in section "Texture Maps" rather than tiles textures.
</p>
<h4><a name="s03_05_05_03">3.5.5.3 </a>Material Maps</h4>
<a name="s03_05_05_03_i1"><a name="material_map"></a>
<p>
The <code>material_map</code> patterned texture extends the concept of image maps to apply to entire textures
rather than solid colors. A material map allows you to wrap a 2-D bit-mapped texture pattern around your 3-D objects.
</p>
<p>
Instead of placing a solid color of the image on the shape like an image map, an entire texture is specified based
on the index or color of the image at that point. You must specify a list of textures to be used like a <em> texture
palette</em> rather than the usual color palette.
</p>
<p>
When used with mapped file types such as GIF, and some PNG and TGA images, the index of the pixel is used as an
index into the list of textures you supply. For unmapped file types such as some PNG and TGA images the 8 bit value of
the red component in the range 0-255 is used as an index.
</p>
<p>
If the index of a pixel is greater than the number of textures in your list then the index is taken modulo N where
N is the length of your list of textures.
</p>
<p class="Note">
<strong>Note:</strong> The <code> material_map</code> statement has nothing to do with the <code>
material</code> statement. A <code>material_map</code> is <em> not</em> a way to create patterned <code>material</code>.
See "<a href="#l145">Material</a>" for explanation of this unrelated, yet similarly named, older feature.
</p>
<h5><a name="s03_05_05_03_01">3.5.5.3.1 </a>Specifying a Material Map</h5>
<p>
The syntax for a <code>material_map</code> is:
</p>
<pre>
MATERIAL_MAP:
texture
{
material_map
{
BITMAP_TYPE "bitmap.ext"
[BITMAP_MODS...] TEXTURE... [TRANSFORMATIONS...]
}
}
BITMAP_TYPE:
gif | tga | iff | ppm | pgm | png | jpeg | tiff | sys
BITMAP_MOD:
map_type Type | once | interpolate Type
</pre>
<p>
After the required <em>BITMAP_TYPE</em> keyword is a string expression containing the name of a bitmapped material
file of the specified type. Several optional modifiers may follow the file specification. The modifiers are described
below.
</p>
<p class="Note">
<strong>Note:</strong> earlier versions of POV-Ray allowed some modifiers before the <em>BITMAP_TYPE</em>
but that syntax is being phased out in favor of the syntax described here.
</p>
<p class="Note">
<strong>Note:</strong> <code>sys</code> format is a system-specific format such as BMP for Windows or
Pict for Macintosh.
</p>
<p>
Filenames specified in the <code>material_map</code> statements will be searched for in the home (current)
directory first and, if not found, will then be searched for in directories specified by any <code> +L</code> or <code>Library_Path</code>
options active. This would facilitate keeping all your material maps files in a separate subdirectory and giving a <code>
Library_Path</code> option to specify where your library of material maps are. See "<a href="s_95.html#s03_01_02_05_04">Library
Paths</a>" for details.
</p>
<p>
By default, the material is mapped onto the x-y-plane. The material is <em> projected</em> onto the object as
though there were a slide projector somewhere in the -z-direction. The material exactly fills the square area from
(x,y) coordinates (0,0) to (1,1) regardless of the material's original size in pixels. If you would like to change
this default you may translate, rotate or scale the texture to map it onto the object's surface as desired.
</p>
<p>
The file name is optionally followed by one or more <em> BITMAP_MODIFIERS</em>. There are no modifiers which are
unique to a <code> material_map</code>. It only uses the generic bitmap modifiers <code> map_type</code>, <code>once</code>
and <code> interpolate</code> described in "Bitmap Modifiers".
</p>
<p>
Although <code> interpolate</code> is legal in material maps, the color index is interpolated before the texture is
chosen. It does not interpolate the final color as you might hope it would. In general, interpolation of material maps
serves no useful purpose but this may be fixed in future versions.
</p>
<p>
Next is one or more <code>texture</code> statements. Each texture in the list corresponds to an index in the bitmap
file. For example:
</p>
<pre>
texture {
material_map {
png "povmap.png"
texture { //used with index 0
pigment {color red 0.3 green 0.1 blue 1}
normal {ripples 0.85 frequency 10 }
finish {specular 0.75}
scale 5
}
texture { //used with index 1
pigment {White}
finish {
ambient 0 diffuse 0
reflection 0.9 specular 0.75
}
}
// used with index 2
texture {pigment{NeonPink} finish{Luminous}}
texture { //used with index 3
pigment {
gradient y
color_map {
[0.00 rgb < 1 , 0 , 0>]
[0.33 rgb < 0 , 0 , 1>]
[0.66 rgb < 0 , 1 , 0>]
[1.00 rgb < 1 , 0 , 0>]
}
}
finish{specular 0.75}
scale 8
}
}
scale 30
translate <-15, -15, 0>
}
</pre>
<p>
After a <code>material_map</code> statement but still inside the texture statement you may apply any legal texture
modifiers.
</p>
<p class="Note">
<strong>Note:</strong> no other pigment, normal, or finish statements may be added to the texture
outside the material map.
</p>
<p>
The following is illegal:
</p>
<pre>
texture {
material_map {
gif "matmap.gif"
texture {T1}
texture {T2}
texture {T3}
}
finish {phong 1.0}
}
</pre>
<p>
The finish must be individually added to each texture. Earlier versions of POV-Ray allowed such specifications but
they were ignored. The above restrictions on syntax were necessary for various bug fixes. This means some POV-Ray 1.0
scenes using material maps many need minor modifications that cannot be done automatically with the version
compatibility mode.
</p>
<p>
If particular index values are not used in an image then it may be necessary to supply dummy textures. It may be
necessary to use a paint program or other utility to examine the map file's palette to determine how to arrange the
texture list.
</p>
<p>
The textures within a material map texture may be layered but material map textures do not work as part of a
layered texture. To use a layered texture inside a material map you must declare it as a texture identifier and invoke
it in the texture list.
</p>
<p>
<a name="l145">
<small><strong>More about "Material"</strong></small>
</a>
<ul>
<li><small>
<a href="s_113.html#s03_04_09_03">3.4.9.3 Material</a> in 3.4.9 Object Modifiers
</small>
<li><small>
<a href="s_161.html#s03_08_09_02">3.8.9.2 Material</a> in 3.8.9 Object Modifiers
</small>
</ul>
</p>
<br>
<table class="NavBar" width="100%">
<tr>
<td align="left" nowrap="" valign="middle" width="32">
<a href="s_118.html"><img alt="previous" border="0" src="prev.png"></a>
</td>
<td align="left" valign="middle" width="30%">
<a href="s_118.html">3.5.4 Halo</a>
</td>
<td align="center" valign="middle">
<strong>3.5.5 Patterned Textures</strong>
</td>
<td align="right" valign="middle" width="30%">
<a href="s_120.html">3.5.6 Layered Textures</a>
</td>
<td align="right" nowrap="" valign="middle" width="32">
<a href="s_120.html"><img alt="next" border="0" src="next.png"></a>
</td>
</tr>
</table>
</body> </html>
|