Skip to content

Commit

Permalink
Write system to modify depth texture
Browse files Browse the repository at this point in the history
  • Loading branch information
JMS55 committed Dec 31, 2023
1 parent 32b382d commit 842cfe7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
1 change: 0 additions & 1 deletion crates/bevy_core_pipeline/src/core_3d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ pub fn prepare_core_3d_depth_textures(
// Required to read the output of the prepass
usage |= TextureUsages::COPY_SRC;
}
usage |= TextureUsages::TEXTURE_BINDING; // TODO: Required by MeshletPlugin
render_target_usage
.entry(camera.target.clone())
.and_modify(|u| *u |= usage)
Expand Down
2 changes: 0 additions & 2 deletions crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,13 +590,11 @@ pub fn queue_material_meshes<M: Material>(
if ssao {
view_key |= MeshPipelineKey::SCREEN_SPACE_AMBIENT_OCCLUSION;
}

if let Some(camera_3d) = camera_3d {
view_key |= screen_space_specular_transmission_pipeline_key(
camera_3d.screen_space_specular_transmission_quality,
);
}

let rangefinder = view.rangefinder3d();
for visible_entity in &visible_entities.entities {
let Some(material_asset_id) = render_material_instances.get(visible_entity) else {
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_pbr/src/meshlet/material_draw_prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ pub fn prepare_material_meshlet_meshes<M: Material>(
});
opaque_pass_material_map.push((material_id, pipeline_id, material.bind_group.clone()));

// TODO: Need a different pipeline descriptor for the prepass
let pipeline_id = *cache
.entry(view_key)
.or_insert_with(|| pipeline_cache.queue_render_pipeline(pipeline_descriptor));
Expand Down
19 changes: 16 additions & 3 deletions crates/bevy_pbr/src/meshlet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ use self::{
use crate::Material;
use bevy_app::{App, Plugin};
use bevy_asset::{load_internal_asset, AssetApp, Handle};
use bevy_core_pipeline::core_3d::{graph::node::*, CORE_3D};
use bevy_ecs::{bundle::Bundle, schedule::IntoSystemConfigs};
use bevy_core_pipeline::core_3d::{
graph::node::*, prepare_core_3d_depth_textures, Camera3d, CORE_3D,
};
use bevy_ecs::{bundle::Bundle, schedule::IntoSystemConfigs, system::Query};
use bevy_render::{
render_graph::{RenderGraphApp, ViewNodeRunner},
render_resource::Shader,
render_resource::{Shader, TextureUsages},
view::{InheritedVisibility, Msaa, ViewVisibility, Visibility},
ExtractSchedule, Render, RenderApp, RenderSet,
};
Expand Down Expand Up @@ -138,6 +140,9 @@ impl Plugin for MeshletPlugin {
(
perform_pending_meshlet_mesh_writes.in_set(RenderSet::PrepareAssets),
prepare_meshlet_per_frame_resources.in_set(RenderSet::PrepareResources),
add_depth_texture_usages
.before(prepare_core_3d_depth_textures)
.in_set(RenderSet::PrepareResources),
prepare_meshlet_view_bind_groups.in_set(RenderSet::PrepareBindGroups),
),
);
Expand Down Expand Up @@ -185,3 +190,11 @@ impl<M: Material> Default for MaterialMeshletMeshBundle<M> {
}
}
}

fn add_depth_texture_usages(mut views_3d: Query<&mut Camera3d>) {
for mut camera_3d in &mut views_3d {
let mut usages: TextureUsages = camera_3d.depth_texture_usages.into();
usages |= TextureUsages::TEXTURE_BINDING;
camera_3d.depth_texture_usages = usages.into();
}
}

0 comments on commit 842cfe7

Please sign in to comment.