Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Clustered forward rendering #3153

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ae605ad
WIP clustered forward
superdump Sep 21, 2021
ecbe8c4
More WIP clustered forward
superdump Sep 25, 2021
cd89fb6
Some more plumbing WIP
superdump Sep 26, 2021
19c6a5d
More WIP
superdump Sep 27, 2021
2787a8f
A bunch of bugfixes and debug stuff
superdump Sep 28, 2021
87a909f
Minor tweaks
superdump Sep 28, 2021
185df2f
bevy_pbr2: Do not queue shadow passes when shadows are disabled
superdump Sep 28, 2021
65d2647
bevy_pbr2: Flip screen y for calculating clusters
superdump Sep 29, 2021
881e054
bevy_pbr2: Move add_clusters to an exclusive system in PostUpdate
superdump Sep 29, 2021
7176734
bevy_pbr2: Use a constant for the point light near distance
superdump Sep 29, 2021
be46eea
Appease Vulkan
superdump Sep 30, 2021
6a56687
Fix indexing for offsets and counts
superdump Sep 30, 2021
07373da
Various fixes
superdump Sep 30, 2021
f3fc3e5
bevy_render2: Add some Aabb helpers
superdump Oct 1, 2021
3adfee6
bevy_pbr2: Optimise assign lights to clusters
superdump Oct 1, 2021
336463b
bevy_pbr2: Precalculate some factors used for clustered forward shading
superdump Oct 1, 2021
74ce02a
bevy_pbr2: Update tile size when screen size changes
superdump Oct 1, 2021
e26c42c
bevy_pbr2: Fix calculation of clusters affected by light
superdump Oct 1, 2021
79371a0
bevy_pbr2: Pack PointLight into 64 bytes to allow 256 lights max!
superdump Oct 2, 2021
84d1692
bevy_pbr2: Do not allocate max point lights shadow maps!
superdump Oct 3, 2021
7615d2d
bevy_pbr2: Minor optimisation - precalculated ln values
superdump Oct 3, 2021
02a69fb
bevy_pbr2: Some wgpu 0.11 / naga 0.7 fixes
superdump Oct 8, 2021
41caae7
Clean up rebase mistakes
superdump Nov 18, 2021
37acff5
bevy_pbr2: Clean up clustered-forward debug code
superdump Nov 20, 2021
8df8d5d
bevy_pbr2: Clean up WIP debugging stuff
superdump Nov 20, 2021
8f0e600
bevy_pbr2: Limit the number of point light shadow maps queued
superdump Nov 20, 2021
ae7cc0e
bevy_pbr2: Fix up scheduling of systems
superdump Nov 20, 2021
da4ee64
Appease clippy
superdump Nov 21, 2021
0bf9846
pbr.wgsl: Use index accessors for matrices
superdump Nov 22, 2021
8eaffdf
mesh_view_bind_group.wgsl: Fix code in comment
superdump Nov 22, 2021
5afd959
uniform_vec: Remove code used for debugging
superdump Nov 22, 2021
396d86b
Fix a couple of comments
superdump Nov 22, 2021
93b508f
Fix comment indentation style
superdump Nov 22, 2021
552b463
bevy_pbr2: Improvements to comments
superdump Nov 22, 2021
4656c22
bevy_pbr2: Add some comments about reference material for clustered-f…
superdump Nov 25, 2021
098847a
bevy_pbr2: Appease clippy
superdump Nov 25, 2021
cdeb00b
bevy_pbr2: Aspect-ratio independent cluster tile configuration
superdump Dec 5, 2021
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
6 changes: 3 additions & 3 deletions pipelined/bevy_core_pipeline/src/main_pass_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Node for MainPass3dNode {
let pass_descriptor = RenderPassDescriptor {
label: Some("main_opaque_pass_3d"),
// NOTE: The opaque pass clears and initializes the color
// buffer as well as writing to it.
// buffer as well as writing to it.
color_attachments: &[target.get_color_attachment(Operations {
load: LoadOp::Clear(clear_color.0.into()),
store: true,
Expand Down Expand Up @@ -135,8 +135,8 @@ impl Node for MainPass3dNode {
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
view: &depth.view,
// NOTE: For the transparent pass we load the depth buffer but do not write to it.
// As the opaque and alpha mask passes run first, opaque meshes can occlude
// transparent ones.
// As the opaque and alpha mask passes run first, opaque meshes can occlude
// transparent ones.
depth_ops: Some(Operations {
load: LoadOp::Load,
store: false,
Expand Down
1 change: 1 addition & 0 deletions pipelined/bevy_pbr2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ bevy_reflect = { path = "../../crates/bevy_reflect", version = "0.5.0", features
bevy_render2 = { path = "../bevy_render2", version = "0.5.0" }
bevy_transform = { path = "../../crates/bevy_transform", version = "0.5.0" }
bevy_utils = { path = "../../crates/bevy_utils", version = "0.5.0" }
bevy_window = { path = "../../crates/bevy_window", version = "0.5.0" }

# other
bitflags = "1.2"
Expand Down
42 changes: 40 additions & 2 deletions pipelined/bevy_pbr2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,29 @@ impl Plugin for PbrPlugin {
.init_resource::<DirectionalLightShadowMap>()
.init_resource::<PointLightShadowMap>()
.init_resource::<AmbientLight>()
.init_resource::<VisiblePointLights>()
.add_system_to_stage(
CoreStage::PostUpdate,
// NOTE: Clusters need to have been added before update_clusters is run so
// add as an exclusive system
add_clusters
.exclusive_system()
.label(SimulationLightSystems::AddClusters),
)
.add_system_to_stage(
CoreStage::PostUpdate,
// NOTE: Must come after add_clusters!
update_clusters
.label(SimulationLightSystems::UpdateClusters)
.after(TransformSystem::TransformPropagate),
)
.add_system_to_stage(
CoreStage::PostUpdate,
assign_lights_to_clusters
.label(SimulationLightSystems::AssignLightsToClusters)
.after(TransformSystem::TransformPropagate)
.after(SimulationLightSystems::UpdateClusters),
)
.add_system_to_stage(
CoreStage::PostUpdate,
update_directional_light_frusta
Expand All @@ -70,11 +93,12 @@ impl Plugin for PbrPlugin {
CoreStage::PostUpdate,
update_point_light_frusta
.label(SimulationLightSystems::UpdatePointLightFrusta)
.after(TransformSystem::TransformPropagate),
.after(TransformSystem::TransformPropagate)
.after(SimulationLightSystems::AssignLightsToClusters),
)
.add_system_to_stage(
CoreStage::PostUpdate,
check_light_visibility
check_light_mesh_visibility
.label(SimulationLightSystems::CheckLightVisibility)
.after(TransformSystem::TransformPropagate)
.after(VisibilitySystems::CalculateBounds)
Expand All @@ -88,6 +112,10 @@ impl Plugin for PbrPlugin {

let render_app = app.sub_app(RenderApp);
render_app
.add_system_to_stage(
RenderStage::Extract,
render::extract_clusters.label(RenderLightSystems::ExtractClusters),
)
.add_system_to_stage(
RenderStage::Extract,
render::extract_lights.label(RenderLightSystems::ExtractLights),
Expand All @@ -100,6 +128,15 @@ impl Plugin for PbrPlugin {
.exclusive_system()
.label(RenderLightSystems::PrepareLights),
)
.add_system_to_stage(
RenderStage::Prepare,
// this is added as an exclusive system because it contributes new views. it must run (and have Commands applied)
// _before_ the `prepare_views()` system is run. ideally this becomes a normal system when "stageless" features come out
render::prepare_clusters
.exclusive_system()
.label(RenderLightSystems::PrepareClusters)
.after(RenderLightSystems::PrepareLights),
)
.add_system_to_stage(
RenderStage::Queue,
render::queue_shadows.label(RenderLightSystems::QueueShadows),
Expand All @@ -111,6 +148,7 @@ impl Plugin for PbrPlugin {
.init_resource::<ShadowPipeline>()
.init_resource::<DrawFunctions<Shadow>>()
.init_resource::<LightMeta>()
.init_resource::<GlobalLightMeta>()
.init_resource::<SpecializedPipelines<PbrPipeline>>()
.init_resource::<SpecializedPipelines<ShadowPipeline>>();

Expand Down
Loading