|
If it is not necessary for light beams to interact with atmospheric media,
then fog
may be a faster way to simulate haze or fog. This
feature artificially adds color to every pixel based on the distance the ray
has traveled. The syntax for fog is:
FOG: fog { [FOG_IDENTIFIER] [FOG_ITEMS...] } FOG_ITEMS: fog_type Fog_Type | distance Distance | COLOR | turbulence <Turbulence> | turb_depth Turb_Depth | omega Omega | lambda Lambda | octaves Octaves | fog_offset Fog_Offset | fog_alt Fog_Alt | up <Fog_Up> | TRANSFORMATION
lambda : 2.0 fog_type : 1 fog_offset : 0.0 fog_alt : 0.0 octaves : 6 omega : 0.5 turbulence : <0,0,0> turb_depth : 0.5 up : <0,1,0>
Currently there are two fog types, the default fog_type 1
is
a constant fog and fog_type 2
is ground fog. The constant fog
has a constant density everywhere while the ground fog has a constant density
for all heights below a given point on the up axis and thins out along this
axis.
The color of a pixel with an intersection depth d is calculated by
PIXEL_COLOR = exp(-d/D) * OBJECT_COLOR + (1-exp(-d/D)) * FOG_COLOR
where D is the specified value of the required fog distance
keyword. At depth 0 the final color is the object's color. If the
intersection depth equals the fog distance the final color consists of 64%
of the object's color and 36% of the fog's color.
Note: for this equation, a distance of zero is undefined. In practice, povray will treat this value as "fog is off". To use an extremely thick fog, use a small nonzero number such as 1e-6 or 1e-10.
For ground fog, the height below which the fog has constant density is
specified by the fog_offset
keyword. The fog_alt
keyword is used to specify the rate by which the fog fades away. The default
values for both are 0.0 so be sure to specify them if ground fog is used. At
an altitude of Fog_Offset+Fog_Alt
the fog has a
density of 25%. The density of the fog at height less than or equal to
Fog_Offset is 1.0 and for height larger than than Fog_Offset
is calculated by:
1/(1 + (y - Fog_Offset) / Fog_Alt) ^2
The total density along a ray is calculated by integrating from the height of the starting point to the height of the end point.
The optional up
vector specifies a direction pointing up,
generally the same as the camera's up vector. All calculations done
during the ground fog evaluation are done relative to this up vector, i. e.
the actual heights are calculated along this vector. The up vector can also
be modified using any of the known transformations described in
"Transformations". Though it may not be a good idea to scale the up
vector - the results are hardly predictable - it is quite useful to be able
to rotate it. You should also note that translations do not affect the up
direction (and thus don't affect the fog).
The required fog color has three purposes. First it defines the color to be used in blending the fog and the background. Second it is used to specify a translucency threshold. By using a transmittance larger than zero one can make sure that at least that amount of light will be seen through the fog. With a transmittance of 0.3 you'll see at least 30% of the background. Third it can be used to make a filtering fog. With a filter value larger than zero the amount of background light given by the filter value will be multiplied with the fog color. A filter value of 0.7 will lead to a fog that filters 70% of the background light and leaves 30% unfiltered.
Fogs may be layered. That is, you can apply as many layers of fog as you like. Generally this is most effective if each layer is a ground fog of different color, altitude and with different turbulence values. To use multiple layers of fogs, just add all of them to the scene.
You may optionally stir up the fog by adding turbulence. The turbulence
keyword may be followed by a float or vector to specify an amount of
turbulence to be used. The omega
, lambda
and
octaves
turbulence parameters may also be specified. See
section "Pattern Modifiers" for details on all of these
turbulence parameters.
Additionally the fog turbulence may be scaled along the direction of the
viewing ray using the turb_depth
amount. Typical values are from
0.0 to 1.0 or more. The default value is 0.5 but any float value may be
used.
Note: the fog feature will not work if the camera is inside a non-hollow object (see section "Empty and Solid Objects" for a detailed explanation).
|