feat: implement SkyTex and SkyLight

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2025-08-26 15:11:54 +02:00
parent 51de346f6b
commit 1c6b42e69a
6 changed files with 68 additions and 36 deletions

View File

@@ -1,2 +1,2 @@
[build]
rustflags = ["--cfg", "tokio_unstable"]
rustflags = ["--cfg", "tokio_unstable"]

71
Cargo.lock generated
View File

@@ -14,9 +14,9 @@ dependencies = [
[[package]]
name = "ab_glyph_rasterizer"
version = "0.1.9"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2187590a23ab1e3df8681afdf0987c48504d80291f002fcdb651f0ef5e25169"
checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618"
[[package]]
name = "accesskit"
@@ -605,6 +605,20 @@ dependencies = [
"zbus",
]
[[package]]
name = "bevy-equirect"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0a4903e9341281cc79e69f5e9706a1800bfeb1a41b01a4d1c8b50cd2fe21d97"
dependencies = [
"bevy_app",
"bevy_asset",
"bevy_ecs",
"bevy_image",
"glam",
"wgpu-types",
]
[[package]]
name = "bevy-mesh-text-3d"
version = "0.1.0"
@@ -3490,7 +3504,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667"
dependencies = [
"cfg-if",
"windows-targets 0.48.5",
"windows-targets 0.53.2",
]
[[package]]
@@ -4031,7 +4045,7 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d"
dependencies = [
"proc-macro-crate 1.3.1",
"proc-macro-crate 3.3.0",
"proc-macro2",
"quote",
"syn 2.0.104",
@@ -4423,9 +4437,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "owned_ttf_parser"
version = "0.25.0"
version = "0.25.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec719bbf3b2a81c109a4e20b1f129b5566b7dce654bc3872f6a05abf82b2c4"
checksum = "36820e9051aca1014ddc75770aab4d68bc1e9e632f0f5627c4086bc216fb583b"
dependencies = [
"ttf-parser 0.25.1",
]
@@ -4769,7 +4783,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d"
dependencies = [
"anyhow",
"itertools 0.11.0",
"itertools 0.14.0",
"proc-macro2",
"quote",
"syn 2.0.104",
@@ -5450,6 +5464,7 @@ dependencies = [
"ash",
"bevy",
"bevy-dmabuf",
"bevy-equirect",
"bevy-mesh-text-3d",
"bevy_mod_openxr",
"bevy_mod_xr",
@@ -6115,7 +6130,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69fff37da548239c3bf9e64a12193d261e8b22b660991c6fd2df057c168f435f"
dependencies = [
"cc",
"windows-targets 0.48.5",
"windows-targets 0.52.6",
]
[[package]]
@@ -6430,13 +6445,13 @@ dependencies = [
[[package]]
name = "wayland-backend"
version = "0.3.10"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe770181423e5fc79d3e2a7f4410b7799d5aab1de4372853de3c6aa13ca24121"
checksum = "673a33c33048a5ade91a6b139580fa174e19fb0d23f396dca9fa15f2e1e49b35"
dependencies = [
"cc",
"downcast-rs 1.2.1",
"rustix 0.38.44",
"rustix 1.0.8",
"scoped-tls",
"smallvec",
"wayland-sys",
@@ -6444,12 +6459,12 @@ dependencies = [
[[package]]
name = "wayland-client"
version = "0.31.10"
version = "0.31.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978fa7c67b0847dbd6a9f350ca2569174974cd4082737054dbb7fbb79d7d9a61"
checksum = "c66a47e840dc20793f2264eb4b3e4ecb4b75d91c0dd4af04b456128e0bdd449d"
dependencies = [
"bitflags 2.9.1",
"rustix 0.38.44",
"rustix 1.0.8",
"wayland-backend",
"wayland-scanner",
]
@@ -6467,20 +6482,20 @@ dependencies = [
[[package]]
name = "wayland-cursor"
version = "0.31.10"
version = "0.31.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a65317158dec28d00416cb16705934070aef4f8393353d41126c54264ae0f182"
checksum = "447ccc440a881271b19e9989f75726d60faa09b95b0200a9b7eb5cc47c3eeb29"
dependencies = [
"rustix 0.38.44",
"rustix 1.0.8",
"wayland-client",
"xcursor",
]
[[package]]
name = "wayland-protocols"
version = "0.32.8"
version = "0.32.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "779075454e1e9a521794fed15886323ea0feda3f8b0fc1390f5398141310422a"
checksum = "efa790ed75fbfd71283bd2521a1cfdc022aabcc28bdcff00851f9e4ae88d9901"
dependencies = [
"bitflags 2.9.1",
"wayland-backend",
@@ -6490,9 +6505,9 @@ dependencies = [
[[package]]
name = "wayland-protocols-plasma"
version = "0.3.8"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fd38cdad69b56ace413c6bcc1fbf5acc5e2ef4af9d5f8f1f9570c0c83eae175"
checksum = "a07a14257c077ab3279987c4f8bb987851bf57081b93710381daea94f2c2c032"
dependencies = [
"bitflags 2.9.1",
"wayland-backend",
@@ -6503,9 +6518,9 @@ dependencies = [
[[package]]
name = "wayland-protocols-wlr"
version = "0.3.8"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cb6cdc73399c0e06504c437fe3cf886f25568dd5454473d565085b36d6a8bbf"
checksum = "efd94963ed43cf9938a090ca4f7da58eb55325ec8200c3848963e98dc25b78ec"
dependencies = [
"bitflags 2.9.1",
"wayland-backend",
@@ -6516,9 +6531,9 @@ dependencies = [
[[package]]
name = "wayland-scanner"
version = "0.31.6"
version = "0.31.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "896fdafd5d28145fce7958917d69f2fd44469b1d4e861cb5961bcbeebc6d1484"
checksum = "54cb1e9dc49da91950bdfd8b848c49330536d9d1fb03d4bfec8cae50caa50ae3"
dependencies = [
"proc-macro2",
"quick-xml",
@@ -6527,9 +6542,9 @@ dependencies = [
[[package]]
name = "wayland-sys"
version = "0.31.6"
version = "0.31.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbcebb399c77d5aa9fa5db874806ee7b4eba4e73650948e8f93963f128896615"
checksum = "34949b42822155826b41db8e5d0c1be3a2bd296c747577a43a3e6daefc296142"
dependencies = [
"dlib",
"log",
@@ -6711,7 +6726,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.48.0",
"windows-sys 0.59.0",
]
[[package]]

View File

@@ -34,7 +34,12 @@ wayland = [
"dep:ash",
]
profile_tokio = ["dep:console-subscriber", "tokio/tracing"]
profile_app = ["dep:tracing-tracy", "bevy/trace_tracy", "bevy/trace"]
profile_app = [
"dep:tracing-tracy",
"bevy/trace_tracy",
"bevy/trace",
"dep:tracy-client",
]
bevy_debugging = ["bevy/bevy_remote", "bevy/track_location"]
[package.metadata.appimage]
@@ -80,7 +85,7 @@ thiserror = "2.0.11"
tracing = { version = "0.1.40", features = ["release_max_level_warn"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracing-tracy = { version = "0.11.1", optional = true }
tracy-client = { version = "=0.18.0" }
tracy-client = { version = "=0.18.0", optional = true }
# (de)serialization
serde = { version = "1.0.205", features = ["derive"] }
@@ -158,6 +163,7 @@ vulkano = { git = "https://github.com/Schmarni-Dev/vulkano", branch = "0_35_dmab
wgpu-hal = { version = "24", optional = true, features = ["vulkan"] }
ash = { version = "0.38.0", optional = true, default-features = false }
rustix = { version = "1.0.8", features = ["time"] }
bevy-equirect = "0.1.0"
[dependencies.stardust-xr]
workspace = true

View File

@@ -9,6 +9,7 @@ pub mod tracking_offset;
#[cfg(feature = "wayland")]
mod wayland;
use crate::nodes::drawable::sky::SkyPlugin;
use crate::nodes::input;
use bevy::MinimalPlugins;
@@ -379,6 +380,7 @@ fn bevy_loop(
);
app.add_plugins(bevy_sk::hand::HandPlugin);
app.add_plugins(bevy_equirect::EquirectangularPlugin);
// app.add_plugins(HandGizmosPlugin);
app.world_mut().resource_mut::<AmbientLight>().brightness = 1000.0;
if let Some(priority) = args.overlay_priority {
@@ -415,6 +417,8 @@ fn bevy_loop(
TextNodePlugin,
LinesNodePlugin,
AudioNodePlugin,
// not really a node ig? at least for now
SkyPlugin,
));
// object plugins
app.add_plugins((PlaySpacePlugin, HandPlugin, ControllerPlugin, HmdPlugin));

View File

@@ -78,11 +78,11 @@ fn build_line_mesh(
let mut peekable = line.points.iter().peekable();
while let Some(curr) = peekable.next() {
// Skip this point if it has the same position as the previous point
if let Some(prev) = last {
if Vec3::from(prev.point) == Vec3::from(curr.point) {
last = Some(curr);
continue;
}
if let Some(prev) = last
&& Vec3::from(prev.point) == Vec3::from(curr.point)
{
last = Some(curr);
continue;
}
let mut end = false;
@@ -127,6 +127,9 @@ fn build_line_mesh(
(Some(last), None) => last,
(Some(last), Some(next)) => last.lerp(next, 0.5),
};
if !quat.is_finite() {
panic!("non finite quat: next: {next:?}, last: {last:?}, curr: {curr:?},");
}
let normals = [
Vec3::X,
Vec3::new(1., 0., 1.).normalize(),

View File

@@ -1,5 +1,6 @@
pub mod lines;
pub mod model;
pub mod sky;
pub mod text;
use self::{lines::Lines, model::Model, text::Text};
@@ -13,6 +14,7 @@ use color_eyre::eyre::eyre;
use model::ModelPart;
use parking_lot::Mutex;
use stardust_xr::values::ResourceID;
use tracing::info;
use std::{ffi::OsStr, path::PathBuf, sync::Arc};
static QUEUED_SKYLIGHT: Mutex<Option<Option<PathBuf>>> = Mutex::new(None);
@@ -51,6 +53,7 @@ impl InterfaceAspect for Interface {
calling_client: Arc<Client>,
tex: Option<ResourceID>,
) -> Result<()> {
info!("setting sky tex");
let resource_path = tex
.map(|tex| {
get_resource_file(&tex, &calling_client, &[OsStr::new("hdr")])
@@ -66,6 +69,7 @@ impl InterfaceAspect for Interface {
calling_client: Arc<Client>,
light: Option<ResourceID>,
) -> Result<()> {
info!("setting sky light");
let resource_path = light
.map(|light| {
get_resource_file(&light, &calling_client, &[OsStr::new("hdr")])