From 022f8a46b4044c4f29a13f36e6eb6ca06763e862 Mon Sep 17 00:00:00 2001 From: SpinnerX Date: Mon, 20 Apr 2026 13:56:23 -0700 Subject: [PATCH 1/3] Minor code cleanup in uniforms.cppm --- atlas/drivers/vulkan/uniforms.cppm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/atlas/drivers/vulkan/uniforms.cppm b/atlas/drivers/vulkan/uniforms.cppm index a5f27c1e..79c786ee 100644 --- a/atlas/drivers/vulkan/uniforms.cppm +++ b/atlas/drivers/vulkan/uniforms.cppm @@ -1,6 +1,7 @@ module; #include +#include export module atlas.drivers.vulkan.uniforms; @@ -42,7 +43,6 @@ export namespace atlas::vulkan { struct geometry_uniform { glm::mat4 model{ 1.f }; glm::vec4 color{ 1.f }; - // std::vector texture_paths; }; /** @@ -70,7 +70,6 @@ export namespace atlas::vulkan { struct light_scene_ubo { alignas(16) uint32_t num_lights; - // alignas(16) std::array light_sources; - alignas(16) point_light_ubo light_sources[10]; + alignas(16) std::array light_sources; }; }; \ No newline at end of file From 40a73f9e93f7b0f03efa241f157fcc4a1947ce55 Mon Sep 17 00:00:00 2001 From: SpinnerX Date: Mon, 20 Apr 2026 14:53:19 -0700 Subject: [PATCH 2/3] Loading environments are now serialized remove the need to recompile project everytime the paths change --- LevelScene | 77 +++++++++++++++++++++++++ atlas/core/application.cppm | 4 +- atlas/core/scene/components.cppm | 4 ++ atlas/core/scene/scene.cppm | 15 +++++ atlas/core/serialize/serializer.cppm | 11 ++++ atlas/drivers/vulkan/render_system.cppm | 11 +--- editor/level_scene.cppm | 5 ++ 7 files changed, 117 insertions(+), 10 deletions(-) create mode 100644 LevelScene diff --git a/LevelScene b/LevelScene new file mode 100644 index 00000000..a174f96a --- /dev/null +++ b/LevelScene @@ -0,0 +1,77 @@ +Scene: LevelScene +Environment: assets/skybox/mirrored_hall_8k.hdr +Entities: + - Entity: Point Light 1 + Transform: + Position: [-0.400000006, 7.69999981, -10.1999998] + Scale: [0.899999976, 0.899999976, -3.70000005] + Rotation: [0, 0, 0] + Quaternion: [0, 0, 0, 1] + Mesh Source: + Model Path: "" + Diffuse: "" + Specular: "" + Point Light: + Color: [1, 1.55999994, 2.92000008, 1.90999997] + Attenuation: 10.0769997 + Ambient: [1, 1, 1, 1] + Diffuse: [1, 1, 1, 1] + Specular: [1, 1, 1, 1] + - Entity: Viking Room + Transform: + Position: [-8, 1.79999995, 1.5] + Scale: [1, 1, 1] + Rotation: [2.29999995, 95.9000015, 91.8000031] + Quaternion: [0, 0, 0, 1] + Mesh Source: + Model Path: assets/models/viking_room.obj + Diffuse: assets/models/viking_room.png + Specular: "" + Point Light: + Color: [1, 1, 1, 1] + Attenuation: 1 + Ambient: [1, 1, 1, 1] + Diffuse: [1, 1, 1, 1] + Specular: [1, 1, 1, 1] + Physics Body: + Linear Velocity: [0, 10, 0] + Angular Velocity: [-0.100000001, 0, 0] + Force: [0, 0, 0] + Impulse: [0, 10, 0] + Torque: [0, 0, 0] + Mass Factor: 1 + Center Mass Position: [0, 0, 0] + Friction: 15 + Restitution: 0.300000012 + Body Movement Type: 2 + Body Layer Type: 1 + Box Collider: + Half Extent: [0.5, 0.5, 0.5] + Sphere Collider: + Radius: 1 + - Entity: Cube + Transform: + Position: [-7.5999999, 4.67999983, -1.79999995] + Scale: [1, 1, 1] + Rotation: [2.9000001, 16.5, 0.600000024] + Quaternion: [-1.5550123e-08, -1.33205403e-05, -1.63867355e-08, 1] + Mesh Source: + Model Path: assets/models/cube.obj + Diffuse: assets/models/container_diffuse.png + Specular: assets/models/wallace_gromit_image.jpg + Physics Body: + Linear Velocity: [-7.65907615e-11, -2.44006509e-10, 2.08939643e-10] + Angular Velocity: [2.11050205e-10, -3.93799064e-16, 7.73631575e-11] + Force: [0, 0, 0] + Impulse: [0, 0, 0] + Torque: [0, 0, 0] + Mass Factor: 1 + Center Mass Position: [-2.70028043, 1.2799989, 4.10127163] + Friction: 0.800000012 + Restitution: 0.200000003 + Body Movement Type: 2 + Body Layer Type: 1 + Box Collider: + Half Extent: [1, 1, 1] + Sphere Collider: + Radius: 0.5 \ No newline at end of file diff --git a/atlas/core/application.cppm b/atlas/core/application.cppm index eff0f7fc..a7623e41 100644 --- a/atlas/core/application.cppm +++ b/atlas/core/application.cppm @@ -126,6 +126,8 @@ export namespace atlas { ref current_scene = m_current_world->current(); + invoke_start(current_scene.get()); + m_renderer->current_scene_context(current_scene); // Bug-prone API. @@ -135,8 +137,6 @@ export namespace atlas { m_renderer->preload( m_window->current_swapchain().swapchain_renderpass()); - invoke_start(current_scene.get()); - /* - flecs::system is how your able to schedule changes for given portions of data in this case the projection/view matrices are diff --git a/atlas/core/scene/components.cppm b/atlas/core/scene/components.cppm index edc63420..61ce7999 100644 --- a/atlas/core/scene/components.cppm +++ b/atlas/core/scene/components.cppm @@ -25,6 +25,10 @@ export namespace atlas { } }; + struct environment { + std::string filepath=""; + }; + struct material_metadata { glm::vec4 ambient{ 0.2f }; glm::vec4 diffuse{ 0.5f }; diff --git a/atlas/core/scene/scene.cppm b/atlas/core/scene/scene.cppm index 770bb3d3..4b8c6899 100644 --- a/atlas/core/scene/scene.cppm +++ b/atlas/core/scene/scene.cppm @@ -9,6 +9,7 @@ import atlas.core.utilities; import atlas.core.event; import atlas.core.scene.game_object; import atlas.core.scene.uuid; +import atlas.core.scene.components; export namespace atlas { /** @@ -229,6 +230,20 @@ export namespace atlas { */ [[nodiscard]] uint64_t unique_id() const { return m_scene_uuid; } + + void set_environment_map(const std::string& p_filepath) { + environment environment_mapping = { + .filepath = p_filepath, + }; + + m_registry.set(environment_mapping); + } + + template + [[nodiscard]] const T* get() const { + return m_registry.get(); + } + /** * @brief Requires to return flecs::world is returned by reference to * prevent making copies of flecs::world diff --git a/atlas/core/serialize/serializer.cppm b/atlas/core/serialize/serializer.cppm index abc909bc..9cb3c0a2 100644 --- a/atlas/core/serialize/serializer.cppm +++ b/atlas/core/serialize/serializer.cppm @@ -16,6 +16,7 @@ import atlas.common; import atlas.core.scene; import atlas.core.serialize.types; import atlas.core.scene.components; +import atlas.logger; namespace atlas { // used to serialize entities @@ -234,6 +235,16 @@ namespace atlas { return false; } + console_log_info("Before loading environment mappings!"); + std::string environment_map_data=""; + if(data["Environment"]) { + environment_map_data = data["Environment"].as(); + + console_log_info("Environment Map Loaded Path (from yaml): {}", environment_map_data); + } + + p_registry.set({ .filepath = environment_map_data }); + YAML::Node entity_objects = data["Entities"]; if (entity_objects) { diff --git a/atlas/drivers/vulkan/render_system.cppm b/atlas/drivers/vulkan/render_system.cppm index 90479d8c..4fa8dcdc 100644 --- a/atlas/drivers/vulkan/render_system.cppm +++ b/atlas/drivers/vulkan/render_system.cppm @@ -278,15 +278,10 @@ export namespace atlas::vulkan { // }; // m_skybox = environment_map(m_device, faces, // m_physical.memory_properties(), m_final_renderpass); std::string - // filename = "assets/skybox/rogland_clear_night_24k.hdr"; - // std::string filename = "assets/skybox/HDR_multi_nebulae_1.hdr"; - std::string filename = - "assets/skybox/HDR_silver_and_gold_nebulae.hdr"; - // m_skybox = environment_map(m_device, - // std::filesystem::path("assets/skybox/monkstown_castle_4k.hdr"), - // m_physical.memory_properties(), m_final_renderpass); + + const environment* environment_data = m_current_scene->get(); m_skybox = environment_map(m_device, - std::filesystem::path(filename), + std::filesystem::path(environment_data->filepath), m_physical.memory_properties(), m_final_renderpass); diff --git a/editor/level_scene.cppm b/editor/level_scene.cppm index fe8c215d..283557a5 100644 --- a/editor/level_scene.cppm +++ b/editor/level_scene.cppm @@ -418,6 +418,11 @@ public: } flecs::world registry = *this; + + // TODO: Should consider having this be a custom UI property to the editor. + auto viking_room = entity("Viking Room"); + atlas::mesh_source* src = viking_room.get_mut(); + src->flip = true; m_physics_engine = atlas::physics::engine(registry, *event_handle()); } From 2eebd4a956a253cc5101632cbbd3fa20d23c45a9 Mon Sep 17 00:00:00 2001 From: SpinnerX Date: Mon, 20 Apr 2026 15:06:20 -0700 Subject: [PATCH 3/3] Updated environment path in LevelScene.yml --- LevelScene | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LevelScene b/LevelScene index a174f96a..f7355b9b 100644 --- a/LevelScene +++ b/LevelScene @@ -1,5 +1,5 @@ Scene: LevelScene -Environment: assets/skybox/mirrored_hall_8k.hdr +Environment: assets/skybox/monkstown_castle_4k.hdr Entities: - Entity: Point Light 1 Transform: