Skip to content

Commit

Permalink
[editor] exposed wind animation property for the materials
Browse files Browse the repository at this point in the history
  • Loading branch information
PanosK92 committed Jan 6, 2025
1 parent 00c0c94 commit 44dedcf
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions editor/Widgets/Properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,11 @@ 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);

//= MAP ===============================================================================
material->SetProperty(MaterialProperty::TextureTilingX, tiling.x);
material->SetProperty(MaterialProperty::TextureTilingY, tiling.y);
Expand Down
4 changes: 2 additions & 2 deletions runtime/Game/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ namespace Spartan
material->SetTexture(MaterialTextureType::Color, "project\\terrain\\vegetation_tree_2\\branches_color.png");
material->SetTexture(MaterialTextureType::Normal, "project\\terrain\\vegetation_tree_2\\branches_normal.png");
material->SetTexture(MaterialTextureType::Occlusion, "project\\terrain\\vegetation_tree_2\\branches_ao.png");
material->SetProperty(MaterialProperty::VertexAnimateWind, 1.0f);
material->SetProperty(MaterialProperty::WindAnimation, 1.0f);
material->SetProperty(MaterialProperty::SubsurfaceScattering, 0.0f);
material->SetProperty(MaterialProperty::WorldSpaceHeight, renderable->GetBoundingBox(BoundingBoxType::Transformed).GetSize().y);
material->SetProperty(MaterialProperty::CullMode, static_cast<float>(RHI_CullMode::None));
Expand All @@ -663,7 +663,7 @@ namespace Spartan
material->SetColor(Color::standard_white);
material->SetTexture(MaterialTextureType::Color, "project\\terrain\\vegetation_plant_1\\ormbunke.png");
material->SetProperty(MaterialProperty::SubsurfaceScattering, 0.0f);
material->SetProperty(MaterialProperty::VertexAnimateWind, 1.0f);
material->SetProperty(MaterialProperty::WindAnimation, 1.0f);
material->SetProperty(MaterialProperty::WorldSpaceHeight, renderable->GetBoundingBox(BoundingBoxType::Transformed).GetSize().y);
material->SetProperty(MaterialProperty::CullMode, static_cast<float>(RHI_CullMode::None));
renderable->SetMaterial(material);
Expand Down
2 changes: 1 addition & 1 deletion runtime/Rendering/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace Spartan
case MaterialProperty::TextureOffsetX: return "texture_offset_x";
case MaterialProperty::TextureOffsetY: return "texture_offset_y";
case MaterialProperty::TextureSlopeBased: return "texture_slope_based";
case MaterialProperty::VertexAnimateWind: return "vertex_animate_wind";
case MaterialProperty::WindAnimation: return "vertex_animate_wind";
case MaterialProperty::VertexAnimateWater: return "vertex_animate_water";
case MaterialProperty::CullMode: return "cull_mode";
case MaterialProperty::Max: return "max";
Expand Down
2 changes: 1 addition & 1 deletion runtime/Rendering/Material.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace Spartan
TextureOffsetX, // offset of the texture along the X-axis
TextureOffsetY, // offset of the texture along the Y-axis
TextureSlopeBased, // applies texture mapping based on the mesh slope
VertexAnimateWind, // applies vertex-based animation to simulate wind
WindAnimation, // applies vertex-based animation to simulate wind
VertexAnimateWater, // applies vertex-based animation to simulate water flow
CullMode, // sets the culling mode based on RHI_CullMode enum values
Gltf, // indicates if the material was imported from a glTF file
Expand Down
2 changes: 1 addition & 1 deletion runtime/Rendering/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ namespace Spartan
properties[index].flags |= material->HasTextureOfType(MaterialTextureType::Emission) ? (1U << 6) : 0;
properties[index].flags |= material->HasTextureOfType(MaterialTextureType::Occlusion) ? (1U << 7) : 0;
properties[index].flags |= material->GetProperty(MaterialProperty::TextureSlopeBased) ? (1U << 8) : 0;
properties[index].flags |= material->GetProperty(MaterialProperty::VertexAnimateWind) ? (1U << 9) : 0;
properties[index].flags |= material->GetProperty(MaterialProperty::WindAnimation) ? (1U << 9) : 0;
properties[index].flags |= material->GetProperty(MaterialProperty::VertexAnimateWater) ? (1U << 10) : 0;
properties[index].flags |= material->IsTessellated() ? (1U << 11) : 0;
// when changing the bit flags, ensure that you also update the Surface struct in common_structs.hlsl, so that it reads those flags as expected
Expand Down

0 comments on commit 44dedcf

Please sign in to comment.