一键导入
dev-noise-texture
Add procedural noise texture generation to the asset pipeline — C tool, Python plugin, web UI with live preview
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Add procedural noise texture generation to the asset pipeline — C tool, Python plugin, web UI with live preview
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Add PBR texture loading with separate roughness/metallic support to an SDL GPU project using forge_scene.h
Add Cook-Torrance PBR shading with GGX, Schlick-GGX, and Schlick Fresnel to an SDL GPU project alongside forge_scene.h
Add instanced grass rendering with segmented blades, wind animation, LOD density rings, and terrain LOD with geomorphing to an SDL GPU project
Add an asset pipeline lesson — hybrid Python + C track for asset processing, procedural geometry, and web frontend
Add an audio lesson — sound playback, mixing, spatial audio, DSP effects, with SDL GPU scenes and forge UI
Run a quality review pass on a lesson before publishing, catching recurring issues found across project PR history
| name | dev-noise-texture |
| description | Add procedural noise texture generation to the asset pipeline — C tool, Python plugin, web UI with live preview |
| user_invokable | true |
Add procedural noise texture generation to the forge-gpu asset pipeline.
A C tool samples noise functions from forge_math.h across a pixel grid
and writes grayscale BMP heightmaps. A Python pipeline plugin invokes the
tool as a subprocess, and the web UI provides interactive parameter tuning
with live preview.
| Function | Output | Use case |
|---|---|---|
forge_noise_perlin2d | [-1, 1] | Basic gradient noise |
forge_noise_simplex2d | [-1, 1] | Less axis-aligned than Perlin |
forge_noise_fbm2d | [-1, 1] | Multi-scale terrain, clouds |
forge_noise_ridged_fbm2d | [0, 1] | Mountain ridges, rivers |
forge_noise_worley2d | F1, F2 distances | Voronoi cells, edges |
forge_noise_domain_warp2d | [-1, 1] | Organic distortion |
| Function | Purpose |
|---|---|
find_noise_tool() | Locate forge_noise_tool binary |
run_noise_tool() | Invoke tool as subprocess with CLI args |
generate_noise_textures() | Batch generation from pipeline.toml config |
NoisePlugin.process() | Plugin entry point for pipeline integration |
| Endpoint | Method | Purpose |
|---|---|---|
/api/generate/noise | POST | Generate full-resolution texture |
/api/generate/noise/preview | GET | Stream a 256×256 BMP preview |
common/math/forge_math.h with full
documentation (parameters, output range, usage example)tests/math/test_math.c (determinism, range, edge cases)NOISE_* enum value and parse_type case in tools/noise/main.cVALID_TYPES in pipeline/plugins/noise.pyNOISE_TYPES array in pipeline/web/src/routes/generate/noise.tsxNoiseGenerateRequest type dropdown and server endpointBuild the tool: cmake --build build --target forge_noise_tool
Add [noise] config to pipeline.toml:
[noise]
noise_enabled = true
output_dir = "generated"
[[noise.textures]]
name = "terrain_height"
type = "fbm"
width = 1024
height = 1024
seed = 42
tiling = true
Generate: uv run python -m pipeline generate-noise
Or use the web UI: uv run python -m pipeline serve --reload
Map 2D coordinates onto a 4D torus — each axis traces a circle in a separate 2D plane:
float angle_u = u * 2.0f * FORGE_PI;
float angle_v = v * 2.0f * FORGE_PI;
float r = frequency / (2.0f * FORGE_PI);
/* Noise sees (r*cos(u) + r*cos(v), r*sin(u) + r*sin(v)) — continuous
* across the tile boundary because each circle closes on itself. */
Central differences on the heightmap with wrapping:
float dx = (heightmap[y*w + xp] - heightmap[y*w + xm]) * strength;
float dy = (heightmap[yp*w + x] - heightmap[ym*w + x]) * strength;
/* Normal = normalize(-dx, -dy, 1), mapped to [0, 255] RGB */
Forgetting to normalize output. Perlin/Simplex/fBm return [-1, 1], ridged returns [0, 1], Worley returns [0, ~1.5]. The tool normalizes via min/max scan before writing BMP pixels.
Tool not found on MSVC. Multi-config generators put binaries in
build/tools/noise/Debug/. The tool_finder.py searches config
subdirectories automatically.
Normal map source ordering. In pipeline.toml, the heightmap entry must appear before the normal map entry that references it (the plugin processes entries in order).
Tiling with Worley noise. The 4D torus approximation works well for gradient-based noise but can produce visible seams with Worley at low frequencies. Increase frequency or use fBm/ridged for seamless tiles.
forge_noise_tool heightmap.bmp fbm \
--width 1024 --height 1024 --seed 42 \
--octaves 6 --frequency 4.0 --persistence 0.5 --tiling
forge_noise_tool normals.bmp fbm \
--width 1024 --height 1024 --seed 42 \
--octaves 6 --frequency 4.0 --normal-map --normal-strength 2.0
from pathlib import Path
from pipeline.plugins.noise import find_noise_tool, run_noise_tool
tool = find_noise_tool()
if tool is None:
raise RuntimeError("forge_noise_tool not found — build it first")
run_noise_tool(
Path("output.bmp"), "ridged",
width=512, height=512, seed=42,
frequency=4.0, octaves=6, tiling=True,
tool=tool,
)
import { noisePreviewUrl } from "@/lib/api"
const url = noisePreviewUrl({
noise_type: "worley-edge",
width: 256, height: 256,
seed: 42, frequency: 8.0,
})
// -> "/api/generate/noise/preview?noise_type=worley-edge&..."