diff options
27 files changed, 1795 insertions, 67 deletions
@@ -57,6 +57,8 @@ All third-party dependencies are licensed under their own license. - [x] Mat4 functions - [ ] SIMD 4x4 multiply - [ ] Quaternion functions (not fully fleshed out) +- [x] Camera + - [ ] Swap to quaternion for internal orientation - [ ] Transform gizmo - [ ] Mesh generation - [x] Cube diff --git a/assets/shaders/pbr_textured.frag b/assets/shaders/pbr_textured.frag index 5353fa7..8148f05 100644 --- a/assets/shaders/pbr_textured.frag +++ b/assets/shaders/pbr_textured.frag @@ -21,11 +21,16 @@ uniform Lights { PointLight pointLights[NUM_POINT_LIGHTS]; } scene; +uniform PBR_Params { + vec3 albedo; + float metallic; + float roughness; + float ao; +} params; // Material Textures uniform sampler2D albedoMap; uniform sampler2D metallicRoughnessMap; -// uniform sampler2D roughnessMap; uniform sampler2D aoMap; uniform sampler2D normalMap; @@ -56,9 +61,9 @@ vec3 getNormalFromMap() void main() { // vec3 albedo = pow(texture(albedoMap, fragTexCoords).rgb, vec3(2.2)); - vec3 albedo = texture(albedoMap, fragTexCoords).rgb; - float metallic = texture(metallicRoughnessMap, fragTexCoords).b; - float roughness = texture(metallicRoughnessMap, fragTexCoords).g; + vec3 albedo = params.albedo * texture(albedoMap, fragTexCoords).rgb; + float metallic = params.metallic * texture(metallicRoughnessMap, fragTexCoords).b; + float roughness = params.roughness * texture(metallicRoughnessMap, fragTexCoords).g; float ao = texture(aoMap, fragTexCoords).r; // vec3 norm = normalize(fragNormal); // N diff --git a/bindgen/rust/Cargo.lock b/bindgen/rust/Cargo.lock index 0a1d69e..75bf0a5 100644 --- a/bindgen/rust/Cargo.lock +++ b/bindgen/rust/Cargo.lock @@ -93,13 +93,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" [[package]] -name = "celeritas-rs" +name = "celeritas" version = "0.1.0" dependencies = [ "celeritas-sys", "egui", "egui_glfw", "gl", + "serde", + "serde_json", ] [[package]] @@ -107,6 +109,7 @@ name = "celeritas-sys" version = "0.1.0" dependencies = [ "bindgen", + "serde", ] [[package]] @@ -378,6 +381,12 @@ dependencies = [ ] [[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] name = "khronos_api" version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -682,12 +691,49 @@ dependencies = [ ] [[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] +name = "serde" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "serde_json" +version = "1.0.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/bindgen/rust/Cargo.toml b/bindgen/rust/Cargo.toml index 765c5d0..8f9da64 100644 --- a/bindgen/rust/Cargo.toml +++ b/bindgen/rust/Cargo.toml @@ -1,10 +1,12 @@ [package] -name = "celeritas-rs" +name = "celeritas" version = "0.1.0" edition = "2021" [dependencies] celeritas-sys = { path = "./celeritas-sys" } +serde = { version = "1.0.204", features = ["derive"] } +serde_json = "1.0.120" egui = "0.27.1" egui_glfw = { git = "https://github.com/omnisci3nce/egui_glfw.git", rev = "67b432695433feb59761f3ae984b966ca3da31db" } diff --git a/bindgen/rust/celeritas-sys/Cargo.lock b/bindgen/rust/celeritas-sys/Cargo.lock index 56df9ac..89c7407 100644 --- a/bindgen/rust/celeritas-sys/Cargo.lock +++ b/bindgen/rust/celeritas-sys/Cargo.lock @@ -100,6 +100,8 @@ dependencies = [ "egui", "egui_glfw", "gl", + "serde", + "serde_json", ] [[package]] @@ -371,6 +373,12 @@ dependencies = [ ] [[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] name = "khronos_api" version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -675,12 +683,49 @@ dependencies = [ ] [[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] +name = "serde" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "serde_json" +version = "1.0.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/bindgen/rust/celeritas-sys/Cargo.toml b/bindgen/rust/celeritas-sys/Cargo.toml index bb5d692..0b52e3c 100644 --- a/bindgen/rust/celeritas-sys/Cargo.toml +++ b/bindgen/rust/celeritas-sys/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] +serde = { version = "1.0.204", features = ["derive"] } [build-dependencies] bindgen = "0.69.4" @@ -11,4 +12,5 @@ bindgen = "0.69.4" [dev-dependencies] egui = "0.27.1" egui_glfw = { git = "https://github.com/omnisci3nce/egui_glfw.git", rev = "67b432695433feb59761f3ae984b966ca3da31db" } -gl = "0.14.0"
\ No newline at end of file +gl = "0.14.0" +serde_json = "1.0.120"
\ No newline at end of file diff --git a/bindgen/rust/celeritas-sys/build.rs b/bindgen/rust/celeritas-sys/build.rs index 097e26b..f7bf741 100644 --- a/bindgen/rust/celeritas-sys/build.rs +++ b/bindgen/rust/celeritas-sys/build.rs @@ -1,7 +1,33 @@ use std::env; use std::path::PathBuf; +use bindgen::callbacks::ParseCallbacks; + +const serializable_types: &[&'static str] = &[ + "Vec2", + "Vec3", + "Vec4", + "Mat4", + "Quat", + "DirectionalLight", + "PointLight", +]; + +#[derive(Debug)] +struct DeriveSerialize; +impl ParseCallbacks for DeriveSerialize { + fn add_derives(&self, info: &bindgen::callbacks::DeriveInfo<'_>) -> Vec<String> { + if (serializable_types.contains(&info.name)) { + vec!["Serialize".to_string(), "Deserialize".to_string()] + } else { + vec![] + } + } +} + fn main() { + /* */ + // Tell cargo to look for shared libraries in the specified directory // TODO: we need to look based on OS println!("cargo:rustc-link-search=../../../build/macosx/arm64/debug"); @@ -43,6 +69,7 @@ fn main() { // Tell cargo to invalidate the built crate whenever any of the // included header files changed. .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) + .parse_callbacks(Box::new(DeriveSerialize)) // Finish the builder and generate the bindings. .generate() // Unwrap the Result and panic on failure. diff --git a/bindgen/rust/celeritas-sys/examples/scene.rs b/bindgen/rust/celeritas-sys/examples/scene.rs new file mode 100644 index 0000000..f3ea135 --- /dev/null +++ b/bindgen/rust/celeritas-sys/examples/scene.rs @@ -0,0 +1,169 @@ +use std::{ + ffi::CString, + fs::{self, File}, + io::Write, + path::Path, + ptr::{self, addr_of_mut}, +}; + +use serde::{Deserialize, Serialize}; + +use celeritas_sys::*; +use egui_backend::egui::{vec2, Pos2, Rect}; +use egui_glfw as egui_backend; +use egui_glfw::glfw::{fail_on_errors, Context}; + +use egui_glfw::glfw; + +// use celeritas_sys::{ffi::*, SerializableScene}; +use celeritas_sys::*; + +/// Wrapper around a string that is the path to a gltf model **relative** to the configured +/// `ASSETS` folder +#[derive(Debug, Serialize, Deserialize)] +pub struct ModelPath(String); + +/// Scene that can be saved and loaded from disk +#[derive(Debug, Serialize, Deserialize)] +pub struct SerializableScene { + pub sun: DirectionalLight, + pub point_lights: [Option<PointLight>; 4], + pub camera_orientation: (Vec3, Vec3), + pub models: Vec<ModelPath>, +} + +// Runtime Scene <-> Serialized Scene + +impl SerializableScene { + /// TODO: docs + pub fn store_to_file(&self, filepath: &Path) { + let mut file = File::create(filepath).expect("creation failed"); + let json = serde_json::to_string(&self).expect("serialize failed"); + file.write(&json.as_bytes()).expect("writing failed"); + } + /// TODO: docs + pub fn load_from_file(filepath: &Path) -> Self { + let contents = fs::read_to_string(filepath).expect("Filepath should be open and read-able"); + + serde_json::from_str(&contents).expect("Should be deserializable") + } +} + +fn main() { + unsafe { + let p: *mut GLFWwindow = ptr::null_mut(); + Core_Bringup(p); + + // let core = get_global_core(); + + let camera_pos = Vec3 { + x: 18.9, + y: 10.6, + z: 11.6, + }; + let camera_front = Vec3 { + x: -0.6, + y: -0.2, + z: -0.7, + }; + let mut camera = Camera_Create( + camera_pos, + camera_front, + Vec3 { + x: 0.0, + y: 1.0, + z: 0.0, + }, + 45.0, + ); + SetCamera(camera); + + let mut cube_geo = Geo_CreateCuboid(f32x3 { + x: 2.0, + y: 2.0, + z: 2.0, + }); + + let scene = SerializableScene { + sun: DirectionalLight { + direction: Vec3 { + x: 0.0, + y: 1.0, + z: 0.0, + }, + ambient: Vec3 { + x: 1.0, + y: 1.0, + z: 1.0, + }, + diffuse: Vec3 { + x: 1.0, + y: 1.0, + z: 1.0, + }, + specular: Vec3 { + x: 0.0, + y: 0.0, + z: 0.0, + }, + }, + point_lights: [None, None, None, None], + camera_orientation: (camera_pos, camera_front), + models: vec![], + }; + + let scene_path = Path::new("default_scene.json"); + scene.store_to_file(scene_path); + + let rehydrated_scene = SerializableScene::load_from_file(scene_path); + dbg!(&rehydrated_scene); + + // let mut crate_mesh = Mesh_Create(addr_of_mut!(cube_geo), false); + // let albedo_map = TextureLoadFromFile( + // CString::new("assets/demo/crate/Wood_Crate_001_basecolor.jpg") + // .unwrap() + // .as_ptr() as *const i8, + // ); + // let roughness_map = TextureLoadFromFile( + // CString::new("assets/demo/crate/Wood_Crate_001_roughness.jpg") + // .unwrap() + // .as_ptr() as *const i8, + // ); + // let normal_map = TextureLoadFromFile( + // CString::new("assets/demo/crate/Wood_Crate_001_normal.jpg") + // .unwrap() + // .as_ptr() as *const i8, + // ); + // let ao_map = TextureLoadFromFile( + // CString::new("assets/demo/crate/Wood_Crate_001_ambientOcclusion.jpg") + // .unwrap() + // .as_ptr() as *const i8, + // ); + // let name: [i8; 64] = [0; 64]; + // let mut crate_mat = Material { + // name: name, + // kind: 0, + // param_albedo: Vec3 { + // x: 0.0, + // y: 0.0, + // z: 0.0, + // }, + // param_metallic: 0.0, + // param_roughness: 0.0, + // param_ao: 0.0, + // pbr_albedo_map: albedo_map, + // pbr_normal_map: normal_map, + // metal_roughness_combined: true, + // pbr_metallic_map: TextureHandle { raw: 99999 }, + // pbr_roughness_map: roughness_map, + // pbr_ao_map: ao_map, + // }; + // let crate_renderent = RenderEnt { + // mesh: addr_of_mut!(crate_mesh), + // material: addr_of_mut!(crate_mat), + // affine: mat4_ident(), + // casts_shadows: true, + // }; + // let mut render_ents: [RenderEnt; 1] = [crate_renderent]; + } +} diff --git a/bindgen/rust/celeritas-sys/src/lib.rs b/bindgen/rust/celeritas-sys/src/lib.rs index 1f64680..d0a863e 100644 --- a/bindgen/rust/celeritas-sys/src/lib.rs +++ b/bindgen/rust/celeritas-sys/src/lib.rs @@ -2,6 +2,8 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] +use serde::{Deserialize, Serialize}; + pub mod egui_utils; include!(concat!(env!("OUT_DIR"), "/bindings.rs")); diff --git a/bindgen/rust/examples/scene.rs b/bindgen/rust/examples/scene.rs new file mode 100644 index 0000000..b411ffc --- /dev/null +++ b/bindgen/rust/examples/scene.rs @@ -0,0 +1,97 @@ +use std::{ffi::CString, path::Path, ptr::addr_of_mut}; + +use celeritas::{ffi::*, SerializableScene}; + +fn main() { + unsafe { + let camera_pos = Vec3 { + x: 18.9, + y: 10.6, + z: 11.6, + }; + let camera_front = Vec3 { + x: -0.6, + y: -0.2, + z: -0.7, + }; + let mut camera = Camera_Create( + camera_pos, + camera_front, + Vec3 { + x: 0.0, + y: 1.0, + z: 0.0, + }, + 45.0, + ); + SetCamera(camera); + + let mut cube_geo = Geo_CreateCuboid(f32x3 { + x: 2.0, + y: 2.0, + z: 2.0, + }); + + let scene = SerializableScene { + sun: DirectionalLight { direction: Vec3 { x: 0.0, y: 1.0, z: 0.0 }, + ambient: Vec3 { x: 1.0, y: 1.0, z: 1.0 }, diffuse: Vec3 { x: 1.0, y: 1.0, z: 1.0 }, specular: Vec3 { x: 0.0, y: 0.0, z: 0.0 } }, + point_lights: [None, None, None, None], + camera_orientation: (camera_pos, camera_front), + models: vec![], + }; + + let scene_path = Path::new("default_scene.json"); + scene.store_to_file(scene_path); + + let rehydrated_scene = SerializableScene::load_from_file(scene_path); + dbg!(&rehydrated_scene); + + // let mut crate_mesh = Mesh_Create(addr_of_mut!(cube_geo), false); + // let albedo_map = TextureLoadFromFile( + // CString::new("assets/demo/crate/Wood_Crate_001_basecolor.jpg") + // .unwrap() + // .as_ptr() as *const i8, + // ); + // let roughness_map = TextureLoadFromFile( + // CString::new("assets/demo/crate/Wood_Crate_001_roughness.jpg") + // .unwrap() + // .as_ptr() as *const i8, + // ); + // let normal_map = TextureLoadFromFile( + // CString::new("assets/demo/crate/Wood_Crate_001_normal.jpg") + // .unwrap() + // .as_ptr() as *const i8, + // ); + // let ao_map = TextureLoadFromFile( + // CString::new("assets/demo/crate/Wood_Crate_001_ambientOcclusion.jpg") + // .unwrap() + // .as_ptr() as *const i8, + // ); + // let name: [i8; 64] = [0; 64]; + // let mut crate_mat = Material { + // name: name, + // kind: 0, + // param_albedo: Vec3 { + // x: 0.0, + // y: 0.0, + // z: 0.0, + // }, + // param_metallic: 0.0, + // param_roughness: 0.0, + // param_ao: 0.0, + // pbr_albedo_map: albedo_map, + // pbr_normal_map: normal_map, + // metal_roughness_combined: true, + // pbr_metallic_map: TextureHandle { raw: 99999 }, + // pbr_roughness_map: roughness_map, + // pbr_ao_map: ao_map, + // }; + // let crate_renderent = RenderEnt { + // mesh: addr_of_mut!(crate_mesh), + // material: addr_of_mut!(crate_mat), + // affine: mat4_ident(), + // casts_shadows: true, + // }; + // let mut render_ents: [RenderEnt; 1] = [crate_renderent]; +} +} diff --git a/bindgen/rust/src/lib.rs b/bindgen/rust/src/lib.rs index f9e77b0..f3382a2 100644 --- a/bindgen/rust/src/lib.rs +++ b/bindgen/rust/src/lib.rs @@ -3,4 +3,43 @@ #![warn(missing_docs)] #![cfg_attr(docsrs, feature(doc_cfg))] +use std::{ + fs::{self, File}, + io::Write, + path::Path, +}; + pub use celeritas_sys as ffi; +use celeritas_sys::{DirectionalLight, PointLight, Vec3}; +use serde::{Deserialize, Serialize}; + +/// Wrapper around a string that is the path to a gltf model **relative** to the configured +/// `ASSETS` folder +#[derive(Debug, Serialize, Deserialize)] +pub struct ModelPath(String); + +/// Scene that can be saved and loaded from disk +#[derive(Debug, Serialize, Deserialize)] +pub struct SerializableScene { + pub sun: DirectionalLight, + pub point_lights: [Option<PointLight>; 4], + pub camera_orientation: (Vec3, Vec3), + pub models: Vec<ModelPath>, +} + +// Runtime Scene <-> Serialized Scene + +impl SerializableScene { + /// TODO: docs + pub fn store_to_file(&self, filepath: &Path) { + let mut file = File::create(filepath).expect("creation failed"); + let json = serde_json::to_string(&self).expect("serialize failed"); + file.write(&json.as_bytes()).expect("writing failed"); + } + /// TODO: docs + pub fn load_from_file(filepath: &Path) -> Self { + let contents = fs::read_to_string(filepath).expect("Filepath should be open and read-able"); + + serde_json::from_str(&contents).expect("Should be deserializable") + } +} diff --git a/default_scene.json b/default_scene.json new file mode 100644 index 0000000..fda2c94 --- /dev/null +++ b/default_scene.json @@ -0,0 +1 @@ +{"sun":{"direction":{"x":0.0,"y":1.0,"z":0.0},"ambient":{"x":1.0,"y":1.0,"z":1.0},"diffuse":{"x":1.0,"y":1.0,"z":1.0},"specular":{"x":0.0,"y":0.0,"z":0.0}},"point_lights":[null,null,null,null],"camera_orientation":[{"x":18.9,"y":10.6,"z":11.6},{"x":-0.6,"y":-0.2,"z":-0.7}],"models":[]}
\ No newline at end of file diff --git a/editor/Cargo.lock b/editor/Cargo.lock new file mode 100644 index 0000000..66ea6d0 --- /dev/null +++ b/editor/Cargo.lock @@ -0,0 +1,1098 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ab_glyph" +version = "0.2.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79faae4620f45232f599d9bc7b290f88247a0834162c4495ab2f02d60004adfb" +dependencies = [ + "ab_glyph_rasterizer", + "owned_ttf_parser", +] + +[[package]] +name = "ab_glyph_rasterizer" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "bindgen" +version = "0.69.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +dependencies = [ + "bitflags 2.6.0", + "cexpr", + "clang-sys", + "itertools", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.72", + "which", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + +[[package]] +name = "cc" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" + +[[package]] +name = "celeritas" +version = "0.1.0" +dependencies = [ + "celeritas-sys", + "egui", + "egui_glfw", + "gl", + "serde", + "serde_json", +] + +[[package]] +name = "celeritas-sys" +version = "0.1.0" +dependencies = [ + "bindgen", + "serde", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "cli-clipboard" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04087c1d4a2aa259784a563932aee09cbb0869d490775e051096174b070f3e3d" +dependencies = [ + "clipboard-win", + "objc", + "objc-foundation", + "objc_id", + "wl-clipboard-rs", + "x11-clipboard", +] + +[[package]] +name = "clipboard-win" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7191c27c2357d9b7ef96baac1773290d4ca63b24205b82a3fd8a0637afcf0362" +dependencies = [ + "error-code", + "str-buf", + "winapi", +] + +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + +[[package]] +name = "derive-new" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3418329ca0ad70234b9735dc4ceed10af4df60eff9c8e7b06cb5e520d92c3535" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + +[[package]] +name = "ecolor" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20930a432bbd57a6d55e07976089708d4893f3d556cf42a0d79e9e321fa73b10" + +[[package]] +name = "editor" +version = "0.1.0" +dependencies = [ + "celeritas", + "egui", + "egui_glfw", + "gl", +] + +[[package]] +name = "egui" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "584c5d1bf9a67b25778a3323af222dbe1a1feb532190e103901187f92c7fe29a" +dependencies = [ + "ahash", + "epaint", + "nohash-hasher", +] + +[[package]] +name = "egui_glfw" +version = "0.55.1" +source = "git+https://github.com/omnisci3nce/egui_glfw.git?rev=67b432695433feb59761f3ae984b966ca3da31db#67b432695433feb59761f3ae984b966ca3da31db" +dependencies = [ + "cli-clipboard", + "egui", + "gl", + "glfw", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "emath" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4c3a552cfca14630702449d35f41c84a0d15963273771c6059175a803620f3f" + +[[package]] +name = "epaint" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b381f8b149657a4acf837095351839f32cd5c4aec1817fc4df84e18d76334176" +dependencies = [ + "ab_glyph", + "ahash", + "ecolor", + "emath", + "nohash-hasher", + "parking_lot", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "error-code" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21" +dependencies = [ + "libc", + "str-buf", +] + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "gethostname" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "gl" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a94edab108827d67608095e269cf862e60d920f144a5026d3dbcfd8b877fb404" +dependencies = [ + "gl_generator", +] + +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + +[[package]] +name = "glfw" +version = "0.55.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a310dfc7966e5340f5d0e314fa7eed8888f1cd3bfcaa433d35cbd32d430e50c" +dependencies = [ + "bitflags 1.3.2", + "glfw-sys", + "objc", + "raw-window-handle 0.5.2", + "raw-window-handle 0.6.2", + "winapi", +] + +[[package]] +name = "glfw-sys" +version = "5.0.0+3.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dfc32d45fb58ff38b112696907963a7d671e9cf742b16f882062169a053cf88" +dependencies = [ + "cmake", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libloading" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +dependencies = [ + "cfg-if", + "windows-targets", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nix" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", +] + +[[package]] +name = "objc-foundation" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +dependencies = [ + "block", + "objc", + "objc_id", +] + +[[package]] +name = "objc_id" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +dependencies = [ + "objc", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "os_pipe" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29d73ba8daf8fac13b0501d1abeddcfe21ba7401ada61a819144b6c2a4f32209" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "owned_ttf_parser" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "490d3a563d3122bf7c911a59b0add9389e5ec0f5f0c3ac6b91ff235a0e6a7f90" +dependencies = [ + "ttf-parser", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "prettyplease" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +dependencies = [ + "proc-macro2", + "syn 2.0.72", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "raw-window-handle" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "redox_syscall" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +dependencies = [ + "bitflags 2.6.0", +] + +[[package]] +name = "regex" +version = "1.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "serde_json" +version = "1.0.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "str-buf" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys", +] + +[[package]] +name = "thiserror" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "tree_magic_mini" +version = "3.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469a727cac55b41448315cc10427c069c618ac59bb6a4480283fcd811749bdc2" +dependencies = [ + "fnv", + "home", + "memchr", + "nom", + "once_cell", + "petgraph", +] + +[[package]] +name = "ttf-parser" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8686b91785aff82828ed725225925b33b4fde44c4bb15876e5f7c832724c420a" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wayland-client" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f3b068c05a039c9f755f881dc50f01732214f5685e379829759088967c46715" +dependencies = [ + "bitflags 1.3.2", + "downcast-rs", + "libc", + "nix", + "wayland-commons", + "wayland-scanner", + "wayland-sys", +] + +[[package]] +name = "wayland-commons" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902" +dependencies = [ + "nix", + "once_cell", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-protocols" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b950621f9354b322ee817a23474e479b34be96c2e909c14f7bc0100e9a970bc6" +dependencies = [ + "bitflags 1.3.2", + "wayland-client", + "wayland-commons", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f4303d8fa22ab852f789e75a967f0a2cdc430a607751c0499bada3e451cbd53" +dependencies = [ + "proc-macro2", + "quote", + "xml-rs", +] + +[[package]] +name = "wayland-sys" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be12ce1a3c39ec7dba25594b97b42cb3195d54953ddb9d3d95a7c3902bc6e9d4" +dependencies = [ + "pkg-config", +] + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-wsapoll" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1eafc5f679c576995526e81635d0cf9695841736712b4e892f87abbe6fed3f28" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wl-clipboard-rs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "981a303dfbb75d659f6612d05a14b2e363c103d24f676a2d44a00d18507a1ad9" +dependencies = [ + "derive-new", + "libc", + "log", + "nix", + "os_pipe", + "tempfile", + "thiserror", + "tree_magic_mini", + "wayland-client", + "wayland-protocols", +] + +[[package]] +name = "x11-clipboard" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "980b9aa9226c3b7de8e2adb11bf20124327c054e0e5812d2aac0b5b5a87e7464" +dependencies = [ + "x11rb", +] + +[[package]] +name = "x11rb" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "592b4883219f345e712b3209c62654ebda0bb50887f330cbd018d0f654bfd507" +dependencies = [ + "gethostname", + "nix", + "winapi", + "winapi-wsapoll", + "x11rb-protocol", +] + +[[package]] +name = "x11rb-protocol" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56b245751c0ac9db0e006dc812031482784e434630205a93c73cfefcaabeac67" +dependencies = [ + "nix", +] + +[[package]] +name = "xml-rs" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] diff --git a/editor/Cargo.toml b/editor/Cargo.toml new file mode 100644 index 0000000..580e726 --- /dev/null +++ b/editor/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "editor" +version = "0.1.0" +edition = "2021" + +[dependencies] +celeritas = { path = "../bindgen/rust"} +egui = "0.27.1" +egui_glfw = { git = "https://github.com/omnisci3nce/egui_glfw.git", rev = "67b432695433feb59761f3ae984b966ca3da31db" } +gl = "0.14.0"
\ No newline at end of file diff --git a/editor/build.rs b/editor/build.rs new file mode 100644 index 0000000..c37df51 --- /dev/null +++ b/editor/build.rs @@ -0,0 +1,20 @@ +fn main() { + // Tell cargo to look for shared libraries in the specified directory + // TODO: we need to look based on OS + // println!("cargo:rustc-link-search=/Users/josh/code/CodenameVentus/deps/celeritas-core/build/macosx/arm64/debug"); + // // println!("cargo:rustc-link-search=../../build/windows/x64/debug"); + + // // Tell cargo to tell rustc to link the system bzip2 + // // shared library. + // println!("cargo:rustc-link-lib=framework=CoreFoundation"); + // println!("cargo:rustc-link-lib=framework=Cocoa"); + // println!("cargo:rustc-link-lib=framework=IOKit"); + // println!("cargo:rustc-link-lib=framework=OpenGL"); + + // println!("cargo:rustc-link-lib=core_static"); + // println!("cargo:rustc-link-lib=glfw3"); + // println!("cargo:rustc-link-lib=framework=Cocoa"); + // println!("cargo:rustc-link-lib=framework=Foundation"); + // println!("cargo:rustc-link-lib=framework=QuartzCore"); + +}
\ No newline at end of file diff --git a/editor/src/lib.rs b/editor/src/lib.rs new file mode 100644 index 0000000..495da30 --- /dev/null +++ b/editor/src/lib.rs @@ -0,0 +1,2 @@ + +// Scene storage diff --git a/editor/src/main.rs b/editor/src/main.rs new file mode 100644 index 0000000..962a4cc --- /dev/null +++ b/editor/src/main.rs @@ -0,0 +1,89 @@ +use std::{ + ffi::CString, + fs::{self, File}, + io::Write, + path::Path, + ptr::{self, addr_of_mut}, +}; + + +use egui_backend::egui::{vec2, Pos2, Rect}; +use egui_glfw as egui_backend; +use egui_glfw::glfw::{fail_on_errors, Context}; + +use egui_glfw::glfw; + +use celeritas::*; +use ffi::*; + +fn main() { + unsafe { + let p: *mut GLFWwindow = ptr::null_mut(); + Core_Bringup(p); + + // let core = get_global_core(); + + let camera_pos = Vec3 { + x: 18.9, + y: 10.6, + z: 11.6, + }; + let camera_front = Vec3 { + x: -0.6, + y: -0.2, + z: -0.7, + }; + let mut camera = Camera_Create( + camera_pos, + camera_front, + Vec3 { + x: 0.0, + y: 1.0, + z: 0.0, + }, + 45.0, + ); + SetCamera(camera); + + let mut cube_geo = Geo_CreateCuboid(f32x3 { + x: 2.0, + y: 2.0, + z: 2.0, + }); + + let scene = SerializableScene { + sun: DirectionalLight { + direction: Vec3 { + x: 0.0, + y: 1.0, + z: 0.0, + }, + ambient: Vec3 { + x: 1.0, + y: 1.0, + z: 1.0, + }, + diffuse: Vec3 { + x: 1.0, + y: 1.0, + z: 1.0, + }, + specular: Vec3 { + x: 0.0, + y: 0.0, + z: 0.0, + }, + }, + point_lights: [None, None, None, None], + camera_orientation: (camera_pos, camera_front), + models: vec![], + }; + + let scene_path = Path::new("default_scene.json"); + scene.store_to_file(scene_path); + + let rehydrated_scene = SerializableScene::load_from_file(scene_path); + dbg!(&rehydrated_scene); + + } +} diff --git a/examples/game_demo/game_demo.c b/examples/game_demo/game_demo.c index 21a353f..7b746d3 100644 --- a/examples/game_demo/game_demo.c +++ b/examples/game_demo/game_demo.c @@ -10,6 +10,7 @@ #include "keys.h" #include "loaders.h" #include "maths.h" +#include "pbr.h" #include "primitives.h" #include "ral_types.h" #include "render.h" @@ -59,19 +60,21 @@ int main() { // gltf file Geometry cube_geo = Geo_CreateCuboid(f32x3(2.0, 2.0, 2.0)); Mesh crate_mesh = Mesh_Create(&cube_geo, false); // dont free as we may use later - TextureHandle albedo_map = TextureLoadFromFile("assets/demo/crate/Wood_Crate_001_basecolor.jpg"); + // TextureHandle albedo_map = + // TextureLoadFromFile("assets/demo/crate/Wood_Crate_001_basecolor.jpg"); TextureHandle roughness_map = TextureLoadFromFile("assets/demo/crate/Wood_Crate_001_roughness.jpg"); TextureHandle normal_map = TextureLoadFromFile("assets/demo/crate/Wood_Crate_001_normal.jpg"); TextureHandle ao_map = TextureLoadFromFile("assets/demo/crate/Wood_Crate_001_ambientOcclusion.jpg"); - Material crate_mat = { .name = "Wood_Crate", - .kind = MAT_PBR, - .metal_roughness_combined = true, - .pbr_albedo_map = albedo_map, - .pbr_metallic_map = roughness_map, - .pbr_normal_map = normal_map, - .pbr_ao_map = ao_map }; + Material crate_mat = PBRMaterialDefault(); + // crate_mat.name = "Wood_Crate"; + // crate_mat.albedo_map = albedo_map; + crate_mat.metallic_roughness_map = roughness_map; + crate_mat.normal_map = normal_map; + crate_mat.ambient_occlusion_map = ao_map; + crate_mat.base_colour = vec3(1.0, 1.0, 1.0); + crate_mat.metallic = 0.0; // ModelHandle cube_handle = ModelLoad_gltf("assets/models/gltf/Cube/glTF/Cube.gltf", false); // ModelHandle cube_handle = ModelLoad_gltf("../../assets/prototyper/prototyper_m.gltf", false); @@ -107,8 +110,8 @@ int main() { // BEGIN Draw calls // Shadow_Run(entities, entity_count); - printf("cam pos: %f %f %f cam frontL %f %f %f\n", cam.position.x, cam.position.y, - cam.position.z, cam.front.x, cam.front.y, cam.front.z); + // printf("cam pos: %f %f %f cam frontL %f %f %f\n", cam.position.x, cam.position.y, + // cam.position.z, cam.front.x, cam.front.y, cam.front.z); if (draw_debug) { // draw the player model with shadows diff --git a/src/core/core.c b/src/core/core.c index 20bc813..fffb43d 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -78,6 +78,4 @@ Core* get_global_core() { return &g_core; } GLFWwindow* Core_GetGlfwWindowPtr(Core* core) { return g_core.window; } -struct Renderer* Core_GetRenderer(Core* core) { - return core->renderer; -}
\ No newline at end of file +struct Renderer* Core_GetRenderer(Core* core) { return core->renderer; }
\ No newline at end of file diff --git a/src/new_render/pbr.c b/src/new_render/pbr.c index 6df4e97..ccc4dcf 100644 --- a/src/new_render/pbr.c +++ b/src/new_render/pbr.c @@ -4,9 +4,11 @@ #include "file.h" #include "log.h" #include "maths.h" +#include "mem.h" #include "ral_common.h" #include "ral_impl.h" #include "ral_types.h" +#include "render.h" #include "render_scene.h" #include "render_types.h" #include "shader_layouts.h" @@ -145,13 +147,57 @@ ShaderDataLayout PBRMaterial_GetLayout(void* data) { .label = "normalMap", .kind = BINDING_TEXTURE, }; + ShaderBinding b5 = { .label = "PBR_Params", + .kind = BINDING_BYTES, + .data.bytes.size = sizeof(PBR_Params) }; if (has_data) { - b1.data.texture.handle = d->mat.pbr_albedo_map; - b2.data.texture.handle = d->mat.pbr_metallic_map; - b3.data.texture.handle = d->mat.pbr_ao_map; - b4.data.texture.handle = d->mat.pbr_normal_map; + TextureHandle white1x1 = Render_GetWhiteTexture(); + if (d->mat.albedo_map.raw != INVALID_TEX_HANDLE.raw) { + b1.data.texture.handle = d->mat.albedo_map; + } else { + b1.data.texture.handle = white1x1; + } + + if (d->mat.metallic_roughness_map.raw != INVALID_TEX_HANDLE.raw) { + b2.data.texture.handle = d->mat.metallic_roughness_map; + } else { + b2.data.texture.handle = white1x1; + } + + if (d->mat.ambient_occlusion_map.raw != INVALID_TEX_HANDLE.raw) { + b3.data.texture.handle = d->mat.ambient_occlusion_map; + } else { + b3.data.texture.handle = white1x1; + } + + if (d->mat.normal_map.raw != INVALID_TEX_HANDLE.raw) { + b4.data.texture.handle = d->mat.normal_map; + } else { + b4.data.texture.handle = white1x1; + } + + arena* frame = Render_GetFrameArena(); + PBR_Params* params = arena_alloc(frame, sizeof(PBR_Params)); + params->albedo = d->mat.base_colour; + params->metallic = d->mat.metallic; + params->roughness = d->mat.roughness; + params->ambient_occlusion = d->mat.ambient_occlusion; + b5.data.bytes.data = params; } - return (ShaderDataLayout){ .bindings = { b1, b2, b3, b4 }, .binding_count = 4 }; + return (ShaderDataLayout){ .bindings = { b1, b2, b3, b4, b5 }, .binding_count = 5 }; +} + +Material PBRMaterialDefault() { + return (Material){ .name = "Standard Material", + .kind = MAT_PBR, + .base_colour = vec3(1.0, 1.0, 1.0), + .metallic = 0.0, + .roughness = 0.5, + .ambient_occlusion = 0.0, + .albedo_map = INVALID_TEX_HANDLE, + .metallic_roughness_map = INVALID_TEX_HANDLE, + .normal_map = INVALID_TEX_HANDLE, + .ambient_occlusion_map = INVALID_TEX_HANDLE }; }
\ No newline at end of file diff --git a/src/new_render/pbr.h b/src/new_render/pbr.h index 914975b..0aa9dfe 100644 --- a/src/new_render/pbr.h +++ b/src/new_render/pbr.h @@ -36,7 +36,7 @@ typedef struct PBR_Params { Vec3 albedo; f32 metallic; f32 roughness; - f32 ao; + f32 ambient_occlusion; } PBR_Params; typedef struct PBR_Textures { @@ -48,10 +48,13 @@ typedef struct PBR_Textures { TextureHandle ao_map; } PBR_Textures; + // --- Internal typedef struct MaterialMap MaterialMap; +Material PBRMaterialDefault(); + GPU_Renderpass* PBR_RPassCreate(); GPU_Pipeline* PBR_PipelineCreate(GPU_Renderpass* rpass); diff --git a/src/new_render/render.c b/src/new_render/render.c index cfe68d7..5202cd3 100644 --- a/src/new_render/render.c +++ b/src/new_render/render.c @@ -40,6 +40,7 @@ struct Renderer { // Text_Storage text; ResourcePools* resource_pools; arena frame_arena; + TextureHandle white_1x1; }; Renderer* get_renderer() { return g_core.renderer; } @@ -62,6 +63,7 @@ bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window INFO("GLFWwindow pointer was provided!!!! Skipping generic glfw init.."); window = optional_window; } else { + INFO("No GLFWwindow provided - creating one"); // NOTE: all platforms use GLFW at the moment but thats subject to change glfwInit(); @@ -95,11 +97,11 @@ bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window ren->window = window; *out_window = window; - // glfwMakeContextCurrent(ren->window); + glfwMakeContextCurrent(ren->window); // FIXME // DEBUG("Set up GLFW window callbacks"); - // glfwSetWindowSizeCallback(window, Render_WindowSizeChanged); + glfwSetWindowSizeCallback(window, Render_WindowSizeChanged); // set the RAL backend up if (!GPU_Backend_Init(config.window_name, window, ren->resource_pools)) { @@ -126,6 +128,9 @@ bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window ren->terrain = malloc(sizeof(Terrain_Storage)); // Terrain_Init(ren->terrain); + // load default textures + ren->white_1x1 = TextureLoadFromFile("assets/textures/white1x1.png"); + return true; } @@ -273,4 +278,14 @@ Shadow_Storage* Render_GetShadowStorage() { Terrain_Storage* Render_GetTerrainStorage() { Renderer* ren = Core_GetRenderer(&g_core); return ren->terrain; +} + +TextureHandle Render_GetWhiteTexture() { + Renderer* ren = Core_GetRenderer(&g_core); + return ren->white_1x1; +} + +arena* Render_GetFrameArena() { + Renderer* ren = Core_GetRenderer(&g_core); + return &ren->frame_arena; }
\ No newline at end of file diff --git a/src/new_render/render.h b/src/new_render/render.h index 2df684c..b8c34b9 100644 --- a/src/new_render/render.h +++ b/src/new_render/render.h @@ -77,4 +77,6 @@ typedef struct Terrain_Storage Terrain_Storage; RenderScene* Render_GetScene(); Shadow_Storage* Render_GetShadowStorage(); -Terrain_Storage* Render_GetTerrainStorage();
\ No newline at end of file +Terrain_Storage* Render_GetTerrainStorage(); +TextureHandle Render_GetWhiteTexture(); +arena* Render_GetFrameArena();
\ No newline at end of file diff --git a/src/new_render/render_types.h b/src/new_render/render_types.h index e0bd76b..f4f108a 100644 --- a/src/new_render/render_types.h +++ b/src/new_render/render_types.h @@ -53,22 +53,23 @@ typedef enum MaterialKind { static const char* material_kind_names[] = { "Blinn Phong", "PBR (Textures)", "PBR (Params)", "Count (This should be an error)" }; +/** + * @brief + * @note mostly references https://google.github.io/filament/Filament.html#materialsystem/standardmodel + */ typedef struct Material { char name[64]; - MaterialKind kind; - // parameterised pbr - Vec3 param_albedo; - f32 param_metallic; - f32 param_roughness; - f32 param_ao; - // textured pbr - TextureHandle pbr_albedo_map; - TextureHandle pbr_normal_map; - bool metal_roughness_combined; - TextureHandle pbr_metallic_map; - TextureHandle pbr_roughness_map; - TextureHandle pbr_ao_map; + MaterialKind kind; // at the moment all materials are PBR materials + Vec3 base_colour; // linear RGB {0,0,0} to {1,1,1} + f32 metallic; + f32 roughness; + f32 ambient_occlusion; + TextureHandle albedo_map; + TextureHandle normal_map; + TextureHandle metallic_roughness_map; + TextureHandle ambient_occlusion_map; } Material; + #ifndef TYPED_MATERIAL_ARRAY KITC_DECL_TYPED_ARRAY(Material) #define TYPED_MATERIAL_ARRAY diff --git a/src/ral/backends/opengl/backend_opengl.c b/src/ral/backends/opengl/backend_opengl.c index ad9969f..7929a16 100644 --- a/src/ral/backends/opengl/backend_opengl.c +++ b/src/ral/backends/opengl/backend_opengl.c @@ -37,10 +37,10 @@ bool GPU_Backend_Init(const char* window_name, struct GLFWwindow* window, BackendPools_Init(&context.pool_arena, &context.gpu_pools); context.resource_pools = res_pools; - // glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); - // glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); - // glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - // glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // glad: load all opengl function pointers if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { @@ -57,8 +57,7 @@ bool GPU_Backend_Init(const char* window_name, struct GLFWwindow* window, } // All of these are no-ops in OpenGL -void GPU_Backend_Shutdown() { /* TODO */ -} +void GPU_Backend_Shutdown() { /* TODO */ } bool GPU_Device_Create(GPU_Device* out_device) { return true; } void GPU_Device_Destroy(GPU_Device* device) {} bool GPU_Swapchain_Create(GPU_Swapchain* out_swapchain) { return true; } diff --git a/src/resources/gltf.c b/src/resources/gltf.c index eb2647d..c575fb9 100644 --- a/src/resources/gltf.c +++ b/src/resources/gltf.c @@ -12,6 +12,7 @@ #include "maths_types.h" #include "mem.h" #include "path.h" +#include "pbr.h" #include "ral_types.h" #include "render.h" #include "render_types.h" @@ -202,49 +203,53 @@ bool model_load_gltf_str(const char *file_string, const char *filepath, Str8 rel cgltf_material gltf_material = data->materials[m]; cgltf_pbr_metallic_roughness pbr = gltf_material.pbr_metallic_roughness; + Material our_material = PBRMaterialDefault(); + TRACE("Has PBR metallic roughness "); // we will use base color texture like blinn phong cgltf_texture_view albedo_tex_view = pbr.base_color_texture; // albedo - char albedo_map_path[1024]; if (albedo_tex_view.texture != NULL) { + char albedo_map_path[1024]; snprintf(albedo_map_path, sizeof(albedo_map_path), "%s/%s", relative_path.buf, albedo_tex_view.texture->image->uri); + our_material.albedo_map = TextureLoadFromFile(albedo_map_path); } else { WARN("GLTF model has no albedo map"); } cgltf_texture_view metal_rough_tex_view = pbr.metallic_roughness_texture; - char metal_rough_map_path[1024]; if (metal_rough_tex_view.texture != NULL) { + char metal_rough_map_path[1024]; snprintf(metal_rough_map_path, sizeof(metal_rough_map_path), "%s/%s", relative_path.buf, metal_rough_tex_view.texture->image->uri); + our_material.metallic_roughness_map = TextureLoadFromFile(metal_rough_map_path); } else { - WARN("GLTF model has no metal/rougnness map"); + WARN("GLTF model has no metal/roughness map"); } cgltf_texture_view normal_tex_view = gltf_material.normal_texture; - char normal_map_path[1024]; if (normal_tex_view.texture != NULL) { + char normal_map_path[1024]; snprintf(normal_map_path, sizeof(normal_map_path), "%s/%s", relative_path.buf, normal_tex_view.texture->image->uri); + our_material.normal_map = TextureLoadFromFile(normal_map_path); } else { WARN("GLTF model has no normal map"); } - TextureHandle albedo_map = TextureLoadFromFile(albedo_map_path); - TextureHandle metal_roughness_map = TextureLoadFromFile(metal_rough_map_path); - TextureHandle normal_map = TextureLoadFromFile(normal_map_path); - - // material our_material = - // pbr_material_load(albedo_map_path, normal_map_path, true, metal_rough_map_path, NULL, - // NULL); - Material our_material = { - .kind = MAT_PBR, - .metal_roughness_combined = true, - .pbr_albedo_map = albedo_map, - .pbr_metallic_map = metal_roughness_map, - .pbr_normal_map = normal_map, - }; + // TextureHandle albedo_map = TextureLoadFromFile(albedo_map_path); + // TextureHandle metal_roughness_map = TextureLoadFromFile(metal_rough_map_path); + // TextureHandle normal_map = TextureLoadFromFile(normal_map_path); + + // Material our_material = { + // .kind = MAT_PBR, + // // .metal_roughness_combined = true, + // .albedo_map = albedo_map, + // .metallic_roughness_map = metal_roughness_map, + // .normal_map= normal_map, + // .ambient_occlusion_map = INVALID_TEX_HANDLE, + + // }; // our_material.name = malloc(strlen(gltf_material.name) + 1); u32 string_length = strlen(gltf_material.name) + 1; diff --git a/src/systems/input.c b/src/systems/input.c index b5cdcdb..152b349 100644 --- a/src/systems/input.c +++ b/src/systems/input.c @@ -33,7 +33,7 @@ bool Input_Init(Input_State *input, GLFWwindow *window) { void Input_Shutdown(Input_State *input) {} void Input_Update(Input_State *input) { - // glfwPollEvents(); + glfwPollEvents(); // --- update keyboard input // if we go from un-pressed -> pressed, set as "just pressed" |