bevy/crates
Sou1gh0st df3fcbd116
Fix incorrect function calls to hsv_to_rgb in render debug code. (#14260)
# Objective

- Fixes https://github.com/bevyengine/bevy/issues/14139

## Solution

- correct the input parameters at these call sites.

## Testing

1. Use a 3D scene example with PBR lighting and shadows enabled, such as
the `shadow_caster_receiver` and `load_gltf` example, for testing.
2. Enable relevant shader defines in crates/bevy_pbr/src/pbr_material.rs
for the StandardMaterial.
```rust
impl Material for StandardMaterial {
    // ...
    fn specialize(
            _pipeline: &MaterialPipeline<Self>,
            descriptor: &mut RenderPipelineDescriptor,
            _layout: &MeshVertexBufferLayoutRef,
            key: MaterialPipelineKey<Self>,
        ) -> Result<(), SpecializedMeshPipelineError> {
            // ...
            // shader_defs.push("CLUSTERED_FORWARD_DEBUG_Z_SLICES".into());
            // shader_defs.push("CLUSTERED_FORWARD_DEBUG_CLUSTER_COHERENCY".into());
            shader_defs.push("DIRECTIONAL_LIGHT_SHADOW_MAP_DEBUG_CASCADES".into());
            // ...
    }
}
``` 

## Showcase
### CLUSTERED_FORWARD_DEBUG_Z_SLICES
- example: examples/3d/shadow_caster_receiver.rs

![Screenshot2024_07_10_143150](https://github.com/bevyengine/bevy/assets/6300263/fbd12712-5cb9-489d-a7d1-ed55f72fb234)

### CLUSTERED_FORWARD_DEBUG_CLUSTER_COHERENCY
- example: examples/3d/shadow_caster_receiver.rs

![Screenshot2024_07_10_143312](https://github.com/bevyengine/bevy/assets/6300263/8eca5d7a-27b6-4ff5-9f8d-d10b49b3f990)

### DIRECTIONAL_LIGHT_SHADOW_MAP_DEBUG_CASCADES
For this one, we need to use a large scene and modity the
`CascadeShadowConfigBuilder`, here is a simple patch for the `load_gltf`
example:
```
diff --git a/examples/3d/load_gltf.rs b/examples/3d/load_gltf.rs
index 358446238..9403aa288 100644
--- a/examples/3d/load_gltf.rs
+++ b/examples/3d/load_gltf.rs
@@ -18,7 +18,7 @@ fn main() {
 fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
     commands.spawn((
         Camera3dBundle {
-            transform: Transform::from_xyz(0.7, 0.7, 1.0)
+            transform: Transform::from_xyz(0.7, 0.7, 2.0)
                 .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
             ..default()
         },
@@ -39,30 +39,40 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
         // We also adjusted the shadow map to be larger since we're
         // only using a single cascade.
         cascade_shadow_config: CascadeShadowConfigBuilder {
-            num_cascades: 1,
-            maximum_distance: 1.6,
+            num_cascades: 5,
+            maximum_distance: 20.0,
             ..default()
         }
         .into(),
         ..default()
     });
+
     commands.spawn(SceneBundle {
         scene: asset_server
             .load(GltfAssetLabel::Scene(0).from_asset("models/FlightHelmet/FlightHelmet.gltf")),
         ..default()
     });
+
+    for i in 1..=10 {
+        commands.spawn(SceneBundle {
+            scene: asset_server
+                .load(GltfAssetLabel::Scene(0).from_asset("models/FlightHelmet/FlightHelmet.gltf")),
+            transform: Transform::from_xyz(i as f32 * 0.5, 0.0, i as f32 * -2.0),
+            ..default()
+        });
+    }
 }
 
 fn animate_light_direction(
     time: Res<Time>,
     mut query: Query<&mut Transform, With<DirectionalLight>>,
 ) {
-    for mut transform in &mut query {
-        transform.rotation = Quat::from_euler(
-            EulerRot::ZYX,
-            0.0,
-            time.elapsed_seconds() * PI / 5.0,
-            -FRAC_PI_4,
-        );
-    }
+    // for mut transform in &mut query {
+    //     transform.rotation = Quat::from_euler(
+    //         EulerRot::ZYX,
+    //         0.0,
+    //         time.elapsed_seconds() * PI / 5.0,
+    //         -FRAC_PI_4,
+    //     );
+    // }
 }
``` 

![Screenshot2024_07_10_145737](https://github.com/bevyengine/bevy/assets/6300263/c5c71894-f9f7-45fa-9b4f-598e324b42d0)

---------

Co-authored-by: ickshonpe <david.curthoys@googlemail.com>
2024-08-02 19:19:53 +02:00
..
bevy_a11y Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_animation Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_app Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_asset EmptyPathStream is only used in android/wasm32 (#14200) 2024-08-02 18:58:30 +02:00
bevy_audio Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_color Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_core Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_core_pipeline Fix error/typo in SMAA shader (#14338) 2024-08-02 19:19:14 +02:00
bevy_derive Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_dev_tools Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_diagnostic Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_dylib Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_dynamic_plugin Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_ecs Allow observer systems to have outputs (#14159) 2024-08-02 19:16:46 +02:00
bevy_encase_derive Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_gilrs Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_gizmos Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_gltf fix building cargo_gltf with feature dds (#14360) 2024-08-02 19:19:24 +02:00
bevy_hierarchy Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_input bevy_input: allow use without bevy_reflect (#14167) 2024-08-02 19:11:13 +02:00
bevy_internal Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_log Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_macro_utils Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_math Fix swapped docs for Rot2::rotation_to/from_y (#14307) 2024-08-02 19:15:56 +02:00
bevy_mikktspace Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_pbr Fix incorrect function calls to hsv_to_rgb in render debug code. (#14260) 2024-08-02 19:19:53 +02:00
bevy_ptr Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_reflect Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_render Make Viewport::default() return a 1x1 viewport (#14372) 2024-08-02 19:19:14 +02:00
bevy_scene Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_sprite Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_state Make initial StateTransition run before PreStartup (#14208) 2024-08-02 19:17:57 +02:00
bevy_tasks Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_text Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_time Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_transform Optimize unnecessary normalizations for Transform::local_{xyz} (#14171) 2024-08-02 18:58:31 +02:00
bevy_ui add entity to error message (#14163) 2024-08-02 18:58:30 +02:00
bevy_utils Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
bevy_window Fix bevy_window failing with serialize feature (#14298) 2024-08-02 19:18:25 +02:00
bevy_winit Dirty fix for App hanging when windows are invisible on WindowsOS (#14155) 2024-08-02 19:12:05 +02:00