| 12
 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
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 
 | 
<!--  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.6.2 Media</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_128.html"><img alt="previous" border="0" src="prev.png"></a> 
   
  </td>
   
  <td align="left" valign="middle" width="30%">
    <a href="s_128.html">3.6.1 Interior</a> 
  </td>
   
  <td align="center" valign="middle">
    <strong class="NavBar">POV-Ray 3.6 for UNIX documentation</strong><br> <strong>3.6.2 
   Media</strong> 
  </td>
   
  <td align="right" valign="middle" width="30%">
    <a href="s_130.html">3.6.3 Photons</a> 
  </td>
   
  <td align="right" nowrap="" valign="middle" width="32">
    <a href="s_130.html"><img alt="next" border="0" src="next.png"></a> 
   
  </td>
   
 </tr>
  
</table>
 
<h3><a name="s03_06_02">3.6.2 </a>Media</h3>
<a name="s03_06_02_i1"><a name="atmosphere"></a><a name="s03_06_02_i2">
<p>
  The <code>media</code> statement is used to specify particulate matter suspended in a medium such air or water. It 
 can be used to specify smoke, haze, fog, gas, fire, dust etc. Previous versions of POV-Ray had two incompatible 
 systems for generating such effects. One was <code>halo</code> for effects enclosed in a transparent or 
 semi-transparent object. The other was <code>atmosphere</code> for effects that permeated the entire scene. This 
 duplication of systems was complex and unnecessary. Both <code> halo</code> and <code>atmosphere</code> have been 
 eliminated. See "<a href="s_128.html#s03_06_01_01">Why are Interior and Media Necessary?</a>" for further 
 details on this change. See "<a href="s_128.html#s03_06_01_08">Object Media</a>" for details on how to use <code>media</code> 
 with objects. See "<a href="s_101.html#s03_03_02_01">Atmospheric Media</a>" for details on using <code>media</code> 
 for atmospheric effects outside of objects. This section and the sub-sections which follow explains the details of the 
 various <code> media</code> options which are useful for either object media or atmospheric media. 
</p>
<p>
  Media works by sampling the density of particles at some specified number of points along the ray's path. 
 Sub-samples are also taken until the results reach a specified confidence level. POV-Ray provides three methods of 
 sampling. When used in an object's <code> interior</code> statement, sampling only occurs inside the object. When used 
 for atmospheric media, the samples run from the camera location until the ray strikes an object. Therefore for 
 localized effects, it is best to use an enclosing object even though the density pattern might only produce results in 
 a small area whether the media was enclosed or not. 
</p>
<p>
  The complete syntax for a <code>media</code> statement is as follows:<a name="s03_06_02_i3"><a name="media"></a><a name="s03_06_02_i4"><a name="media, keyword"></a><a name="s03_06_02_i5"><a name="s03_06_02_i6"><a name="method, media"></a><a name="s03_06_02_i7"><a name="s03_06_02_i8"><a name="intervals, media"></a><a name="s03_06_02_i9"><a name="s03_06_02_i10"><a name="samples, media"></a><a name="s03_06_02_i11"><a name="s03_06_02_i12"><a name="confidence, media"></a><a name="s03_06_02_i13"><a name="s03_06_02_i14"><a name="variance, media"></a><a name="s03_06_02_i15"><a name="s03_06_02_i16"><a name="ratio, media"></a><a name="s03_06_02_i17"><a name="s03_06_02_i18"><a name="absorption, media"></a><a name="s03_06_02_i19"><a name="s03_06_02_i20"><a name="emission, media"></a><a name="s03_06_02_i21"><a name="s03_06_02_i22"><a name="aa_threshold, media"></a><a name="s03_06_02_i23"><a name="s03_06_02_i24"><a name="aa_level, media"></a><a name="s03_06_02_i25"><a name="s03_06_02_i26"><a name="scattering, media"></a><a name="s03_06_02_i27"><a name="s03_06_02_i28"><a name="eccentricity, media"></a><a name="s03_06_02_i29"><a name="s03_06_02_i30"><a name="extinction, media"></a><a name="s03_06_02_i31"><a name="s03_06_02_i32"><a name="density, media"></a><a name="s03_06_02_i33"> 
 
</p>
<pre>
MEDIA:
    media { [MEDIA_IDENTIFIER] [MEDIA_ITEMS...] }
MEDIA_ITEMS:
    method Number | intervals Number | samples Min, Max |
    confidence Value  | variance Value | ratio Value |
    absorption COLOR | emission COLOR | aa_threshold Value |
    aa_level Value | 
    scattering { 
       Type, COLOR [ eccentricity Value ] [ extinction Value ]
    }  | 
    density { 
       [DENSITY_IDENTIFIER] [PATTERN_TYPE] [DENSITY_MODIFIER...]
    }   | 
    TRANSFORMATIONS
DENSITY_MODIFIER:
    PATTERN_MODIFIER | DENSITY_LIST | COLOR_LIST |
    color_map { COLOR_MAP_BODY } | colour_map { COLOR_MAP_BODY } |
    density_map { DENSITY_MAP_BODY }
</pre>
<p>
  Media default values: <a name="s03_06_02_i34"> 
</p>
<pre>
aa_level     : 4
aa_threshold : 0.1
absorption   : <0,0,0>
confidence   : 0.9
emission     : <0,0,0>
intervals    : 10
method       : 3
ratio        : 0.9
samples      : Min 1, Max 1
variance     : 1/128
SCATTERING
  COLOR        : <0,0,0>
  eccentricity : 0.0
  extinction   : 1.0
</pre>
<p>
  If a media identifier is specified, it must be the first item. All other media items may be specified in any order. 
 All are optional. You may have multiple <code>density</code> statements in a single <code>media</code> statement. See 
 "<a href="s_129.html#s03_06_02_03_04">Multiple Density vs. Multiple Media</a>" for details. Transformations 
 apply only the <code>density</code> statements which have been already specified. Any <code>density</code> after a 
 transformation is not affected. If the <code>media</code> has no <code>density</code> statements and none was 
 specified in any media identifier, then the transformation has no effect. All other media items except for <code> 
 density</code> and transformations override default values or any previously set values for this <code>media</code> 
 statement. 
</p>
<p class="Note">
  <strong>Note:</strong> some media effects depend upon light sources. However the participation of a 
 light source depends upon the <code>media_interaction</code> and <code>media_attenuation</code> keywords. See "<a href="s_111.html#s03_04_07_10">Atmospheric 
 Media Interaction</a>" and "<a href="s_111.html#s03_04_07_11">Atmospheric Attenuation</a>" for details. 
</p>
<p class="Note">
  <strong>Note:</strong> In the POV-Ray 3.1 documentation it said: "Note a strange design 
 side-effect was discovered during testing and it was too difficult to fix. If the enclosing object uses <code><a href="s_97.html#s03_02_01_05">transmit</a></code> 
 rather than <code><a href="s_97.html#s03_02_01_05">filter</a></code> for transparency, then the <code>media</code> 
 casts no shadows." This is not the case anymore since POV-Ray 3.5. Whether you specify <code>transmit</code> or <code>filter</code> 
 to create a transparent container object, the <code>media</code> will always cast a shadow. If a shadow is not 
 desired, use the <code>no_shadow</code> keyword for the container object. 
</p>
<h4><a name="s03_06_02_01">3.6.2.1 </a>Media Types</h4>
<a name="s03_06_02_01_i1">
<p>
  There are three types of particle interaction in <code>media</code>: absorbing, emitting, and scattering. All three 
 activities may occur in a single media. Each of these three specifications requires a color. Only the red, green, and 
 blue components of the color are used. The filter and transmit values are ignored. For this reason it is permissible 
 to use one float value to specify an intensity of white color. For example the following two lines are legal and 
 produce the same results: 
</p>
<pre>
  emission 0.75
  emission rgb<0.75,0.75,0.75>
</pre>
<h5><a name="s03_06_02_01_01">3.6.2.1.1 </a>Absorption</h5>
<p>
  The <code>absorption</code> keyword specifies a color of light which is absorbed when looking through the media. 
 For example <code>absorption rgb<0,1,0></code> blocks the green light but permits red and blue to get through. 
 Therefore a white object behind the media will appear magenta. 
</p>
<p>
  The default value is <code>rgb<0,0,0></code> which means no light is absorbed -- all light passes through 
 normally. 
</p>
<h5><a name="s03_06_02_01_02">3.6.2.1.2 </a>Emission</h5>
<a name="s03_06_02_01_02_i1"><a name="emission"></a>
<p>
  The <code>emission</code> keyword specifies a color of the light emitted from the particles. Although we say they 
 "emit" light, this only means that they are visible without any illumination shining on them. They do not 
 really emit light that is cast on to nearby objects. This is similar to an object with high <code>ambient</code> 
 values. The default value is <code> rgb<0,0,0></code> which means no light is emitted. 
</p>
<h5><a name="s03_06_02_01_03">3.6.2.1.3 </a>Scattering</h5>
<a name="s03_06_02_01_03_i1"><a name="scattering"></a>
<p>
  The syntax of a <code>scattering</code> statement is: 
</p>
<pre>
SCATTERING:
    scattering { 
        Type, COLOR [ eccentricity Value ] [ extinction Value ] 
    }
</pre>
<p>
  The first float value specifies the type of scattering. This is followed by the color of the scattered light. The 
 default value if no <code> scattering</code> statement is given is <code>rgb<0,0,0></code> which means no 
 scattering occurs. 
</p>
<p>
  <a name="s03_06_02_01_03_i2"><a name="extinction"></a> <a name="s03_06_02_01_03_i3"><a name="absorption"></a> The 
 scattering effect is only visible when light is shining on the media from a light source. This is similar to <code>diffuse</code> 
 reflection off of an object. In addition to reflecting light, a scattering media also absorbs light like an <code> 
 absorption</code> media. The balance between how much absorption occurs for a given amount of scattering is controlled 
 by the optional <code> extinction</code> keyword and a single float value. The default value of 1.0 gives an 
 extinction effect that matches the scattering. Values such as <code>extinction 0.25</code> give 25% the normal amount. 
 Using <code> extinction 0.0</code> turns it off completely. Any value other than the 1.0 default is contrary to the 
 real physical model but decreasing extinction can give you more artistic flexibility. 
</p>
<p>
  The integer value <em><code> Type</code></em> specifies one of five different scattering phase functions 
 representing the different models: isotropic, Mie (haze and murky atmosphere), Rayleigh, and Henyey-Greenstein. 
</p>
<p>
  Type 1, <em>isotropic scattering</em> is the simplest form of scattering because it is independent of direction. 
 The amount of light scattered by particles in the atmosphere does not depend on the angle between the viewing 
 direction and the incoming light. 
</p>
<p>
  Types 2 and 3 are <em>Mie haze</em> and <em>Mie murky</em> scattering which are used for relatively small particles 
 such as minuscule water droplets of fog, cloud particles, and particles responsible for the polluted sky. In this 
 model the scattering is extremely directional in the forward direction i.e. the amount of scattered light is largest 
 when the incident light is anti-parallel to the viewing direction (the light goes directly to the viewer). It is 
 smallest when the incident light is parallel to the viewing direction. The haze and murky atmosphere models differ in 
 their scattering characteristics. The murky model is much more directional than the haze model. 
</p>
<p>
  <br><center><img alt="The Mie haze scattering function" src="images/reference/miehaze.png"></center> 
</p>
<p>
  <br><center><img alt="The Mie murky scattering function." src="images/reference/miemurky.png"></center> 
</p>
<p>
  Type 4 <em>Rayleigh scattering</em> models the scattering for extremely small particles such as molecules of the 
 air. The amount of scattered light depends on the incident light angle. It is largest when the incident light is 
 parallel or anti-parallel to the viewing direction and smallest when the incident light is perpendicular to the 
 viewing direction. You should note that the Rayleigh model used in POV-Ray does not take the dependency of scattering 
 on the wavelength into account. 
</p>
<p>
  <br><center><img alt="The Rayleigh scattering function." src="images/reference/raylscat.png"></center> <a name="s03_06_02_01_03_i4"><a name="eccentricity"></a> 
 
</p>
<p>
  Type 5 is the <em>Henyey-Greenstein scattering</em> model. It is based on an analytical function and can be used to 
 model a large variety of different scattering types. The function models an ellipse with a given eccentricity e. This 
 eccentricity is specified by the optional keyword <code> eccentricity</code> which is only used for scattering type 
 five. The default eccentricity value of zero defines isotropic scattering while positive values lead to scattering in 
 the direction of the light and negative values lead to scattering in the opposite direction of the light. Larger 
 values of e (or smaller values in the negative case) increase the directional property of the scattering. 
</p>
<p>
  <br><center><img alt="The Henyey-Greenstein scattering function for different eccentricity values." src="images/reference/hgscatt.png"></center> 
 
</p>
<h4><a name="s03_06_02_02">3.6.2.2 </a>Sampling Parameters & Methods</h4>
<a name="s03_06_02_02_i1"><a name="intervals"></a>
<p>
  Media effects are calculated by sampling the media along the path of the ray. It uses a method called <em>Monte 
 Carlo integration.</em> The <code>intervals</code> keyword may be used to specify the integer number of intervals used 
 to sample the ray. The default number of intervals is 10. For object media the intervals are spread between the entry 
 and exit points as the ray passes through the container object. For atmospheric media, the intervals spans the entire 
 length of the ray from its start until it hits an object. For media types which interact with spotlights or cylinder 
 lights, the intervals which are not illuminated by these light types are weighted differently than the illuminated 
 intervals when distributing samples.<a name="s03_06_02_02_i2"><a name="ratio"></a> 
</p>
<p>
  The <code>ratio</code> keyword distributes intervals differently between lit and unlit areas. The default value of <code>ratio 
 0.9</code> means that lit intervals get more samples than unlit intervals. Note that the total number of intervals 
 must exceed the number of illuminated intervals. If a ray passes in and out of 8 spotlights but you have only 
 specified 5 intervals then an error occurs.<a name="s03_06_02_02_i3"><a name="samples"></a> 
</p>
<p>
  The <code>samples</code> <em><code>Min</code></em>, <em><code> Max</code></em> keyword specifies the minimum and 
 maximum number of samples taken per interval. The default values are <code>samples 1,1</code>. <a name="s03_06_02_02_i4"><a name="s03_06_02_02_i5"> 
 
</p>
<p>
  As each interval is sampled, the variance is computed. If the variance is below a threshold value, then no more 
 samples are needed. The <code>variance</code> and <code>confidence</code> keywords specify the permitted variance 
 allowed and the confidence that you are within that variance. The exact calculations are quite complex and involve 
 chi-squared tests and other statistical principles too messy to describe here. The default values are <code>variance 
 1.0/128</code> and <code>confidence 0.9</code>. For slower more accurate results, decrease the variance and increase 
 the confidence. 
</p>
<p class="Note">
  <strong>Note:</strong> the maximum number of samples limits the calculations even if the proper 
 variance and confidence are never reached.<a name="s03_06_02_02_i6"><a name="method"></a> 
</p>
<p>
  The <code>method</code> keyword lets you specify what sampling method is used, POV-Ray provides three. <code>Method 
 1</code> is the method described above. 
</p>
<p>
  Sample <code>method 2</code> distributes samples evenly along the viewing ray or light ray. The latter can make 
 things look smoother sometimes. If you specify a max samples higher than the minimum samples, POV will take additional 
 samples, but they will be random, just like in method 1. Therefore, it is suggested you set the max samples equal to 
 the minimum samples. <code>jitter</code> will cause method 2 to look similar to method 1. It should be followed by a 
 float, and a value of 1 will stagger the samples in the full range between samples.<a name="s03_06_02_02_i7"><a name="aa_level"></a><a name="s03_06_02_02_i8"><a name="aa_threshold"></a> 
 
</p>
<p>
  Sample <code>method 3</code> uses adaptive sampling (similar to adaptive anti-aliasing) which is very much like the 
 sampling method used in POV-Ray 3.0's atmosphere. This code was written from the ground-up to work with media, 
 however. Adaptive sampling works by taking another sample between two existing samples if there is too much variance 
 in the original two samples. This leads to fewer samples being taken in areas where the effect from the media remains 
 constant. The adaptive sampling is only performed if the minimum samples are set to 3 or more. 
</p>
<p>
  You can specify the anti-aliasing recursion depth using the <code>aa_level</code> keyword followed by an integer. 
 You can specify the anti-aliasing threshold by using the <code>aa_threshold</code> followed by a float. The default 
 for <code>aa_level</code> is 4 and the default <code>aa_threshold</code> is 0.1. <code>jitter</code> also works with 
 method 3. Sample method 3 ignores the maximum samples value. It is usually best to only use one interval with method 
 3. Too many intervals can lead to artefacts, and POV will create more intervals if it needs them. 
</p>
<h4><a name="s03_06_02_03">3.6.2.3 </a>Density</h4>
<a name="s03_06_02_03_i1">
<p>
  Particles of media are normally distributed in constant density throughout the media. However the <code>density</code> 
 statement allows you to vary the density across space using any of POV-Ray's pattern functions such as those used in 
 textures. If no <code>density</code> statement is given then the density remains a constant value of 1.0 throughout 
 the media. More than one <code>density</code> may be specified per <code>media</code> statement. See "<a href="s_129.html#s03_06_02_03_04">Multiple 
 Density vs. Multiple Media</a>". The syntax for <code>density</code> is: 
</p>
<pre>
DENSITY:
    density
    {
        [DENSITY_IDENTIFIER]
        [DENSITY_TYPE]
        [DENSITY_MODIFIER...]
    }
DENSITY_TYPE:
    PATTERN_TYPE | COLOR 
DENSITY_MODIFIER:
    PATTERN_MODIFIER | DENSITY_LIST | color_map { COLOR_MAP_BODY } |
    colour_map { COLOR_MAP_BODY } | density_map { DENSITY_MAP_BODY }
</pre>
<p>
  The <code>density</code> statement may begin with an optional density identifier. All subsequent values modify the 
 defaults or the values in the identifier. The next item is a pattern type. This is any one of POV-Ray's pattern 
 functions such as <code><a href="s_125.html#s03_05_11_04">bozo</a></code>, <code><a href="#l160">wood</a></code>, <code><a href="#l161">gradient</a></code>, 
 <code><a href="s_125.html#s03_05_11_35">waves</a></code>, etc. Of particular usefulness are the <code><a href="s_125.html#s03_05_11_31">spherical</a></code>, 
 <code><a href="s_125.html#s03_05_11_26">planar</a></code>, <code> <a href="s_125.html#s03_05_11_10">cylindrical</a></code>, 
 and <code><a href="s_125.html#s03_05_11_03">boxed</a></code> patterns which were previously available only for use 
 with our discontinued <code>halo</code> feature. All patterns return a value from 0.0 to 1.0. This value is 
 interpreted as the density of the media at that particular point. See "<a href="s_125.html#s03_05_11">Patterns</a>" 
 for details on particular pattern types. Although a solid <em>COLOR</em> pattern is legal, in general it is used only 
 when the <code>density</code> statement is inside a <code>density_map</code>. 
</p>
<h5><a name="s03_06_02_03_01">3.6.2.3.1 </a>General Density Modifiers</h5>
<p>
  A <code>density</code> statement may be modified by any of the general pattern modifiers such as transformations, <code>turbulence</code> 
 and <code> warp</code>. See "<a href="#l162">Pattern Modifiers</a>" for details. In addition there are 
 several density-specific modifiers which can be used. 
</p>
<h5><a name="s03_06_02_03_02">3.6.2.3.2 </a>Density with color_map</h5>
<a name="s03_06_02_03_02_i1">
<p>
  Typically a <code>media</code> uses just one constant color throughout. Even if you vary the density, it is usually 
 just one color which is specified by the <code>absorption</code>, <code>emission</code>, or <code> scattering</code> 
 keywords. However when using <code>emission</code> to simulate fire or explosions, the center of the flame (high 
 density area) is typically brighter and white or yellow. The outer edge of the flame (less density) fades to orange, 
 red, or in some cases deep blue. To model the density-dependent change in color which is visible, you may specify a <code> 
 color_map</code>. The pattern function returns a value from 0.0 to 1.0 and the value is passed to the color map to 
 compute what color or blend of colors is used. See "<a href="s_115.html#s03_05_01_03">Color Maps</a>" for 
 details on how pattern values work with <code>color_map</code>. This resulting color is multiplied by the <code> 
 absorption</code>, <code>emission</code> and <code> scattering</code> color. Currently there is no way to specify 
 different color maps for each media type within the same <code>media</code> statement. 
</p>
<p>
  Consider this example: 
</p>
<pre>
  media{
    emission 0.75
    scattering {1, 0.5}
    density { spherical
      color_map {
        [0.0 rgb <0,0,0.5>]
        [0.5 rgb <0.8, 0.8, 0.4>]
        [1.0 rgb <1,1,1>]
      }
    }
  }
</pre>
<p>
  The color map ranges from white at density 1.0 to bright yellow at density 0.5 to deep blue at density 0. Assume we 
 sample a point at density 0.5. The emission is 0.75*<0.8,0.8,0.4> or <0.6,0.6,0.3>. Similarly the 
 scattering color is 0.5*<0.8,0.8,0.4> or <0.4,0.4,0.2>. 
</p>
<p>
  For block pattern types <code>checker</code>, <code> hexagon</code>, and <code> brick</code> you may specify a 
 color list such as this: 
</p>
<pre>
  density{
    checker 
    density {rgb<1,0,0>}
    density {rgb<0,0,0>}
  }
</pre>
<p>
  See "<a href="s_115.html#s03_05_01_02">Color List Pigments</a>" which describes how <code>pigment</code> 
 uses a color list. The same principles apply when using them with <code>density</code>. 
</p>
<h5><a name="s03_06_02_03_03">3.6.2.3.3 </a>Density Maps and Density Lists</h5>
<a name="s03_06_02_03_03_i1"><a name="density_map"></a>
<p>
  In addition to specifying blended colors with a color map you may create a blend of densities using a <code>density_map</code>. 
 The syntax for a density map is identical to a color map except you specify a density in each map entry (and not a 
 color). 
</p>
<p>
  The syntax for <code>density_map</code> is as follows: 
</p>
<pre>
DENSITY_MAP:
    density_map { DENSITY_MAP_BODY }
DENSITY_MAP_BODY:
    DENSITY_MAP_IDENTIFIER | DENSITY_MAP_ENTRY...
DENSITY_MAP_ENTRY:
    [ Value DENSITY_BODY ]
</pre>
<p>
  Where <em><code>Value</code></em> is a float value between 0.0 and 1.0 inclusive and each <em>DENSITY_BODY</em> is 
 anything which can be inside a <code>density{...}</code> statement. The <code>density</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> DENSITY_MAP_ENTRY</em>. 
 They are not notational symbols denoting optional parts. The brackets surround each entry in the density map. 
</p>
<p>
  There may be from 2 to 256 entries in the map. 
</p>
<p>
  Density maps may be nested to any level of complexity you desire. The densities in a map may have color maps or 
 density maps or any type of density you want. 
</p>
<p>
  Entire densities may also be used with the block patterns such as <code> checker</code>, <code>hexagon</code> and <code>brick</code>. 
 For example... 
</p>
<pre>
  density {
    checker
    density { Flame scale .8 }
    density { Fire scale .5 }
  }
</pre>
<p class="Note">
  <strong>Note:</strong> in the case of block patterns the <code>density</code> wrapping is required 
 around the density information. 
</p>
<p>
  A density map is also used with the <code>average</code> density type. See "<a href="s_125.html#s03_05_11_02">Average</a>" 
 for details. 
</p>
<p>
  You may declare and use density map identifiers but the only way to declare a density block pattern list is to 
 declare a density identifier for the entire density. 
</p>
<h5><a name="s03_06_02_03_04">3.6.2.3.4 </a>Multiple Density vs. Multiple Media</h5>
<p>
  It is possible to have more than one <code>media</code> specified per object and it is legal to have more than one <code>density</code> 
 per <code> media</code>. The effects are quite different. Consider this example: 
</p>
<pre>
  object {
    MyObject
    pigment { rgbf 1 }
    interior {
      media {
        density { Some_Density }
        density { Another_Density }
      }
    }
  }
</pre>
<p>
  As the media is sampled, calculations are performed for each density pattern at each sample point. The resulting 
 samples are multiplied together. Suppose one density returned <code>rgb<.8,.8,.4></code> and the other returned <code>rgb<.25,.25,0></code>. 
 The resulting color is <code> rgb<.2,.2,0></code>. 
</p>
<p class="Note">
  <strong>Note:</strong> in areas where one density returns zero, it will wipe out the other density. 
 The end result is that only density areas which overlap will be visible. This is similar to a CSG intersection 
 operation. Now consider 
</p>
<pre>
  object { 
    MyObject
    pigment { rgbf 1 }
    interior {
      media {
        density { Some_Density }
      }
      media {
        density { Another_Density }
      }
    }
  }
</pre>
<p>
  In this case each media is computed independently. The resulting colors are added together. Suppose one density and 
 media returned <code> rgb<.8,.8,.4></code> and the other returned <code> rgb<.25,.25,0></code>. The 
 resulting color is <code> rgb<1.05,1.05,.4></code>. The end result is that density areas which overlap will be 
 especially bright and all areas will be visible. This is similar to a <a href="#l163">CSG</a> <a href="s_110.html#s03_04_06_02">union</a> 
 operation. See the sample scene <code>scenes\interior\media\media4.pov</code> for an example which illustrates this. 
</p>
<p>
 <a name="l160">
<small><strong>More about "wood"</strong></small>
</a>
 <ul>
  
  <li><small>
   <a href="s_125.html#s03_05_11_36">3.5.11.36 Wood</a> in 3.5.11 Patterns
  </small>
  <li><small>
   <a href="s_148.html#s03_07_17_03">3.7.17.3 Woods</a> in 3.7.17 textures.inc
  </small>
 </ul>
</p>
<p>
 <a name="l161">
<small><strong>More about "gradient"</strong></small>
</a>
 <ul>
  
  <li><small>
   <a href="s_125.html#s03_05_11_17">3.5.11.17 Gradient</a> in 3.5.11 Patterns
  </small>
  <li><small>
   <a href="s_140.html#s03_07_09_03">3.7.9.3 Vector Analysis</a> in 3.7.9 math.inc
  </small>
 </ul>
</p>
<p>
 <a name="l162">
<small><strong>More about "Pattern Modifiers"</strong></small>
</a>
 <ul>
  
  <li><small>
   <a href="s_126.html#s03_05_12">3.5.12 Pattern Modifiers</a> in 3.5 Textures
  </small>
  <li><small>
   <a href="s_162.html#s03_08_10_08">3.8.10.8 Pattern Modifiers</a> in 3.8.10 Texture
  </small>
 </ul>
</p>
<p>
 <a name="l163">
<small><strong>More about "CSG"</strong></small>
</a>
 <ul>
  
  <li><small>
   <a href="s_110.html#s03_04_06">3.4.6 Constructive Solid Geometry</a> in 3.4 Objects
  </small>
  <li><small>
   <a href="s_160.html#s03_08_08_06">3.8.8.6 CSG</a> in 3.8.8 Objects
  </small>
 </ul>
</p>
 <br> 
<table class="NavBar" width="100%">
  
 <tr>
   
  <td align="left" nowrap="" valign="middle" width="32">
    <a href="s_128.html"><img alt="previous" border="0" src="prev.png"></a> 
   
  </td>
   
  <td align="left" valign="middle" width="30%">
    <a href="s_128.html">3.6.1 Interior</a> 
  </td>
   
  <td align="center" valign="middle">
    <strong>3.6.2 Media</strong> 
  </td>
   
  <td align="right" valign="middle" width="30%">
    <a href="s_130.html">3.6.3 Photons</a> 
  </td>
   
  <td align="right" nowrap="" valign="middle" width="32">
    <a href="s_130.html"><img alt="next" border="0" src="next.png"></a> 
   
  </td>
   
 </tr>
  
</table>
 </body> </html>
 |