|
1 | | -# Materialize CLI |
| 1 | +# Materialize — PBR Map Generation |
2 | 2 |
|
3 | | -A **Rust CLI** that generates PBR (Physically Based Rendering) maps from diffuse textures using GPU compute shaders via [wgpu](https://wgpu.rs/). No GUI, no Unity — just one command and six maps. |
| 3 | +A **Rust CLI** that generates PBR (Physically Based Rendering) maps from diffuse/albedo textures using GPU compute shaders via [wgpu](https://wgpu.rs/). No GUI, no Unity — one command, six maps. |
4 | 4 |
|
5 | | -Inspired by the original [Materialize](https://github.com/BoundingBoxSoftware/Materialize) (Unity/Windows). **Language:** English (this file) · [Português (`README_PT.md`)](README_PT.md). |
6 | | - |
7 | | -**Who is this for?** Game developers, 3D artists, and anyone who needs PBR maps from diffuse textures — in engines like Unity, Unreal, Godot, or in Blender, without running a GUI or the Windows-only original. |
8 | | - |
9 | | -**GameDev monorepo:** **Hunyuan3D-Paint 2.1** (`paint3d texture`) already outputs a **PBR GLB**. This CLI is for **PBR maps from a diffuse image** (e.g. **Texture2D** + `texture2d.materialize` in GameAssets). See [`Text3D/docs/PBR_MATERIALIZE.md`](../Text3D/docs/PBR_MATERIALIZE.md). |
| 5 | +Inspired by the original [Materialize](https://github.com/BoundingBoxSoftware/Materialize) by Bounding Box Software (Unity/Windows). This is a from-scratch Rust CLI that preserves the same concept — turning a single diffuse image into a complete PBR material set. |
10 | 6 |
|
11 | 7 | --- |
12 | 8 |
|
13 | | -## Generated maps |
| 9 | +## Overview |
14 | 10 |
|
15 | | -From a single diffuse/albedo image, the tool outputs six maps: |
| 11 | +Materialize takes a single diffuse/albedo texture and produces six PBR maps: |
16 | 12 |
|
17 | 13 | | Map | Description | |
18 | 14 | |-----|-------------| |
19 | | -| **Height** | Surface elevation for parallax/displacement | |
20 | | -| **Normal** | Surface normals for lighting | |
21 | | -| **Metallic** | Metallic vs dielectric mask | |
22 | | -| **Smoothness** | Roughness/smoothness (base + metallic contribution) | |
| 15 | +| **Height** | Surface elevation for parallax / displacement effects | |
| 16 | +| **Normal** | Per-pixel surface normals for realistic lighting | |
| 17 | +| **Metallic** | Metallic vs. dielectric mask | |
| 18 | +| **Smoothness** | Inverse roughness (base + metallic contribution) | |
23 | 19 | | **Edge** | Edge detection derived from normals | |
24 | | -| **AO** | Ambient occlusion (cavity-style from height) | |
25 | | - |
26 | | ---- |
| 20 | +| **AO** | Ambient occlusion (cavity-style, derived from height) | |
27 | 21 |
|
28 | | -## Features |
| 22 | +**Key properties:** |
29 | 23 |
|
30 | | -- **Minimal** — Command-line only; easy to script and automate |
31 | | -- **Fast** — GPU compute shaders (wgpu); no CPU-bound image loops |
| 24 | +- **Fast** — GPU compute shaders via wgpu; no CPU-bound image loops |
32 | 25 | - **Cross-platform** — Linux, macOS, Windows (Vulkan, Metal, DirectX 12) |
33 | | -- **Flexible** — Output formats: PNG, JPG, TGA, EXR; configurable quality for JPEG |
| 26 | +- **No CUDA required** — wgpu works with any modern GPU |
| 27 | +- **Scriptable** — CLI-only; easy to batch and integrate into pipelines |
34 | 28 |
|
35 | 29 | --- |
36 | 30 |
|
37 | | -## Quick start |
| 31 | +## Installation |
38 | 32 |
|
39 | | -### Install (GameDev monorepo) |
| 33 | +### GameDev monorepo (recommended) |
40 | 34 |
|
41 | | -If you have the **GameDev** monorepo (this folder lives under `GameDev/Materialize`), use the unified installer from the **repository root**: |
| 35 | +From the repository root: |
42 | 36 |
|
43 | 37 | ```bash |
44 | | -cd /path/to/GameDev |
45 | 38 | ./install.sh materialize |
46 | 39 | ``` |
47 | 40 |
|
48 | | -See [docs/INSTALLING.md](../docs/INSTALLING.md). Requires **Rust** (`cargo`) and Python 3 for the installer wrapper. |
| 41 | +This compiles the crate and installs the binary to `~/.local/bin/`. Ensure `~/.local/bin` is on your `PATH`. |
| 42 | + |
| 43 | +### Standalone build |
| 44 | + |
| 45 | +Requires **Rust** 1.87+ and a GPU with up-to-date drivers. |
| 46 | + |
| 47 | +```bash |
| 48 | +cd Materialize |
| 49 | +cargo build --release |
| 50 | +cargo install --path . |
| 51 | +``` |
49 | 52 |
|
50 | | -### Install (standalone clone) |
| 53 | +The `materialize` binary is placed in Cargo's `~/.cargo/bin/`. |
51 | 54 |
|
52 | | -Requires **Python 3** (installer) and **Rust** (cargo) to build. The installer compiles and places the binary in `~/.local/bin/materialize` (ensure it’s on your `PATH`). |
| 55 | +### Manual install script |
53 | 56 |
|
54 | 57 | ```bash |
| 58 | +# Clone and run installer (places binary in ~/.local/bin) |
55 | 59 | git clone https://github.com/maikramer/Materialize-CLI.git |
56 | 60 | cd Materialize-CLI |
57 | | -./install.sh |
| 61 | +./install.sh # install |
| 62 | +./install.sh reinstall |
| 63 | +./install.sh uninstall |
58 | 64 | ``` |
59 | 65 |
|
60 | | -- **Linux/macOS:** `./install.sh` | `./install.sh uninstall` | `./install.sh reinstall` |
61 | | -- **Windows:** `.\install.ps1` or `install.bat` |
| 66 | +--- |
| 67 | + |
| 68 | +## Commands |
| 69 | + |
| 70 | +### `materialize <INPUT>` (default command) |
62 | 71 |
|
63 | | -### Run |
| 72 | +Generate PBR maps from a diffuse/albedo image. |
64 | 73 |
|
65 | 74 | ```bash |
66 | 75 | materialize texture.png |
67 | | -# Writes to current directory: |
68 | | -# texture_height.png, texture_normal.png, texture_metallic.png, |
69 | | -# texture_smoothness.png, texture_edge.png, texture_ao.png |
70 | | - |
71 | 76 | materialize texture.png -o ./out/ -v |
| 77 | +materialize skin.png --preset skin -o ./materials/ |
72 | 78 | materialize diffuse.png --format png --quiet |
73 | 79 | ``` |
74 | 80 |
|
75 | | -### Manual build (Cargo) |
| 81 | +#### Options |
76 | 82 |
|
77 | | -```bash |
78 | | -cargo build --release |
79 | | -cargo install --path . |
80 | | -``` |
| 83 | +| Flag | Short | Type | Default | Description | |
| 84 | +|------|-------|------|---------|-------------| |
| 85 | +| `--output` | `-o` | path | `.` | Output directory | |
| 86 | +| `--format` | `-f` | str | `png` | Output format: `png`, `jpg`, `jpeg`, `tga`, `exr` | |
| 87 | +| `--preset` | `-p` | str | `default` | Material preset (see below) | |
| 88 | +| `--quality` | `-q` | int | `95` | JPEG quality 0–100 (ignored for other formats) | |
| 89 | +| `--verbose` | `-v` | flag | — | Print progress and timing information | |
| 90 | +| `--quiet` | — | flag | — | Suppress generated file list on success | |
| 91 | +| `--help` | `-h` | — | — | Show help message | |
| 92 | +| `--version` | `-V` | — | — | Show version (`materialize-cli 1.0.0`) | |
81 | 93 |
|
82 | | ---- |
| 94 | +### `materialize skill install` |
83 | 95 |
|
84 | | -## Usage |
| 96 | +Install the Materialize CLI [Cursor AI skill](.cursor/skills/materialize-cli/) into the current project's `.cursor/skills/materialize-cli/` directory. |
85 | 97 |
|
86 | | -### Syntax |
87 | | - |
88 | | -```text |
89 | | -materialize [OPTIONS] [INPUT] [COMMAND] |
| 98 | +```bash |
| 99 | +materialize skill install |
90 | 100 | ``` |
91 | 101 |
|
92 | | -### Options |
| 102 | +--- |
| 103 | + |
| 104 | +## PBR Presets |
93 | 105 |
|
94 | | -| Option | Short | Default | Description | |
95 | | -|--------|-------|---------|-------------| |
96 | | -| `--output` | `-o` | `./` | Output directory | |
97 | | -| `--format` | `-f` | `png` | Output format: `png`, `jpg`, `jpeg`, `tga`, `exr` | |
98 | | -| `--quality` | `-q` | `95` | JPEG quality (0–100) when using `-f jpg` | |
99 | | -| `--verbose` | `-v` | — | Print progress and timing | |
100 | | -| `--quiet` | — | — | Do not list generated files on success | |
101 | | -| `--help` | `-h` | — | Show help | |
102 | | -| `--version` | `-V` | — | Show version | |
| 106 | +Presets tune the generation parameters for specific material types. Use `-p` / `--preset` to select one. |
103 | 107 |
|
104 | | -### Subcommands |
| 108 | +| Preset | Description | Characteristics | |
| 109 | +|--------|-------------|-----------------| |
| 110 | +| `default` | General purpose | Balanced settings for any texture | |
| 111 | +| `skin` | Human/character skin | No metallic, high smoothness, subtle normals | |
| 112 | +| `floor` | Ground surfaces (stone, tile, dirt) | Pronounced height, strong AO, rough surface | |
| 113 | +| `metal` | Metallic surfaces | Boosted metallic, sharp edges, polished look | |
| 114 | +| `fabric` | Cloth / textile | Matte, no metallic, soft edges | |
| 115 | +| `wood` | Wood grain | No metallic, moderate grain detail | |
| 116 | +| `stone` | Rock / stone | Very rough, deep AO, strong normals | |
105 | 117 |
|
106 | | -- **`materialize skill install`** — Installs the Materialize CLI [Cursor skill](.cursor/skills/materialize-cli/) into the current project’s `.cursor/skills/materialize-cli/`. |
| 118 | +```bash |
| 119 | +materialize brick_diffuse.png -p stone -o ./out/ |
| 120 | +materialize character_skin.png --preset skin -v |
| 121 | +materialize metal_panel.jpg -p metal -f exr -o ./hdr/ |
| 122 | +``` |
107 | 123 |
|
108 | | -### Output naming |
| 124 | +--- |
109 | 125 |
|
110 | | -For input `texture.png`, outputs are: |
| 126 | +## Output Files |
111 | 127 |
|
112 | | -- `texture_height.png` |
113 | | -- `texture_normal.png` |
114 | | -- `texture_metallic.png` |
115 | | -- `texture_smoothness.png` |
116 | | -- `texture_edge.png` |
117 | | -- `texture_ao.png` |
| 128 | +From an input file `texture.png`, Materialize generates six files in the output directory (extension follows `--format`): |
118 | 129 |
|
119 | | -(Extension follows `--format`.) |
| 130 | +| File | Description | |
| 131 | +|------|-------------| |
| 132 | +| `texture_height.{ext}` | Height / displacement map | |
| 133 | +| `texture_normal.{ext}` | Normal map | |
| 134 | +| `texture_metallic.{ext}` | Metallic map | |
| 135 | +| `texture_smoothness.{ext}` | Smoothness map | |
| 136 | +| `texture_edge.{ext}` | Edge detection map | |
| 137 | +| `texture_ao.{ext}` | Ambient occlusion map | |
120 | 138 |
|
121 | 139 | ### Exit codes |
122 | 140 |
|
123 | 141 | | Code | Meaning | |
124 | 142 | |------|---------| |
125 | | -| `0` | Success | |
| 143 | +| `0` | Success — files generated | |
126 | 144 | | `1` | Generic error | |
127 | 145 | | `2` | Input file not found | |
128 | 146 | | `3` | Unsupported input format | |
129 | | -| `4` | GPU error (no adapter) | |
| 147 | +| `4` | GPU error (no adapter found) | |
130 | 148 | | `5` | I/O error (permissions, disk full, etc.) | |
131 | 149 | | `6` | Image too large for GPU | |
132 | 150 |
|
133 | 151 | --- |
134 | 152 |
|
135 | | -## Examples |
| 153 | +## Pipeline Integration |
136 | 154 |
|
137 | | -```bash |
138 | | -# Default: current directory, PNG |
139 | | -materialize brick.png |
| 155 | +Materialize runs **after** Texture2D or Paint3D to generate PBR maps from diffuse textures. It is integrated into the GameDev monorepo pipeline at several points: |
140 | 156 |
|
141 | | -# Custom output directory and verbose |
142 | | -materialize brick.png -o ./materials/brick/ -v |
| 157 | +- **GameAssets batch** — via `materialize: true` in the `texture2d` block of `game.yaml` |
| 158 | +- **Paint3D** — `vertex-pbr` command uses Materialize for map generation |
| 159 | +- **Standalone** — can process any diffuse image from any source |
143 | 160 |
|
144 | | -# EXR for HDR / precision |
145 | | -materialize texture.png -f exr -o ./out/ |
| 161 | +Uses wgpu compute shaders for cross-platform GPU acceleration — no CUDA required. Works on Linux (Vulkan), macOS (Metal), and Windows (DirectX 12) with any modern GPU. |
146 | 162 |
|
147 | | -# Batch (parallel with xargs) |
148 | | -ls *.png | xargs -P 4 -I {} materialize {} -o ./output/ |
| 163 | +```bash |
| 164 | +# Typical pipeline: generate texture, then PBR maps |
| 165 | +texture2d generate "brick wall" -o ./textures/ |
| 166 | +materialize textures/brick_wall.png -p stone -o ./materials/brick/ |
| 167 | +``` |
| 168 | + |
| 169 | +### Batch processing |
| 170 | + |
| 171 | +```bash |
| 172 | +# Parallel batch with xargs |
| 173 | +ls textures/*.png | xargs -P 4 -I {} materialize {} -o ./pbr/ |
149 | 174 |
|
150 | | -# Script-friendly: quiet, check exit code |
| 175 | +# Script-friendly: quiet mode, check exit code |
151 | 176 | materialize texture.png -o ./out/ --quiet |
152 | | -if [ $? -eq 0 ]; then echo "OK"; fi |
| 177 | +if [ $? -eq 0 ]; then echo "PBR maps generated"; fi |
153 | 178 | ``` |
154 | 179 |
|
155 | 180 | --- |
156 | 181 |
|
157 | | -## Getting help |
| 182 | +## Development |
158 | 183 |
|
159 | | -- **Bugs & features** — [Open an issue](https://github.com/maikramer/Materialize-CLI/issues) (templates for bug reports and feature requests are available). |
160 | | -- **Questions** — [GitHub Discussions](https://github.com/maikramer/Materialize-CLI/discussions). |
161 | | -- **Contributing** — See [CONTRIBUTING.md](CONTRIBUTING.md). We follow a [Code of Conduct](CODE_OF_CONDUCT.md). |
| 184 | +```bash |
| 185 | +cd Materialize |
| 186 | + |
| 187 | +# Build |
| 188 | +cargo build |
| 189 | + |
| 190 | +# Run tests |
| 191 | +cargo test |
| 192 | + |
| 193 | +# Format (auto-fix) |
| 194 | +cargo fmt |
| 195 | + |
| 196 | +# Lint |
| 197 | +cargo clippy -- -D warnings |
| 198 | +``` |
| 199 | + |
| 200 | +Requires **Rust** 1.87+ (edition 2024). Dev dependencies: `tempfile` for integration tests. |
162 | 201 |
|
163 | 202 | --- |
164 | 203 |
|
165 | | -## Requirements |
| 204 | +## License & Attribution |
| 205 | + |
| 206 | +**MIT License** — see [LICENSE](LICENSE). |
166 | 207 |
|
167 | | -- **Rust** 1.75+ |
168 | | -- **GPU** with Vulkan (Linux), Metal (macOS), or DirectX 12 (Windows); up-to-date drivers |
| 208 | +This project is based on [Materialize](https://github.com/BoundingBoxSoftware/Materialize) by **Bounding Box Software**. The original Materialize is a Unity-based Windows application for generating PBR maps. This is a from-scratch Rust reimplementation that preserves the concept and algorithmic approach. |
169 | 209 |
|
170 | 210 | --- |
171 | 211 |
|
172 | 212 | ## Documentation |
173 | 213 |
|
174 | 214 | - [docs/README.md](docs/README.md) — Overview, installation details, and doc index |
175 | | -- [docs/cli-api.md](docs/cli-api.md) — Full CLI reference, env vars, shell completion |
| 215 | +- [docs/cli-api.md](docs/cli-api.md) — Full CLI reference, environment variables, shell completion |
176 | 216 | - [docs/architecture.md](docs/architecture.md) — System structure |
177 | 217 | - [docs/features.md](docs/features.md) — Capabilities |
178 | 218 | - [docs/algorithms.md](docs/algorithms.md) — Processing algorithms |
179 | | -- [docs/shaders.md](docs/shaders.md) — WGSL shaders |
| 219 | +- [docs/shaders.md](docs/shaders.md) — WGSL compute shaders |
180 | 220 | - [docs/roadmap.md](docs/roadmap.md) — Future plans |
181 | 221 |
|
182 | | ---- |
183 | | - |
184 | | -## License |
| 222 | +## Getting Help |
185 | 223 |
|
186 | | -[MIT](LICENSE). Based on the original Materialize by Bounding Box Software. |
| 224 | +- **Bugs & features** — [Open an issue](https://github.com/maikramer/Materialize-CLI/issues) |
| 225 | +- **Questions** — [GitHub Discussions](https://github.com/maikramer/Materialize-CLI/discussions) |
| 226 | +- **Contributing** — See [CONTRIBUTING.md](CONTRIBUTING.md) |
0 commit comments