forked from kaosat-dev/Blenvy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(Bevy): Update to bevy 0.13 (kaosat-dev#136)
* chore(crates): updated crates to Bevy 0.13 * updated deps * updated / changed code where relevant * updated README files * bumped version numbers for upcoming release * updated rust-toolchain * updated assets where relevant * closes kaosat-dev#132 * feat(bevy_gltf_components): * added GltfProcessed flag component to improve performance of iteration over added<gltfExtras> * closes kaosat-dev#144 * light & shadow processing is now integrated, to match lights coming from Blender: you can now control whether lights cast shadows, the cascade resolution , background color etc from Blender * closes kaosat-dev#155 * feat(bevy_registry_export): added boilerplate to make registry path relative to assets folder * closes kaosat-dev#137 * feat(tools): added boilerplate for internal tools * clean zip file generator for blender add-on releases * example gltf file generator * feat(lighting): added components, exporter support & testing for blender-configurable shadows * added BlenderLightShadows component to bevy_gltf_components * added writing shadow information to gltf_auto_export * updated tests * closes kaosat-dev#157 Co-authored-by: Jan Hohenheim <[email protected]>
- Loading branch information
1 parent
9cb9dda
commit 09915f5
Showing
146 changed files
with
7,017 additions
and
2,170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use bevy::prelude::*; | ||
|
||
mod lighting; | ||
pub use lighting::*; | ||
|
||
pub(crate) fn plugin(app: &mut App) { | ||
app.add_plugins(lighting::plugin); | ||
} |
97 changes: 97 additions & 0 deletions
97
crates/bevy_gltf_components/src/blender_settings/lighting.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
use bevy::pbr::DirectionalLightShadowMap; | ||
use bevy::prelude::*; | ||
|
||
use crate::GltfComponentsSet; | ||
|
||
pub(crate) fn plugin(app: &mut App) { | ||
app.register_type::<BlenderBackgroundShader>() | ||
.register_type::<BlenderShadowSettings>() | ||
.register_type::<BlenderLightShadows>() | ||
.add_systems( | ||
Update, | ||
(process_lights, process_shadowmap, process_background_shader) | ||
.after(GltfComponentsSet::Injection), | ||
); | ||
} | ||
|
||
#[derive(Component, Reflect, Default, Debug, PartialEq, Clone)] | ||
#[reflect(Component)] | ||
#[non_exhaustive] | ||
/// The properties of a light's shadow , to enable controlling per light shadows from Blender | ||
pub struct BlenderLightShadows { | ||
pub enabled: bool, | ||
pub buffer_bias: f32, | ||
} | ||
|
||
/// The background color as described by Blender's [background shader](https://docs.blender.org/manual/en/latest/render/shader_nodes/shader/background.html). | ||
#[derive(Component, Reflect, Default, Debug, PartialEq, Clone)] | ||
#[reflect(Component)] | ||
#[non_exhaustive] | ||
pub struct BlenderBackgroundShader { | ||
pub color: Color, | ||
pub strength: f32, | ||
} | ||
|
||
/// The settings used by EEVEE's [shadow rendering](https://docs.blender.org/manual/en/latest/render/eevee/render_settings/shadows.html). | ||
#[derive(Component, Reflect, Default, Debug, PartialEq, Clone)] | ||
#[reflect(Component)] | ||
#[non_exhaustive] | ||
pub struct BlenderShadowSettings { | ||
pub cascade_size: usize, | ||
} | ||
|
||
fn process_lights( | ||
mut directional_lights: Query< | ||
(&mut DirectionalLight, Option<&BlenderLightShadows>), | ||
Added<DirectionalLight>, | ||
>, | ||
mut spot_lights: Query<(&mut SpotLight, Option<&BlenderLightShadows>), Added<SpotLight>>, | ||
mut point_lights: Query<(&mut PointLight, Option<&BlenderLightShadows>), Added<PointLight>>, | ||
) { | ||
for (mut light, blender_light_shadows) in directional_lights.iter_mut() { | ||
if let Some(blender_light_shadows) = blender_light_shadows { | ||
light.shadows_enabled = blender_light_shadows.enabled; | ||
} else { | ||
light.shadows_enabled = true; | ||
} | ||
} | ||
for (mut light, blender_light_shadows) in spot_lights.iter_mut() { | ||
if let Some(blender_light_shadows) = blender_light_shadows { | ||
light.shadows_enabled = blender_light_shadows.enabled; | ||
} else { | ||
light.shadows_enabled = true; | ||
} | ||
} | ||
|
||
for (mut light, blender_light_shadows) in point_lights.iter_mut() { | ||
if let Some(blender_light_shadows) = blender_light_shadows { | ||
light.shadows_enabled = blender_light_shadows.enabled; | ||
} else { | ||
light.shadows_enabled = true; | ||
} | ||
} | ||
} | ||
|
||
fn process_shadowmap( | ||
shadowmaps: Query<&BlenderShadowSettings, Added<BlenderShadowSettings>>, | ||
mut commands: Commands, | ||
) { | ||
for shadowmap in shadowmaps.iter() { | ||
commands.insert_resource(DirectionalLightShadowMap { | ||
size: shadowmap.cascade_size, | ||
}); | ||
} | ||
} | ||
|
||
fn process_background_shader( | ||
background_shaders: Query<&BlenderBackgroundShader, Added<BlenderBackgroundShader>>, | ||
mut commands: Commands, | ||
) { | ||
for background_shader in background_shaders.iter() { | ||
commands.insert_resource(AmbientLight { | ||
color: background_shader.color, | ||
// Just a guess, see <https://github.com/bevyengine/bevy/issues/12280> | ||
brightness: background_shader.strength * 400.0, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.