Skip to content

Commit

Permalink
[game] sponza world wind is now set at 20% of the base value
Browse files Browse the repository at this point in the history
  • Loading branch information
PanosK92 committed Jan 7, 2025
1 parent bb32baa commit b1a6748
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions data/shaders/common_vertex_processing.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions runtime/Game/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,8 @@ namespace Spartan
material->SetProperty(MaterialProperty::WindAnimation, 1.0f);
}
}

Renderer::SetWind(Renderer::GetWind() * 0.2f);
}

void create_doom()
Expand Down
7 changes: 6 additions & 1 deletion runtime/Rendering/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions runtime/Rendering/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ namespace Spartan
static void Screenshot(const std::string& file_path);
static void SetEntities(std::unordered_map<uint64_t, std::shared_ptr<Entity>>& entities);
static bool CanUseCmdList();

// wind
static const Math::Vector3& GetWind();
static void SetWind(const Math::Vector3& wind);

//= RESOLUTION/SIZE =============================================================================
Expand Down

0 comments on commit b1a6748

Please sign in to comment.