Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/bevy_animation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ impl Plugin for AnimationPlugin {
// `PostUpdate`. For now, we just disable ambiguity testing
// for this system.
animate_targets
.before(bevy_mesh::InheritWeights)
.before(bevy_mesh::InheritWeightSystems)
.ambiguous_with_all(),
trigger_untargeted_animation_events,
expire_completed_transitions,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_anti_aliasing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords = ["bevy"]
trace = []
webgl = []
webgpu = []
smaa_luts = ["bevy_render/ktx2", "bevy_image/ktx2", "bevy_image/zstd"]
smaa_luts = ["bevy_image/ktx2", "bevy_image/zstd"]

[dependencies]
# bevy
Expand Down
9 changes: 9 additions & 0 deletions crates/bevy_camera/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod primitives;
mod projection;
pub mod visibility;

use bevy_ecs::schedule::SystemSet;
pub use camera::*;
pub use clear_color::*;
pub use components::*;
Expand Down Expand Up @@ -37,3 +38,11 @@ pub mod prelude {
PerspectiveProjection, Projection,
};
}

/// Label for `camera_system<T>`, shared across all `T`.
#[derive(SystemSet, Clone, Eq, PartialEq, Hash, Debug)]
pub struct CameraUpdateSystems;

/// Deprecated alias for [`CameraUpdateSystems`].
#[deprecated(since = "0.17.0", note = "Renamed to `CameraUpdateSystems`.")]
pub type CameraUpdateSystem = CameraUpdateSystems;
8 changes: 0 additions & 8 deletions crates/bevy_camera/src/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ impl Plugin for CameraProjectionPlugin {
}
}

/// Label for `camera_system<T>`, shared across all `T`.
#[derive(SystemSet, Clone, Eq, PartialEq, Hash, Debug)]
pub struct CameraUpdateSystems;

/// Deprecated alias for [`CameraUpdateSystems`].
#[deprecated(since = "0.17.0", note = "Renamed to `CameraUpdateSystems`.")]
pub type CameraUpdateSystem = CameraUpdateSystems;

/// Describes a type that can generate a projection matrix, allowing it to be added to a
/// [`Camera`]'s [`Projection`] component.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ keywords = ["bevy"]
trace = []
webgl = []
webgpu = []
tonemapping_luts = ["bevy_render/ktx2", "bevy_image/ktx2", "bevy_image/zstd"]
tonemapping_luts = ["bevy_image/ktx2", "bevy_image/zstd"]

[dependencies]
# bevy
Expand Down
83 changes: 82 additions & 1 deletion crates/bevy_image/src/image.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
use crate::ImageLoader;

#[cfg(feature = "basis-universal")]
use super::basis::*;
#[cfg(feature = "dds")]
use super::dds::*;
#[cfg(feature = "ktx2")]
use super::ktx2::*;
use bevy_app::{App, Plugin};
#[cfg(not(feature = "bevy_reflect"))]
use bevy_reflect::TypePath;
#[cfg(feature = "bevy_reflect")]
use bevy_reflect::{std_traits::ReflectDefault, Reflect};

use bevy_asset::{Asset, RenderAssetUsages};
use bevy_asset::{uuid_handle, Asset, AssetApp, Assets, Handle, RenderAssetUsages};
use bevy_color::{Color, ColorToComponents, Gray, LinearRgba, Srgba, Xyza};
use bevy_ecs::resource::Resource;
use bevy_math::{AspectRatio, UVec2, UVec3, Vec2};
Expand All @@ -35,6 +38,84 @@ impl BevyDefault for TextureFormat {
}
}

/// A handle to a 1 x 1 transparent white image.
///
/// Like [`Handle<Image>::default`], this is a handle to a fallback image asset.
/// While that handle points to an opaque white 1 x 1 image, this handle points to a transparent 1 x 1 white image.
// Number randomly selected by fair WolframAlpha query. Totally arbitrary.
pub const TRANSPARENT_IMAGE_HANDLE: Handle<Image> =
uuid_handle!("d18ad97e-a322-4981-9505-44c59a4b5e46");

/// Adds the [`Image`] as an asset and makes sure that they are extracted and prepared for the GPU.
pub struct ImagePlugin {
/// The default image sampler to use when [`ImageSampler`] is set to `Default`.
pub default_sampler: ImageSamplerDescriptor,
}

impl Default for ImagePlugin {
fn default() -> Self {
ImagePlugin::default_linear()
}
}

impl ImagePlugin {
/// Creates image settings with linear sampling by default.
pub fn default_linear() -> ImagePlugin {
ImagePlugin {
default_sampler: ImageSamplerDescriptor::linear(),
}
}

/// Creates image settings with nearest sampling by default.
pub fn default_nearest() -> ImagePlugin {
ImagePlugin {
default_sampler: ImageSamplerDescriptor::nearest(),
}
}
}

impl Plugin for ImagePlugin {
fn build(&self, app: &mut App) {
#[cfg(feature = "exr")]
app.init_asset_loader::<crate::ExrTextureLoader>();

#[cfg(feature = "hdr")]
app.init_asset_loader::<crate::HdrTextureLoader>();

app.init_asset::<Image>();
#[cfg(feature = "bevy_reflect")]
app.register_asset_reflect::<Image>();

let mut image_assets = app.world_mut().resource_mut::<Assets<Image>>();

image_assets
.insert(&Handle::default(), Image::default())
.unwrap();
image_assets
.insert(&TRANSPARENT_IMAGE_HANDLE, Image::transparent())
.unwrap();

#[cfg(feature = "compressed_image_saver")]
if let Some(processor) = app
.world()
.get_resource::<bevy_asset::processor::AssetProcessor>()
{
processor.register_processor::<bevy_asset::processor::LoadTransformAndSave<
ImageLoader,
bevy_asset::transformer::IdentityAssetTransformer<Image>,
crate::CompressedImageSaver,
>>(crate::CompressedImageSaver.into());
processor.set_default_processor::<bevy_asset::processor::LoadTransformAndSave<
ImageLoader,
bevy_asset::transformer::IdentityAssetTransformer<Image>,
crate::CompressedImageSaver,
>>("png");
}

app.preregister_asset_loader::<ImageLoader>(ImageLoader::SUPPORTED_FILE_EXTENSIONS);
}
}

pub const TEXTURE_ASSET_INDEX: u64 = 0;
pub const SAMPLER_ASSET_INDEX: u64 = 1;

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_image/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod prelude {
pub use crate::{
dynamic_texture_atlas_builder::DynamicTextureAtlasBuilder,
texture_atlas::{TextureAtlas, TextureAtlasLayout, TextureAtlasSources},
BevyDefault as _, Image, ImageFormat, TextureAtlasBuilder, TextureError,
BevyDefault as _, Image, ImageFormat, ImagePlugin, TextureAtlasBuilder, TextureError,
};
}

Expand Down
26 changes: 12 additions & 14 deletions crates/bevy_internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,16 @@ detailed_trace = ["bevy_ecs/detailed_trace", "bevy_render?/detailed_trace"]
sysinfo_plugin = ["bevy_diagnostic/sysinfo_plugin"]

# Enables compressed KTX2 UASTC texture output on the asset processor
compressed_image_saver = [
"bevy_image/compressed_image_saver",
"bevy_render/compressed_image_saver",
]

# Texture formats that have specific rendering support (HDR enabled by default)
basis-universal = ["bevy_image/basis-universal", "bevy_render/basis-universal"]
exr = ["bevy_image/exr", "bevy_render/exr"]
hdr = ["bevy_image/hdr", "bevy_render/hdr"]
ktx2 = ["bevy_image/ktx2", "bevy_render/ktx2"]
compressed_image_saver = ["bevy_image/compressed_image_saver"]

# For ktx2 supercompression
zlib = ["bevy_image/zlib"]
zstd = ["bevy_image/zstd"]
zstd_rust = ["bevy_image/zstd_rust"]
zstd_c = ["bevy_image/zstd_c"]

# Image format support (PNG enabled by default)
# Image format support (HDR and PNG enabled by default)
basis-universal = ["bevy_image/basis-universal"]
bmp = ["bevy_image/bmp"]
ff = ["bevy_image/ff"]
gif = ["bevy_image/gif"]
Expand All @@ -59,6 +51,9 @@ tga = ["bevy_image/tga"]
tiff = ["bevy_image/tiff"]
webp = ["bevy_image/webp"]
dds = ["bevy_image/dds"]
exr = ["bevy_image/exr"]
hdr = ["bevy_image/hdr"]
ktx2 = ["bevy_image/ktx2"]

# Enable SPIR-V passthrough
spirv_shader_passthrough = ["bevy_render/spirv_shader_passthrough"]
Expand Down Expand Up @@ -89,11 +84,14 @@ symphonia-wav = ["bevy_audio/symphonia-wav"]

# Shader formats
shader_format_glsl = [
"bevy_render/shader_format_glsl",
"bevy_shader/shader_format_glsl",
"bevy_pbr?/shader_format_glsl",
]
shader_format_spirv = ["bevy_render/shader_format_spirv"]
shader_format_wesl = ["bevy_render/shader_format_wesl"]
shader_format_spirv = [
"bevy_shader/shader_format_spirv",
"bevy_render?/shader_format_spirv",
]
shader_format_wesl = ["bevy_shader/shader_format_wesl"]

serialize = [
"bevy_a11y?/serialize",
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_internal/src/default_plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ plugin_group! {
bevy_render:::RenderPlugin,
// NOTE: Load this after renderer initialization so that it knows about the supported
// compressed texture formats.
#[cfg(feature = "bevy_render")]
bevy_render::texture:::ImagePlugin,
#[cfg(feature = "bevy_image")]
bevy_image:::ImagePlugin,
#[cfg(feature = "bevy_render")]
#[custom(cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded")))]
bevy_render::pipelined_rendering:::PipelinedRenderingPlugin,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_mesh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ impl BaseMeshPipelineKey {

/// `bevy_render::mesh::inherit_weights` runs in this `SystemSet`
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
pub struct InheritWeights;
pub struct InheritWeightSystems;
4 changes: 2 additions & 2 deletions crates/bevy_pbr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ experimental_pbr_pcss = ["bevy_light/experimental_pbr_pcss"]
pbr_specular_textures = []
pbr_clustered_decals = []
pbr_light_textures = []
bluenoise_texture = ["bevy_render/ktx2", "bevy_image/ktx2", "bevy_image/zstd"]
shader_format_glsl = ["bevy_render/shader_format_glsl"]
bluenoise_texture = ["bevy_image/ktx2", "bevy_image/zstd"]
shader_format_glsl = ["bevy_shader/shader_format_glsl"]
trace = ["bevy_render/trace"]
# Enables the meshlet renderer for dense high-poly scenes (experimental)
meshlet = ["dep:lz4_flex", "dep:range-alloc", "dep:bevy_tasks"]
Expand Down
11 changes: 0 additions & 11 deletions crates/bevy_render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,9 @@ keywords = ["bevy"]
# wgpu-types = { git = "https://github.com/gfx-rs/wgpu", rev = "..." }
decoupled_naga = ["bevy_shader/decoupled_naga"]

# Enables compressed KTX2 UASTC texture output on the asset processor
compressed_image_saver = ["bevy_image/compressed_image_saver"]

# Texture formats (require more than just image support)
basis-universal = ["bevy_image/basis-universal"]
exr = ["bevy_image/exr"]
hdr = ["bevy_image/hdr"]
ktx2 = ["bevy_image/ktx2"]

multi_threaded = ["bevy_tasks/multi_threaded"]

shader_format_glsl = ["bevy_shader/shader_format_glsl"]
shader_format_spirv = ["bevy_shader/shader_format_spirv", "wgpu/spirv"]
shader_format_wesl = ["bevy_shader/shader_format_wesl"]

# Enable SPIR-V shader passthrough
spirv_shader_passthrough = ["wgpu/spirv"]
Expand Down
9 changes: 4 additions & 5 deletions crates/bevy_render/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,8 @@ mod wgpu_wrapper;
pub mod prelude {
#[doc(hidden)]
pub use crate::{
alpha::AlphaMode,
camera::NormalizedRenderTargetExt as _,
texture::{ImagePlugin, ManualTextureViews},
view::Msaa,
ExtractSchedule,
alpha::AlphaMode, camera::NormalizedRenderTargetExt as _, texture::ManualTextureViews,
view::Msaa, ExtractSchedule,
};
}

Expand All @@ -91,6 +88,7 @@ use crate::{
renderer::{render_system, RenderInstance},
settings::RenderCreation,
storage::StoragePlugin,
texture::TexturePlugin,
view::{ViewPlugin, WindowRenderPlugin},
};
use alloc::sync::Arc;
Expand Down Expand Up @@ -424,6 +422,7 @@ impl Plugin for RenderPlugin {
MeshPlugin,
GlobalsPlugin,
MorphPlugin,
TexturePlugin,
BatchingPlugin {
debug_flags: self.debug_flags,
},
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/mesh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Plugin for MeshPlugin {
pub struct MorphPlugin;
impl Plugin for MorphPlugin {
fn build(&self, app: &mut App) {
app.add_systems(PostUpdate, inherit_weights.in_set(InheritWeights));
app.add_systems(PostUpdate, inherit_weights.in_set(InheritWeightSystems));
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/render_resource/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl Deref for Sampler {
/// A rendering resource for the default image sampler which is set during renderer
/// initialization.
///
/// The [`ImagePlugin`](crate::texture::ImagePlugin) can be set during app initialization to change the default
/// The [`ImagePlugin`](bevy_image::ImagePlugin) can be set during app initialization to change the default
/// image sampler.
#[derive(Resource, Debug, Clone, Deref, DerefMut)]
pub struct DefaultImageSampler(pub(crate) Sampler);
Loading
Loading