Skip to content

Commit

Permalink
[editor] exposed cull mode (back, front, none) in the material proper…
Browse files Browse the repository at this point in the history
…ties as it can be freely changed without creating new PSOs (thanks Vulkan)
  • Loading branch information
PanosK92 committed Jan 7, 2025
1 parent e496b1b commit d3a6d5c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 15 deletions.
29 changes: 25 additions & 4 deletions editor/Widgets/Properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> cull_modes =
{
"Back",
"Front",
"None"
};

ImGui::Text("Culling");
ImGui::SameLine(column_pos_x);
uint32_t cull_mode_index = static_cast<uint32_t>(material->GetProperty(MaterialProperty::CullMode));
if (ImGuiSp::combo_box("##mat_cull_mode", cull_modes, &cull_mode_index))
{
material->SetProperty(MaterialProperty::CullMode, static_cast<float>(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);
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<img align="center" padding="2" src="https://raw.githubusercontent.com/PanosK92/SpartanEngine/master/data/textures/banner.bmp"/>

<p>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.</p>
<p>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.</p>

- <img align="left" width="32" src="https://i.pinimg.com/736x/99/65/5e/99655e9fe24eb0a7ea38de683cedb735.jpg"/>For occasional updates regarding the project's development, you can follow me on <a href="https://twitter.com/panoskarabelas1?ref_src=twsrc%5Etfw">X</a>.

Expand Down
4 changes: 2 additions & 2 deletions runtime/Game/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -797,8 +799,6 @@ namespace Spartan
material->SetProperty(MaterialProperty::WindAnimation, 1.0f);
}
}

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

void create_doom()
Expand Down
11 changes: 5 additions & 6 deletions runtime/World/Components/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions runtime/World/Components/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d3a6d5c

Please sign in to comment.