From 30e58ae0b27b5ea53c3de6bc75ebfc6caf5b116e Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 9 May 2026 12:52:31 -0700 Subject: [PATCH] feat(editor): add --gen-texture-houndstooth classic-textile motif MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 67th procedural texture: the classic 19th-century Scottish houndstooth broken-check pattern via a hard-coded seamless 8x8 motif: 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 1 1 0 0 0 1 1 1 1 0 0 0 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 1 1 1 0 0 1 1 1 1 1 0 0 1 1 1 1 1 0 0 Each motif cell scales to `cellSize` pixels (default 4 → 32 px tile), so a 256x256 texture shows 8 motifs in each axis. Tile-seam-perfect: no row offset or fractional pixel issues since lookup is integer mod 8. Useful for noble-house tabard accents, formal-attire trim, upholstery in palace dining rooms, drapes / wall hangings, gentry-quarter banners. Distinct from --gen-texture-tartan (weighted multi-color stripes) and --gen-texture-checker (simple binary squares) — houndstooth has the iconic 4-pointed "tooth" silhouette. --- tools/editor/cli_arg_required.cpp | 1 + tools/editor/cli_gen_texture.cpp | 63 +++++++++++++++++++++++++++++++ tools/editor/cli_help.cpp | 2 + 3 files changed, 66 insertions(+) diff --git a/tools/editor/cli_arg_required.cpp b/tools/editor/cli_arg_required.cpp index f9782eda..c3dac44f 100644 --- a/tools/editor/cli_arg_required.cpp +++ b/tools/editor/cli_arg_required.cpp @@ -102,6 +102,7 @@ const char* const kArgRequired[] = { "--gen-texture-mesh-screen", "--gen-texture-bamboo", "--gen-texture-blueprint", "--gen-texture-rust-streaks", "--gen-texture-plaid", "--gen-texture-diamond-grid", + "--gen-texture-houndstooth", "--validate-glb", "--info-glb", "--info-glb-tree", "--info-glb-bytes", "--validate-jsondbc", "--check-glb-bounds", "--validate-stl", "--validate-png", "--validate-blp", diff --git a/tools/editor/cli_gen_texture.cpp b/tools/editor/cli_gen_texture.cpp index f27919ae..73337235 100644 --- a/tools/editor/cli_gen_texture.cpp +++ b/tools/editor/cli_gen_texture.cpp @@ -3500,6 +3500,68 @@ int handleKnit(int& i, int argc, char** argv) { return 0; } +int handleHoundstooth(int& i, int argc, char** argv) { + // Houndstooth: classic textile broken-check pattern. The 8x8 + // motif stored below tiles seamlessly to produce the + // unmistakable 4-pointed tooth shape that 19th-century + // Scottish weavers gave us. Each motif cell scales to + // `cellSize` pixels (default 4 → 32x32 tile = 4 motifs side- + // to-side at 256x256). + std::string outPath = argv[++i]; + std::string aHex = argv[++i]; // tooth color + std::string bHex = argv[++i]; // background color + int cellSize = 4; + int W = 256, H = 256; + parseOptInt(i, argc, argv, cellSize); + parseOptInt(i, argc, argv, W); + parseOptInt(i, argc, argv, H); + if (W < 1 || H < 1 || W > 8192 || H > 8192 || + cellSize < 1 || cellSize > 256) { + std::fprintf(stderr, + "gen-texture-houndstooth: invalid dims (W/H 1..8192, " + "cellSize 1..256)\n"); + return 1; + } + uint8_t ar, ag, ab, br_, bg_, bb_; + if (!parseHexOrError(aHex, ar, ag, ab, + "gen-texture-houndstooth")) return 1; + if (!parseHexOrError(bHex, br_, bg_, bb_, + "gen-texture-houndstooth")) return 1; + // The classic 8x8 houndstooth motif. 1 = tooth color, 0 = bg. + // Tiles seamlessly in both axes. + static const uint8_t motif[8][8] = { + {1, 1, 1, 1, 0, 0, 0, 0}, + {1, 1, 1, 1, 0, 0, 0, 1}, + {1, 1, 1, 0, 0, 0, 1, 1}, + {1, 1, 0, 0, 0, 1, 1, 1}, + {0, 0, 0, 0, 1, 1, 1, 1}, + {0, 0, 0, 1, 1, 1, 1, 1}, + {0, 0, 1, 1, 1, 1, 1, 0}, + {0, 1, 1, 1, 1, 1, 0, 0}, + }; + std::vector pixels(static_cast(W) * H * 3, 0); + for (int y = 0; y < H; ++y) { + int motifY = (y / cellSize) % 8; + for (int x = 0; x < W; ++x) { + int motifX = (x / cellSize) % 8; + uint8_t r, g, b; + if (motif[motifY][motifX]) { + r = ar; g = ag; b = ab; + } else { + r = br_; g = bg_; b = bb_; + } + setPixelRGB(pixels, W, x, y, r, g, b); + } + } + if (!savePngOrError(outPath, W, H, pixels, + "gen-texture-houndstooth")) return 1; + printPngWrote(outPath, W, H); + std::printf(" tooth/bg : %s / %s\n", aHex.c_str(), bHex.c_str()); + std::printf(" cell : %d px (8x8 motif → %d-px tile)\n", + cellSize, cellSize * 8); + return 0; +} + int handleDiamondGrid(int& i, int argc, char** argv) { // Axis-aligned grid of solid diamond shapes (no row offset) // separated by visible bg gaps. Distinct from @@ -4882,6 +4944,7 @@ constexpr TextureEntry kTextureTable[] = { {"--gen-texture-rust-streaks", 3, handleRustStreaks}, {"--gen-texture-plaid", 3, handlePlaid}, {"--gen-texture-diamond-grid", 3, handleDiamondGrid}, + {"--gen-texture-houndstooth", 3, handleHoundstooth}, }; } // namespace diff --git a/tools/editor/cli_help.cpp b/tools/editor/cli_help.cpp index c6ccd135..38b896e7 100644 --- a/tools/editor/cli_help.cpp +++ b/tools/editor/cli_help.cpp @@ -167,6 +167,8 @@ void printUsage(const char* argv0) { std::printf(" Plaid: 2 sets of crossed translucent bands; intersections darken via combined half-alpha\n"); std::printf(" --gen-texture-diamond-grid [cellW] [cellH] [fillFrac] [W H]\n"); std::printf(" Diamond grid: axis-aligned solid diamonds in cells with bg gaps (clean tile / mosaic / floor inlay)\n"); + std::printf(" --gen-texture-houndstooth [cellSize] [W H]\n"); + std::printf(" Houndstooth: classic textile broken-check pattern via seamless 8x8 motif (Scottish weave)\n"); std::printf(" --add-texture-to-zone [renameTo]\n"); std::printf(" Copy an existing PNG into (optionally renaming it on the way in)\n"); std::printf(" --gen-mesh [size]\n");