From d3a6d5cd6147669d4e7c62f2d93e7a5d03b37e3f Mon Sep 17 00:00:00 2001 From: Panos Karabelas Date: Tue, 7 Jan 2025 20:29:48 +0000 Subject: [PATCH] [editor] exposed cull mode (back, front, none) in the material properties as it can be freely changed without creating new PSOs (thanks Vulkan) --- editor/Widgets/Properties.cpp | 29 +++++++++++++++++++++++++---- readme.md | 2 +- runtime/Game/Game.cpp | 4 ++-- runtime/World/Components/Camera.cpp | 11 +++++------ runtime/World/Components/Camera.h | 4 ++-- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/editor/Widgets/Properties.cpp b/editor/Widgets/Properties.cpp index 891b24c9a..e33eee680 100644 --- a/editor/Widgets/Properties.cpp +++ b/editor/Widgets/Properties.cpp @@ -863,10 +863,31 @@ void Properties::ShowMaterial(Material* material) const ImGui::SameLine(); ImGui::InputFloat("##matOffsetY", &offset.y, 0.01f, 0.1f, "%.2f", ImGuiInputTextFlags_CharsDecimal); } - // wind animation - bool wind_animation = material->GetProperty(MaterialProperty::WindAnimation) != 0.0f; - ImGui::Checkbox("Wind animation", &wind_animation); - material->SetProperty(MaterialProperty::WindAnimation, wind_animation ? 1.0f : 0.0f); + // rendering + { + // cull mode + { + static vector cull_modes = + { + "Back", + "Front", + "None" + }; + + ImGui::Text("Culling"); + ImGui::SameLine(column_pos_x); + uint32_t cull_mode_index = static_cast(material->GetProperty(MaterialProperty::CullMode)); + if (ImGuiSp::combo_box("##mat_cull_mode", cull_modes, &cull_mode_index)) + { + material->SetProperty(MaterialProperty::CullMode, static_cast(cull_mode_index)); + } + } + + // wind animation + bool wind_animation = material->GetProperty(MaterialProperty::WindAnimation) != 0.0f; + ImGui::Checkbox("Wind animation", &wind_animation); + material->SetProperty(MaterialProperty::WindAnimation, wind_animation ? 1.0f : 0.0f); + } //= MAP =============================================================================== material->SetProperty(MaterialProperty::TextureTilingX, tiling.x); diff --git a/readme.md b/readme.md index c15f02d1f..1245a3b7d 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,7 @@ -

Spartan Engine is one of the most advanced one-man game engines out there, pushing the limits of real-time approaches. What started as a portfolio project has evolved into a cutting-edge project for developers to explore, learn, and contribute. This isn't an engine for the average user, it's designed for advanced research and experimentation, ideal for industry veterans looking to experiment, not to build a game (yet). With a thriving Discord community of over 440 members, including industry veterans, and contribution perks that you won't believe when you see, it's one of the most unique projects you'll ever come across.

+

Spartan Engine is one of the most advanced one-man game engines out there, pushing the limits of real-time approaches. What started as a portfolio project has evolved into a cutting-edge project for developers to explore, learn, and contribute. This isn't an engine for the average user, it's designed for advanced research and experimentation, ideal for industry veterans looking to experiment, not to build a game (yet). With a thriving Discord community of over 440 members, including industry veterans, and contribution perks that you won't believe when you see, it's one of the most unique projects you'll come across.

- For occasional updates regarding the project's development, you can follow me on X. diff --git a/runtime/Game/Game.cpp b/runtime/Game/Game.cpp index 4c8fe8ca2..2a04e0edb 100644 --- a/runtime/Game/Game.cpp +++ b/runtime/Game/Game.cpp @@ -689,9 +689,11 @@ namespace Spartan void create_sponza() { + // set the mood create_camera(Vector3(19.2692f, 2.65f, 0.1677f), Vector3(-18.0f, -90.0f, 0.0f)); create_sun(LightIntensity::black_hole, false); create_music("project\\music\\jake_chudnow_olive.mp3"); + Renderer::SetWind(Vector3(0.0f, 0.2f, 1.0f) * 0.1f); // point light { @@ -797,8 +799,6 @@ namespace Spartan material->SetProperty(MaterialProperty::WindAnimation, 1.0f); } } - - Renderer::SetWind(Renderer::GetWind() * 0.2f); } void create_doom() diff --git a/runtime/World/Components/Camera.cpp b/runtime/World/Components/Camera.cpp index e2972f502..5717cffdd 100644 --- a/runtime/World/Components/Camera.cpp +++ b/runtime/World/Components/Camera.cpp @@ -156,7 +156,7 @@ namespace Spartan return IsInViewFrustum(box); } - const Math::Ray Camera::ComputePickingRay() + const Ray Camera::ComputePickingRay() { Vector3 ray_start = GetEntity()->GetPosition(); Vector3 ray_direction = ScreenToWorldCoordinates(Input::GetMousePositionRelativeToEditorViewport(), 1.0f); @@ -327,17 +327,16 @@ namespace Spartan { if (GetFlag(CameraFlags::CanBeControlled)) { - ProcessInputFpsControl(); + Input_FpsControl(); } // shortcuts { - // focus on selected entity: f - ProcessInputLerpToEntity(); + Input_LerpToEntity(); // f } } - void Camera::ProcessInputFpsControl() + void Camera::Input_FpsControl() { static const float movement_speed_max = 5.0f; static float movement_acceleration = 1.0f; @@ -582,7 +581,7 @@ namespace Spartan } } - void Camera::ProcessInputLerpToEntity() + void Camera::Input_LerpToEntity() { // set focused entity as a lerp target if (Input::GetKeyDown(KeyCode::F)) diff --git a/runtime/World/Components/Camera.h b/runtime/World/Components/Camera.h index 03064ea42..9ad53acc8 100644 --- a/runtime/World/Components/Camera.h +++ b/runtime/World/Components/Camera.h @@ -140,8 +140,8 @@ namespace Spartan private: void ComputeMatrices(); void ProcessInput(); - void ProcessInputFpsControl(); - void ProcessInputLerpToEntity(); + void Input_FpsControl(); + void Input_LerpToEntity(); uint32_t m_flags = 0; float m_aperture = 2.8f; // aperture value in f-stop. Controls the amount of light, depth of field and chromatic aberration