feat: unset sky
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -2620,7 +2620,7 @@ checksum = "2f2b15926089e5526bb2dd738a2eb0e59034356e06eb71e1cd912358c0e62c4d"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "stardust-xr"
|
name = "stardust-xr"
|
||||||
version = "0.45.0"
|
version = "0.45.0"
|
||||||
source = "git+https://github.com/StardustXR/core.git?branch=dev#752e34817e045997c7bdca53cda6bb8a0055e902"
|
source = "git+https://github.com/StardustXR/core.git?branch=dev#8640276cc5b445fc486694f63f884323fc818860"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cluFlock",
|
"cluFlock",
|
||||||
"color-eyre",
|
"color-eyre",
|
||||||
@@ -2641,7 +2641,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "stardust-xr-schemas"
|
name = "stardust-xr-schemas"
|
||||||
version = "1.5.3"
|
version = "1.5.3"
|
||||||
source = "git+https://github.com/StardustXR/core.git?branch=dev#752e34817e045997c7bdca53cda6bb8a0055e902"
|
source = "git+https://github.com/StardustXR/core.git?branch=dev#8640276cc5b445fc486694f63f884323fc818860"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"flatbuffers",
|
"flatbuffers",
|
||||||
"flexbuffers",
|
"flexbuffers",
|
||||||
|
|||||||
21
src/main.rs
21
src/main.rs
@@ -29,7 +29,7 @@ use stereokit_rust::sk::{
|
|||||||
use stereokit_rust::system::{Handed, Input, LogLevel, Renderer};
|
use stereokit_rust::system::{Handed, Input, LogLevel, Renderer};
|
||||||
use stereokit_rust::tex::{SHCubemap, Tex, TexFormat, TexType};
|
use stereokit_rust::tex::{SHCubemap, Tex, TexFormat, TexType};
|
||||||
use stereokit_rust::ui::Ui;
|
use stereokit_rust::ui::Ui;
|
||||||
use stereokit_rust::util::{Color128, Time};
|
use stereokit_rust::util::{Color128, SphericalHarmonics, Time};
|
||||||
use tokio::net::UnixListener;
|
use tokio::net::UnixListener;
|
||||||
use tokio::sync::Notify;
|
use tokio::sync::Notify;
|
||||||
use tracing::metadata::LevelFilter;
|
use tracing::metadata::LevelFilter;
|
||||||
@@ -202,6 +202,9 @@ async fn main() {
|
|||||||
info!("Cleanly shut down Stardust");
|
info!("Cleanly shut down Stardust");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DEFAULT_SKYTEX: OnceLock<Tex> = OnceLock::new();
|
||||||
|
static DEFAULT_SKYLIGHT: OnceLock<SphericalHarmonics> = OnceLock::new();
|
||||||
|
|
||||||
fn stereokit_loop(
|
fn stereokit_loop(
|
||||||
sk_ready_notifier: Arc<Notify>,
|
sk_ready_notifier: Arc<Notify>,
|
||||||
project_dirs: Option<ProjectDirs>,
|
project_dirs: Option<ProjectDirs>,
|
||||||
@@ -249,6 +252,14 @@ fn stereokit_loop(
|
|||||||
|
|
||||||
// Skytex/light stuff
|
// Skytex/light stuff
|
||||||
{
|
{
|
||||||
|
let _ = DEFAULT_SKYTEX.set(Tex::gen_color(
|
||||||
|
Color128::BLACK,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
TexType::Cubemap,
|
||||||
|
TexFormat::RGBA32,
|
||||||
|
));
|
||||||
|
let _ = DEFAULT_SKYLIGHT.set(Renderer::get_skylight());
|
||||||
if let Some(sky) = project_dirs
|
if let Some(sky) = project_dirs
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|dirs| dirs.config_dir().join("skytex.hdr"))
|
.map(|dirs| dirs.config_dir().join("skytex.hdr"))
|
||||||
@@ -257,13 +268,7 @@ fn stereokit_loop(
|
|||||||
{
|
{
|
||||||
sky.render_as_sky();
|
sky.render_as_sky();
|
||||||
} else {
|
} else {
|
||||||
Renderer::skytex(Tex::gen_color(
|
Renderer::skytex(DEFAULT_SKYTEX.get().unwrap());
|
||||||
Color128::BLACK,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
TexType::Cubemap,
|
|
||||||
TexFormat::RGBA32,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,11 @@ use super::{
|
|||||||
Aspect, AspectIdentifier, Node,
|
Aspect, AspectIdentifier, Node,
|
||||||
spatial::{Spatial, Transform},
|
spatial::{Spatial, Transform},
|
||||||
};
|
};
|
||||||
use crate::core::{client::Client, error::Result, resource::get_resource_file};
|
use crate::{DEFAULT_SKYLIGHT, nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO};
|
||||||
use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO;
|
use crate::{
|
||||||
|
DEFAULT_SKYTEX,
|
||||||
|
core::{client::Client, error::Result, resource::get_resource_file},
|
||||||
|
};
|
||||||
use color_eyre::eyre::eyre;
|
use color_eyre::eyre::eyre;
|
||||||
use model::ModelPart;
|
use model::ModelPart;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
@@ -22,21 +25,32 @@ pub fn draw(token: &MainThreadToken) {
|
|||||||
lines::draw_all(token);
|
lines::draw_all(token);
|
||||||
model::draw_all(token);
|
model::draw_all(token);
|
||||||
text::draw_all(token);
|
text::draw_all(token);
|
||||||
|
match QUEUED_SKYTEX.lock().take() {
|
||||||
if let Some(skytex) = QUEUED_SKYTEX.lock().take() {
|
Some(Some(skytex)) => {
|
||||||
if let Ok(skytex) = SHCubemap::from_cubemap(skytex, true, 100) {
|
if let Ok(skytex) = SHCubemap::from_cubemap(skytex, true, 100) {
|
||||||
Renderer::skytex(skytex.tex);
|
Renderer::skytex(skytex.tex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Some(None) => {
|
||||||
|
Renderer::skytex(DEFAULT_SKYTEX.get().unwrap());
|
||||||
|
}
|
||||||
|
None => {}
|
||||||
}
|
}
|
||||||
if let Some(skylight) = QUEUED_SKYLIGHT.lock().take() {
|
match QUEUED_SKYLIGHT.lock().take() {
|
||||||
if let Ok(skylight) = SHCubemap::from_cubemap(skylight, true, 100) {
|
Some(Some(skylight)) => {
|
||||||
Renderer::skylight(skylight.sh);
|
if let Ok(skylight) = SHCubemap::from_cubemap(skylight, true, 100) {
|
||||||
|
Renderer::skylight(skylight.sh);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Some(None) => {
|
||||||
|
Renderer::skylight(*DEFAULT_SKYLIGHT.get().unwrap());
|
||||||
|
}
|
||||||
|
None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static QUEUED_SKYLIGHT: Mutex<Option<PathBuf>> = Mutex::new(None);
|
static QUEUED_SKYLIGHT: Mutex<Option<Option<PathBuf>>> = Mutex::new(None);
|
||||||
static QUEUED_SKYTEX: Mutex<Option<PathBuf>> = Mutex::new(None);
|
static QUEUED_SKYTEX: Mutex<Option<Option<PathBuf>>> = Mutex::new(None);
|
||||||
|
|
||||||
stardust_xr_server_codegen::codegen_drawable_protocol!();
|
stardust_xr_server_codegen::codegen_drawable_protocol!();
|
||||||
|
|
||||||
@@ -66,9 +80,17 @@ impl Aspect for Text {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl InterfaceAspect for Interface {
|
impl InterfaceAspect for Interface {
|
||||||
fn set_sky_tex(_node: Arc<Node>, calling_client: Arc<Client>, tex: ResourceID) -> Result<()> {
|
fn set_sky_tex(
|
||||||
let resource_path = get_resource_file(&tex, &calling_client, &[OsStr::new("hdr")])
|
_node: Arc<Node>,
|
||||||
.ok_or(eyre!("Could not find resource"))?;
|
calling_client: Arc<Client>,
|
||||||
|
tex: Option<ResourceID>,
|
||||||
|
) -> Result<()> {
|
||||||
|
let resource_path = tex
|
||||||
|
.map(|tex| {
|
||||||
|
get_resource_file(&tex, &calling_client, &[OsStr::new("hdr")])
|
||||||
|
.ok_or(eyre!("Could not find resource"))
|
||||||
|
})
|
||||||
|
.transpose()?;
|
||||||
QUEUED_SKYTEX.lock().replace(resource_path);
|
QUEUED_SKYTEX.lock().replace(resource_path);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -76,10 +98,14 @@ impl InterfaceAspect for Interface {
|
|||||||
fn set_sky_light(
|
fn set_sky_light(
|
||||||
_node: Arc<Node>,
|
_node: Arc<Node>,
|
||||||
calling_client: Arc<Client>,
|
calling_client: Arc<Client>,
|
||||||
light: ResourceID,
|
light: Option<ResourceID>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let resource_path = get_resource_file(&light, &calling_client, &[OsStr::new("hdr")])
|
let resource_path = light
|
||||||
.ok_or(eyre!("Could not find resource"))?;
|
.map(|light| {
|
||||||
|
get_resource_file(&light, &calling_client, &[OsStr::new("hdr")])
|
||||||
|
.ok_or(eyre!("Could not find resource"))
|
||||||
|
})
|
||||||
|
.transpose()?;
|
||||||
QUEUED_SKYLIGHT.lock().replace(resource_path);
|
QUEUED_SKYLIGHT.lock().replace(resource_path);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user