DistanceFog

DistanceFog

  • color : bevy_color::color::Color
  • directional_light_color : bevy_color::color::Color
  • directional_light_exponent : f32
  • falloff : bevy_pbr::fog::FogFalloff

Description

Configures the “classic” computer graphics distance fog effect, in which objects appear progressively more covered in atmospheric haze the further away they are from the camera. Affects meshes rendered via the PBR StandardMaterial.

Falloff

The rate at which fog intensity increases with distance is controlled by the falloff mode. Currently, the following fog falloff modes are supported:

  • [FogFalloff::Linear]
  • [FogFalloff::Exponential]
  • [FogFalloff::ExponentialSquared]
  • [FogFalloff::Atmospheric]

Example

# use bevy_ecs::prelude::*;
# use bevy_render::prelude::*;
# use bevy_core_pipeline::prelude::*;
# use bevy_pbr::prelude::*;
# use bevy_color::Color;
# fn system(mut commands: Commands) {
commands.spawn((
    // Setup your camera as usual
    Camera3d::default(),
    // Add fog to the same entity
    DistanceFog {
        color: Color::WHITE,
        falloff: FogFalloff::Exponential { density: 1e-3 },
        ..Default::default()
    },
));
# }
# bevy_ecs::system::assert_is_system(system);

Material Override

Once enabled for a specific camera, the fog effect can also be disabled for individual StandardMaterial instances via the fog_enabled flag.

Functions