If sphere is set to TRUE
, an environmental sphere enclosing the whole scene is drawn.
If not, but the material properties include a bitmap as a texture, the bitmap is drawn in the
background of the scene. (The bitmap colors modify the general color setting.)
If neither a sphere nor a bitmap background is drawn, the background is filled with a
solid color.
The fogScale
parameter should be a positive value
to change the density of the fog in the plot. For
fogtype = "linear"
it multiplies the density of the
fog; for the exponential fog types it multiplies the density
parameter used in the display.
See
the OpenGL 2.1 reference
for the formulas used in the fog calculations within R (though the
"exp2"
formula appears to be wrong, at least on my
system). In WebGL displays,
the following rules are used. They appear to match the
rules used in R on my system.
For "linear"
fog, the near clipping plane is
taken as \(c=0\), and the
far clipping plane is taken as \(c=1\). The
amount of fog is \(s * c\) clamped to a 0 to 1
range, where \(s = fogScale\).
For "exp"
and "exp2"
fog, the observer location
is negative at a distance depending on the field of view.
The formula for the distance is
$$c = [1-sin(theta)]/[1 + sin(theta)]$$
where \(theta = FOV/2\).
We calculate $$c' = d(1-c) + c$$
so \(c'\) runs from 0 at the observer to
1 at the far clipping plane.
For "exp"
fog, the amount of fog is
\(1 - exp(-s * c')\).
For "exp2"
fog, the amount of fog is
\(1 - exp[-(s * c')^2]\).