Skip to content

Commit

Permalink
Migrate fog volumes to required components (#15568)
Browse files Browse the repository at this point in the history
# Objective

Another part of the migration to required components: fog volumes!

## Solution

Deprecate `FogVolumeBundle` and make `FogVolume` require `Transform` and
`Visibility`, as per the [chosen
proposal](https://hackmd.io/@bevy/required_components/%2FcO7JPSAQR5G0J_j5wNwtOQ).

---

## Migration Guide

Replace all insertions of `FogVolumeBundle` with the `Visibility`
component. The other components required by it will now be inserted
automatically.
  • Loading branch information
Jondolf authored Oct 1, 2024
1 parent 40e88dc commit 0fe17b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions crates/bevy_pbr/src/volumetric_fog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
//!
//! [Henyey-Greenstein phase function]: https://www.pbr-book.org/4ed/Volume_Scattering/Phase_Functions#TheHenyeyndashGreensteinPhaseFunction

#![expect(deprecated)]

use bevy_app::{App, Plugin};
use bevy_asset::{load_internal_asset, Assets, Handle};
use bevy_color::Color;
Expand Down Expand Up @@ -121,6 +123,10 @@ pub type VolumetricFogSettings = VolumetricFog;
/// A convenient [`Bundle`] that contains all components necessary to generate a
/// fog volume.
#[derive(Bundle, Clone, Debug, Default)]
#[deprecated(
since = "0.15.0",
note = "Use the `FogVolume` component instead. Inserting it will now also insert the other components required by it automatically."
)]
pub struct FogVolumeBundle {
/// The actual fog volume.
pub fog_volume: FogVolume,
Expand All @@ -139,6 +145,7 @@ pub struct FogVolumeBundle {

#[derive(Clone, Component, Debug, Reflect)]
#[reflect(Component, Default, Debug)]
#[require(Transform, Visibility)]
pub struct FogVolume {
/// The color of the fog.
///
Expand Down
10 changes: 5 additions & 5 deletions examples/3d/volumetric_fog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use bevy::{
color::palettes::css::RED,
core_pipeline::{bloom::Bloom, tonemapping::Tonemapping, Skybox},
math::vec3,
pbr::{FogVolumeBundle, VolumetricFog, VolumetricLight},
pbr::{FogVolume, VolumetricFog, VolumetricLight},
prelude::*,
};

Expand Down Expand Up @@ -122,10 +122,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_settings: R
));

// Add the fog volume.
commands.spawn(FogVolumeBundle {
transform: Transform::from_scale(Vec3::splat(35.0)),
..default()
});
commands.spawn((
FogVolume::default(),
Transform::from_scale(Vec3::splat(35.0)),
));

// Add the help text.
commands.spawn(
Expand Down

0 comments on commit 0fe17b8

Please sign in to comment.