Skip to content

Commit 6822e1e

Browse files
committed
Be more specific about the regex matching in material overrides
1 parent 0ae754f commit 6822e1e

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

articles/remote-rendering/how-tos/conversion/override-materials.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ For the full list of texture maps you can ignore, see the [JSON schema](#json-sc
7979
By default, an entry in the material overrides file applies when its name matches the material name exactly.
8080
Since it's common that the same override should apply to multiple materials, you can optionally provide a regular expression as the entry name.
8181
The field `nameMatching` has a default value `exact`, but it can be set to `regex` to state that the entry should apply to every matching material.
82-
The syntax used is the same syntax used for JavaScript.
82+
The syntax of the regex expression is the same syntax used for JavaScript.
83+
84+
> [!TIP]
85+
> There are free regex testing websites available to test and debug a regular expression against arbitrary strings.
86+
8387
The following example shows an override that applies to materials with names like `Material2`, `Material01` and `Material999`.
8488

8589
```json
@@ -97,9 +101,28 @@ The following example shows an override that applies to materials with names lik
97101
]
98102
```
99103

100-
At most, one entry in a material override file applies to a single material.
101-
If there's an exact match (that is, `nameMatching` is absent or equals `exact`) for the material name, then that entry is chosen.
102-
Otherwise, the first regex entry in the file that matches the material name is chosen.
104+
This example shows an override that is applied to _all_ materials:
105+
106+
```json
107+
[
108+
{
109+
"name": ".*",
110+
"nameMatching": "regex",
111+
"albedoColor": {
112+
"r": 0.0,
113+
"g": 0.0,
114+
"b": 1.0,
115+
"a": 1.0
116+
}
117+
}
118+
]
119+
```
120+
121+
The order in which every material finds a matching override is as follows:
122+
1. First, it tests for exact name match (that is, it checks all overrides where `nameMatching` is absent or equals `exact`).
123+
1. If no override is found, it tests all overrides with `regex` name matching mode and uses _the first_ override that matches.
124+
125+
A single material never gets more than one override applied, even if multiple `regex` expressions apply to the material name.
103126

104127
### Getting information about which entries applied
105128

0 commit comments

Comments
 (0)