diff --git a/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs b/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs index 5a6d4330f2..76698d14c4 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs @@ -6,8 +6,8 @@ use bevy_render::{ }; use bevy_utils::{Entry, HashMap}; -use super::pipeline::AutoExposureSettingsUniform; -use super::AutoExposureSettings; +use super::pipeline::AutoExposureUniform; +use super::AutoExposure; #[derive(Resource, Default)] pub(super) struct AutoExposureBuffers { @@ -16,19 +16,19 @@ pub(super) struct AutoExposureBuffers { pub(super) struct AutoExposureBuffer { pub(super) state: StorageBuffer, - pub(super) settings: UniformBuffer, + pub(super) settings: UniformBuffer, } #[derive(Resource)] pub(super) struct ExtractedStateBuffers { - changed: Vec<(Entity, AutoExposureSettings)>, + changed: Vec<(Entity, AutoExposure)>, removed: Vec, } pub(super) fn extract_buffers( mut commands: Commands, - changed: Extract>>, - mut removed: Extract>, + changed: Extract>>, + mut removed: Extract>, ) { commands.insert_resource(ExtractedStateBuffers { changed: changed @@ -50,7 +50,7 @@ pub(super) fn prepare_buffers( let (low_percent, high_percent) = settings.filter.into_inner(); let initial_state = 0.0f32.clamp(min_log_lum, max_log_lum); - let settings = AutoExposureSettingsUniform { + let settings = AutoExposureUniform { min_log_lum, inv_log_lum_range: 1.0 / (max_log_lum - min_log_lum), log_lum_range: max_log_lum - min_log_lum, diff --git a/crates/bevy_core_pipeline/src/auto_exposure/mod.rs b/crates/bevy_core_pipeline/src/auto_exposure/mod.rs index d50d1451d8..dccd63bff0 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/mod.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/mod.rs @@ -26,14 +26,15 @@ use node::AutoExposureNode; use pipeline::{ AutoExposurePass, AutoExposurePipeline, ViewAutoExposurePipeline, METERING_SHADER_HANDLE, }; -pub use settings::AutoExposureSettings; +#[allow(deprecated)] +pub use settings::{AutoExposure, AutoExposureSettings}; use crate::auto_exposure::compensation_curve::GpuAutoExposureCompensationCurve; use crate::core_3d::graph::{Core3d, Node3d}; /// Plugin for the auto exposure feature. /// -/// See [`AutoExposureSettings`] for more details. +/// See [`AutoExposure`] for more details. pub struct AutoExposurePlugin; #[derive(Resource)] @@ -58,8 +59,8 @@ impl Plugin for AutoExposurePlugin { .resource_mut::>() .insert(&Handle::default(), AutoExposureCompensationCurve::default()); - app.register_type::(); - app.add_plugins(ExtractComponentPlugin::::default()); + app.register_type::(); + app.add_plugins(ExtractComponentPlugin::::default()); let Some(render_app) = app.get_sub_app_mut(RenderApp) else { return; @@ -113,9 +114,9 @@ fn queue_view_auto_exposure_pipelines( pipeline_cache: Res, mut compute_pipelines: ResMut>, pipeline: Res, - view_targets: Query<(Entity, &AutoExposureSettings)>, + view_targets: Query<(Entity, &AutoExposure)>, ) { - for (entity, settings) in view_targets.iter() { + for (entity, auto_exposure) in view_targets.iter() { let histogram_pipeline = compute_pipelines.specialize(&pipeline_cache, &pipeline, AutoExposurePass::Histogram); let average_pipeline = @@ -124,8 +125,8 @@ fn queue_view_auto_exposure_pipelines( commands.entity(entity).insert(ViewAutoExposurePipeline { histogram_pipeline, mean_luminance_pipeline: average_pipeline, - compensation_curve: settings.compensation_curve.clone(), - metering_mask: settings.metering_mask.clone(), + compensation_curve: auto_exposure.compensation_curve.clone(), + metering_mask: auto_exposure.metering_mask.clone(), }); } } diff --git a/crates/bevy_core_pipeline/src/auto_exposure/pipeline.rs b/crates/bevy_core_pipeline/src/auto_exposure/pipeline.rs index 937e18f410..684c8dd9e2 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/pipeline.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/pipeline.rs @@ -27,7 +27,7 @@ pub struct ViewAutoExposurePipeline { } #[derive(ShaderType, Clone, Copy)] -pub struct AutoExposureSettingsUniform { +pub struct AutoExposureUniform { pub(super) min_log_lum: f32, pub(super) inv_log_lum_range: f32, pub(super) log_lum_range: f32, @@ -59,7 +59,7 @@ impl FromWorld for AutoExposurePipeline { ShaderStages::COMPUTE, ( uniform_buffer::(false), - uniform_buffer::(false), + uniform_buffer::(false), texture_2d(TextureSampleType::Float { filterable: false }), texture_2d(TextureSampleType::Float { filterable: false }), texture_1d(TextureSampleType::Float { filterable: false }), diff --git a/crates/bevy_core_pipeline/src/auto_exposure/settings.rs b/crates/bevy_core_pipeline/src/auto_exposure/settings.rs index c5d28c94c4..80feb8fba0 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/settings.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/settings.rs @@ -25,7 +25,7 @@ use bevy_utils::default; /// #[derive(Component, Clone, Reflect, ExtractComponent)] #[reflect(Component)] -pub struct AutoExposureSettings { +pub struct AutoExposure { /// The range of exposure values for the histogram. /// /// Pixel values below this range will be ignored, and pixel values above this range will be @@ -88,7 +88,10 @@ pub struct AutoExposureSettings { pub compensation_curve: Handle, } -impl Default for AutoExposureSettings { +#[deprecated(since = "0.15.0", note = "Renamed to `AutoExposure`")] +pub type AutoExposureSettings = AutoExposure; + +impl Default for AutoExposure { fn default() -> Self { Self { range: -8.0..=8.0, diff --git a/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs b/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs index ba48e4b0fe..28d55d360a 100644 --- a/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs +++ b/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs @@ -1,4 +1,4 @@ -use super::{BloomSettings, BLOOM_SHADER_HANDLE, BLOOM_TEXTURE_FORMAT}; +use super::{Bloom, BLOOM_SHADER_HANDLE, BLOOM_TEXTURE_FORMAT}; use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; use bevy_ecs::{ prelude::{Component, Entity}, @@ -33,7 +33,7 @@ pub struct BloomDownsamplingPipelineKeys { first_downsample: bool, } -/// The uniform struct extracted from [`BloomSettings`] attached to a Camera. +/// The uniform struct extracted from [`Bloom`] attached to a Camera. /// Will be available for use in the Bloom shader. #[derive(Component, ShaderType, Clone)] pub struct BloomUniforms { @@ -136,10 +136,10 @@ pub fn prepare_downsampling_pipeline( pipeline_cache: Res, mut pipelines: ResMut>, pipeline: Res, - views: Query<(Entity, &BloomSettings)>, + views: Query<(Entity, &Bloom)>, ) { - for (entity, settings) in &views { - let prefilter = settings.prefilter_settings.threshold > 0.0; + for (entity, bloom) in &views { + let prefilter = bloom.prefilter.threshold > 0.0; let pipeline_id = pipelines.specialize( &pipeline_cache, diff --git a/crates/bevy_core_pipeline/src/bloom/mod.rs b/crates/bevy_core_pipeline/src/bloom/mod.rs index b5c4c6b72c..f3d416f44c 100644 --- a/crates/bevy_core_pipeline/src/bloom/mod.rs +++ b/crates/bevy_core_pipeline/src/bloom/mod.rs @@ -3,7 +3,10 @@ mod settings; mod upsampling_pipeline; use bevy_color::{Gray, LinearRgba}; -pub use settings::{BloomCompositeMode, BloomPrefilterSettings, BloomSettings}; +#[allow(deprecated)] +pub use settings::{ + Bloom, BloomCompositeMode, BloomPrefilter, BloomPrefilterSettings, BloomSettings, +}; use crate::{ core_2d::graph::{Core2d, Node2d}, @@ -44,11 +47,11 @@ impl Plugin for BloomPlugin { fn build(&self, app: &mut App) { load_internal_asset!(app, BLOOM_SHADER_HANDLE, "bloom.wgsl", Shader::from_wgsl); - app.register_type::(); - app.register_type::(); + app.register_type::(); + app.register_type::(); app.register_type::(); app.add_plugins(( - ExtractComponentPlugin::::default(), + ExtractComponentPlugin::::default(), UniformComponentPlugin::::default(), )); @@ -100,7 +103,7 @@ impl ViewNode for BloomNode { &'static BloomTexture, &'static BloomBindGroups, &'static DynamicUniformIndex, - &'static BloomSettings, + &'static Bloom, &'static UpsamplingPipelineIds, &'static BloomDownsamplingPipelineIds, ); @@ -324,18 +327,18 @@ fn prepare_bloom_textures( mut commands: Commands, mut texture_cache: ResMut, render_device: Res, - views: Query<(Entity, &ExtractedCamera, &BloomSettings)>, + views: Query<(Entity, &ExtractedCamera, &Bloom)>, ) { - for (entity, camera, settings) in &views { + for (entity, camera, bloom) in &views { if let Some(UVec2 { x: width, y: height, }) = camera.physical_viewport_size { // How many times we can halve the resolution minus one so we don't go unnecessarily low - let mip_count = settings.max_mip_dimension.ilog2().max(2) - 1; + let mip_count = bloom.max_mip_dimension.ilog2().max(2) - 1; let mip_height_ratio = if height != 0 { - settings.max_mip_dimension as f32 / height as f32 + bloom.max_mip_dimension as f32 / height as f32 } else { 0. }; @@ -457,19 +460,18 @@ fn prepare_bloom_bind_groups( /// * `max_mip` - the index of the lowest frequency pyramid level. /// /// This function can be visually previewed for all values of *mip* (normalized) with tweakable -/// [`BloomSettings`] parameters on [Desmos graphing calculator](https://www.desmos.com/calculator/ncc8xbhzzl). -fn compute_blend_factor(bloom_settings: &BloomSettings, mip: f32, max_mip: f32) -> f32 { +/// [`Bloom`] parameters on [Desmos graphing calculator](https://www.desmos.com/calculator/ncc8xbhzzl). +fn compute_blend_factor(bloom: &Bloom, mip: f32, max_mip: f32) -> f32 { let mut lf_boost = (1.0 - - (1.0 - (mip / max_mip)).powf(1.0 / (1.0 - bloom_settings.low_frequency_boost_curvature))) - * bloom_settings.low_frequency_boost; + - (1.0 - (mip / max_mip)).powf(1.0 / (1.0 - bloom.low_frequency_boost_curvature))) + * bloom.low_frequency_boost; let high_pass_lq = 1.0 - - (((mip / max_mip) - bloom_settings.high_pass_frequency) - / bloom_settings.high_pass_frequency) + - (((mip / max_mip) - bloom.high_pass_frequency) / bloom.high_pass_frequency) .clamp(0.0, 1.0); - lf_boost *= match bloom_settings.composite_mode { - BloomCompositeMode::EnergyConserving => 1.0 - bloom_settings.intensity, + lf_boost *= match bloom.composite_mode { + BloomCompositeMode::EnergyConserving => 1.0 - bloom.intensity, BloomCompositeMode::Additive => 1.0, }; - (bloom_settings.intensity + lf_boost) * high_pass_lq + (bloom.intensity + lf_boost) * high_pass_lq } diff --git a/crates/bevy_core_pipeline/src/bloom/settings.rs b/crates/bevy_core_pipeline/src/bloom/settings.rs index 4e8e0ff1f7..3fc35dc4d5 100644 --- a/crates/bevy_core_pipeline/src/bloom/settings.rs +++ b/crates/bevy_core_pipeline/src/bloom/settings.rs @@ -26,7 +26,7 @@ use bevy_render::{extract_component::ExtractComponent, prelude::Camera}; /// used in Bevy as well as a visualization of the curve's respective scattering profile. #[derive(Component, Reflect, Clone)] #[reflect(Component, Default)] -pub struct BloomSettings { +pub struct Bloom { /// Controls the baseline of how much the image is scattered (default: 0.15). /// /// This parameter should be used only to control the strength of the bloom @@ -90,15 +90,21 @@ pub struct BloomSettings { /// * 1.0 - maximum scattering angle is 90 degrees pub high_pass_frequency: f32, - pub prefilter_settings: BloomPrefilterSettings, + /// Controls the threshold filter used for extracting the brightest regions from the input image + /// before blurring them and compositing back onto the original image. + /// + /// Changing these settings creates a physically inaccurate image and makes it easy to make + /// the final result look worse. However, they can be useful when emulating the 1990s-2000s game look. + /// See [`BloomPrefilter`] for more information. + pub prefilter: BloomPrefilter, /// Controls whether bloom textures /// are blended between or added to each other. Useful /// if image brightening is desired and a must-change - /// if `prefilter_settings` are used. + /// if `prefilter` is used. /// /// # Recommendation - /// Set to [`BloomCompositeMode::Additive`] if `prefilter_settings` are + /// Set to [`BloomCompositeMode::Additive`] if `prefilter` is /// configured in a non-energy-conserving way, /// otherwise set to [`BloomCompositeMode::EnergyConserving`]. pub composite_mode: BloomCompositeMode, @@ -112,7 +118,10 @@ pub struct BloomSettings { pub uv_offset: f32, } -impl BloomSettings { +#[deprecated(since = "0.15.0", note = "Renamed to `Bloom`")] +pub type BloomSettings = Bloom; + +impl Bloom { const DEFAULT_MAX_MIP_DIMENSION: u32 = 512; const DEFAULT_UV_OFFSET: f32 = 0.004; @@ -124,7 +133,7 @@ impl BloomSettings { low_frequency_boost: 0.7, low_frequency_boost_curvature: 0.95, high_pass_frequency: 1.0, - prefilter_settings: BloomPrefilterSettings { + prefilter: BloomPrefilter { threshold: 0.0, threshold_softness: 0.0, }, @@ -139,7 +148,7 @@ impl BloomSettings { low_frequency_boost: 0.7, low_frequency_boost_curvature: 0.95, high_pass_frequency: 1.0, - prefilter_settings: BloomPrefilterSettings { + prefilter: BloomPrefilter { threshold: 0.6, threshold_softness: 0.2, }, @@ -154,7 +163,7 @@ impl BloomSettings { low_frequency_boost: 0.0, low_frequency_boost_curvature: 0.0, high_pass_frequency: 1.0 / 3.0, - prefilter_settings: BloomPrefilterSettings { + prefilter: BloomPrefilter { threshold: 0.0, threshold_softness: 0.0, }, @@ -164,7 +173,7 @@ impl BloomSettings { }; } -impl Default for BloomSettings { +impl Default for Bloom { fn default() -> Self { Self::NATURAL } @@ -179,7 +188,7 @@ impl Default for BloomSettings { /// * Changing these settings makes it easy to make the final result look worse /// * Non-default prefilter settings should be used in conjunction with [`BloomCompositeMode::Additive`] #[derive(Default, Clone, Reflect)] -pub struct BloomPrefilterSettings { +pub struct BloomPrefilter { /// Baseline of the quadratic threshold curve (default: 0.0). /// /// RGB values under the threshold curve will not contribute to the effect. @@ -194,19 +203,22 @@ pub struct BloomPrefilterSettings { pub threshold_softness: f32, } +#[deprecated(since = "0.15.0", note = "Renamed to `BloomPrefilter`")] +pub type BloomPrefilterSettings = BloomPrefilter; + #[derive(Debug, Clone, Reflect, PartialEq, Eq, Hash, Copy)] pub enum BloomCompositeMode { EnergyConserving, Additive, } -impl ExtractComponent for BloomSettings { +impl ExtractComponent for Bloom { type QueryData = (&'static Self, &'static Camera); type QueryFilter = (); type Out = (Self, BloomUniforms); - fn extract_component((settings, camera): QueryItem<'_, Self::QueryData>) -> Option { + fn extract_component((bloom, camera): QueryItem<'_, Self::QueryData>) -> Option { match ( camera.physical_viewport_rect(), camera.physical_viewport_size(), @@ -215,8 +227,8 @@ impl ExtractComponent for BloomSettings { camera.hdr, ) { (Some(URect { min: origin, .. }), Some(size), Some(target_size), true, true) => { - let threshold = settings.prefilter_settings.threshold; - let threshold_softness = settings.prefilter_settings.threshold_softness; + let threshold = bloom.prefilter.threshold; + let threshold_softness = bloom.prefilter.threshold_softness; let knee = threshold * threshold_softness.clamp(0.0, 1.0); let uniform = BloomUniforms { @@ -232,10 +244,10 @@ impl ExtractComponent for BloomSettings { aspect: AspectRatio::try_from_pixels(size.x, size.y) .expect("Valid screen size values for Bloom settings") .ratio(), - uv_offset: settings.uv_offset, + uv_offset: bloom.uv_offset, }; - Some((settings.clone(), uniform)) + Some((bloom.clone(), uniform)) } _ => None, } diff --git a/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs b/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs index 161c251e36..91a23310ef 100644 --- a/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs +++ b/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs @@ -1,5 +1,5 @@ use super::{ - downsampling_pipeline::BloomUniforms, BloomCompositeMode, BloomSettings, BLOOM_SHADER_HANDLE, + downsampling_pipeline::BloomUniforms, Bloom, BloomCompositeMode, BLOOM_SHADER_HANDLE, BLOOM_TEXTURE_FORMAT, }; use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; @@ -133,14 +133,14 @@ pub fn prepare_upsampling_pipeline( pipeline_cache: Res, mut pipelines: ResMut>, pipeline: Res, - views: Query<(Entity, &BloomSettings)>, + views: Query<(Entity, &Bloom)>, ) { - for (entity, settings) in &views { + for (entity, bloom) in &views { let pipeline_id = pipelines.specialize( &pipeline_cache, &pipeline, BloomUpsamplingPipelineKeys { - composite_mode: settings.composite_mode, + composite_mode: bloom.composite_mode, final_pipeline: false, }, ); @@ -149,7 +149,7 @@ pub fn prepare_upsampling_pipeline( &pipeline_cache, &pipeline, BloomUpsamplingPipelineKeys { - composite_mode: settings.composite_mode, + composite_mode: bloom.composite_mode, final_pipeline: true, }, ); diff --git a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs index f76e063672..422b4d626d 100644 --- a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs +++ b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs @@ -34,10 +34,10 @@ pub use node::CasNode; /// based on the local contrast. This can help avoid over-sharpening areas with high contrast /// and under-sharpening areas with low contrast. /// -/// To use this, add the [`ContrastAdaptiveSharpeningSettings`] component to a 2D or 3D camera. +/// To use this, add the [`ContrastAdaptiveSharpening`] component to a 2D or 3D camera. #[derive(Component, Reflect, Clone)] #[reflect(Component)] -pub struct ContrastAdaptiveSharpeningSettings { +pub struct ContrastAdaptiveSharpening { /// Enable or disable sharpening. pub enabled: bool, /// Adjusts sharpening strength. Higher values increase the amount of sharpening. @@ -54,9 +54,12 @@ pub struct ContrastAdaptiveSharpeningSettings { pub denoise: bool, } -impl Default for ContrastAdaptiveSharpeningSettings { +#[deprecated(since = "0.15.0", note = "Renamed to `ContrastAdaptiveSharpening`")] +pub type ContrastAdaptiveSharpeningSettings = ContrastAdaptiveSharpening; + +impl Default for ContrastAdaptiveSharpening { fn default() -> Self { - ContrastAdaptiveSharpeningSettings { + ContrastAdaptiveSharpening { enabled: true, sharpening_strength: 0.6, denoise: false, @@ -68,7 +71,7 @@ impl Default for ContrastAdaptiveSharpeningSettings { #[reflect(Component)] pub struct DenoiseCas(bool); -/// The uniform struct extracted from [`ContrastAdaptiveSharpeningSettings`] attached to a [`Camera`]. +/// The uniform struct extracted from [`ContrastAdaptiveSharpening`] attached to a [`Camera`]. /// Will be available for use in the CAS shader. #[doc(hidden)] #[derive(Component, ShaderType, Clone)] @@ -76,7 +79,7 @@ pub struct CasUniform { sharpness: f32, } -impl ExtractComponent for ContrastAdaptiveSharpeningSettings { +impl ExtractComponent for ContrastAdaptiveSharpening { type QueryData = &'static Self; type QueryFilter = With; type Out = (DenoiseCas, CasUniform); @@ -110,9 +113,9 @@ impl Plugin for CasPlugin { Shader::from_wgsl ); - app.register_type::(); + app.register_type::(); app.add_plugins(( - ExtractComponentPlugin::::default(), + ExtractComponentPlugin::::default(), UniformComponentPlugin::::default(), )); @@ -241,12 +244,12 @@ fn prepare_cas_pipelines( sharpening_pipeline: Res, views: Query<(Entity, &ExtractedView, &DenoiseCas), With>, ) { - for (entity, view, cas_settings) in &views { + for (entity, view, cas) in &views { let pipeline_id = pipelines.specialize( &pipeline_cache, &sharpening_pipeline, CasPipelineKey { - denoise: cas_settings.0, + denoise: cas.0, texture_format: if view.hdr { ViewTarget::TEXTURE_FORMAT_HDR } else { diff --git a/crates/bevy_core_pipeline/src/dof/dof.wgsl b/crates/bevy_core_pipeline/src/dof/dof.wgsl index e1ea4c22f1..2af11077f8 100644 --- a/crates/bevy_core_pipeline/src/dof/dof.wgsl +++ b/crates/bevy_core_pipeline/src/dof/dof.wgsl @@ -52,7 +52,7 @@ struct DepthOfFieldParams { max_circle_of_confusion_diameter: f32, /// The depth value that we clamp distant objects to. See the comment in - /// [`DepthOfFieldSettings`] for more information. + /// [`DepthOfField`] for more information. max_depth: f32, /// Padding. diff --git a/crates/bevy_core_pipeline/src/dof/mod.rs b/crates/bevy_core_pipeline/src/dof/mod.rs index a35bdc0723..162fbf9d62 100644 --- a/crates/bevy_core_pipeline/src/dof/mod.rs +++ b/crates/bevy_core_pipeline/src/dof/mod.rs @@ -7,7 +7,7 @@ //! [depth of field], and this term is used more generally in computer graphics //! to refer to the effect that simulates focus of lenses. //! -//! Attaching [`DepthOfFieldSettings`] to a camera causes Bevy to simulate the +//! Attaching [`DepthOfField`] to a camera causes Bevy to simulate the //! focus of a camera lens. Generally, Bevy's implementation of depth of field //! is optimized for speed instead of physical accuracy. Nevertheless, the depth //! of field effect in Bevy is based on physical parameters. @@ -68,10 +68,13 @@ const DOF_SHADER_HANDLE: Handle = Handle::weak_from_u128(203186118073921 /// A plugin that adds support for the depth of field effect to Bevy. pub struct DepthOfFieldPlugin; -/// Depth of field settings. +/// A component that enables a [depth of field] postprocessing effect when attached to a [`Camera3d`], +/// simulating the focus of a camera lens. +/// +/// [depth of field]: https://en.wikipedia.org/wiki/Depth_of_field #[derive(Component, Clone, Copy, Reflect)] #[reflect(Component, Default)] -pub struct DepthOfFieldSettings { +pub struct DepthOfField { /// The appearance of the effect. pub mode: DepthOfFieldMode, @@ -112,6 +115,9 @@ pub struct DepthOfFieldSettings { pub max_depth: f32, } +#[deprecated(since = "0.15.0", note = "Renamed to `DepthOfField`")] +pub type DepthOfFieldSettings = DepthOfField; + /// Controls the appearance of the effect. #[derive(Clone, Copy, Default, PartialEq, Debug, Reflect)] #[reflect(Default, PartialEq)] @@ -156,11 +162,11 @@ pub struct DepthOfFieldUniform { coc_scale_factor: f32, /// The maximum circle of confusion diameter in pixels. See the comment in - /// [`DepthOfFieldSettings`] for more information. + /// [`DepthOfField`] for more information. max_circle_of_confusion_diameter: f32, /// The depth value that we clamp distant objects to. See the comment in - /// [`DepthOfFieldSettings`] for more information. + /// [`DepthOfField`] for more information. max_depth: f32, /// Padding. @@ -199,7 +205,7 @@ impl Plugin for DepthOfFieldPlugin { fn build(&self, app: &mut App) { load_internal_asset!(app, DOF_SHADER_HANDLE, "dof.wgsl", Shader::from_wgsl); - app.register_type::(); + app.register_type::(); app.register_type::(); app.add_plugins(UniformComponentPlugin::::default()); @@ -339,7 +345,7 @@ impl ViewNode for DepthOfFieldNode { view_depth_texture, view_pipelines, view_bind_group_layouts, - dof_settings_uniform_index, + depth_of_field_uniform_index, auxiliary_dof_texture, ): QueryItem<'w, Self::ViewQuery>, world: &'w World, @@ -440,7 +446,11 @@ impl ViewNode for DepthOfFieldNode { // Set the per-view bind group. render_pass.set_bind_group(0, &view_bind_group, &[view_uniform_offset.offset]); // Set the global bind group shared among all invocations of the shader. - render_pass.set_bind_group(1, global_bind_group, &[dof_settings_uniform_index.index()]); + render_pass.set_bind_group( + 1, + global_bind_group, + &[depth_of_field_uniform_index.index()], + ); // Render the full-screen pass. render_pass.draw(0..3, 0..1); } @@ -449,7 +459,7 @@ impl ViewNode for DepthOfFieldNode { } } -impl Default for DepthOfFieldSettings { +impl Default for DepthOfField { fn default() -> Self { let physical_camera_default = PhysicalCameraParameters::default(); Self { @@ -463,8 +473,8 @@ impl Default for DepthOfFieldSettings { } } -impl DepthOfFieldSettings { - /// Initializes [`DepthOfFieldSettings`] from a set of +impl DepthOfField { + /// Initializes [`DepthOfField`] from a set of /// [`PhysicalCameraParameters`]. /// /// By passing the same [`PhysicalCameraParameters`] object to this function @@ -472,10 +482,10 @@ impl DepthOfFieldSettings { /// results for both the exposure and depth of field effects can be /// obtained. /// - /// All fields of the returned [`DepthOfFieldSettings`] other than + /// All fields of the returned [`DepthOfField`] other than /// `focal_length` and `aperture_f_stops` are set to their default values. - pub fn from_physical_camera(camera: &PhysicalCameraParameters) -> DepthOfFieldSettings { - DepthOfFieldSettings { + pub fn from_physical_camera(camera: &PhysicalCameraParameters) -> DepthOfField { + DepthOfField { sensor_height: camera.sensor_height, aperture_f_stops: camera.aperture_f_stops, ..default() @@ -521,10 +531,10 @@ impl FromWorld for DepthOfFieldGlobalBindGroupLayout { /// specific to each view. pub fn prepare_depth_of_field_view_bind_group_layouts( mut commands: Commands, - view_targets: Query<(Entity, &DepthOfFieldSettings, &Msaa)>, + view_targets: Query<(Entity, &DepthOfField, &Msaa)>, render_device: Res, ) { - for (view, dof_settings, msaa) in view_targets.iter() { + for (view, depth_of_field, msaa) in view_targets.iter() { // Create the bind group layout for the passes that take one input. let single_input = render_device.create_bind_group_layout( Some("depth of field bind group layout (single input)"), @@ -544,7 +554,7 @@ pub fn prepare_depth_of_field_view_bind_group_layouts( // If needed, create the bind group layout for the second bokeh pass, // which takes two inputs. We only need to do this if bokeh is in use. - let dual_input = match dof_settings.mode { + let dual_input = match depth_of_field.mode { DepthOfFieldMode::Gaussian => None, DepthOfFieldMode::Bokeh => Some(render_device.create_bind_group_layout( Some("depth of field bind group layout (dual input)"), @@ -581,7 +591,7 @@ pub fn prepare_depth_of_field_view_bind_group_layouts( /// need to set the appropriate flag to tell Bevy to make samplable depth /// buffers. pub fn configure_depth_of_field_view_targets( - mut view_targets: Query<&mut Camera3d, With>, + mut view_targets: Query<&mut Camera3d, With>, ) { for mut camera_3d in view_targets.iter_mut() { let mut depth_texture_usages = TextureUsages::from(camera_3d.depth_texture_usages); @@ -595,10 +605,10 @@ pub fn configure_depth_of_field_view_targets( pub fn prepare_depth_of_field_global_bind_group( global_bind_group_layout: Res, mut dof_bind_group: ResMut, - dof_settings_uniforms: Res>, + depth_of_field_uniforms: Res>, render_device: Res, ) { - let Some(dof_settings_uniforms) = dof_settings_uniforms.binding() else { + let Some(depth_of_field_uniforms) = depth_of_field_uniforms.binding() else { return; }; @@ -606,7 +616,7 @@ pub fn prepare_depth_of_field_global_bind_group( Some("depth of field global bind group"), &global_bind_group_layout.layout, &BindGroupEntries::sequential(( - dof_settings_uniforms, // `dof_params` + depth_of_field_uniforms, // `dof_params` &global_bind_group_layout.color_texture_sampler, // `color_texture_sampler` )), )); @@ -618,11 +628,11 @@ pub fn prepare_auxiliary_depth_of_field_textures( mut commands: Commands, render_device: Res, mut texture_cache: ResMut, - mut view_targets: Query<(Entity, &ViewTarget, &DepthOfFieldSettings)>, + mut view_targets: Query<(Entity, &ViewTarget, &DepthOfField)>, ) { - for (entity, view_target, dof_settings) in view_targets.iter_mut() { + for (entity, view_target, depth_of_field) in view_targets.iter_mut() { // An auxiliary texture is only needed for bokeh. - if dof_settings.mode != DepthOfFieldMode::Bokeh { + if depth_of_field.mode != DepthOfFieldMode::Bokeh { continue; } @@ -655,12 +665,12 @@ pub fn prepare_depth_of_field_pipelines( view_targets: Query<( Entity, &ExtractedView, - &DepthOfFieldSettings, + &DepthOfField, &ViewDepthOfFieldBindGroupLayouts, &Msaa, )>, ) { - for (entity, view, dof_settings, view_bind_group_layouts, msaa) in view_targets.iter() { + for (entity, view, depth_of_field, view_bind_group_layouts, msaa) in view_targets.iter() { let dof_pipeline = DepthOfFieldPipeline { view_bind_group_layouts: view_bind_group_layouts.clone(), global_bind_group_layout: global_bind_group_layout.layout.clone(), @@ -670,7 +680,7 @@ pub fn prepare_depth_of_field_pipelines( let (hdr, multisample) = (view.hdr, *msaa != Msaa::Off); // Go ahead and specialize the pipelines. - match dof_settings.mode { + match depth_of_field.mode { DepthOfFieldMode::Gaussian => { commands .entity(entity) @@ -795,10 +805,10 @@ impl SpecializedRenderPipeline for DepthOfFieldPipeline { } } -/// Extracts all [`DepthOfFieldSettings`] components into the render world. +/// Extracts all [`DepthOfField`] components into the render world. fn extract_depth_of_field_settings( mut commands: Commands, - mut query: Extract>, + mut query: Extract>, ) { if !DEPTH_TEXTURE_SAMPLING_SUPPORTED { info_once!( @@ -807,25 +817,25 @@ fn extract_depth_of_field_settings( return; } - for (entity, dof_settings, projection) in query.iter_mut() { + for (entity, depth_of_field, projection) in query.iter_mut() { // Depth of field is nonsensical without a perspective projection. let Projection::Perspective(ref perspective_projection) = *projection else { continue; }; let focal_length = - calculate_focal_length(dof_settings.sensor_height, perspective_projection.fov); + calculate_focal_length(depth_of_field.sensor_height, perspective_projection.fov); - // Convert `DepthOfFieldSettings` to `DepthOfFieldUniform`. + // Convert `DepthOfField` to `DepthOfFieldUniform`. commands.get_or_spawn(entity).insert(( - *dof_settings, + *depth_of_field, DepthOfFieldUniform { - focal_distance: dof_settings.focal_distance, + focal_distance: depth_of_field.focal_distance, focal_length, coc_scale_factor: focal_length * focal_length - / (dof_settings.sensor_height * dof_settings.aperture_f_stops), - max_circle_of_confusion_diameter: dof_settings.max_circle_of_confusion_diameter, - max_depth: dof_settings.max_depth, + / (depth_of_field.sensor_height * depth_of_field.aperture_f_stops), + max_circle_of_confusion_diameter: depth_of_field.max_circle_of_confusion_diameter, + max_depth: depth_of_field.max_depth, pad_a: 0, pad_b: 0, pad_c: 0, diff --git a/crates/bevy_core_pipeline/src/fxaa/mod.rs b/crates/bevy_core_pipeline/src/fxaa/mod.rs index f338a56437..85fe16bd48 100644 --- a/crates/bevy_core_pipeline/src/fxaa/mod.rs +++ b/crates/bevy_core_pipeline/src/fxaa/mod.rs @@ -49,9 +49,12 @@ impl Sensitivity { } } +/// A component for enabling Fast Approximate Anti-Aliasing (FXAA) +/// for a [`bevy_render::camera::Camera`]. #[derive(Reflect, Component, Clone, ExtractComponent)] #[reflect(Component, Default)] #[extract_component_filter(With)] +#[doc(alias = "FastApproximateAntiAliasing")] pub struct Fxaa { /// Enable render passes for FXAA. pub enabled: bool, @@ -60,7 +63,7 @@ pub struct Fxaa { /// Use higher sensitivity for a slower, smoother, result. /// [`Ultra`](`Sensitivity::Ultra`) and [`Extreme`](`Sensitivity::Extreme`) /// settings can result in significant smearing and loss of detail. - + /// /// The minimum amount of local contrast required to apply algorithm. pub edge_threshold: Sensitivity, diff --git a/crates/bevy_core_pipeline/src/lib.rs b/crates/bevy_core_pipeline/src/lib.rs index ec77241466..98c00c0c74 100644 --- a/crates/bevy_core_pipeline/src/lib.rs +++ b/crates/bevy_core_pipeline/src/lib.rs @@ -34,9 +34,10 @@ pub use skybox::Skybox; /// Expect bugs, missing features, compatibility issues, low performance, and/or future breaking changes. pub mod experimental { pub mod taa { + #[allow(deprecated)] pub use crate::taa::{ TemporalAntiAliasBundle, TemporalAntiAliasNode, TemporalAntiAliasPlugin, - TemporalAntiAliasSettings, + TemporalAntiAliasSettings, TemporalAntiAliasing, }; } } diff --git a/crates/bevy_core_pipeline/src/motion_blur/node.rs b/crates/bevy_core_pipeline/src/motion_blur/node.rs index 24f470c563..2497bd633d 100644 --- a/crates/bevy_core_pipeline/src/motion_blur/node.rs +++ b/crates/bevy_core_pipeline/src/motion_blur/node.rs @@ -33,10 +33,10 @@ impl ViewNode for MotionBlurNode { &self, _graph: &mut RenderGraphContext, render_context: &mut RenderContext, - (view_target, pipeline_id, prepass_textures, settings, msaa): QueryItem, + (view_target, pipeline_id, prepass_textures, motion_blur, msaa): QueryItem, world: &World, ) -> Result<(), NodeRunError> { - if settings.samples == 0 || settings.shutter_angle <= 0.0 { + if motion_blur.samples == 0 || motion_blur.shutter_angle <= 0.0 { return Ok(()); // We can skip running motion blur in these cases. } diff --git a/crates/bevy_core_pipeline/src/smaa/mod.rs b/crates/bevy_core_pipeline/src/smaa/mod.rs index e6e00e54b0..a41a77c806 100644 --- a/crates/bevy_core_pipeline/src/smaa/mod.rs +++ b/crates/bevy_core_pipeline/src/smaa/mod.rs @@ -11,7 +11,7 @@ //! which have made SMAA less popular when advanced photorealistic rendering //! features are used in recent years. //! -//! To use SMAA, add [`SmaaSettings`] to a [`bevy_render::camera::Camera`]. In a +//! To use SMAA, add [`Smaa`] to a [`bevy_render::camera::Camera`]. In a //! pinch, you can simply use the default settings (via the [`Default`] trait) //! for a high-quality, high-performance appearance. When using SMAA, you will //! likely want set [`bevy_render::view::Msaa`] to [`bevy_render::view::Msaa::Off`] @@ -95,17 +95,21 @@ const SMAA_SEARCH_LUT_TEXTURE_HANDLE: Handle = Handle::weak_from_u128(318 /// Adds support for subpixel morphological antialiasing, or SMAA. pub struct SmaaPlugin; -/// Add this component to a [`bevy_render::camera::Camera`] to enable subpixel -/// morphological antialiasing (SMAA). +/// A component for enabling Subpixel Morphological Anti-Aliasing (SMAA) +/// for a [`bevy_render::camera::Camera`]. #[derive(Clone, Copy, Default, Component, Reflect, ExtractComponent)] #[reflect(Component, Default)] -pub struct SmaaSettings { +#[doc(alias = "SubpixelMorphologicalAntiAliasing")] +pub struct Smaa { /// A predefined set of SMAA parameters: i.e. a quality level. /// /// Generally, you can leave this at its default level. pub preset: SmaaPreset, } +#[deprecated(since = "0.15.0", note = "Renamed to `Smaa`")] +pub type SmaaSettings = Smaa; + /// A preset quality level for SMAA. /// /// Higher values are slower but result in a higher-quality image. @@ -339,8 +343,8 @@ impl Plugin for SmaaPlugin { .resource_mut::>() .insert(SMAA_SEARCH_LUT_TEXTURE_HANDLE.id(), lut_placeholder()); - app.add_plugins(ExtractComponentPlugin::::default()) - .register_type::(); + app.add_plugins(ExtractComponentPlugin::::default()) + .register_type::(); let Some(render_app) = app.get_sub_app_mut(RenderApp) else { return; @@ -614,13 +618,13 @@ fn prepare_smaa_pipelines( pipeline_cache: Res, mut specialized_render_pipelines: ResMut, smaa_pipelines: Res, - view_targets: Query<(Entity, &ExtractedView, &SmaaSettings)>, + view_targets: Query<(Entity, &ExtractedView, &Smaa)>, ) { - for (entity, view, settings) in &view_targets { + for (entity, view, smaa) in &view_targets { let edge_detection_pipeline_id = specialized_render_pipelines.edge_detection.specialize( &pipeline_cache, &smaa_pipelines.edge_detection, - settings.preset, + smaa.preset, ); let blending_weight_calculation_pipeline_id = specialized_render_pipelines @@ -628,7 +632,7 @@ fn prepare_smaa_pipelines( .specialize( &pipeline_cache, &smaa_pipelines.blending_weight_calculation, - settings.preset, + smaa.preset, ); let neighborhood_blending_pipeline_id = specialized_render_pipelines @@ -642,7 +646,7 @@ fn prepare_smaa_pipelines( } else { TextureFormat::bevy_default() }, - preset: settings.preset, + preset: smaa.preset, }, ); @@ -660,7 +664,7 @@ fn prepare_smaa_uniforms( mut commands: Commands, render_device: Res, render_queue: Res, - view_targets: Query<(Entity, &ExtractedView), With>, + view_targets: Query<(Entity, &ExtractedView), With>, mut smaa_info_buffer: ResMut, ) { smaa_info_buffer.clear(); @@ -691,7 +695,7 @@ fn prepare_smaa_textures( mut commands: Commands, render_device: Res, mut texture_cache: ResMut, - view_targets: Query<(Entity, &ExtractedCamera), (With, With)>, + view_targets: Query<(Entity, &ExtractedCamera), (With, With)>, ) { for (entity, camera) in &view_targets { let Some(texture_size) = camera.physical_target_size else { @@ -765,7 +769,7 @@ fn prepare_smaa_bind_groups( render_device: Res, smaa_pipelines: Res, images: Res>, - view_targets: Query<(Entity, &SmaaTextures), (With, With)>, + view_targets: Query<(Entity, &SmaaTextures), (With, With)>, ) { // Fetch the two lookup textures. These are bundled in this library. let (Some(search_texture), Some(area_texture)) = ( diff --git a/crates/bevy_core_pipeline/src/taa/mod.rs b/crates/bevy_core_pipeline/src/taa/mod.rs index 4a78af178e..3fecdf34b7 100644 --- a/crates/bevy_core_pipeline/src/taa/mod.rs +++ b/crates/bevy_core_pipeline/src/taa/mod.rs @@ -40,14 +40,14 @@ const TAA_SHADER_HANDLE: Handle = Handle::weak_from_u128(656865235226276 /// Plugin for temporal anti-aliasing. /// -/// See [`TemporalAntiAliasSettings`] for more details. +/// See [`TemporalAntiAliasing`] for more details. pub struct TemporalAntiAliasPlugin; impl Plugin for TemporalAntiAliasPlugin { fn build(&self, app: &mut App) { load_internal_asset!(app, TAA_SHADER_HANDLE, "taa.wgsl", Shader::from_wgsl); - app.register_type::(); + app.register_type::(); let Some(render_app) = app.get_sub_app_mut(RenderApp) else { return; @@ -88,7 +88,7 @@ impl Plugin for TemporalAntiAliasPlugin { /// Bundle to apply temporal anti-aliasing. #[derive(Bundle, Default, Clone)] pub struct TemporalAntiAliasBundle { - pub settings: TemporalAntiAliasSettings, + pub settings: TemporalAntiAliasing, pub jitter: TemporalJitter, pub depth_prepass: DepthPrepass, pub motion_vector_prepass: MotionVectorPrepass, @@ -136,7 +136,8 @@ pub struct TemporalAntiAliasBundle { /// /// If no [`MipBias`] component is attached to the camera, TAA will add a MipBias(-1.0) component. #[derive(Component, Reflect, Clone)] -pub struct TemporalAntiAliasSettings { +#[doc(alias = "Taa")] +pub struct TemporalAntiAliasing { /// Set to true to delete the saved temporal history (past frames). /// /// Useful for preventing ghosting when the history is no longer @@ -147,7 +148,10 @@ pub struct TemporalAntiAliasSettings { pub reset: bool, } -impl Default for TemporalAntiAliasSettings { +#[deprecated(since = "0.15.0", note = "Renamed to `TemporalAntiAliasing`")] +pub type TemporalAntiAliasSettings = TemporalAntiAliasing; + +impl Default for TemporalAntiAliasing { fn default() -> Self { Self { reset: true } } @@ -347,7 +351,7 @@ impl SpecializedRenderPipeline for TaaPipeline { fn extract_taa_settings(mut commands: Commands, mut main_world: ResMut) { let mut cameras_3d = main_world - .query_filtered::<(Entity, &Camera, &Projection, &mut TemporalAntiAliasSettings), ( + .query_filtered::<(Entity, &Camera, &Projection, &mut TemporalAntiAliasing), ( With, With, With, @@ -367,10 +371,7 @@ fn extract_taa_settings(mut commands: Commands, mut main_world: ResMut, - mut query: Query< - (Entity, &mut TemporalJitter, Option<&MipBias>), - With, - >, + mut query: Query<(Entity, &mut TemporalJitter, Option<&MipBias>), With>, mut commands: Commands, ) { // Halton sequence (2, 3) - 0.5, skipping i = 0 @@ -407,7 +408,7 @@ fn prepare_taa_history_textures( mut texture_cache: ResMut, render_device: Res, frame_count: Res, - views: Query<(Entity, &ExtractedCamera, &ExtractedView), With>, + views: Query<(Entity, &ExtractedCamera, &ExtractedView), With>, ) { for (entity, camera, view) in &views { if let Some(physical_target_size) = camera.physical_target_size { @@ -461,7 +462,7 @@ fn prepare_taa_pipelines( pipeline_cache: Res, mut pipelines: ResMut>, pipeline: Res, - views: Query<(Entity, &ExtractedView, &TemporalAntiAliasSettings)>, + views: Query<(Entity, &ExtractedView, &TemporalAntiAliasing)>, ) { for (entity, view, taa_settings) in &views { let mut pipeline_key = TaaPipelineKey { diff --git a/crates/bevy_pbr/src/deferred/mod.rs b/crates/bevy_pbr/src/deferred/mod.rs index eb4ba66cf0..378f91b629 100644 --- a/crates/bevy_pbr/src/deferred/mod.rs +++ b/crates/bevy_pbr/src/deferred/mod.rs @@ -1,6 +1,6 @@ use crate::{ graph::NodePbr, irradiance_volume::IrradianceVolume, prelude::EnvironmentMapLight, - MeshPipeline, MeshViewBindGroup, RenderViewLightProbes, ScreenSpaceAmbientOcclusionSettings, + MeshPipeline, MeshViewBindGroup, RenderViewLightProbes, ScreenSpaceAmbientOcclusion, ScreenSpaceReflectionsUniform, ViewEnvironmentMapUniformOffset, ViewLightProbesUniformOffset, ViewScreenSpaceReflectionsUniformOffset, }; @@ -434,7 +434,7 @@ pub fn prepare_deferred_lighting_pipelines( Option<&DebandDither>, Option<&ShadowFilteringMethod>, ( - Has, + Has, Has, ), ( diff --git a/crates/bevy_pbr/src/fog.rs b/crates/bevy_pbr/src/fog.rs index 894ced95a4..7db237aa9c 100644 --- a/crates/bevy_pbr/src/fog.rs +++ b/crates/bevy_pbr/src/fog.rs @@ -34,7 +34,7 @@ use bevy_render::{extract_component::ExtractComponent, prelude::Camera}; /// # ..Default::default() /// }, /// // Add fog to the same entity -/// FogSettings { +/// DistanceFog { /// color: Color::WHITE, /// falloff: FogFalloff::Exponential { density: 1e-3 }, /// ..Default::default() @@ -51,7 +51,7 @@ use bevy_render::{extract_component::ExtractComponent, prelude::Camera}; #[derive(Debug, Clone, Component, Reflect, ExtractComponent)] #[extract_component_filter(With)] #[reflect(Component, Default)] -pub struct FogSettings { +pub struct DistanceFog { /// The color of the fog effect. /// /// **Tip:** The alpha channel of the color can be used to “modulate” the fog effect without @@ -73,6 +73,9 @@ pub struct FogSettings { pub falloff: FogFalloff, } +#[deprecated(since = "0.15.0", note = "Renamed to `DistanceFog`")] +pub type FogSettings = DistanceFog; + /// Allows switching between different fog falloff modes, and configuring their parameters. /// /// ## Convenience Methods @@ -149,7 +152,7 @@ pub enum FogFalloff { /// scale. Typically, for scenes with objects in the scale of thousands of units, you might want density values /// in the ballpark of `0.001`. Conversely, for really small scale scenes you might want really high values of /// density; - /// - Combine the `density` parameter with the [`FogSettings`] `color`'s alpha channel for easier artistic control. + /// - Combine the `density` parameter with the [`DistanceFog`] `color`'s alpha channel for easier artistic control. /// /// ## Formula /// @@ -197,7 +200,7 @@ pub enum FogFalloff { /// /// - Use the [`FogFalloff::from_visibility_squared()`] convenience method to create an exponential squared falloff /// with the proper density for a desired visibility distance in world units; - /// - Combine the `density` parameter with the [`FogSettings`] `color`'s alpha channel for easier artistic control. + /// - Combine the `density` parameter with the [`DistanceFog`] `color`'s alpha channel for easier artistic control. /// /// ## Formula /// @@ -244,7 +247,7 @@ pub enum FogFalloff { /// - Use the [`FogFalloff::from_visibility_colors()`] or [`FogFalloff::from_visibility_color()`] convenience methods /// to create an atmospheric falloff with the proper densities for a desired visibility distance in world units and /// extinction and inscattering colors; - /// - Combine the atmospheric fog parameters with the [`FogSettings`] `color`'s alpha channel for easier artistic control. + /// - Combine the atmospheric fog parameters with the [`DistanceFog`] `color`'s alpha channel for easier artistic control. /// /// ## Formula /// @@ -463,9 +466,9 @@ impl FogFalloff { } } -impl Default for FogSettings { +impl Default for DistanceFog { fn default() -> Self { - FogSettings { + DistanceFog { color: Color::WHITE, falloff: FogFalloff::Linear { start: 0.0, diff --git a/crates/bevy_pbr/src/lib.rs b/crates/bevy_pbr/src/lib.rs index ba2848b8a8..ed57085363 100644 --- a/crates/bevy_pbr/src/lib.rs +++ b/crates/bevy_pbr/src/lib.rs @@ -57,8 +57,10 @@ pub use prepass::*; pub use render::*; pub use ssao::*; pub use ssr::*; +#[allow(deprecated)] pub use volumetric_fog::{ - FogVolume, FogVolumeBundle, VolumetricFogPlugin, VolumetricFogSettings, VolumetricLight, + FogVolume, FogVolumeBundle, VolumetricFog, VolumetricFogPlugin, VolumetricFogSettings, + VolumetricLight, }; /// The PBR prelude. @@ -71,7 +73,7 @@ pub mod prelude { DirectionalLightBundle, MaterialMeshBundle, PbrBundle, PointLightBundle, SpotLightBundle, }, - fog::{FogFalloff, FogSettings}, + fog::{DistanceFog, FogFalloff}, light::{light_consts, AmbientLight, DirectionalLight, PointLight, SpotLight}, light_probe::{ environment_map::{EnvironmentMapLight, ReflectionProbeBundle}, @@ -303,7 +305,7 @@ impl Plugin for PbrPlugin { .register_type::() .register_type::() .register_type::() - .register_type::() + .register_type::() .register_type::() .init_resource::() .init_resource::() diff --git a/crates/bevy_pbr/src/light/mod.rs b/crates/bevy_pbr/src/light/mod.rs index f6124c71de..7de24c347c 100644 --- a/crates/bevy_pbr/src/light/mod.rs +++ b/crates/bevy_pbr/src/light/mod.rs @@ -486,7 +486,7 @@ pub enum ShadowFilteringMethod { /// A randomized filter that varies over time, good when TAA is in use. /// /// Good quality when used with - /// [`TemporalAntiAliasSettings`](bevy_core_pipeline::experimental::taa::TemporalAntiAliasSettings) + /// [`TemporalAntiAliasing`](bevy_core_pipeline::experimental::taa::TemporalAntiAliasing) /// and good performance. /// /// For directional and spot lights, this uses a [method by Jorge Jimenez for diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index 9da61b2ce9..ac072afffd 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -553,7 +553,7 @@ pub fn queue_material_meshes( Option<&Tonemapping>, Option<&DebandDither>, Option<&ShadowFilteringMethod>, - Has, + Has, ( Has, Has, diff --git a/crates/bevy_pbr/src/meshlet/material_pipeline_prepare.rs b/crates/bevy_pbr/src/meshlet/material_pipeline_prepare.rs index 1a5c3e2d56..6a0f093d81 100644 --- a/crates/bevy_pbr/src/meshlet/material_pipeline_prepare.rs +++ b/crates/bevy_pbr/src/meshlet/material_pipeline_prepare.rs @@ -45,7 +45,7 @@ pub fn prepare_material_meshlet_meshes_main_opaque_pass( Option<&Tonemapping>, Option<&DebandDither>, Option<&ShadowFilteringMethod>, - Has, + Has, ( Has, Has, diff --git a/crates/bevy_pbr/src/render/fog.rs b/crates/bevy_pbr/src/render/fog.rs index 1421ddcd6d..02bd6ac736 100644 --- a/crates/bevy_pbr/src/render/fog.rs +++ b/crates/bevy_pbr/src/render/fog.rs @@ -11,7 +11,7 @@ use bevy_render::{ Render, RenderApp, RenderSet, }; -use crate::{FogFalloff, FogSettings}; +use crate::{DistanceFog, FogFalloff}; /// The GPU-side representation of the fog configuration that's sent as a uniform to the shader #[derive(Copy, Clone, ShaderType, Default, Debug)] @@ -51,7 +51,7 @@ pub fn prepare_fog( render_device: Res, render_queue: Res, mut fog_meta: ResMut, - views: Query<(Entity, Option<&FogSettings>), With>, + views: Query<(Entity, Option<&DistanceFog>), With>, ) { let views_iter = views.iter(); let view_count = views_iter.len(); @@ -136,8 +136,8 @@ impl Plugin for FogPlugin { fn build(&self, app: &mut App) { load_internal_asset!(app, FOG_SHADER_HANDLE, "fog.wgsl", Shader::from_wgsl); - app.register_type::(); - app.add_plugins(ExtractComponentPlugin::::default()); + app.register_type::(); + app.add_plugins(ExtractComponentPlugin::::default()); if let Some(render_app) = app.get_sub_app_mut(RenderApp) { render_app diff --git a/crates/bevy_pbr/src/render/mesh_view_types.wgsl b/crates/bevy_pbr/src/render/mesh_view_types.wgsl index c1d379e3b4..35e981cc85 100644 --- a/crates/bevy_pbr/src/render/mesh_view_types.wgsl +++ b/crates/bevy_pbr/src/render/mesh_view_types.wgsl @@ -139,7 +139,7 @@ struct LightProbes { // Settings for screen space reflections. // // For more information on these settings, see the documentation for -// `bevy_pbr::ssr::ScreenSpaceReflectionsSettings`. +// `bevy_pbr::ssr::ScreenSpaceReflections`. struct ScreenSpaceReflectionsSettings { perceptual_roughness_threshold: f32, thickness: f32, diff --git a/crates/bevy_pbr/src/ssao/mod.rs b/crates/bevy_pbr/src/ssao/mod.rs index cba48b8f8b..02a81b014d 100644 --- a/crates/bevy_pbr/src/ssao/mod.rs +++ b/crates/bevy_pbr/src/ssao/mod.rs @@ -68,7 +68,7 @@ impl Plugin for ScreenSpaceAmbientOcclusionPlugin { Shader::from_wgsl ); - app.register_type::(); + app.register_type::(); } fn finish(&self, app: &mut App) { @@ -129,7 +129,7 @@ impl Plugin for ScreenSpaceAmbientOcclusionPlugin { /// Bundle to apply screen space ambient occlusion. #[derive(Bundle, Default, Clone)] pub struct ScreenSpaceAmbientOcclusionBundle { - pub settings: ScreenSpaceAmbientOcclusionSettings, + pub settings: ScreenSpaceAmbientOcclusion, pub depth_prepass: DepthPrepass, pub normal_prepass: NormalPrepass, } @@ -149,16 +149,20 @@ pub struct ScreenSpaceAmbientOcclusionBundle { /// and add the [`DepthPrepass`] and [`NormalPrepass`] components to your camera. /// /// It strongly recommended that you use SSAO in conjunction with -/// TAA ([`bevy_core_pipeline::experimental::taa::TemporalAntiAliasSettings`]). +/// TAA ([`bevy_core_pipeline::experimental::taa::TemporalAntiAliasing`]). /// Doing so greatly reduces SSAO noise. /// /// SSAO is not supported on `WebGL2`, and is not currently supported on `WebGPU` or `DirectX12`. #[derive(Component, ExtractComponent, Reflect, PartialEq, Eq, Hash, Clone, Default, Debug)] #[reflect(Component)] -pub struct ScreenSpaceAmbientOcclusionSettings { +#[doc(alias = "Ssao")] +pub struct ScreenSpaceAmbientOcclusion { pub quality_level: ScreenSpaceAmbientOcclusionQualityLevel, } +#[deprecated(since = "0.15.0", note = "Renamed to `ScreenSpaceAmbientOcclusion`")] +pub type ScreenSpaceAmbientOcclusionSettings = ScreenSpaceAmbientOcclusion; + #[derive(Reflect, PartialEq, Eq, Hash, Clone, Copy, Default, Debug)] pub enum ScreenSpaceAmbientOcclusionQualityLevel { Low, @@ -444,7 +448,7 @@ impl FromWorld for SsaoPipelines { #[derive(PartialEq, Eq, Hash, Clone)] struct SsaoPipelineKey { - ssao_settings: ScreenSpaceAmbientOcclusionSettings, + ssao_settings: ScreenSpaceAmbientOcclusion, temporal_jitter: bool, } @@ -484,7 +488,7 @@ fn extract_ssao_settings( mut commands: Commands, cameras: Extract< Query< - (Entity, &Camera, &ScreenSpaceAmbientOcclusionSettings, &Msaa), + (Entity, &Camera, &ScreenSpaceAmbientOcclusion, &Msaa), (With, With, With), >, >, @@ -516,7 +520,7 @@ fn prepare_ssao_textures( mut commands: Commands, mut texture_cache: ResMut, render_device: Res, - views: Query<(Entity, &ExtractedCamera), With>, + views: Query<(Entity, &ExtractedCamera), With>, ) { for (entity, camera) in &views { let Some(physical_viewport_size) = camera.physical_viewport_size else { @@ -603,11 +607,7 @@ fn prepare_ssao_pipelines( pipeline_cache: Res, mut pipelines: ResMut>, pipeline: Res, - views: Query<( - Entity, - &ScreenSpaceAmbientOcclusionSettings, - Has, - )>, + views: Query<(Entity, &ScreenSpaceAmbientOcclusion, Has)>, ) { for (entity, ssao_settings, temporal_jitter) in &views { let pipeline_id = pipelines.specialize( diff --git a/crates/bevy_pbr/src/ssr/mod.rs b/crates/bevy_pbr/src/ssr/mod.rs index 1ae86b10a1..6d9c8c6dd7 100644 --- a/crates/bevy_pbr/src/ssr/mod.rs +++ b/crates/bevy_pbr/src/ssr/mod.rs @@ -60,7 +60,7 @@ pub struct ScreenSpaceReflectionsPlugin; #[derive(Bundle, Default)] pub struct ScreenSpaceReflectionsBundle { /// The component that enables SSR. - pub settings: ScreenSpaceReflectionsSettings, + pub settings: ScreenSpaceReflections, /// The depth prepass, needed for SSR. pub depth_prepass: DepthPrepass, /// The deferred prepass, needed for SSR. @@ -92,7 +92,8 @@ pub struct ScreenSpaceReflectionsBundle { /// which is required for screen-space raymarching. #[derive(Clone, Copy, Component, Reflect)] #[reflect(Component, Default)] -pub struct ScreenSpaceReflectionsSettings { +#[doc(alias = "Ssr")] +pub struct ScreenSpaceReflections { /// The maximum PBR roughness level that will enable screen space /// reflections. pub perceptual_roughness_threshold: f32, @@ -133,10 +134,13 @@ pub struct ScreenSpaceReflectionsSettings { pub use_secant: bool, } -/// A version of [`ScreenSpaceReflectionsSettings`] for upload to the GPU. +#[deprecated(since = "0.15.0", note = "Renamed to `ScreenSpaceReflections`")] +pub type ScreenSpaceReflectionsSettings = ScreenSpaceReflections; + +/// A version of [`ScreenSpaceReflections`] for upload to the GPU. /// /// For more information on these fields, see the corresponding documentation in -/// [`ScreenSpaceReflectionsSettings`]. +/// [`ScreenSpaceReflections`]. #[derive(Clone, Copy, Component, ShaderType)] pub struct ScreenSpaceReflectionsUniform { perceptual_roughness_threshold: f32, @@ -195,8 +199,8 @@ impl Plugin for ScreenSpaceReflectionsPlugin { Shader::from_wgsl ); - app.register_type::() - .add_plugins(ExtractComponentPlugin::::default()); + app.register_type::() + .add_plugins(ExtractComponentPlugin::::default()); let Some(render_app) = app.get_sub_app_mut(RenderApp) else { return; @@ -234,7 +238,7 @@ impl Plugin for ScreenSpaceReflectionsPlugin { } } -impl Default for ScreenSpaceReflectionsSettings { +impl Default for ScreenSpaceReflections { // Reasonable default values. // // These are from @@ -485,8 +489,8 @@ pub fn prepare_ssr_settings( } } -impl ExtractComponent for ScreenSpaceReflectionsSettings { - type QueryData = Read; +impl ExtractComponent for ScreenSpaceReflections { + type QueryData = Read; type QueryFilter = (); @@ -553,8 +557,8 @@ impl SpecializedRenderPipeline for ScreenSpaceReflectionsPipeline { } } -impl From for ScreenSpaceReflectionsUniform { - fn from(settings: ScreenSpaceReflectionsSettings) -> Self { +impl From for ScreenSpaceReflectionsUniform { + fn from(settings: ScreenSpaceReflections) -> Self { Self { perceptual_roughness_threshold: settings.perceptual_roughness_threshold, thickness: settings.thickness, diff --git a/crates/bevy_pbr/src/volumetric_fog/mod.rs b/crates/bevy_pbr/src/volumetric_fog/mod.rs index 82aedd3d0b..9107bebd79 100644 --- a/crates/bevy_pbr/src/volumetric_fog/mod.rs +++ b/crates/bevy_pbr/src/volumetric_fog/mod.rs @@ -6,9 +6,9 @@ //! for light beams from directional lights to shine through, creating what is //! known as *light shafts* or *god rays*. //! -//! To add volumetric fog to a scene, add [`VolumetricFogSettings`] to the +//! To add volumetric fog to a scene, add [`VolumetricFog`] to the //! camera, and add [`VolumetricLight`] to directional lights that you wish to -//! be volumetric. [`VolumetricFogSettings`] feature numerous settings that +//! be volumetric. [`VolumetricFog`] feature numerous settings that //! allow you to define the accuracy of the simulation, as well as the look of //! the fog. Currently, only interaction with directional lights that have //! shadow maps is supported. Note that the overhead of the effect scales @@ -79,7 +79,7 @@ pub struct VolumetricLight; /// rays. #[derive(Clone, Copy, Component, Debug, Reflect)] #[reflect(Component)] -pub struct VolumetricFogSettings { +pub struct VolumetricFog { /// Color of the ambient light. /// /// This is separate from Bevy's [`AmbientLight`](crate::light::AmbientLight) because an @@ -115,6 +115,9 @@ pub struct VolumetricFogSettings { pub step_count: u32, } +#[deprecated(since = "0.15.0", note = "Renamed to `VolumetricFog`")] +pub type VolumetricFogSettings = VolumetricFog; + /// A convenient [`Bundle`] that contains all components necessary to generate a /// fog volume. #[derive(Bundle, Clone, Debug, Default)] @@ -218,7 +221,7 @@ impl Plugin for VolumetricFogPlugin { meshes.insert(&PLANE_MESH, Plane3d::new(Vec3::Z, Vec2::ONE).mesh().into()); meshes.insert(&CUBE_MESH, Cuboid::new(1.0, 1.0, 1.0).mesh().into()); - app.register_type::() + app.register_type::() .register_type::(); let Some(render_app) = app.get_sub_app_mut(RenderApp) else { @@ -261,7 +264,7 @@ impl Plugin for VolumetricFogPlugin { } } -impl Default for VolumetricFogSettings { +impl Default for VolumetricFog { fn default() -> Self { Self { step_count: 64, diff --git a/crates/bevy_pbr/src/volumetric_fog/render.rs b/crates/bevy_pbr/src/volumetric_fog/render.rs index 618e984db0..9a35a92eae 100644 --- a/crates/bevy_pbr/src/volumetric_fog/render.rs +++ b/crates/bevy_pbr/src/volumetric_fog/render.rs @@ -47,7 +47,7 @@ use bitflags::bitflags; use crate::{ FogVolume, MeshPipelineViewLayoutKey, MeshPipelineViewLayouts, MeshViewBindGroup, ViewEnvironmentMapUniformOffset, ViewFogUniformOffset, ViewLightProbesUniformOffset, - ViewLightsUniformOffset, ViewScreenSpaceReflectionsUniformOffset, VolumetricFogSettings, + ViewLightsUniformOffset, ViewScreenSpaceReflectionsUniformOffset, VolumetricFog, VolumetricLight, }; @@ -152,7 +152,7 @@ pub struct VolumetricFogPipelineKey { flags: VolumetricFogPipelineKeyFlags, } -/// The same as [`VolumetricFogSettings`] and [`FogVolume`], but formatted for +/// The same as [`VolumetricFog`] and [`FogVolume`], but formatted for /// the GPU. /// /// See the documentation of those structures for more information on these @@ -266,11 +266,11 @@ impl FromWorld for VolumetricFogPipeline { } } -/// Extracts [`VolumetricFogSettings`], [`FogVolume`], and [`VolumetricLight`]s +/// Extracts [`VolumetricFog`], [`FogVolume`], and [`VolumetricLight`]s /// from the main world to the render world. pub fn extract_volumetric_fog( mut commands: Commands, - view_targets: Extract>, + view_targets: Extract>, fog_volumes: Extract>, volumetric_lights: Extract>, ) { @@ -278,10 +278,8 @@ pub fn extract_volumetric_fog( return; } - for (entity, volumetric_fog_settings) in view_targets.iter() { - commands - .get_or_spawn(entity) - .insert(*volumetric_fog_settings); + for (entity, volumetric_fog) in view_targets.iter() { + commands.get_or_spawn(entity).insert(*volumetric_fog); } for (entity, fog_volume, fog_transform) in fog_volumes.iter() { @@ -606,7 +604,7 @@ pub fn prepare_volumetric_fog_pipelines( Has, Has, ), - With, + With, >, meshes: Res>, ) { @@ -666,11 +664,11 @@ pub fn prepare_volumetric_fog_pipelines( } } -/// A system that converts [`VolumetricFogSettings`] into [`VolumetricFogUniform`]s. +/// A system that converts [`VolumetricFog`] into [`VolumetricFogUniform`]s. pub fn prepare_volumetric_fog_uniforms( mut commands: Commands, mut volumetric_lighting_uniform_buffer: ResMut, - view_targets: Query<(Entity, &ExtractedView, &VolumetricFogSettings)>, + view_targets: Query<(Entity, &ExtractedView, &VolumetricFog)>, fog_volumes: Query<(Entity, &FogVolume, &GlobalTransform)>, render_device: Res, render_queue: Res, @@ -690,7 +688,7 @@ pub fn prepare_volumetric_fog_uniforms( local_from_world_matrices.push(fog_transform.compute_matrix().inverse()); } - for (view_entity, extracted_view, volumetric_fog_settings) in view_targets.iter() { + for (view_entity, extracted_view, volumetric_fog) in view_targets.iter() { let world_from_view = extracted_view.world_from_view.compute_matrix(); let mut view_fog_volumes = vec![]; @@ -721,9 +719,9 @@ pub fn prepare_volumetric_fog_uniforms( far_planes: get_far_planes(&view_from_local), fog_color: fog_volume.fog_color.to_linear().to_vec3(), light_tint: fog_volume.light_tint.to_linear().to_vec3(), - ambient_color: volumetric_fog_settings.ambient_color.to_linear().to_vec3(), - ambient_intensity: volumetric_fog_settings.ambient_intensity, - step_count: volumetric_fog_settings.step_count, + ambient_color: volumetric_fog.ambient_color.to_linear().to_vec3(), + ambient_intensity: volumetric_fog.ambient_intensity, + step_count: volumetric_fog.step_count, bounding_radius, absorption: fog_volume.absorption, scattering: fog_volume.scattering, @@ -731,7 +729,7 @@ pub fn prepare_volumetric_fog_uniforms( density_texture_offset: fog_volume.density_texture_offset, scattering_asymmetry: fog_volume.scattering_asymmetry, light_intensity: fog_volume.light_intensity, - jitter_strength: volumetric_fog_settings.jitter, + jitter_strength: volumetric_fog.jitter, }); view_fog_volumes.push(ViewFogVolume { @@ -753,7 +751,7 @@ pub fn prepare_volumetric_fog_uniforms( /// default. pub fn prepare_view_depth_textures_for_volumetric_fog( mut view_targets: Query<&mut Camera3d>, - fog_volumes: Query<&VolumetricFogSettings>, + fog_volumes: Query<&VolumetricFog>, ) { if fog_volumes.is_empty() { return; diff --git a/crates/bevy_pbr/src/volumetric_fog/volumetric_fog.wgsl b/crates/bevy_pbr/src/volumetric_fog/volumetric_fog.wgsl index 2c30eddbea..6b4b1791e6 100644 --- a/crates/bevy_pbr/src/volumetric_fog/volumetric_fog.wgsl +++ b/crates/bevy_pbr/src/volumetric_fog/volumetric_fog.wgsl @@ -28,7 +28,7 @@ position_view_to_world } -// The GPU version of [`VolumetricFogSettings`]. See the comments in +// The GPU version of [`VolumetricFog`]. See the comments in // `volumetric_fog/mod.rs` for descriptions of the fields here. struct VolumetricFog { clip_from_local: mat4x4, diff --git a/examples/2d/bloom_2d.rs b/examples/2d/bloom_2d.rs index 3735fcf300..a603ced251 100644 --- a/examples/2d/bloom_2d.rs +++ b/examples/2d/bloom_2d.rs @@ -2,7 +2,7 @@ use bevy::{ core_pipeline::{ - bloom::{BloomCompositeMode, BloomSettings}, + bloom::{Bloom, BloomCompositeMode}, tonemapping::Tonemapping, }, prelude::*, @@ -32,7 +32,7 @@ fn setup( tonemapping: Tonemapping::TonyMcMapface, // 2. Using a tonemapper that desaturates to white is recommended ..default() }, - BloomSettings::default(), // 3. Enable bloom for the camera + Bloom::default(), // 3. Enable bloom for the camera )); // Sprite @@ -78,120 +78,113 @@ fn setup( // ------------------------------------------------------------------------------------------------ fn update_bloom_settings( - mut camera: Query<(Entity, Option<&mut BloomSettings>), With>, + mut camera: Query<(Entity, Option<&mut Bloom>), With>, mut text: Query<&mut Text>, mut commands: Commands, keycode: Res>, time: Res