kitgit

tirbofish/dropbear · diff

c4de601 · Thribhu K

wip: this is a tomorrow problem Unverified

diff --git a/crates/dropbear-engine/src/graphics.rs b/crates/dropbear-engine/src/graphics.rs
index 344f16e..8cb81c3 100644
--- a/crates/dropbear-engine/src/graphics.rs
+++ b/crates/dropbear-engine/src/graphics.rs
@@ -106,7 +106,7 @@ impl SharedGraphicsContext {
                         module: &shader.module,
                         entry_point: Some("fs_main"),
                         targets: &[Some(wgpu::ColorTargetState {
-                            format: wgpu::TextureFormat::Rgba16Float,
+                            format: Texture::TEXTURE_FORMAT,
                             blend: Some(wgpu::BlendState::REPLACE),
                             write_mask: wgpu::ColorWrites::ALL,
                         })],
diff --git a/crates/dropbear-engine/src/lib.rs b/crates/dropbear-engine/src/lib.rs
index 9d4831b..bc3694f 100644
--- a/crates/dropbear-engine/src/lib.rs
+++ b/crates/dropbear-engine/src/lib.rs
@@ -192,16 +192,16 @@ Hardware:
 
         let surface_caps = surface.get_capabilities(&adapter);
 
-        let surface_format = surface_caps
-            .formats
-            .iter()
-            .find(|f| f.is_srgb())
-            .copied()
-            .unwrap_or(TextureFormat::Rgba16Float);
+        // let surface_format = surface_caps
+        //     .formats
+        //     .iter()
+        //     .find(|f| f.is_srgb())
+        //     .copied()
+        //     .unwrap_or(TextureFormat::Rgba16Float);
         
         let config = SurfaceConfiguration {
             usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
-            format: surface_format,
+            format: Texture::TEXTURE_FORMAT,
             width: initial_width,
             height: initial_height,
             present_mode: surface_caps.present_modes[0],
@@ -246,7 +246,7 @@ Hardware:
 
         let result = Self {
             surface: Arc::new(surface),
-            surface_format,
+            surface_format: Texture::TEXTURE_FORMAT,
             device: Arc::new(device),
             queue: Arc::new(queue),
             config,
diff --git a/crates/dropbear-engine/src/lighting.rs b/crates/dropbear-engine/src/lighting.rs
index 6131f67..faa7d07 100644
--- a/crates/dropbear-engine/src/lighting.rs
+++ b/crates/dropbear-engine/src/lighting.rs
@@ -2,6 +2,7 @@ use crate::attenuation::{Attenuation, RANGE_50};
 use crate::buffer::{ResizableBuffer, StorageBuffer, UniformBuffer};
 use crate::graphics::SharedGraphicsContext;
 use crate::shader::Shader;
+use crate::texture::Texture;
 use crate::{
     entity::{EntityTransform, Transform},
     model::{self, Model, Vertex},
@@ -540,7 +541,7 @@ impl LightManager {
                     module: &shader.module,
                     entry_point: Some("fs_main"),
                     targets: &[Some(wgpu::ColorTargetState {
-                        format: wgpu::TextureFormat::Rgba16Float,
+                        format: Texture::TEXTURE_FORMAT,
                         blend: Some(wgpu::BlendState {
                             alpha: wgpu::BlendComponent::REPLACE,
                             color: wgpu::BlendComponent::REPLACE,
diff --git a/crates/dropbear-engine/src/texture.rs b/crates/dropbear-engine/src/texture.rs
index 964d8ce..fdb663e 100644
--- a/crates/dropbear-engine/src/texture.rs
+++ b/crates/dropbear-engine/src/texture.rs
@@ -72,6 +72,7 @@ pub struct Texture {
 impl Texture {
     /// Describes the depth format for all Texture related functions in WGPU to use. Makes life easier
     pub const DEPTH_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Depth32Float;
+    pub const TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb;
 
     /// Creates a new depth texture. This is an internal function.
     pub fn depth_texture(
@@ -139,7 +140,7 @@ impl Texture {
             mip_level_count: 1, // leave me alone
             sample_count: 1,
             dimension: wgpu::TextureDimension::D2,
-            format: wgpu::TextureFormat::Rgba16Float,
+            format: Texture::TEXTURE_FORMAT,
             usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::TEXTURE_BINDING,
             view_formats: &[],
         };
@@ -209,7 +210,7 @@ impl Texture {
                 mip_level_count: 1,
                 sample_count: 1,
                 dimension: wgpu::TextureDimension::D2,
-                format: wgpu::TextureFormat::Rgba8UnormSrgb,
+                format: Texture::TEXTURE_FORMAT,
                 usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST | wgpu::TextureUsages::RENDER_ATTACHMENT,
                 view_formats: &[],
             }
diff --git a/crates/eucalyptus-core/src/config.rs b/crates/eucalyptus-core/src/config.rs
index 8fbcc18..e743cae 100644
--- a/crates/eucalyptus-core/src/config.rs
+++ b/crates/eucalyptus-core/src/config.rs
@@ -129,9 +129,10 @@ impl ProjectConfig {
                     if io_err.kind() == std::io::ErrorKind::NotFound {
                         log::warn!("resources.eucc not found, creating default.");
                         let default = ResourceConfig {
-                            path: project_root.join("../../../resources"),
+                            path: project_root.join("/resources"),
                             nodes: vec![],
                         };
+                        log::debug!("Writing to {}", default.path.display());
                         default.write_to(&project_root)?;
                         {
                             let mut cfg = RESOURCES.write();
diff --git a/crates/eucalyptus-core/src/physics/collider/shader.rs b/crates/eucalyptus-core/src/physics/collider/shader.rs
index 2728314..50d6368 100644
--- a/crates/eucalyptus-core/src/physics/collider/shader.rs
+++ b/crates/eucalyptus-core/src/physics/collider/shader.rs
@@ -3,7 +3,7 @@
 use std::mem::size_of;
 use std::sync::Arc;
 
-use dropbear_engine::entity::Transform;
+use dropbear_engine::{entity::Transform, texture::Texture};
 use dropbear_engine::graphics::SharedGraphicsContext;
 use dropbear_engine::shader::Shader;
 use dropbear_engine::wgpu::*;
@@ -59,7 +59,7 @@ impl ColliderWireframePipeline {
                 module: &shader.module,
                 entry_point: Some("fs_main"),
                 targets: &[Some(ColorTargetState {
-                    format: TextureFormat::Rgba16Float,
+                    format: Texture::TEXTURE_FORMAT,
                     blend: Some(BlendState::ALPHA_BLENDING),
                     write_mask: ColorWrites::ALL,
                 })],
@@ -75,7 +75,7 @@ impl ColliderWireframePipeline {
                 conservative: false,
             },
             depth_stencil: Some(DepthStencilState {
-                format: TextureFormat::Depth32Float,
+                format: Texture::DEPTH_FORMAT,
                 depth_write_enabled: false,
                 depth_compare: CompareFunction::Always,
                 stencil: StencilState::default(),
diff --git a/crates/eucalyptus-editor/src/editor/dock.rs b/crates/eucalyptus-editor/src/editor/dock.rs
index b653799..6590b8d 100644
--- a/crates/eucalyptus-editor/src/editor/dock.rs
+++ b/crates/eucalyptus-editor/src/editor/dock.rs
@@ -1167,9 +1167,9 @@ impl<'a> EditorTabViewer<'a> {
         let entries = match Self::sorted_entries(current_path) {
             Ok(entries) => entries,
             Err(err) => {
-                log::warn!(
+                log_once::warn_once!(
                     "Unable to enumerate resources at '{}': {}",
-                    current_path.display(),
+                    current_path.parent().unwrap_or(current_path).display(),
                     err
                 );
                 return;
diff --git a/crates/eucalyptus-editor/src/editor/mod.rs b/crates/eucalyptus-editor/src/editor/mod.rs
index 091f639..b4c171d 100644
--- a/crates/eucalyptus-editor/src/editor/mod.rs
+++ b/crates/eucalyptus-editor/src/editor/mod.rs
@@ -1332,6 +1332,8 @@ impl Editor {
         let collider_pipeline = ColliderWireframePipeline::new(graphics.clone());
         self.collider_wireframe_pipeline = Some(collider_pipeline);
 
+        self.texture_id = Some((*graphics.texture_id).clone());
+
         self.window = Some(graphics.window.clone());
         self.is_world_loaded.mark_rendering_loaded();
     }
diff --git a/crates/eucalyptus-editor/src/editor/scene.rs b/crates/eucalyptus-editor/src/editor/scene.rs
index 36678c4..ffdd8e9 100644
--- a/crates/eucalyptus-editor/src/editor/scene.rs
+++ b/crates/eucalyptus-editor/src/editor/scene.rs
@@ -349,6 +349,16 @@ impl Scene for Editor {
 
     fn render<'a>(&mut self, graphics: Arc<SharedGraphicsContext>, frame_ctx: FrameGraphicsContext<'a>) {
         self.show_ui(&graphics.get_egui_context());
+        let clear_color = Color {
+            r: 100.0 / 255.0,
+            g: 149.0 / 255.0,
+            b: 237.0 / 255.0,
+            a: 1.0,
+        };
+        self.color = clear_color;
+        self.size = graphics.viewport_texture.size;
+        self.texture_id = Some(*graphics.texture_id.clone());
+        self.window = Some(graphics.window.clone());
         eucalyptus_core::logging::render(&graphics.get_egui_context());
 
         let cam = {
@@ -375,13 +385,6 @@ impl Scene for Editor {
         };
         log_once::debug_once!("Pipeline ready");
 
-        let clear_color = Color {
-            r: 100.0 / 255.0,
-            g: 149.0 / 255.0,
-            b: 237.0 / 255.0,
-            a: 1.0,
-        };
-
         let lights = {
             let mut lights = Vec::new();
             let mut query = self.world.query::<(&Light, &LightComponent)>();
diff --git a/crates/eucalyptus-editor/src/menu.rs b/crates/eucalyptus-editor/src/menu.rs
index 77cbb9f..e886b5a 100644
--- a/crates/eucalyptus-editor/src/menu.rs
+++ b/crates/eucalyptus-editor/src/menu.rs
@@ -362,6 +362,7 @@ impl Scene for MainMenu {
                 .add_filter("Eucalyptus Configuration Files", &["eucp"])
                 .pick_file()
             {
+                log::debug!("Reading from {}", path.display());
                 match ProjectConfig::read_from(&path) {
                     Ok(config) => {
                         log::info!("Loaded project: {:?}", path);