From b1a6748470f3e1690f5bea6c111be19065cab0cd Mon Sep 17 00:00:00 2001 From: Panos Karabelas Date: Tue, 7 Jan 2025 18:47:02 +0000 Subject: [PATCH] [game] sponza world wind is now set at 20% of the base value --- data/shaders/common_vertex_processing.hlsl | 4 ++-- runtime/Game/Game.cpp | 2 ++ runtime/Rendering/Renderer.cpp | 7 ++++++- runtime/Rendering/Renderer.h | 3 +++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/data/shaders/common_vertex_processing.hlsl b/data/shaders/common_vertex_processing.hlsl index 2d3406bba..70d64c6f4 100644 --- a/data/shaders/common_vertex_processing.hlsl +++ b/data/shaders/common_vertex_processing.hlsl @@ -84,7 +84,7 @@ struct vertex_processing // normalize wind direction and calculate magnitude float3 wind_direction = normalize(wind); - float wind_magnitude = length(wind); + float wind_magnitude = length(wind); // height-based sway factor (stronger sway at higher points) float sway_factor = saturate((position_vertex.y - animation_pivot.y) / GetMaterial().world_space_height); @@ -103,7 +103,7 @@ struct vertex_processing // combine all factors for sway float combined_wave = base_wave + flutter; - float3 sway_offset = adjusted_wind_direction * combined_wave * sway_extent * sway_factor; + float3 sway_offset = adjusted_wind_direction * combined_wave * sway_extent * sway_factor * wind_magnitude; // apply the calculated sway to the vertex position_vertex += sway_offset; diff --git a/runtime/Game/Game.cpp b/runtime/Game/Game.cpp index 1db92c987..e928aa059 100644 --- a/runtime/Game/Game.cpp +++ b/runtime/Game/Game.cpp @@ -788,6 +788,8 @@ namespace Spartan material->SetProperty(MaterialProperty::WindAnimation, 1.0f); } } + + Renderer::SetWind(Renderer::GetWind() * 0.2f); } void create_doom() diff --git a/runtime/Rendering/Renderer.cpp b/runtime/Rendering/Renderer.cpp index 0f278b092..f91176131 100644 --- a/runtime/Rendering/Renderer.cpp +++ b/runtime/Rendering/Renderer.cpp @@ -179,7 +179,7 @@ namespace Spartan SetOption(Renderer_Option::PerformanceMetrics, 1.0f); SetOption(Renderer_Option::OcclusionCulling, 0.0f); // disabled by default as it's a WIP (you can see the query delays) - SetWind(Vector3(1.0f, 0.0f, 0.5f) * 5.0f); + SetWind(Vector3(1.0f, 0.0f, 0.5f)); // resolution { @@ -547,6 +547,11 @@ namespace Spartan return cmd_list->GetState() == RHI_CommandListState::Recording; } + const Vector3& Renderer::GetWind() + { + return m_cb_frame_cpu.wind; + } + void Renderer::SetWind(const Math::Vector3& wind) { m_cb_frame_cpu.wind = wind; diff --git a/runtime/Rendering/Renderer.h b/runtime/Rendering/Renderer.h index 74d911507..c4c40f41a 100644 --- a/runtime/Rendering/Renderer.h +++ b/runtime/Rendering/Renderer.h @@ -83,6 +83,9 @@ namespace Spartan static void Screenshot(const std::string& file_path); static void SetEntities(std::unordered_map>& entities); static bool CanUseCmdList(); + + // wind + static const Math::Vector3& GetWind(); static void SetWind(const Math::Vector3& wind); //= RESOLUTION/SIZE =============================================================================