Skip to content

Commit 969ab60

Browse files
Merge branch 'main' into film_grain_effect
2 parents b172d68 + 65f197a commit 969ab60

File tree

117 files changed

+2126
-577
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+2126
-577
lines changed

Cargo.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ statically-linked-dxc = ["bevy_internal/statically-linked-dxc"]
423423
# Forces the wgpu instance to be initialized using the raw Vulkan HAL, enabling additional configuration
424424
raw_vulkan_init = ["bevy_internal/raw_vulkan_init"]
425425

426+
# Pre-populate buffer labels with buffer types for debugging.
427+
type_label_buffers = ["bevy_internal/type_label_buffers"]
428+
426429
# Tracing support, saving a file in Chrome Tracing format
427430
trace_chrome = ["trace", "bevy_internal/trace_chrome"]
428431

@@ -3307,7 +3310,7 @@ doc-scrape-examples = false
33073310
[package.metadata.example.manual_material]
33083311
name = "Manual Material Implementation"
33093312
description = "Demonstrates how to implement a material manually using the mid-level render APIs"
3310-
category = "Shader Advanced"
3313+
category = "Shaders Advanced"
33113314
wasm = true
33123315

33133316
[[example]]
@@ -5089,6 +5092,14 @@ doc-scrape-examples = false
50895092
[package.metadata.example.test_invalid_skinned_mesh]
50905093
hidden = true
50915094

5095+
[[example]]
5096+
name = "test_skinned_mesh_bounds"
5097+
path = "tests/3d/test_skinned_mesh_bounds.rs"
5098+
doc-scrape-examples = true
5099+
5100+
[package.metadata.example.test_skinned_mesh_bounds]
5101+
hidden = true
5102+
50925103
[profile.wasm-release]
50935104
inherits = "release"
50945105
opt-level = "z"

benches/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ bevy_platform = { path = "../crates/bevy_platform", default-features = false, fe
3030
] }
3131

3232
# Other crates
33-
glam = { version = "0.30.7", default-features = false, features = [
33+
glam = { version = "0.31.0", default-features = false, features = [
3434
"std",
3535
"rand",
3636
] }

crates/bevy_anti_alias/src/dlss/extract.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use super::{prepare::DlssRenderContext, Dlss, DlssFeature};
2-
use bevy_camera::{Camera, MainPassResolutionOverride, Projection};
2+
use bevy_camera::{Camera, Hdr, MainPassResolutionOverride, Projection};
33
use bevy_ecs::{
44
query::{Has, With},
55
system::{Commands, Query, ResMut},
66
};
7-
use bevy_render::{sync_world::RenderEntity, view::Hdr, MainWorld};
7+
use bevy_render::{sync_world::RenderEntity, MainWorld};
88

99
pub fn extract_dlss<F: DlssFeature>(
1010
mut commands: Commands,

crates/bevy_anti_alias/src/dlss/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ mod prepare;
2121
pub use dlss_wgpu::DlssPerfQualityMode;
2222

2323
use bevy_app::{App, Plugin};
24+
use bevy_camera::Hdr;
2425
use bevy_core_pipeline::{
2526
core_3d::graph::{Core3d, Node3d},
2627
prepass::{DepthPrepass, MotionVectorPrepass},
@@ -36,7 +37,7 @@ use bevy_render::{
3637
RenderDevice, RenderQueue,
3738
},
3839
texture::CachedTexture,
39-
view::{prepare_view_targets, Hdr},
40+
view::prepare_view_targets,
4041
ExtractSchedule, Render, RenderApp, RenderSystems,
4142
};
4243
use dlss_wgpu::{

crates/bevy_anti_alias/src/dlss/node.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,15 @@ impl ViewNode for DlssNode<DlssSuperResolutionFeature> {
7272

7373
let diagnostics = render_context.diagnostic_recorder();
7474
let command_encoder = render_context.command_encoder();
75-
let mut dlss_context = dlss_context.context.lock().unwrap();
76-
77-
command_encoder.push_debug_group("dlss_super_resolution");
7875
let time_span = diagnostics.time_span(command_encoder, "dlss_super_resolution");
7976

77+
let mut dlss_context = dlss_context.context.lock().unwrap();
8078
let dlss_command_buffer = dlss_context
8179
.render(render_parameters, command_encoder, &adapter)
8280
.expect("Failed to render DLSS Super Resolution");
8381

84-
time_span.end(command_encoder);
85-
command_encoder.pop_debug_group();
8682
render_context.add_command_buffer(dlss_command_buffer);
83+
time_span.end(render_context.command_encoder());
8784

8885
Ok(())
8986
}
@@ -149,19 +146,15 @@ impl ViewNode for DlssNode<DlssRayReconstructionFeature> {
149146

150147
let diagnostics = render_context.diagnostic_recorder();
151148
let command_encoder = render_context.command_encoder();
152-
let mut dlss_context = dlss_context.context.lock().unwrap();
153-
154-
command_encoder.push_debug_group("dlss_ray_reconstruction");
155149
let time_span = diagnostics.time_span(command_encoder, "dlss_ray_reconstruction");
156150

151+
let mut dlss_context = dlss_context.context.lock().unwrap();
157152
let dlss_command_buffer = dlss_context
158153
.render(render_parameters, command_encoder, &adapter)
159154
.expect("Failed to render DLSS Ray Reconstruction");
160155

161-
time_span.end(command_encoder);
162-
command_encoder.pop_debug_group();
163-
164156
render_context.add_command_buffer(dlss_command_buffer);
157+
time_span.end(render_context.command_encoder());
165158

166159
Ok(())
167160
}

crates/bevy_camera/src/camera.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl Default for SubCameraView {
158158
}
159159

160160
/// Information about the current [`RenderTarget`].
161-
#[derive(Debug, Clone)]
161+
#[derive(Debug, Reflect, Clone)]
162162
pub struct RenderTargetInfo {
163163
/// The physical size of this render target (in physical pixels, ignoring scale factor).
164164
pub physical_size: UVec2,
@@ -179,7 +179,7 @@ impl Default for RenderTargetInfo {
179179
}
180180

181181
/// Holds internally computed [`Camera`] values.
182-
#[derive(Default, Debug, Clone)]
182+
#[derive(Default, Debug, Reflect, Clone)]
183183
pub struct ComputedCameraValues {
184184
pub clip_from_view: Mat4,
185185
pub target_info: Option<RenderTargetInfo>,
@@ -355,7 +355,6 @@ pub struct Camera {
355355
/// camera will not be rendered.
356356
pub is_active: bool,
357357
/// Computed values for this camera, such as the projection matrix and the render target size.
358-
#[reflect(ignore, clone)]
359358
pub computed: ComputedCameraValues,
360359
// todo: reflect this when #6042 lands
361360
/// The [`CameraOutputMode`] for this camera.

crates/bevy_camera/src/components.rs

Lines changed: 7 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -27,40 +27,13 @@ pub struct Camera3d {
2727
pub depth_load_op: Camera3dDepthLoadOp,
2828
/// The texture usages for the depth texture created for the main 3d pass.
2929
pub depth_texture_usages: Camera3dDepthTextureUsage,
30-
/// How many individual steps should be performed in the `Transmissive3d` pass.
31-
///
32-
/// Roughly corresponds to how many “layers of transparency” are rendered for screen space
33-
/// specular transmissive objects. Each step requires making one additional
34-
/// texture copy, so it's recommended to keep this number to a reasonably low value. Defaults to `1`.
35-
///
36-
/// ### Notes
37-
///
38-
/// - No copies will be performed if there are no transmissive materials currently being rendered,
39-
/// regardless of this setting.
40-
/// - Setting this to `0` disables the screen-space refraction effect entirely, and falls
41-
/// back to refracting only the environment map light's texture.
42-
/// - If set to more than `0`, any opaque [`clear_color`](Camera::clear_color) will obscure the environment
43-
/// map light's texture, preventing it from being visible “through” transmissive materials. If you'd like
44-
/// to still have the environment map show up in your refractions, you can set the clear color's alpha to `0.0`.
45-
/// Keep in mind that depending on the platform and your window settings, this may cause the window to become
46-
/// transparent.
47-
pub screen_space_specular_transmission_steps: usize,
48-
/// The quality of the screen space specular transmission blur effect, applied to whatever's “behind” transmissive
49-
/// objects when their `roughness` is greater than `0.0`.
50-
///
51-
/// Higher qualities are more GPU-intensive.
52-
///
53-
/// **Note:** You can get better-looking results at any quality level by enabling TAA. See: `TemporalAntiAliasPlugin`
54-
pub screen_space_specular_transmission_quality: ScreenSpaceTransmissionQuality,
5530
}
5631

5732
impl Default for Camera3d {
5833
fn default() -> Self {
5934
Self {
6035
depth_load_op: Default::default(),
6136
depth_texture_usages: TextureUsages::RENDER_ATTACHMENT.into(),
62-
screen_space_specular_transmission_steps: 1,
63-
screen_space_specular_transmission_quality: Default::default(),
6437
}
6538
}
6639
}
@@ -107,33 +80,10 @@ impl From<Camera3dDepthLoadOp> for LoadOp<f32> {
10780
}
10881
}
10982

110-
/// The quality of the screen space transmission blur effect, applied to whatever's “behind” transmissive
111-
/// objects when their `roughness` is greater than `0.0`.
112-
///
113-
/// Higher qualities are more GPU-intensive.
114-
///
115-
/// **Note:** You can get better-looking results at any quality level by enabling TAA. See: `TemporalAntiAliasPlugin`
116-
#[derive(Resource, Default, Clone, Copy, Reflect, PartialEq, PartialOrd, Debug)]
117-
#[reflect(Resource, Default, Clone, Debug, PartialEq)]
118-
pub enum ScreenSpaceTransmissionQuality {
119-
/// Best performance at the cost of quality. Suitable for lower end GPUs. (e.g. Mobile)
120-
///
121-
/// `num_taps` = 4
122-
Low,
123-
124-
/// A balanced option between quality and performance.
125-
///
126-
/// `num_taps` = 8
127-
#[default]
128-
Medium,
129-
130-
/// Better quality. Suitable for high end GPUs. (e.g. Desktop)
131-
///
132-
/// `num_taps` = 16
133-
High,
134-
135-
/// The highest quality, suitable for non-realtime rendering. (e.g. Pre-rendered cinematics and photo mode)
136-
///
137-
/// `num_taps` = 32
138-
Ultra,
139-
}
83+
/// If this component is added to a camera, the camera will use an intermediate "high dynamic range" render texture.
84+
/// This allows rendering with a wider range of lighting values. However, this does *not* affect
85+
/// whether the camera will render with hdr display output (which bevy does not support currently)
86+
/// and only affects the intermediate render texture.
87+
#[derive(Component, Default, Copy, Clone, Reflect, PartialEq, Eq, Hash, Debug)]
88+
#[reflect(Component, Default, PartialEq, Hash, Debug)]
89+
pub struct Hdr;

crates/bevy_camera/src/primitives.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl Sphere {
218218
/// from the plane to the origin is `-8.0` along `NEG_Z`.
219219
///
220220
/// It is used to define a [`Frustum`], but is also a useful mathematical primitive for rendering tasks such as light computation.
221-
#[derive(Clone, Copy, Debug, Default)]
221+
#[derive(Clone, Copy, Reflect, Debug, Default)]
222222
pub struct HalfSpace {
223223
normal_d: Vec4,
224224
}
@@ -285,7 +285,6 @@ impl HalfSpace {
285285
#[derive(Component, Clone, Copy, Debug, Default, Reflect)]
286286
#[reflect(Component, Default, Debug, Clone)]
287287
pub struct Frustum {
288-
#[reflect(ignore, clone)]
289288
pub half_spaces: [HalfSpace; 6],
290289
}
291290

@@ -484,7 +483,6 @@ pub fn face_index_to_name(face_index: usize) -> &'static str {
484483
#[derive(Component, Clone, Debug, Default, Reflect)]
485484
#[reflect(Component, Default, Debug, Clone)]
486485
pub struct CubemapFrusta {
487-
#[reflect(ignore, clone)]
488486
pub frusta: [Frustum; 6],
489487
}
490488

@@ -536,7 +534,6 @@ pub enum CubemapLayout {
536534
#[derive(Component, Debug, Default, Reflect, Clone)]
537535
#[reflect(Component, Default, Debug, Clone)]
538536
pub struct CascadesFrusta {
539-
#[reflect(ignore, clone)]
540537
pub frusta: EntityHashMap<Vec<Frustum>>,
541538
}
542539

crates/bevy_camera/src/visibility/mod.rs

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ use core::any::TypeId;
66
use bevy_ecs::entity::EntityHashMap;
77
use bevy_ecs::lifecycle::HookContext;
88
use bevy_ecs::world::DeferredWorld;
9+
use bevy_mesh::skinning::{
10+
entity_aabb_from_skinned_mesh_bounds, SkinnedMesh, SkinnedMeshInverseBindposes,
11+
};
912
use derive_more::derive::{Deref, DerefMut};
1013
pub use range::*;
1114
pub use render_layers::*;
@@ -265,6 +268,19 @@ impl<'a> SetViewVisibility for Mut<'a, ViewVisibility> {
265268
#[reflect(Component, Default, Debug)]
266269
pub struct NoFrustumCulling;
267270

271+
/// Use this component to enable dynamic skinned mesh bounds. The [`Aabb`]
272+
/// component of the skinned mesh will be automatically updated each frame based
273+
/// on the current joint transforms.
274+
///
275+
/// `DynamicSkinnedMeshBounds` depends on data from `Mesh::skinned_mesh_bounds`
276+
/// and `SkinnedMesh`. The resulting `Aabb` will reliably enclose meshes where
277+
/// vertex positions are only affected by skinning. But the `Aabb` may be larger
278+
/// than is optimal, and doesn't account for morph targets, vertex shaders, and
279+
/// anything else that modifies vertex positions.
280+
#[derive(Debug, Component, Default, Reflect)]
281+
#[reflect(Component, Default, Debug)]
282+
pub struct DynamicSkinnedMeshBounds;
283+
268284
/// Collection of entities visible from the current view.
269285
///
270286
/// This component contains all entities which are visible from the currently
@@ -420,7 +436,9 @@ impl Plugin for VisibilityPlugin {
420436
.add_systems(
421437
PostUpdate,
422438
(
423-
calculate_bounds.in_set(CalculateBounds),
439+
(calculate_bounds, update_skinned_mesh_bounds)
440+
.chain()
441+
.in_set(CalculateBounds),
424442
(visibility_propagate_system, reset_view_visibility)
425443
.in_set(VisibilityPropagate),
426444
check_visibility.in_set(CheckVisibility),
@@ -485,6 +503,36 @@ pub fn calculate_bounds(
485503
});
486504
}
487505

506+
// Update the `Aabb` component of all skinned mesh entities with a `DynamicSkinnedMeshBounds`
507+
// component.
508+
fn update_skinned_mesh_bounds(
509+
inverse_bindposes_assets: Res<Assets<SkinnedMeshInverseBindposes>>,
510+
mesh_assets: Res<Assets<Mesh>>,
511+
mut mesh_entities: Query<
512+
(&mut Aabb, &Mesh3d, &SkinnedMesh, Option<&GlobalTransform>),
513+
With<DynamicSkinnedMeshBounds>,
514+
>,
515+
joint_entities: Query<&GlobalTransform>,
516+
) {
517+
mesh_entities
518+
.par_iter_mut()
519+
.for_each(|(mut aabb, mesh, skinned_mesh, world_from_entity)| {
520+
if let Some(inverse_bindposes_asset) =
521+
inverse_bindposes_assets.get(&skinned_mesh.inverse_bindposes)
522+
&& let Some(mesh_asset) = mesh_assets.get(mesh)
523+
&& let Ok(skinned_aabb) = entity_aabb_from_skinned_mesh_bounds(
524+
&joint_entities,
525+
mesh_asset,
526+
skinned_mesh,
527+
inverse_bindposes_asset,
528+
world_from_entity,
529+
)
530+
{
531+
*aabb = skinned_aabb.into();
532+
}
533+
});
534+
}
535+
488536
/// Updates [`Frustum`].
489537
///
490538
/// This system is used in [`CameraProjectionPlugin`](crate::CameraProjectionPlugin).

crates/bevy_core_pipeline/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ bevy_diagnostic = { path = "../bevy_diagnostic", version = "0.19.0-dev" }
2424
bevy_ecs = { path = "../bevy_ecs", version = "0.19.0-dev" }
2525
bevy_image = { path = "../bevy_image", version = "0.19.0-dev" }
2626
bevy_log = { path = "../bevy_log", version = "0.19.0-dev" }
27+
bevy_light = { path = "../bevy_light", version = "0.19.0-dev" }
2728
bevy_camera = { path = "../bevy_camera", version = "0.19.0-dev" }
2829
bevy_reflect = { path = "../bevy_reflect", version = "0.19.0-dev" }
2930
bevy_shader = { path = "../bevy_shader", version = "0.19.0-dev" }

0 commit comments

Comments
 (0)