Skip to content

Commit 0004b89

Browse files
committed
Add material pool with patches and product variants (1.12.0)
Material pool - Scan a folder of PBR texture sets (ambientCG / Poly Haven naming) into a pool with per-material ticks; names stay stable across rescans and are unique even when folders share a name - Box-projected Principled materials at a real-world Texture Size, so CAD meshes need no UVs; packed ARM supported; normal and opacity maps listed but not used - Moved libraries are rescanned before rendering; pre-flight stops the batch when textures a material uses are missing Material patches - A flat swatch and a lit ball side by side per material, on demand or with Render All, in the scene's colour management; the first shard makes them in sharded runs Product variants - N Full renders per view, each part (or the whole product) drawing a pool material; draws are hashed per seed, product, variant, part and material, so changing the pool moves only the draws it touches - Clay, masks and data passes rendered once per view; products set to Keep Own render once in their own materials - {variant} naming token; manifest variant/materials columns; the pool recorded in provenance; pool materials removed after a run Tests - test_materials.py
1 parent 964af1d commit 0004b89

4 files changed

Lines changed: 1348 additions & 53 deletions

File tree

‎CITATION.cff‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type: software
55
authors:
66
- given-names: Danyal
77
family-names: Sarfraz
8-
version: 1.11.0
8+
version: 1.12.0
99
license: MIT
1010
repository-code: "https://github.com/Danyals-code/Addon-for-MultiView-Rendering-AMVR"
1111
abstract: >-

‎README.md‎

Lines changed: 82 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ every view in one click, with predictable file names like `AA_01_Widget_Front_cl
88

99
- **Blender:** 4.0 and newer
1010
- **Panel location:** `3D Viewport → Sidebar (N key) → MultiView`
11-
- **Version:** 1.11.0
11+
- **Version:** 1.12.0
1212
- **Cite:** see [`CITATION.cff`](CITATION.cff)
1313

1414
---
@@ -186,6 +186,79 @@ The products' own materials are never edited. The preset is applied by a tempora
186186
Geometry Nodes modifier, `MV_Material`, added while the product renders and removed
187187
afterwards, so it also works on STL imports, which arrive with no materials at all.
188188

189+
#### Material Pool
190+
191+
The **Material Pool** sub-panel turns a folder of PBR texture sets into materials for
192+
your products. Point **Texture Folder** at a folder holding one sub-folder per material, as
193+
downloaded from [ambientCG](https://ambientcg.com) or [Poly Haven](https://polyhaven.com),
194+
and click the refresh button. Every folder with a colour map becomes a pool material:
195+
196+
```
197+
textures/
198+
Bricks_A/ Bricks_A_1K-PNG_Color.png, _Roughness, _NormalGL, _Displacement
199+
oak_veneer/ oak_veneer_diff_1k.png, _rough_1k, _arm_1k, _nor_gl_1k
200+
Metal_Plate/ Metal_Plate_Color.jpg, Metal_Plate_Metalness.png
201+
```
202+
203+
Maps are recognised by their names:
204+
- colour: `Color`, `BaseColor`, `Albedo`, `Diffuse`, `diff`
205+
- roughness: `Roughness`, `rough`
206+
- metallic: `Metalness`, `Metallic`, `metal`
207+
- packed AO/rough/metal: `arm`
208+
- height: `Displacement`, `Height`, `disp`, `bump`
209+
- opacity: `Opacity`, `Alpha`
210+
211+
A folder holding a single image uses it as the colour map, unless its name ends in a data
212+
map's word (`_rough`, `_Metalness`, ...). A material is named after its folder. A folder
213+
called `textures`, `maps` or `2k` takes the name of the one above it, since Poly Haven
214+
downloads keep their maps in `<asset>/textures`. Two folders with the same name are told
215+
apart by their path (`wood_Oak`, `metal_Oak`). A material keeps its name when you scan
216+
again, so a library that later gains a second `Oak` names only the new one by its path.
217+
218+
The list shows the maps found for each material as letters (**C** colour, **R** roughness,
219+
**M** metallic, **A** packed, **H** height, **N** normal, **O** opacity). Untick a material
220+
to leave it out.
221+
222+
The list keeps where each texture file is. If the files move (a moved library, or the
223+
`.blend` opened on another machine), the folder is scanned again before rendering. If the
224+
textures a material uses still cannot be found, pre-flight stops the batch.
225+
226+
CAD files have no UV maps, so the textures are box projected in each part's own
227+
coordinates. They stay put when the product turns and need no unwrapping. **Texture Size**
228+
is how much of the real part one repeat of a texture covers, in millimetres. A 100 mm wood
229+
texture looks the same size on a 30 mm knob and a 2 m cabinet, whatever scale Fit on Import
230+
gave them. A product built by hand and never standardized is taken to be in metres.
231+
232+
Normal maps are listed but not used, because they need the UVs these meshes do not have.
233+
Opacity maps are listed but not used either. Masks, part IDs and COCO/BOP annotations are
234+
made once per view, so a material that cut holes in the product would leave them wrong for
235+
that image.
236+
237+
**Product variants.** Set **Variants** above 0 and every Full render is made that many
238+
times per view, each with a different draw from the pool. With **Per Part** on, every part
239+
of the product draws its own material; off, the whole product shares one. A product set to
240+
**Keep Own** in **Products to render** is left out and renders once, in its own materials.
241+
242+
The files get a `_v01`, `_v02`, ... suffix (or use `{variant}` in the naming templates), and
243+
each variant gets its own contact sheet. Clay renders, line art, masks, depth, normals and
244+
part IDs do not depend on the material, so they are rendered once per view. The manifest's
245+
`variant` and `materials` columns record what each image wears, for example
246+
`Block=Bricks_A; Peg=oak_veneer`.
247+
248+
Draws come from the **Seed**, the product's label, the variant number and the part, so
249+
re-running gives the same variants. Adding variants, products or parts never changes the
250+
other draws. Adding or unticking a pool material changes only the draws it wins or held.
251+
The pool's contents are recorded in the manifest's provenance block.
252+
253+
**Material patches.** **Render Patches** writes one image per ticked material into
254+
`materials/` in the output folder. It shows a flat swatch, one repeat seen straight on, next
255+
to a ball under studio lights, with the material's name above. Tick **With Render All** to
256+
make them as part of every batch, listed in the manifest. In a sharded command-line run the
257+
first shard makes them, and rendering just the active product skips them. Patches render in
258+
a scene of their own with the scene's colour management, and the pool materials are deleted
259+
again after each run, so your scene is untouched. They use Cycles when your engine is
260+
Workbench, which cannot show textures.
261+
189262
### 2. Import Products
190263

191264
Add files to the list with **+**, or a whole folder with the folder button, then click
@@ -538,6 +611,7 @@ change it with tokens:
538611
| `{product}` | `Widget` | The product collection's name |
539612
| `{view}` | `Front` | The camera view, or `Sheet` / `Turntable` |
540613
| `{mode}` | `clay` | `clay`, `render` (Both mode), or empty for Full Render |
614+
| `{variant}` | `v01` | The Material Pool variant, empty for everything rendered once |
541615

542616
The defaults are `{label}_{product}` for the folder and `{label}_{product}_{view}_{mode}` for
543617
the file. A token that comes out empty takes one separator next to it along with it, so
@@ -550,6 +624,9 @@ the file. A token that comes out empty takes one separator next to it along with
550624
fields (the first image of the batch, as it will be written) instead of silently vanishing.
551625
- If the template would give two images the same name (no `{view}`, or no `{mode}` in Both
552626
mode), the render stops before it starts and says so.
627+
- With Material Pool variants on, a file name template without `{variant}` gets `_{variant}`
628+
added at the end, unless the folder template has `{variant}`, e.g.
629+
`{label}_{product}/{variant}`, which gives each variant a folder of its own.
553630

554631
#### Contact sheets
555632

@@ -612,9 +689,9 @@ copies are rebuilt.
612689
**Manifest** (CSV + JSON by default) writes `manifest.csv` and/or `manifest.json` into the
613690
output directory, listing every output with:
614691

615-
`label`, `product`, `kind` (render, processed, sheet, turntable), `view`, `mode`, `path`
616-
(relative to the output directory), `width`, `height`, `source_file`, `source_size` and
617-
`source_units`.
692+
`label`, `product`, `kind` (render, processed, sheet, turntable, patch, ...), `view`, `mode`,
693+
`path` (relative to the output directory), `width`, `height`, `source_file`, `source_size`,
694+
`source_units`, `source_sha256`, `variant` and `materials` (see Material Pool).
618695

619696
`source_file`, `source_size` and `source_units` are recorded when a file is imported:
620697
`source_size` is the product's bounding box before Fit on Import rescaled it, in
@@ -733,7 +810,7 @@ a faithful outline, not a finished drawing.
733810
| **Camera Jitter**, **Distance Jitter** | Each view's camera swings up to this far off its canonical direction, and moves nearer or farther |
734811
| **Lights** | The rig turns about the vertical by up to **Light Turn**, and each light changes strength by up to **Light Strength** |
735812
| **HDRI** | Each image is lit and backed by a random HDRI from **HDRI Folder** (empty: the studio HDRIs that ship with Blender), turned and scaled at random |
736-
| **Materials** | The product gets a random material preset and colour per image, in Full renders |
813+
| **Materials** | The product gets a random material preset and colour per image, in Full renders (not when Material Pool variants are on, which choose the materials instead) |
737814
| **Distractors** | Random shapes in random colours, placed behind the product as each camera sees it, in Full renders |
738815

739816
Every draw comes from the **Seed**, the product's label and the view, so the same settings

0 commit comments

Comments
 (0)