mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 22:20:20 +00:00
Don’t prepare lights (and shadow map textures) for 2D cameras (#14574)
# Objective When running the Metal debugger I noticed that 2D cameras have shadow map textures from `bevy_pbr` built for them. For a 2560x1440 2D camera, this PR saves about 40mb of texture memory. ![image](https://github.com/user-attachments/assets/925e9392-2721-41bb-83e9-25c84fd563cd) ![image](https://github.com/user-attachments/assets/0cc3c0a9-cbf7-431c-b444-952c28d4e9d0) ## Solution - Added `With<Camera3d>` filter to the appropriate view queries. ## Testing - This is a trivial fix (the examples still work)
This commit is contained in:
parent
0c7df881e7
commit
4c4a6c4506
2 changed files with 13 additions and 9 deletions
|
@ -2,10 +2,11 @@
|
|||
|
||||
use std::num::NonZeroU64;
|
||||
|
||||
use bevy_core_pipeline::core_3d::Camera3d;
|
||||
use bevy_ecs::{
|
||||
component::Component,
|
||||
entity::{Entity, EntityHashMap},
|
||||
query::Without,
|
||||
query::{With, Without},
|
||||
reflect::ReflectComponent,
|
||||
system::{Commands, Query, Res, Resource},
|
||||
world::{FromWorld, World},
|
||||
|
@ -348,7 +349,7 @@ impl Clusters {
|
|||
|
||||
pub fn add_clusters(
|
||||
mut commands: Commands,
|
||||
cameras: Query<(Entity, Option<&ClusterConfig>, &Camera), Without<Clusters>>,
|
||||
cameras: Query<(Entity, Option<&ClusterConfig>, &Camera), (Without<Clusters>, With<Camera3d>)>,
|
||||
) {
|
||||
for (entity, config, camera) in &cameras {
|
||||
if !camera.is_active {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use bevy_asset::UntypedAssetId;
|
||||
use bevy_color::ColorToComponents;
|
||||
use bevy_core_pipeline::core_3d::CORE_3D_DEPTH_FORMAT;
|
||||
use bevy_core_pipeline::core_3d::{Camera3d, CORE_3D_DEPTH_FORMAT};
|
||||
use bevy_ecs::entity::EntityHashSet;
|
||||
use bevy_ecs::prelude::*;
|
||||
use bevy_ecs::{entity::EntityHashMap, system::lifetimeless::Read};
|
||||
|
@ -515,12 +515,15 @@ pub fn prepare_lights(
|
|||
render_queue: Res<RenderQueue>,
|
||||
mut global_light_meta: ResMut<GlobalClusterableObjectMeta>,
|
||||
mut light_meta: ResMut<LightMeta>,
|
||||
views: Query<(
|
||||
Entity,
|
||||
&ExtractedView,
|
||||
&ExtractedClusterConfig,
|
||||
Option<&RenderLayers>,
|
||||
)>,
|
||||
views: Query<
|
||||
(
|
||||
Entity,
|
||||
&ExtractedView,
|
||||
&ExtractedClusterConfig,
|
||||
Option<&RenderLayers>,
|
||||
),
|
||||
With<Camera3d>,
|
||||
>,
|
||||
ambient_light: Res<AmbientLight>,
|
||||
point_light_shadow_map: Res<PointLightShadowMap>,
|
||||
directional_light_shadow_map: Res<DirectionalLightShadowMap>,
|
||||
|
|
Loading…
Reference in a new issue