diff --git a/Editor/TerrainWindow.cpp b/Editor/TerrainWindow.cpp index 708c8e3ea..b111ff180 100644 --- a/Editor/TerrainWindow.cpp +++ b/Editor/TerrainWindow.cpp @@ -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); diff --git a/Editor/TerrainWindow.h b/Editor/TerrainWindow.h index b08811c0b..8c989999b 100644 --- a/Editor/TerrainWindow.h +++ b/Editor/TerrainWindow.h @@ -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; diff --git a/WickedEngine/wiTerrain.cpp b/WickedEngine/wiTerrain.cpp index bdbc2dec1..d675ef775 100644 --- a/WickedEngine/wiTerrain.cpp +++ b/WickedEngine/wiTerrain.cpp @@ -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 diff --git a/WickedEngine/wiTerrain.h b/WickedEngine/wiTerrain.h index 70f03b867..0de2990ae 100644 --- a/WickedEngine/wiTerrain.h +++ b/WickedEngine/wiTerrain.h @@ -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; diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 236eaf949..f289a8304 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -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);