mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 00:53:52 +00:00
feat(editor): scatter texture patches for natural surface variety
- Scatter Patches: randomly places texture circles across the terrain for natural-looking surface variation (dirt patches, rock outcrops) - Configurable count, min/max radius, and seed - Preset buttons for dirt and rock patches - Uses the existing paint() method with random positions - Adds visual variety to otherwise uniform terrain texturing
This commit is contained in:
parent
16a096b25d
commit
b00143e8f7
3 changed files with 46 additions and 0 deletions
|
|
@ -904,6 +904,28 @@ void EditorUI::renderTexturePaintPanel(EditorApp& app) {
|
|||
selectedTexture_.c_str());
|
||||
|
||||
// Auto-paint by height
|
||||
if (ImGui::CollapsingHeader("Scatter Patches")) {
|
||||
static int patchCount = 15;
|
||||
static float patchMinR = 10.0f, patchMaxR = 30.0f;
|
||||
static int patchSeed = 55;
|
||||
ImGui::SliderInt("Count##patches", &patchCount, 5, 50);
|
||||
ImGui::DragFloatRange2("Radius##patches", &patchMinR, &patchMaxR, 1.0f, 5.0f, 80.0f);
|
||||
ImGui::InputInt("Seed##patches", &patchSeed);
|
||||
if (ImGui::Button("Scatter Dirt Patches", ImVec2(-1, 0))) {
|
||||
app.getTexturePainter().scatterPatches(
|
||||
"Tileset\\Elwynn\\ElwynnDirtBase.blp", patchCount, patchMinR, patchMaxR,
|
||||
static_cast<uint32_t>(patchSeed));
|
||||
app.showToast("Patches scattered");
|
||||
}
|
||||
if (ImGui::Button("Scatter Rock Patches", ImVec2(-1, 0))) {
|
||||
app.getTexturePainter().scatterPatches(
|
||||
"Tileset\\Barrens\\BarrensRock01.blp", patchCount, patchMinR, patchMaxR,
|
||||
static_cast<uint32_t>(patchSeed + 1));
|
||||
app.showToast("Patches scattered");
|
||||
}
|
||||
ImGui::TextColored(ImVec4(0.6f,0.6f,0.6f,1), "Random texture patches for variety");
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Gradient Blend")) {
|
||||
static int gradDir = 0;
|
||||
ImGui::RadioButton("Horizontal##grad", &gradDir, 0);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "core/logger.hpp"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <random>
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
|
|
@ -321,6 +322,25 @@ void TexturePainter::gradientBlend(const std::string& tex1, const std::string& t
|
|||
}
|
||||
}
|
||||
|
||||
void TexturePainter::scatterPatches(const std::string& texturePath, int count,
|
||||
float minRadius, float maxRadius, uint32_t seed) {
|
||||
if (!terrain_ || texturePath.empty()) return;
|
||||
uint32_t texId = ensureTextureInList(texturePath);
|
||||
|
||||
float tileNW_X = (32.0f - static_cast<float>(terrain_->coord.y)) * 533.33333f;
|
||||
float tileNW_Y = (32.0f - static_cast<float>(terrain_->coord.x)) * 533.33333f;
|
||||
|
||||
std::mt19937 rng(seed);
|
||||
std::uniform_real_distribution<float> distX(tileNW_X - 533.33333f, tileNW_X);
|
||||
std::uniform_real_distribution<float> distY(tileNW_Y - 533.33333f, tileNW_Y);
|
||||
std::uniform_real_distribution<float> distR(minRadius, maxRadius);
|
||||
|
||||
for (int p = 0; p < count; p++) {
|
||||
float px = distX(rng), py = distY(rng), pr = distR(rng);
|
||||
paint(glm::vec3(px, py, 0), pr, 0.8f, 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> TexturePainter::erase(const glm::vec3& center, float radius,
|
||||
float strength, float falloff) {
|
||||
if (!terrain_ || activeTexture_.empty()) return {};
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ public:
|
|||
// Gradient blend: transitions base texture from one to another across tile
|
||||
void gradientBlend(const std::string& tex1, const std::string& tex2, bool horizontal);
|
||||
|
||||
// Scatter random texture patches across the terrain
|
||||
void scatterPatches(const std::string& texturePath, int count, float minRadius,
|
||||
float maxRadius, uint32_t seed);
|
||||
|
||||
// Paint the active texture at the given world position
|
||||
// Returns list of modified chunk indices
|
||||
std::vector<int> paint(const glm::vec3& center, float radius, float strength, float falloff);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue