feat(editor): add --gen-texture-mesh-screen orthogonal grid

61st procedural texture: thin horizontal + vertical wires
forming an axis-aligned grid. Distinct from
--gen-texture-lattice (which uses ±45° diagonals to make
diamond openings) — this gives the right-angle window-
screen / chain-link / sci-fi-grille look.

Tested per-axis: a row is "on a wire" if (y % stride) <
wireW; a pixel falls on a wire if either its row OR its
column tests positive. Result is the unmistakable
orthogonal-mesh appearance.

Useful for window screens, anti-pest grates, fish nets,
sewer grilles, sci-fi vent panels, prison-cell windows,
goblin-workshop catwalks. Default 12-stride / 2-wide
gives a coarse mesh; finer versions read as bug screen.
This commit is contained in:
Kelsi 2026-05-09 12:14:10 -07:00
parent dc762eb7ce
commit b1fd3382a9
3 changed files with 56 additions and 0 deletions

View file

@ -94,6 +94,7 @@ const char* const kArgRequired[] = {
"--gen-texture-moss", "--gen-texture-woodgrain",
"--gen-texture-carbon", "--gen-texture-pinstripe",
"--gen-texture-camo", "--gen-texture-snake-skin",
"--gen-texture-mesh-screen",
"--validate-glb", "--info-glb", "--info-glb-tree", "--info-glb-bytes",
"--validate-jsondbc", "--check-glb-bounds", "--validate-stl",
"--validate-png", "--validate-blp",

View file

@ -3546,6 +3546,58 @@ int handleKnit(int& i, int argc, char** argv) {
return 0;
}
int handleMeshScreen(int& i, int argc, char** argv) {
// Orthogonal mesh-screen / grille: thin horizontal + vertical
// wires forming an axis-aligned grid. Distinct from
// --gen-texture-lattice (which uses ±45° diagonals to make
// diamond openings) — this is the right-angle window-screen /
// chain-link / sci-fi-grille look.
std::string outPath = argv[++i];
std::string bgHex = argv[++i];
std::string wireHex = argv[++i];
int stride = 12;
int wireW = 2;
int W = 256, H = 256;
parseOptInt(i, argc, argv, stride);
parseOptInt(i, argc, argv, wireW);
parseOptInt(i, argc, argv, W);
parseOptInt(i, argc, argv, H);
if (W < 1 || H < 1 || W > 8192 || H > 8192 ||
stride < 2 || stride > 1024 ||
wireW < 1 || wireW * 2 >= stride) {
std::fprintf(stderr,
"gen-texture-mesh-screen: invalid dims (W/H 1..8192, "
"stride 2..1024, wireW 1..stride/2)\n");
return 1;
}
uint8_t br_, bg_, bb_, wr, wg, wb_;
if (!parseHexOrError(bgHex, br_, bg_, bb_,
"gen-texture-mesh-screen")) return 1;
if (!parseHexOrError(wireHex, wr, wg, wb_,
"gen-texture-mesh-screen")) return 1;
std::vector<uint8_t> pixels(static_cast<size_t>(W) * H * 3, 0);
for (int y = 0; y < H; ++y) {
bool yOnWire = (y % stride) < wireW;
for (int x = 0; x < W; ++x) {
bool xOnWire = (x % stride) < wireW;
uint8_t r, g, b;
if (xOnWire || yOnWire) {
r = wr; g = wg; b = wb_;
} else {
r = br_; g = bg_; b = bb_;
}
setPixelRGB(pixels, W, x, y, r, g, b);
}
}
if (!savePngOrError(outPath, W, H, pixels,
"gen-texture-mesh-screen")) return 1;
std::printf("Wrote %s\n", outPath.c_str());
std::printf(" size : %dx%d\n", W, H);
std::printf(" bg/wire : %s / %s\n", bgHex.c_str(), wireHex.c_str());
std::printf(" grid : stride=%d, wireW=%d\n", stride, wireW);
return 0;
}
int handleSnakeSkin(int& i, int argc, char** argv) {
// Snake skin: brick-offset grid of diamond-shaped scales.
// Each scale is a rotated square in L1 (taxicab) metric so
@ -4527,6 +4579,7 @@ constexpr TextureEntry kTextureTable[] = {
{"--gen-texture-pinstripe", 3, handlePinstripe},
{"--gen-texture-camo", 3, handleCamo},
{"--gen-texture-snake-skin", 3, handleSnakeSkin},
{"--gen-texture-mesh-screen", 3, handleMeshScreen},
};
} // namespace

View file

@ -155,6 +155,8 @@ void printUsage(const char* argv0) {
std::printf(" Camouflage: 2-octave value noise thresholded into hard bg/fg blobs (woodland disruption pattern)\n");
std::printf(" --gen-texture-snake-skin <out.png> <bgHex> <scaleHex> [cellW] [cellH] [outlineW] [W H]\n");
std::printf(" Snake skin: brick-offset diamond scales (L1 metric) with derived dark outline (reptile / dragon hide)\n");
std::printf(" --gen-texture-mesh-screen <out.png> <bgHex> <wireHex> [stride] [wireW] [W H]\n");
std::printf(" Mesh-screen: orthogonal H+V wire grid (window screen / chain-link / sci-fi grille)\n");
std::printf(" --add-texture-to-zone <zoneDir> <png-path> [renameTo]\n");
std::printf(" Copy an existing PNG into <zoneDir> (optionally renaming it on the way in)\n");
std::printf(" --gen-mesh <wom-base> <cube|plane|sphere|cylinder|torus|cone|ramp> [size]\n");