From e94c9008daa4ed364ca0fe9527b69dfa0739b258 Mon Sep 17 00:00:00 2001 From: robtfm <50659922+robtfm@users.noreply.github.com> Date: Mon, 13 Jan 2025 16:06:24 +0000 Subject: [PATCH] projections and lights --- Cargo.lock | 105 ++++---- crates/common/src/util.rs | 14 ++ .../sdk/components/global_light.proto | 3 + .../sdk/components/texture_camera.proto | 4 + .../scene_runner/src/update_world/lights.rs | 15 +- .../src/settings/bloom_settings.rs | 11 +- crates/system_bridge/src/settings/mod.rs | 27 ++- .../src/settings/shadow_settings.rs | 12 +- .../src/settings/ssao_setting.rs | 9 +- crates/texture_camera/Cargo.toml | 1 + crates/texture_camera/src/lib.rs | 224 +++++++++++------- crates/visuals/src/lib.rs | 34 ++- 12 files changed, 302 insertions(+), 157 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7dd4a95f..db1c9934 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -869,7 +869,7 @@ dependencies = [ [[package]] name = "bevy" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_internal", ] @@ -877,7 +877,7 @@ dependencies = [ [[package]] name = "bevy_a11y" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "accesskit", "bevy_app", @@ -888,7 +888,7 @@ dependencies = [ [[package]] name = "bevy_animation" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_asset", @@ -917,7 +917,7 @@ dependencies = [ [[package]] name = "bevy_app" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_derive", "bevy_ecs", @@ -934,7 +934,7 @@ dependencies = [ [[package]] name = "bevy_asset" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "async-broadcast", "async-fs", @@ -966,7 +966,7 @@ dependencies = [ [[package]] name = "bevy_asset_macros" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_macro_utils 0.14.1", "proc-macro2", @@ -999,7 +999,7 @@ dependencies = [ [[package]] name = "bevy_audio" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_asset", @@ -1017,7 +1017,7 @@ dependencies = [ [[package]] name = "bevy_color" version = "0.14.2" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_math", "bevy_reflect", @@ -1054,7 +1054,7 @@ dependencies = [ [[package]] name = "bevy_core" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_ecs", @@ -1067,7 +1067,7 @@ dependencies = [ [[package]] name = "bevy_core_pipeline" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_asset", @@ -1091,7 +1091,7 @@ dependencies = [ [[package]] name = "bevy_derive" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_macro_utils 0.14.1", "quote", @@ -1101,7 +1101,7 @@ dependencies = [ [[package]] name = "bevy_diagnostic" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_core", @@ -1127,7 +1127,7 @@ dependencies = [ [[package]] name = "bevy_ecs" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "arrayvec", "bevy_ecs_macros", @@ -1147,7 +1147,7 @@ dependencies = [ [[package]] name = "bevy_ecs_macros" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_macro_utils 0.14.1", "proc-macro2", @@ -1192,7 +1192,7 @@ dependencies = [ [[package]] name = "bevy_encase_derive" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_macro_utils 0.14.1", "encase_derive_impl", @@ -1201,7 +1201,7 @@ dependencies = [ [[package]] name = "bevy_gilrs" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_ecs", @@ -1215,7 +1215,7 @@ dependencies = [ [[package]] name = "bevy_gizmos" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_asset", @@ -1237,7 +1237,7 @@ dependencies = [ [[package]] name = "bevy_gizmos_macros" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_macro_utils 0.14.1", "proc-macro2", @@ -1248,7 +1248,7 @@ dependencies = [ [[package]] name = "bevy_gltf" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "base64 0.22.1", "bevy_animation", @@ -1278,7 +1278,7 @@ dependencies = [ [[package]] name = "bevy_hierarchy" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_core", @@ -1291,7 +1291,7 @@ dependencies = [ [[package]] name = "bevy_input" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_ecs", @@ -1305,7 +1305,7 @@ dependencies = [ [[package]] name = "bevy_internal" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_a11y", "bevy_animation", @@ -1358,7 +1358,7 @@ dependencies = [ [[package]] name = "bevy_log" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "android_log-sys", "bevy_app", @@ -1374,7 +1374,7 @@ dependencies = [ [[package]] name = "bevy_macro_utils" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "proc-macro2", "quote", @@ -1397,7 +1397,7 @@ dependencies = [ [[package]] name = "bevy_math" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_reflect", "glam 0.27.0", @@ -1410,7 +1410,7 @@ dependencies = [ [[package]] name = "bevy_mikktspace" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "glam 0.27.0", ] @@ -1418,7 +1418,7 @@ dependencies = [ [[package]] name = "bevy_pbr" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_asset", @@ -1444,12 +1444,12 @@ dependencies = [ [[package]] name = "bevy_ptr" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" [[package]] name = "bevy_reflect" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_ptr", "bevy_reflect_derive", @@ -1468,7 +1468,7 @@ dependencies = [ [[package]] name = "bevy_reflect_derive" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_macro_utils 0.14.1", "proc-macro2", @@ -1480,7 +1480,7 @@ dependencies = [ [[package]] name = "bevy_render" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "async-channel 2.3.1", "bevy_app", @@ -1528,7 +1528,7 @@ dependencies = [ [[package]] name = "bevy_render_macros" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_macro_utils 0.14.1", "proc-macro2", @@ -1539,7 +1539,7 @@ dependencies = [ [[package]] name = "bevy_scene" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_asset", @@ -1568,7 +1568,7 @@ dependencies = [ [[package]] name = "bevy_sprite" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_asset", @@ -1593,7 +1593,7 @@ dependencies = [ [[package]] name = "bevy_state" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_ecs", @@ -1606,7 +1606,7 @@ dependencies = [ [[package]] name = "bevy_state_macros" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_macro_utils 0.14.1", "proc-macro2", @@ -1617,7 +1617,7 @@ dependencies = [ [[package]] name = "bevy_tasks" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "async-channel 2.3.1", "async-executor", @@ -1629,7 +1629,7 @@ dependencies = [ [[package]] name = "bevy_text" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_asset", @@ -1653,7 +1653,7 @@ dependencies = [ [[package]] name = "bevy_time" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_ecs", @@ -1666,7 +1666,7 @@ dependencies = [ [[package]] name = "bevy_transform" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_app", "bevy_ecs", @@ -1679,7 +1679,7 @@ dependencies = [ [[package]] name = "bevy_ui" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_a11y", "bevy_app", @@ -1708,7 +1708,7 @@ dependencies = [ [[package]] name = "bevy_utils" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "ahash", "bevy_utils_proc_macros", @@ -1722,7 +1722,7 @@ dependencies = [ [[package]] name = "bevy_utils_proc_macros" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "proc-macro2", "quote", @@ -1732,7 +1732,7 @@ dependencies = [ [[package]] name = "bevy_window" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "bevy_a11y", "bevy_app", @@ -1747,7 +1747,7 @@ dependencies = [ [[package]] name = "bevy_winit" version = "0.14.1" -source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#2b2f4f676cd6e39cf915232202171fb7f94ef226" +source = "git+https://github.com/robtfm/bevy?branch=release-0.14-dcl-cosmic-noimage#6e227a1264a33390ab2056087082086d8948c436" dependencies = [ "accesskit_winit", "approx", @@ -1815,7 +1815,7 @@ dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", - "itertools 0.12.1", + "itertools 0.10.5", "lazy_static", "lazycell", "log", @@ -1838,7 +1838,7 @@ dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", - "itertools 0.12.1", + "itertools 0.10.5", "proc-macro2", "quote", "regex", @@ -7256,7 +7256,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate 3.2.0", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 2.0.79", @@ -8323,8 +8323,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", - "heck 0.5.0", - "itertools 0.12.1", + "heck 0.4.1", + "itertools 0.10.5", "log", "multimap 0.10.0", "once_cell", @@ -8357,7 +8357,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.10.5", "proc-macro2", "quote", "syn 2.0.79", @@ -8370,7 +8370,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.10.5", "proc-macro2", "quote", "syn 2.0.79", @@ -10524,6 +10524,7 @@ dependencies = [ "ui_core", "urlencoding", "urn", + "visuals", "wallet", "world_ui", ] diff --git a/crates/common/src/util.rs b/crates/common/src/util.rs index 9d0aa51a..a0b94d68 100644 --- a/crates/common/src/util.rs +++ b/crates/common/src/util.rs @@ -14,6 +14,7 @@ use bevy::{ despawn_with_children_recursive, BuildWorldChildren, Bundle, Entity, GlobalTransform, IntoSystemConfigs, Plugin, With, World, }, + render::view::{Layer, RenderLayers}, tasks::Task, }; use ethers_core::types::H160; @@ -440,3 +441,16 @@ impl VolumePanning<'_, '_> { (volume, panning) } } + +pub fn camera_to_render_layer(camera_layer: u32) -> Layer { + (match camera_layer { + 0 => 0, + nonzero => nonzero + 5, + }) as Layer +} + +pub fn camera_to_render_layers<'a>(camera_layers: impl Iterator) -> RenderLayers { + camera_layers.fold(RenderLayers::none(), |result, camera_layer| { + result.with(camera_to_render_layer(*camera_layer)) + }) +} diff --git a/crates/dcl_component/src/proto/decentraland/sdk/components/global_light.proto b/crates/dcl_component/src/proto/decentraland/sdk/components/global_light.proto index 0fc85090..f1f56ed6 100644 --- a/crates/dcl_component/src/proto/decentraland/sdk/components/global_light.proto +++ b/crates/dcl_component/src/proto/decentraland/sdk/components/global_light.proto @@ -18,4 +18,7 @@ message PBGlobalLight { // ambient light intensity. the explorer default ambient brightness is multiplied by this non-physical quantity. // default 1 optional float ambient_brightness = 3; + + // camera layers to apply global light to. defaults to 0 only + repeated uint32 layers = 4; } diff --git a/crates/dcl_component/src/proto/decentraland/sdk/components/texture_camera.proto b/crates/dcl_component/src/proto/decentraland/sdk/components/texture_camera.proto index 137b0a3c..81600cbb 100644 --- a/crates/dcl_component/src/proto/decentraland/sdk/components/texture_camera.proto +++ b/crates/dcl_component/src/proto/decentraland/sdk/components/texture_camera.proto @@ -25,6 +25,10 @@ message PBTextureCamera { // default infinity optional float far_plane = 7; + // ambient light overrides for this camera + optional decentraland.common.Color3 ambient_color_override = 11; + optional float ambient_brightness_override = 12; + oneof mode { Perspective perspective = 8; Orthographic orthographic = 9; diff --git a/crates/scene_runner/src/update_world/lights.rs b/crates/scene_runner/src/update_world/lights.rs index 83470a4c..0911537e 100644 --- a/crates/scene_runner/src/update_world/lights.rs +++ b/crates/scene_runner/src/update_world/lights.rs @@ -5,7 +5,7 @@ use common::{ dynamics::PLAYER_COLLIDER_RADIUS, sets::SceneSets, structs::{AppConfig, PrimaryUser, PRIMARY_AVATAR_LIGHT_LAYER}, - util::TryPushChildrenEx, + util::{camera_to_render_layers, TryPushChildrenEx}, }; use dcl::interface::ComponentPosition; use dcl_component::{ @@ -88,14 +88,25 @@ pub struct GlobalLight { pub direction: Option, pub ambient_color: Option, pub ambient_brightness: Option, + pub layers: RenderLayers, } impl From for GlobalLight { fn from(value: PbGlobalLight) -> Self { + let mut layers = if value.layers.is_empty() { + RenderLayers::default() + } else { + camera_to_render_layers(value.layers.iter()) + }; + if layers.intersects(&RenderLayers::default()) { + layers = layers.with(1); + } + Self { direction: value.direction.as_ref().map(Vector3::world_vec_to_vec3), ambient_color: value.ambient_color.map(Into::into), ambient_brightness: value.ambient_brightness, + layers, } } } @@ -117,6 +128,7 @@ fn update_directional_light( dir_direction: Quat::from_euler(EulerRot::YXZ, FRAC_PI_2 * 0.8, -t, 0.0) * Vec3::NEG_Z, ambient_color: Color::srgb(0.85, 0.85, 1.0), ambient_brightness: 1.0, + layers: RenderLayers::default().with(1), }; let Ok(player) = player.get_single() else { @@ -149,6 +161,7 @@ fn update_directional_light( if let Some(brightness) = global.ambient_brightness { global_light.ambient_brightness = brightness; }; + global_light.layers = global.layers.clone(); } }; diff --git a/crates/system_bridge/src/settings/bloom_settings.rs b/crates/system_bridge/src/settings/bloom_settings.rs index 73bd7b5a..0975fe5c 100644 --- a/crates/system_bridge/src/settings/bloom_settings.rs +++ b/crates/system_bridge/src/settings/bloom_settings.rs @@ -54,8 +54,13 @@ impl AppSetting for BloomSetting { fn apply(&self, cam_res: SystemParamItem, commands: Commands) { self.apply_to_camera(&cam_res, commands, cam_res.0); } - - fn apply_to_camera(&self, _: &SystemParamItem, mut commands: Commands, camera_entity: Entity) { + + fn apply_to_camera( + &self, + _: &SystemParamItem, + mut commands: Commands, + camera_entity: Entity, + ) { let Some(mut cmds) = commands.get_entity(camera_entity) else { return; }; @@ -71,5 +76,5 @@ impl AppSetting for BloomSetting { ..BloomSettings::OLD_SCHOOL }), }; - } + } } diff --git a/crates/system_bridge/src/settings/mod.rs b/crates/system_bridge/src/settings/mod.rs index 4fc3f7de..1c70f824 100644 --- a/crates/system_bridge/src/settings/mod.rs +++ b/crates/system_bridge/src/settings/mod.rs @@ -67,7 +67,12 @@ pub struct NewCameraEvent(pub Entity); impl Plugin for SettingBridgePlugin { fn build(&self, app: &mut App) { - fn apply_to_camera(mut commands: Commands, config: Res, mut new_camera_events: EventReader, param: StaticSystemParam) { + fn apply_to_camera( + mut commands: Commands, + config: Res, + mut new_camera_events: EventReader, + param: StaticSystemParam, + ) { let param = param.into_inner(); for ev in new_camera_events.read() { let setting = S::load(&config); @@ -75,13 +80,21 @@ impl Plugin for SettingBridgePlugin { } } - fn add_int_setting(app: &mut App, settings: &mut Settings, schedule: &mut Schedule) { + fn add_int_setting( + app: &mut App, + settings: &mut Settings, + schedule: &mut Schedule, + ) { settings.add_int_setting::(); schedule.add_systems(apply_setting::); app.add_systems(Update, apply_to_camera::); } - fn add_enum_setting(app: &mut App, settings: &mut Settings, schedule: &mut Schedule) { + fn add_enum_setting( + app: &mut App, + settings: &mut Settings, + schedule: &mut Schedule, + ) { settings.add_enum_setting::(); schedule.add_systems(apply_setting::); app.add_systems(Update, apply_to_camera::); @@ -172,7 +185,13 @@ pub trait AppSetting: Eq + 'static { fn load(config: &AppConfig) -> Self; fn save(&self, config: &mut AppConfig); fn apply(&self, param: SystemParamItem, commands: Commands); - fn apply_to_camera(&self, _param: &SystemParamItem, _commands: Commands, _camera_entity: Entity) {} + fn apply_to_camera( + &self, + _param: &SystemParamItem, + _commands: Commands, + _camera_entity: Entity, + ) { + } } pub trait EnumAppSetting: AppSetting + Sized + std::fmt::Debug { diff --git a/crates/system_bridge/src/settings/shadow_settings.rs b/crates/system_bridge/src/settings/shadow_settings.rs index 0be5cab5..627d66ee 100644 --- a/crates/system_bridge/src/settings/shadow_settings.rs +++ b/crates/system_bridge/src/settings/shadow_settings.rs @@ -62,7 +62,6 @@ impl AppSetting for ShadowSetting { (config, cam_res, mut lights): SystemParamItem, commands: Commands, ) { - let value = if config.graphics.shadow_distance == 0.0 { ShadowSetting::Off } else { @@ -102,9 +101,14 @@ impl AppSetting for ShadowSetting { let primary_cam = cam_res.0; self.apply_to_camera(&(config, cam_res, lights), commands, primary_cam); } - - fn apply_to_camera(&self, _: &SystemParamItem, mut commands: Commands, camera_entity: Entity) { - let Some(mut cmds) = commands.get_entity(camera_entity) else { + + fn apply_to_camera( + &self, + _: &SystemParamItem, + mut commands: Commands, + camera_entity: Entity, + ) { + let Some(mut cmds) = commands.get_entity(camera_entity) else { return; }; match self { diff --git a/crates/system_bridge/src/settings/ssao_setting.rs b/crates/system_bridge/src/settings/ssao_setting.rs index 207e7ee6..06e067f8 100644 --- a/crates/system_bridge/src/settings/ssao_setting.rs +++ b/crates/system_bridge/src/settings/ssao_setting.rs @@ -54,8 +54,13 @@ impl AppSetting for SsaoSetting { let primary_cam = cam_res.0; self.apply_to_camera(&(cam_res, msaa_res), commands, primary_cam); } - - fn apply_to_camera(&self, (_, msaa_res): &SystemParamItem, mut commands: Commands, camera_entity: Entity) { + + fn apply_to_camera( + &self, + (_, msaa_res): &SystemParamItem, + mut commands: Commands, + camera_entity: Entity, + ) { let Some(mut cmds) = commands.get_entity(camera_entity) else { return; }; diff --git a/crates/texture_camera/Cargo.toml b/crates/texture_camera/Cargo.toml index afafcbdd..3250cc3d 100644 --- a/crates/texture_camera/Cargo.toml +++ b/crates/texture_camera/Cargo.toml @@ -25,6 +25,7 @@ world_ui = { workspace = true } analytics = { workspace = true } social = { workspace = true } system_bridge = { workspace = true } +visuals = { workspace = true } bevy = { workspace = true } bevy_egui = { workspace = true } diff --git a/crates/texture_camera/src/lib.rs b/crates/texture_camera/src/lib.rs index 695076b1..8611a904 100644 --- a/crates/texture_camera/src/lib.rs +++ b/crates/texture_camera/src/lib.rs @@ -1,4 +1,4 @@ -use std::collections::VecDeque; +use std::{collections::VecDeque, f32::consts::FRAC_PI_4}; use bevy::{ core_pipeline::{ @@ -13,13 +13,15 @@ use bevy::{ render_asset::RenderAssetUsages, render_resource::{Extent3d, TextureFormat, TextureUsages}, texture::BevyDefault, - view::{ColorGrading, ColorGradingGlobal, ColorGradingSection, Layer, RenderLayers}, - }, utils::hashbrown::HashMap, + view::{ColorGrading, ColorGradingGlobal, ColorGradingSection, RenderLayers}, + }, + utils::hashbrown::HashMap, }; use common::{ dynamics::PLAYER_COLLIDER_RADIUS, sets::SceneSets, - structs::{Cubemap, PrimaryUser, GROUND_RENDERLAYER, PRIMARY_AVATAR_LIGHT_LAYER}, + structs::{AppConfig, Cubemap, PrimaryUser, GROUND_RENDERLAYER, PRIMARY_AVATAR_LIGHT_LAYER}, + util::{camera_to_render_layer, camera_to_render_layers}, }; use dcl_component::{ proto_components::sdk::components::{PbCameraLayers, PbTextureCamera}, @@ -30,6 +32,7 @@ use scene_runner::{ ContainerEntity, ContainingScene, }; use system_bridge::settings::NewCameraEvent; +use visuals::SceneGlobalLight; pub struct TextureCameraPlugin; @@ -79,6 +82,8 @@ pub fn update_texture_cameras( player: Query>, cubemap: Res, mut new_cam_events: EventWriter, + global_light: Res, + config: Res, ) { let active_scenes = player .get_single() @@ -118,76 +123,128 @@ pub fn update_texture_cameras( let image = images.add(image); let render_layers = match texture_cam.0.layer { - None | Some(0) => { - RenderLayers::default().union(&GROUND_RENDERLAYER).union(&PRIMARY_AVATAR_LIGHT_LAYER) - } - Some(nonzero) => RenderLayers::layer(camera_to_render_layer(nonzero)) + None | Some(0) => RenderLayers::default() + .union(&GROUND_RENDERLAYER) + .union(&PRIMARY_AVATAR_LIGHT_LAYER), + Some(nonzero) => RenderLayers::layer(camera_to_render_layer(nonzero)), }; println!("create with layers {render_layers:?}"); - let camera_id = commands - .spawn(( - Camera3dBundle { - camera: Camera { - hdr: true, - order: isize::MIN + container.container_id.id as isize, - target: bevy::render::camera::RenderTarget::Image(image.clone()), - is_active: true, + let far = texture_cam.0.far_plane.unwrap_or(100_000.0); + let projection: Projection = match &texture_cam.0.mode { + None => { + PerspectiveProjection { + far, + ..Default::default() + } + .into() + } + Some(dcl_component::proto_components::sdk::components::pb_texture_camera::Mode::Perspective(p)) => { + PerspectiveProjection { + fov: p.field_of_view.unwrap_or(FRAC_PI_4), + far, + ..Default::default() + }.into() + } + Some(dcl_component::proto_components::sdk::components::pb_texture_camera::Mode::Orthographic(o)) => { + OrthographicProjection { + far, + scaling_mode: bevy::render::camera::ScalingMode::FixedVertical(o.vertical_range.unwrap_or(4.0)), + ..Default::default() + }.into() + } + }; + + let mut camera = commands.spawn(( + Camera3dBundle { + camera: Camera { + hdr: true, + order: isize::MIN + container.container_id.id as isize, + target: bevy::render::camera::RenderTarget::Image(image.clone()), + clear_color: ClearColorConfig::Custom( + texture_cam + .0 + .clear_color + .map(Color::from) + .unwrap_or(Color::BLACK), + ), + is_active: true, + ..Default::default() + }, + tonemapping: Tonemapping::TonyMcMapface, + deband_dither: DebandDither::Enabled, + color_grading: ColorGrading { + // exposure: -0.5, + // gamma: 1.5, + // pre_saturation: 1.0, + // post_saturation: 1.0, + global: ColorGradingGlobal { + exposure: -0.5, + ..default() + }, + shadows: ColorGradingSection { + gamma: 0.75, ..Default::default() }, - tonemapping: Tonemapping::TonyMcMapface, - deband_dither: DebandDither::Enabled, - color_grading: ColorGrading { - // exposure: -0.5, - // gamma: 1.5, - // pre_saturation: 1.0, - // post_saturation: 1.0, - global: ColorGradingGlobal { - exposure: -0.5, - ..default() - }, - shadows: ColorGradingSection { - gamma: 0.75, - ..Default::default() - }, - midtones: ColorGradingSection { - gamma: 0.75, - ..Default::default() - }, - highlights: ColorGradingSection { - gamma: 0.75, - ..Default::default() - }, + midtones: ColorGradingSection { + gamma: 0.75, + ..Default::default() }, - projection: PerspectiveProjection { - // projection: OrthographicProjection { - far: 100000.0, + highlights: ColorGradingSection { + gamma: 0.75, ..Default::default() - } - .into(), - ..Default::default() - }, - BloomSettings { - intensity: 0.15, - ..BloomSettings::OLD_SCHOOL - }, - ShadowFilteringMethod::Gaussian, - DepthPrepass, - NormalPrepass, - render_layers, - Skybox { - image: cubemap.image_handle.clone(), - brightness: 1000.0, + }, }, - )) - .id(); + projection, + ..Default::default() + }, + BloomSettings { + intensity: 0.15, + ..BloomSettings::OLD_SCHOOL + }, + ShadowFilteringMethod::Gaussian, + DepthPrepass, + NormalPrepass, + render_layers, + )); + + if !texture_cam.0.disable_fog() { + camera.insert(FogSettings::default()); + } + + if !texture_cam.0.disable_skybox() { + camera.insert(Skybox { + image: cubemap.image_handle.clone(), + brightness: 1000.0, + }); + } + + if texture_cam.0.ambient_brightness_override.is_some() + || texture_cam.0.ambient_color_override.is_some() + { + camera.insert(AmbientLight { + color: texture_cam + .0 + .ambient_color_override + .map(Color::from) + .unwrap_or(global_light.ambient_color), + brightness: texture_cam + .0 + .ambient_brightness_override + .unwrap_or(global_light.ambient_brightness) + * config.graphics.ambient_brightness as f32 + * 20.0, + }); + } + + let camera_id = camera.id(); commands .entity(ent) .push_children(&[camera_id]) .insert((TextureCamEntity(camera_id), VideoTextureOutput(image))); - new_cam_events.send(NewCameraEvent(ent)); + new_cam_events.send(NewCameraEvent(camera_id)); } else { // set active for current scenes only // TODO: limit / cycle @@ -216,24 +273,17 @@ impl From for CameraLayers { } } -fn camera_to_render_layer(camera_layer: u32) -> Layer { - (match camera_layer { - 0 => 0, - nonzero => nonzero + 5 - }) as Layer -} - -fn camera_to_render_layers<'a>(camera_layers: impl Iterator) -> RenderLayers { - camera_layers.fold(RenderLayers::none(), |result, camera_layer| { - result.with(camera_to_render_layer(*camera_layer)) - }) -} - - +#[allow(clippy::type_complexity)] pub fn update_camera_layers( mut commands: Commands, mut removed: RemovedComponents, - maybe_changed: Query<(Entity, Option<&CameraLayers>, &Parent), (Without, Or<(Changed, Changed)>)>, + maybe_changed: Query< + (Entity, Option<&CameraLayers>, &Parent), + ( + Without, + Or<(Changed, Changed)>, + ), + >, removed_data: Query<(Option<&CameraLayers>, &Parent)>, children: Query<&Children, Without>, render_layers: Query<&RenderLayers>, @@ -245,7 +295,10 @@ pub fn update_camera_layers( let target_render_layers = if let Some(camera_layers) = maybe_layers { camera_to_render_layers(camera_layers.0.iter()) } else { - render_layers.get(parent.get()).cloned().unwrap_or_else(|_| RenderLayers::default()) + render_layers + .get(parent.get()) + .cloned() + .unwrap_or_else(|_| RenderLayers::default()) }; to_check.push_back((entity, target_render_layers)); @@ -261,7 +314,10 @@ pub fn update_camera_layers( let target_render_layers = if let Some(camera_layers) = maybe_layers { camera_to_render_layers(camera_layers.0.iter()) } else { - render_layers.get(parent.get()).cloned().unwrap_or_else(|_| RenderLayers::default()) + render_layers + .get(parent.get()) + .cloned() + .unwrap_or_else(|_| RenderLayers::default()) }; to_check.push_back((removed_entity, target_render_layers)); @@ -276,16 +332,24 @@ pub fn update_camera_layers( if update == &target_layers { continue; } - } + } // if we didn't already update and the existing data matches the requirement then stop here - else if render_layers.get(entity).unwrap_or(&RenderLayers::default()) == &target_layers { + else if render_layers + .get(entity) + .unwrap_or(&RenderLayers::default()) + == &target_layers + { continue; } // update commands.entity(entity).insert(target_layers.clone()); // check children - for child in children.get(entity).map(IntoIterator::into_iter).unwrap_or_default() { + for child in children + .get(entity) + .map(IntoIterator::into_iter) + .unwrap_or_default() + { to_check.push_back((*child, target_layers.clone())); } updated.insert(entity, target_layers); diff --git a/crates/visuals/src/lib.rs b/crates/visuals/src/lib.rs index 0791bddb..a4042a27 100644 --- a/crates/visuals/src/lib.rs +++ b/crates/visuals/src/lib.rs @@ -2,7 +2,7 @@ use bevy::{ core_pipeline::Skybox, pbr::{wireframe::WireframePlugin, DirectionalLightShadowMap}, prelude::*, - render::render_asset::RenderAssetBytesPerFrame, + render::{render_asset::RenderAssetBytesPerFrame, view::RenderLayers}, }; use bevy_atmosphere::{ prelude::{AtmosphereCamera, AtmosphereModel, AtmospherePlugin, Nishita}, @@ -84,18 +84,26 @@ pub struct SceneGlobalLight { pub dir_direction: Vec3, pub ambient_color: Color, pub ambient_brightness: f32, + pub layers: RenderLayers, } static TRANSITION_TIME: f32 = 1.0; -#[allow(clippy::too_many_arguments)] +#[allow(clippy::too_many_arguments, clippy::type_complexity)] fn apply_global_light( setting: Res, mut atmosphere: AtmosphereMut, - mut sun: Query<(&mut Transform, &mut DirectionalLight)>, + mut sun: Query<(&mut Transform, &mut DirectionalLight, &mut RenderLayers)>, mut ambient: ResMut, time: Res