Fog

from panda3d.core import Fog
class Fog

Bases: PandaNode

Specifies how atmospheric fog effects are applied to geometry. The Fog object is now a PandaNode, which means it can be used similarly to a Light to define effects relative to a particular coordinate system within the scene graph.

In exponential mode, the fog effects are always camera-relative, and it does not matter where the Fog node is parented. However, in linear mode, the onset and opaque distances are defined as offsets along the local forward axis (e.g. the Y axis). This allows the fog effect to be localized to a particular region in space, rather than always camera- relative. If the fog object is not parented to any node, it is used to generate traditonal camera-relative fog, as if it were parented to the camera.

Inheritance diagram

Inheritance diagram of Fog

enum Mode
enumerator M_linear = 0

f = (end - z) / (end - start)

enumerator M_exponential = 1

f = e^(-density * z)

enumerator M_exponential_squared = 2

f = e^((-density * z)^2)

__init__(name: str)
property colorLColor
Getter

Returns the color of the fog.

Setter

Sets the color of the fog.

Sets the color of the fog. The alpha component is not used.

property exp_densityfloat
Getter

Returns the density of the fog for exponential calculations. This is only used if the mode is not M_linear.

Setter

Sets the density of the fog for exponential calculations. This is only used if the mode is not M_linear.

If the mode is currently set to M_linear, this function implicitly sets it to M_exponential.

static getClassType()TypeHandle
getColor()LColor

Returns the color of the fog.

getExpDensity()float

Returns the density of the fog for exponential calculations. This is only used if the mode is not M_linear.

getLinearOnsetPoint()LPoint3

Returns the point in space at which the fog begins. This is only used if the mode is M_linear.

getLinearOpaquePoint()LPoint3

Returns the point in space at which the fog completely obscures geometry. This is only used if the mode is M_linear.

getMode() → Mode
property linear_onset_pointLPoint3
Getter

Returns the point in space at which the fog begins. This is only used if the mode is M_linear.

Setter

Specifies the point in space at which the fog begins. This is only used if the mode is M_linear.

Specifies the point in space at which the fog begins. This is only used if the mode is M_linear.

property linear_opaque_pointLPoint3
Getter

Returns the point in space at which the fog completely obscures geometry. This is only used if the mode is M_linear.

Setter

Specifies the point in space at which the fog completely obscures geometry. This is only used if the mode is M_linear.

Specifies the point in space at which the fog completely obscures geometry. This is only used if the mode is M_linear.

property mode → Mode

Getter Setter

Specifies the computation that is used to determine the fog effect. If this is M_linear, then the fog will range from linearly from the onset point to the opaque point (or for the distances specified in setLinearRange()), and the fog object should be parented into the scene graph, or to the camera.

If this is anything else, the onset point and opaque point are not used, and the fog effect is based on the value specified to setExpDensity(), and it doesn’t matter to which node the fog object is parented, or if it is parented anywhere at all.

setColor(color: LColor)None

Sets the color of the fog. The alpha component is not used.

setColor(r: float, g: float, b: float)None

Sets the color of the fog.

setExpDensity(exp_density: float)None

Sets the density of the fog for exponential calculations. This is only used if the mode is not M_linear.

If the mode is currently set to M_linear, this function implicitly sets it to M_exponential.

setLinearFallback(angle: float, onset: float, opaque: float)None

Fog effects are traditionally defined in camera-relative space, but the Panda Fog node has a special mode in which it can define a linear fog effect in an arbitrary coordinate space.

This is done by specifying 3-d onset and opaque points, and parenting the Fog object somewhere within the scene graph. In this mode, the fog will be rendered as if it extended along the vector from the onset point to the opaque point, in 3-d space.

However, the underlying fog effect supported by hardware is generally only one-dimensional, and must be rendered based on linear distance from the camera plane. Thus, this in-the-world effect is most effective when the fog vector from onset point to opaque point is most nearly parallel to the camera’s eye vector.

As the angle between the fog vector and the eye vector increases, the accuracy of the effect diminishes, up to a complete breakdown of the effect at a 90 degree angle.

This function exists to define the workaround to this problem. The linear fallback parameters given here specify how the fog should be rendered when the parameters are exceeded in this way.

The angle parameter is the minimum angle, in degrees, of the fog vector to the eye vector, at which the fallback effect should be employed. The onset and opaque parameters specify the camera-relative onset and opaque distances to pass to the rendering hardware when employing the fallback effect. This supercedes the 3-d onset point and opaque points.

setLinearOnsetPoint(linear_onset_point: LPoint3)None

Specifies the point in space at which the fog begins. This is only used if the mode is M_linear.

setLinearOnsetPoint(x: float, y: float, z: float)None

Specifies the point in space at which the fog begins. This is only used if the mode is M_linear.

setLinearOpaquePoint(linear_opaque_point: LPoint3)None

Specifies the point in space at which the fog completely obscures geometry. This is only used if the mode is M_linear.

setLinearOpaquePoint(x: float, y: float, z: float)None

Specifies the point in space at which the fog completely obscures geometry. This is only used if the mode is M_linear.

setLinearRange(onset: float, opaque: float)None

Specifies the effects of the fog in linear distance units. This is only used if the mode is M_linear.

This specifies a fog that begins at distance onset units from the origin, and becomes totally opaque at distance opaque units from the origin, along the forward axis (usually Y).

This function also implicitly sets the mode the M_linear, if it is not already set.

setMode(mode: Mode)None

Specifies the computation that is used to determine the fog effect. If this is M_linear, then the fog will range from linearly from the onset point to the opaque point (or for the distances specified in setLinearRange()), and the fog object should be parented into the scene graph, or to the camera.

If this is anything else, the onset point and opaque point are not used, and the fog effect is based on the value specified to setExpDensity(), and it doesn’t matter to which node the fog object is parented, or if it is parented anywhere at all.