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: 2 additions & 0 deletions crates/bevy_pbr/src/decal/forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use bevy_render::{
AsBindGroup, CompareFunction, RenderPipelineDescriptor, Shader,
SpecializedMeshPipelineError,
},
RenderDebugFlags,
};

const FORWARD_DECAL_MESH_HANDLE: Handle<Mesh> =
Expand Down Expand Up @@ -48,6 +49,7 @@ impl Plugin for ForwardDecalPlugin {
app.add_plugins(MaterialPlugin::<ForwardDecalMaterial<StandardMaterial>> {
prepass_enabled: false,
shadows_enabled: false,
debug_flags: RenderDebugFlags::default(),
..Default::default()
});
}
Expand Down
7 changes: 6 additions & 1 deletion crates/bevy_pbr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ use bevy_render::{
sync_component::SyncComponentPlugin,
texture::GpuImage,
view::VisibilitySystems,
ExtractSchedule, Render, RenderApp, RenderSet,
ExtractSchedule, Render, RenderApp, RenderDebugFlags, RenderSet,
};

use bevy_transform::TransformSystem;
Expand Down Expand Up @@ -182,6 +182,8 @@ pub struct PbrPlugin {
/// This requires compute shader support and so will be forcibly disabled if
/// the platform doesn't support those.
pub use_gpu_instance_buffer_builder: bool,
/// Debugging flags that can optionally be set when constructing the renderer.
pub debug_flags: RenderDebugFlags,
}

impl Default for PbrPlugin {
Expand All @@ -190,6 +192,7 @@ impl Default for PbrPlugin {
prepass_enabled: true,
add_default_deferred_lighting_plugin: true,
use_gpu_instance_buffer_builder: true,
debug_flags: RenderDebugFlags::default(),
}
}
}
Expand Down Expand Up @@ -333,9 +336,11 @@ impl Plugin for PbrPlugin {
.add_plugins((
MeshRenderPlugin {
use_gpu_instance_buffer_builder: self.use_gpu_instance_buffer_builder,
debug_flags: self.debug_flags,
},
MaterialPlugin::<StandardMaterial> {
prepass_enabled: self.prepass_enabled,
debug_flags: self.debug_flags,
..Default::default()
},
ScreenSpaceAmbientOcclusionPlugin,
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ pub struct MaterialPlugin<M: Material> {
pub prepass_enabled: bool,
/// Controls if shadows are enabled for the Material.
pub shadows_enabled: bool,
/// Debugging flags that can optionally be set when constructing the renderer.
pub debug_flags: RenderDebugFlags,
pub _marker: PhantomData<M>,
}

Expand All @@ -260,6 +262,7 @@ impl<M: Material> Default for MaterialPlugin<M> {
Self {
prepass_enabled: true,
shadows_enabled: true,
debug_flags: RenderDebugFlags::default(),
_marker: Default::default(),
}
}
Expand Down Expand Up @@ -374,7 +377,7 @@ where
}

if self.prepass_enabled {
app.add_plugins(PrepassPlugin::<M>::default());
app.add_plugins(PrepassPlugin::<M>::new(self.debug_flags));
}
}

Expand Down
24 changes: 17 additions & 7 deletions crates/bevy_pbr/src/prepass/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use bevy_render::{
renderer::RenderAdapter,
sync_world::RenderEntity,
view::{RenderVisibilityRanges, VISIBILITY_RANGES_STORAGE_BUFFER_COUNT},
ExtractSchedule, Render, RenderApp, RenderSet,
ExtractSchedule, Render, RenderApp, RenderDebugFlags, RenderSet,
};
pub use prepass_bindings::*;

Expand Down Expand Up @@ -146,11 +146,19 @@ where
/// Sets up the prepasses for a [`Material`].
///
/// This depends on the [`PrepassPipelinePlugin`].
pub struct PrepassPlugin<M: Material>(PhantomData<M>);
pub struct PrepassPlugin<M: Material> {
/// Debugging flags that can optionally be set when constructing the renderer.
pub debug_flags: RenderDebugFlags,
pub phantom: PhantomData<M>,
}

impl<M: Material> Default for PrepassPlugin<M> {
fn default() -> Self {
Self(Default::default())
impl<M: Material> PrepassPlugin<M> {
/// Creates a new [`PrepassPlugin`] with the given debug flags.
pub fn new(debug_flags: RenderDebugFlags) -> Self {
PrepassPlugin {
debug_flags,
phantom: PhantomData,
}
}
}

Expand All @@ -176,8 +184,10 @@ where
),
)
.add_plugins((
BinnedRenderPhasePlugin::<Opaque3dPrepass, MeshPipeline>::default(),
BinnedRenderPhasePlugin::<AlphaMask3dPrepass, MeshPipeline>::default(),
BinnedRenderPhasePlugin::<Opaque3dPrepass, MeshPipeline>::new(self.debug_flags),
BinnedRenderPhasePlugin::<AlphaMask3dPrepass, MeshPipeline>::new(
self.debug_flags,
),
));
}

Expand Down
Loading
Loading