terrain: added tessellation option
This commit is contained in:
@@ -361,6 +361,16 @@ void TerrainWindow::Create(EditorComponent* _editor)
|
||||
});
|
||||
AddWidget(&physicsCheckBox);
|
||||
|
||||
tessellationCheckBox.Create("Tessellation: ");
|
||||
tessellationCheckBox.SetTooltip("Specify whether tessellation is enabled for terrain surface.\nTessellation requires GPU hardware support\nTessellation doesn't work with raytracing effects or Visibility Compute Shading rendering mode.");
|
||||
tessellationCheckBox.SetSize(XMFLOAT2(hei, hei));
|
||||
tessellationCheckBox.SetPos(XMFLOAT2(x, y += step));
|
||||
tessellationCheckBox.SetCheck(true);
|
||||
tessellationCheckBox.OnClick([=](wi::gui::EventArgs args) {
|
||||
terrain->SetTessellationEnabled(args.bValue);
|
||||
});
|
||||
AddWidget(&tessellationCheckBox);
|
||||
|
||||
lodSlider.Create(0.0001f, 0.01f, 0.005f, 10000, "Mesh LOD Distance: ");
|
||||
lodSlider.SetTooltip("Set the LOD (Level Of Detail) distance multiplier.\nLow values increase LOD detail in distance");
|
||||
lodSlider.SetSize(XMFLOAT2(wid, hei));
|
||||
@@ -777,6 +787,7 @@ void TerrainWindow::SetEntity(Entity entity)
|
||||
removalCheckBox.SetCheck(terrain->IsRemovalEnabled());
|
||||
grassCheckBox.SetCheck(terrain->IsGrassEnabled());
|
||||
physicsCheckBox.SetCheck(terrain->IsPhysicsEnabled());
|
||||
tessellationCheckBox.SetCheck(terrain->IsTessellationEnabled());
|
||||
lodSlider.SetValue(terrain->lod_multiplier);
|
||||
generationSlider.SetValue((float)terrain->generation);
|
||||
propGenerationSlider.SetValue((float)terrain->prop_generation);
|
||||
@@ -1049,6 +1060,7 @@ void TerrainWindow::ResizeLayout()
|
||||
centerToCamCheckBox.SetPos(XMFLOAT2(removalCheckBox.GetPos().x - 100, removalCheckBox.GetPos().y));
|
||||
add_checkbox(grassCheckBox);
|
||||
physicsCheckBox.SetPos(XMFLOAT2(grassCheckBox.GetPos().x - 100, grassCheckBox.GetPos().y));
|
||||
add_checkbox(tessellationCheckBox);
|
||||
add(lodSlider);
|
||||
add(generationSlider);
|
||||
add(propGenerationSlider);
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
wi::gui::CheckBox removalCheckBox;
|
||||
wi::gui::CheckBox grassCheckBox;
|
||||
wi::gui::CheckBox physicsCheckBox;
|
||||
wi::gui::CheckBox tessellationCheckBox;
|
||||
wi::gui::Slider lodSlider;
|
||||
wi::gui::Slider generationSlider;
|
||||
wi::gui::Slider propGenerationSlider;
|
||||
|
||||
@@ -935,6 +935,15 @@ namespace wi::terrain
|
||||
{
|
||||
chunk_data.mesh_vertex_positions = chunk_mesh->vertex_positions.data();
|
||||
|
||||
if (IsTessellationEnabled())
|
||||
{
|
||||
chunk_mesh->tessellationFactor = 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
chunk_mesh->tessellationFactor = 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Test: remove off screen chunks
|
||||
// But the problem is that shadow casters shouldn't be removed outside view
|
||||
|
||||
@@ -173,6 +173,7 @@ namespace wi::terrain
|
||||
GRASS = 1 << 2,
|
||||
GENERATION_STARTED = 1 << 4,
|
||||
PHYSICS = 1 << 5,
|
||||
TESSELLATION = 1 << 6,
|
||||
};
|
||||
uint32_t _flags = CENTER_TO_CAM | REMOVAL | GRASS;
|
||||
|
||||
@@ -207,12 +208,14 @@ namespace wi::terrain
|
||||
constexpr bool IsGrassEnabled() const { return _flags & GRASS; }
|
||||
constexpr bool IsGenerationStarted() const { return _flags & GENERATION_STARTED; }
|
||||
constexpr bool IsPhysicsEnabled() const { return _flags & PHYSICS; }
|
||||
constexpr bool IsTessellationEnabled() const { return _flags & TESSELLATION; }
|
||||
|
||||
constexpr void SetCenterToCamEnabled(bool value) { if (value) { _flags |= CENTER_TO_CAM; } else { _flags &= ~CENTER_TO_CAM; } }
|
||||
constexpr void SetRemovalEnabled(bool value) { if (value) { _flags |= REMOVAL; } else { _flags &= ~REMOVAL; } }
|
||||
constexpr void SetGrassEnabled(bool value) { if (value) { _flags |= GRASS; } else { _flags &= ~GRASS; } }
|
||||
constexpr void SetGenerationStarted(bool value) { if (value) { _flags |= GENERATION_STARTED; } else { _flags &= ~GENERATION_STARTED; } }
|
||||
constexpr void SetPhysicsEnabled(bool value) { if (value) { _flags |= PHYSICS; } else { _flags &= ~PHYSICS; } }
|
||||
constexpr void SetTessellationEnabled(bool value) { if (value) { _flags |= TESSELLATION; } else { _flags &= ~TESSELLATION; } }
|
||||
|
||||
float lod_multiplier = 0.005f;
|
||||
int generation = 12;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wi::version
|
||||
// minor features, major updates, breaking compatibility changes
|
||||
const int minor = 71;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 78;
|
||||
const int revision = 79;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user