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] - Spotlights #4715

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
63b91a8
spotlights
robtfm May 4, 2022
fc0a685
update demos
robtfm May 6, 2022
d85cfa2
spotlight cluster culling
robtfm May 10, 2022
19aa631
vary angle in example
robtfm May 10, 2022
61120b5
optimise
robtfm May 10, 2022
f300809
format
robtfm May 10, 2022
c2db39b
use const Vec2 in lights cluster and bounding box when possible (#4602)
mockersf May 6, 2022
2756a8c
spotlight cluster culling
robtfm May 10, 2022
585d101
optimise
robtfm May 10, 2022
c0c5437
format
robtfm May 10, 2022
0cb0544
format
robtfm May 10, 2022
cadcad0
remove debug output
robtfm May 10, 2022
55fb290
fix rebase
robtfm May 10, 2022
91ec7ff
add front_cull test
robtfm May 12, 2022
47fe2ea
shadow maps
robtfm May 13, 2022
8464d7b
fix frustum for culling light entities
robtfm May 13, 2022
87ffc6f
fix spot map offset
robtfm May 14, 2022
6c39cd1
format
robtfm May 14, 2022
5f97f1e
reduce pointlight struct size
robtfm May 16, 2022
2d8a8ed
ci
robtfm May 16, 2022
6f8c9f9
ci?
robtfm May 16, 2022
3de7c9a
clean up maths
robtfm May 17, 2022
f562869
fmt
robtfm May 17, 2022
9357a5e
Merge branch 'main' into spotlight
robtfm May 17, 2022
5f66f57
remove near/far
robtfm May 17, 2022
695bdc5
compress light direction
robtfm Jun 6, 2022
00d3cc2
filament
robtfm Jun 6, 2022
eccfa1b
apply suggestions from code review
robtfm Jun 6, 2022
fb28014
add SpotlightBundle
robtfm Jun 6, 2022
d9b20f4
use xz for direction, revert sign() change
robtfm Jun 7, 2022
e241daa
format
robtfm Jun 7, 2022
109077e
lift condition
robtfm Jun 17, 2022
d3ccb12
fix webgl mipmap sample
robtfm Jun 17, 2022
5968759
remove println
robtfm Jun 21, 2022
b0f651f
Squashed commit of the following:
robtfm Jun 21, 2022
e8e6f1b
reapply to main
robtfm Jun 21, 2022
b1a82d3
Merge branch 'main' into spotlight
robtfm Jun 22, 2022
970a3cc
Merge branch 'main' into spotlight
robtfm Jun 22, 2022
8fd40b2
fmt
robtfm Jun 22, 2022
612813a
fix point light sort order comment
robtfm Jun 25, 2022
d8c362c
add comment on spotlight intensity divisor
robtfm Jun 26, 2022
42cb994
Merge branch 'main' into spotlight
robtfm Jun 26, 2022
68b8ebb
Update Cargo.toml
robtfm Jun 26, 2022
6c8ec1c
build-example-pages
robtfm Jun 26, 2022
723bfeb
spotlight / Spotlight -> spot_light / SpotLight
robtfm Jun 26, 2022
a3809f7
bevy_gltf: Support loading spotlights
superdump Jun 26, 2022
ea909d0
spotlight / Spotlight -> spot_light / SpotLight
robtfm Jun 26, 2022
974fd52
remove unused SPOT_LIGHT flag
robtfm Jun 27, 2022
32a72f2
separate using-facing SpotLight struct
robtfm Jul 8, 2022
8a81014
Merge branch 'main' into spotlight
robtfm Jul 8, 2022
1617119
doc comment
robtfm Jul 8, 2022
45f68ad
ci
robtfm Jul 8, 2022
ab4d91c
ci ci
robtfm Jul 8, 2022
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
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ path = "examples/3d/shapes.rs"
name = "lighting"
path = "examples/3d/lighting.rs"

[[example]]
name = "spotlight"
path = "examples/3d/spotlight.rs"

robtfm marked this conversation as resolved.
Show resolved Hide resolved
[[example]]
name = "load_gltf"
path = "examples/3d/load_gltf.rs"
Expand Down
15 changes: 14 additions & 1 deletion crates/bevy_pbr/src/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{DirectionalLight, PointLight, SpecializedMaterial, StandardMaterial};
use crate::{DirectionalLight, PointLight, SpecializedMaterial, SpotlightAngles, StandardMaterial};
use bevy_asset::Handle;
use bevy_ecs::{bundle::Bundle, component::Component, reflect::ReflectComponent};
use bevy_reflect::Reflect;
Expand Down Expand Up @@ -75,6 +75,19 @@ pub struct PointLightBundle {
pub visibility: Visibility,
}

/// A component bundle for spotlight entities
#[derive(Debug, Bundle, Default)]
pub struct SpotlightBundle {
pub point_light: PointLight,
cart marked this conversation as resolved.
Show resolved Hide resolved
pub spotlight_angles: SpotlightAngles,
pub visible_entities: VisibleEntities,
pub frustum: Frustum,
pub transform: Transform,
pub global_transform: GlobalTransform,
/// Enables or disables the light
pub visibility: Visibility,
}

/// A component bundle for [`DirectionalLight`] entities.
#[derive(Debug, Bundle, Default)]
pub struct DirectionalLightBundle {
Expand Down
21 changes: 15 additions & 6 deletions crates/bevy_pbr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ pub mod prelude {
#[doc(hidden)]
pub use crate::{
alpha::AlphaMode,
bundle::{DirectionalLightBundle, MaterialMeshBundle, PbrBundle, PointLightBundle},
light::{AmbientLight, DirectionalLight, PointLight},
bundle::{
DirectionalLightBundle, MaterialMeshBundle, PbrBundle, PointLightBundle,
SpotlightBundle,
},
light::{AmbientLight, DirectionalLight, PointLight, SpotlightAngles},
material::{Material, MaterialPlugin},
pbr_material::StandardMaterial,
};
Expand Down Expand Up @@ -149,13 +152,20 @@ impl Plugin for PbrPlugin {
.add_system_to_stage(
CoreStage::PostUpdate,
update_directional_light_frusta
.label(SimulationLightSystems::UpdateDirectionalLightFrusta)
.label(SimulationLightSystems::UpdateLightFrusta)
.after(TransformSystem::TransformPropagate),
)
.add_system_to_stage(
CoreStage::PostUpdate,
update_point_light_frusta
.label(SimulationLightSystems::UpdatePointLightFrusta)
.label(SimulationLightSystems::UpdateLightFrusta)
.after(TransformSystem::TransformPropagate)
.after(SimulationLightSystems::AssignLightsToClusters),
)
.add_system_to_stage(
CoreStage::PostUpdate,
update_spotlight_frusta
.label(SimulationLightSystems::UpdateLightFrusta)
.after(TransformSystem::TransformPropagate)
.after(SimulationLightSystems::AssignLightsToClusters),
)
Expand All @@ -165,8 +175,7 @@ impl Plugin for PbrPlugin {
.label(SimulationLightSystems::CheckLightVisibility)
.after(TransformSystem::TransformPropagate)
.after(VisibilitySystems::CalculateBounds)
.after(SimulationLightSystems::UpdateDirectionalLightFrusta)
.after(SimulationLightSystems::UpdatePointLightFrusta)
.after(SimulationLightSystems::UpdateLightFrusta)
// NOTE: This MUST be scheduled AFTER the core renderer visibility check
// because that resets entity ComputedVisibility for the first view
// which would override any results from this otherwise
Expand Down
Loading