-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
shadow_biases: Support moving the light position and resetting biases #10185
Merged
superdump
merged 3 commits into
bevyengine:main
from
superdump:shadow-biases-light-position
Oct 19, 2023
Merged
shadow_biases: Support moving the light position and resetting biases #10185
superdump
merged 3 commits into
bevyengine:main
from
superdump:shadow-biases-light-position
Oct 19, 2023
Conversation
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
superdump
force-pushed
the
shadow-biases-light-position
branch
from
October 19, 2023 14:02
236aa1e
to
a8782ac
Compare
just for sanity's sake could we
diff --git a/examples/3d/shadow_biases.rs b/examples/3d/shadow_biases.rs
index 4553bf791..b62ece509 100644
--- a/examples/3d/shadow_biases.rs
+++ b/examples/3d/shadow_biases.rs
@@ -111,6 +111,7 @@ fn setup(
let style = TextStyle {
font_size: 20.,
+ color: Color::rgb(1.0, 0.0, 0.5),
..default()
};
commands.spawn(
@@ -125,7 +126,7 @@ fn setup(
),
TextSection::new("DirectionalLight", style.clone()),
TextSection::new("]\n", style.clone()),
- TextSection::new("F - switch between filter methods [", style.clone()),
+ TextSection::new("F - switch directional light filter methods [", style.clone()),
TextSection::new("Hardware2x2", style.clone()),
TextSection::new("]\n", style.clone()),
TextSection::new("1/2 - change point light depth bias [", style.clone()),
@@ -269,41 +270,30 @@ fn adjust_point_light_biases(
for mut light in &mut query {
if input.just_pressed(KeyCode::Key1) {
light.shadow_depth_bias -= depth_bias_step_size;
- example_text.single_mut().sections[11].value =
- format!("{:.2}", light.shadow_depth_bias);
}
if input.just_pressed(KeyCode::Key2) {
light.shadow_depth_bias += depth_bias_step_size;
- example_text.single_mut().sections[11].value =
- format!("{:.2}", light.shadow_depth_bias);
}
if input.just_pressed(KeyCode::Key3) {
light.shadow_normal_bias -= normal_bias_step_size;
- example_text.single_mut().sections[14].value =
- format!("{:.1}", light.shadow_normal_bias);
}
if input.just_pressed(KeyCode::Key4) {
light.shadow_normal_bias += normal_bias_step_size;
- example_text.single_mut().sections[14].value =
- format!("{:.1}", light.shadow_normal_bias);
}
if input.just_pressed(KeyCode::R) {
light.shadow_depth_bias = PointLight::DEFAULT_SHADOW_DEPTH_BIAS;
- example_text.single_mut().sections[11].value =
- format!("{:.2}", light.shadow_depth_bias);
light.shadow_normal_bias = PointLight::DEFAULT_SHADOW_NORMAL_BIAS;
- example_text.single_mut().sections[14].value =
- format!("{:.1}", light.shadow_normal_bias);
}
if input.just_pressed(KeyCode::Z) {
light.shadow_depth_bias = 0.0;
- example_text.single_mut().sections[11].value =
- format!("{:.2}", light.shadow_depth_bias);
light.shadow_normal_bias = 0.0;
- example_text.single_mut().sections[14].value =
- format!("{:.1}", light.shadow_normal_bias);
}
- }
+
+ example_text.single_mut().sections[11].value =
+ format!("{:.2}", light.shadow_depth_bias);
+ example_text.single_mut().sections[14].value =
+ format!("{:.1}", light.shadow_normal_bias);
+}
}
fn adjust_directional_light_biases(
@@ -316,40 +306,29 @@ fn adjust_directional_light_biases(
for mut light in &mut query {
if input.just_pressed(KeyCode::Key5) {
light.shadow_depth_bias -= depth_bias_step_size;
- example_text.single_mut().sections[17].value =
- format!("{:.2}", light.shadow_depth_bias);
}
if input.just_pressed(KeyCode::Key6) {
light.shadow_depth_bias += depth_bias_step_size;
- example_text.single_mut().sections[17].value =
- format!("{:.2}", light.shadow_depth_bias);
}
if input.just_pressed(KeyCode::Key7) {
light.shadow_normal_bias -= normal_bias_step_size;
- example_text.single_mut().sections[20].value =
- format!("{:.1}", light.shadow_normal_bias);
}
if input.just_pressed(KeyCode::Key8) {
light.shadow_normal_bias += normal_bias_step_size;
- example_text.single_mut().sections[20].value =
- format!("{:.1}", light.shadow_normal_bias);
}
if input.just_pressed(KeyCode::R) {
light.shadow_depth_bias = DirectionalLight::DEFAULT_SHADOW_DEPTH_BIAS;
- example_text.single_mut().sections[17].value =
- format!("{:.2}", light.shadow_depth_bias);
light.shadow_normal_bias = DirectionalLight::DEFAULT_SHADOW_NORMAL_BIAS;
- example_text.single_mut().sections[20].value =
- format!("{:.1}", light.shadow_normal_bias);
}
if input.just_pressed(KeyCode::Z) {
light.shadow_depth_bias = 0.0;
- example_text.single_mut().sections[17].value =
- format!("{:.2}", light.shadow_depth_bias);
light.shadow_normal_bias = 0.0;
- example_text.single_mut().sections[20].value =
- format!("{:.1}", light.shadow_normal_bias);
}
+
+ example_text.single_mut().sections[17].value =
+ format!("{:.2}", light.shadow_depth_bias);
+ example_text.single_mut().sections[20].value =
+ format!("{:.1}", light.shadow_normal_bias);
}
} |
and maybe the spheres could descend in y so that peter panning shows up? |
robtfm
approved these changes
Oct 19, 2023
ameknite
pushed a commit
to ameknite/bevy
that referenced
this pull request
Nov 6, 2023
…bevyengine#10185) # Objective - Make it possible to move the light position around in the `shadow_biases` example - Also support resetting the depth/normal biases to the engine defaults, or zero. ## Solution - The light position is displayed in the text overlay. - The light position can be adjusted with left/right/up/down/pgup/pgdown. - The depth/normal biases can be reset to defaults by pressing R, or to zero by pressing Z. --------- Co-authored-by: robtfm <[email protected]>
rdrpenguin04
pushed a commit
to rdrpenguin04/bevy
that referenced
this pull request
Jan 9, 2024
…bevyengine#10185) # Objective - Make it possible to move the light position around in the `shadow_biases` example - Also support resetting the depth/normal biases to the engine defaults, or zero. ## Solution - The light position is displayed in the text overlay. - The light position can be adjusted with left/right/up/down/pgup/pgdown. - The depth/normal biases can be reset to defaults by pressing R, or to zero by pressing Z. --------- Co-authored-by: robtfm <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
shadow_biases
exampleSolution