# Face Materials — an author's guide

**For modders and artists using BinEdit's Face > Material dialog.**
Covers the Glass, Foliage and Mesh presets, and every flag and number behind them.

This is the plain-language companion to `GLTF_EXTRAS_SPEC.md`. That document tells a tool
author what the bytes are; this one tells you what the checkboxes *do to your model*.
Nothing here requires you to read either the format or the code.

---

## 1. What a material actually is

Before materials existed, how a face drew was baked into which *opcode* it used. That
sounds like a technical detail, and it was — but it had a very visible consequence:

> A windshield could be **transparent**, or it could be **shiny**, but never both.

Not because the renderer couldn't do it. All three renderers already could. The two
properties simply lived in different opcode families, and there was no way to ask for them
together. A wiring gap, not a rendering gap.

A **material** replaces that with a set of checkboxes and numbers you attach to the faces
you select. Anything you can tick, you can tick together.

Three things follow from this, and they matter:

**Glass, Foliage and Mesh are presets, not types.** The buttons set the same checkboxes you could
set by hand. Nothing in the game ever asks "is this face glass?" — it only ever reads the
flags. A preset is a *starting point*, never a category you are locked into. Press Glass,
then change whatever you like.

**Materials are opt-in.** A model with no material is written and drawn exactly as it always
was. Nothing you already made changes, and nothing needs converting.

**Materials apply to textured faces only.** The dialog says so along the bottom. A solid
colour face has no texture to blend, reflect or tint.

---

## 2. Quick start

| You want | Do this |
|---|---|
| A windscreen, window, or anything see-through and shiny | Select the faces, **Glass preset** |
| Leaves, grass, chain-link, any cut-out card | Select the faces, **Foliage preset** |
| A mesh grille, window guard, tint band — solid in parts, glass elsewhere | Select the faces, **Mesh preset** |
| To undo it | **No Material** — the face returns to being an ordinary textured facet |

Then tune. Sections 3, 4 and 5 say which knob does what.

---

## 3. The Glass preset

Pressing **Glass preset** ticks six flags:

> Lit · Gouraud · Blend · Reflect · Fresnel · No Z-write

and sets five numbers as a starting point:

| Parameter | Preset | What it is doing here |
|---|---|---|
| Reflectivity | 0.35 | Enough to read as glass without mirroring the whole world |
| Fresnel bias | 0.08 | Nearly clear when you look straight at it |
| Fresnel strength | 2.5 | ...and hard to near-opaque at glancing angles |
| Base alpha | 0.35 | How see-through it is face-on |
| Specular power | 32 | Highlight tightness |

### Why each flag is there

**Lit** — the glass takes scene lighting. Untick it and it ignores lights entirely, which is
almost never what you want on a vehicle.

**Gouraud** — smooth shading, *and* the gate for specular and reflection in the shaders.
**Untick Gouraud and you lose your highlight and your reflection**, no matter what the other
boxes say. This one catches people out.

**Blend** — the face is alpha-blended, i.e. actually see-through. Without it, Base alpha
does nothing at all.

**Reflect** — the environment reflection. This is what makes it read as glass rather than
coloured cellophane.

**Fresnel** — view-angle dependence, and the most important idea in the preset. See below.

**No Z-write** — the face doesn't write depth. Transparent surfaces need this, or they punch
holes in whatever should be visible through them. Leave it on for anything you can see
through.

### Fresnel — the part worth understanding

Real glass is nearly clear when you look straight through it, and turns mirror-like when you
look along it at a glancing angle. Fresnel is that effect, and it drives **two** things at
once: how transparent the face is, *and* how strongly it reflects.

Two numbers control it, and they are easy to confuse:

- **Fresnel bias** is the value **face-on** — looking straight at the glass. Low bias = clear
  when viewed head-on. The preset's 0.08 is "nearly clear".
- **Fresnel strength** is how hard it ramps up as your angle gets shallower. Higher strength
  = becomes mirror-like sooner as the surface turns away from you.

So: **bias sets the floor, strength sets the climb.**

If you like the maths, the opacity you end up with is

```
fresnel = saturate( (bias + (1 - bias) * (1 - cos angle)^5) * strength )
opacity = saturate( baseAlpha + (1 - baseAlpha) * fresnel )
```

and that same `fresnel` term also multiplies the reflection weight. Which is why turning
strength up makes glass *both* more opaque and more mirrored towards the edges — one knob,
two visible effects. That is deliberate: it is what real glass does.

### Tuning recipes

| You want | Change |
|---|---|
| Clearer glass overall | Lower **Base alpha** (0.2 is quite clear) |
| Limo tint / darker | Raise **Base alpha** toward 0.6–0.7, and consider Tint |
| More mirror | Raise **Reflectivity** |
| Mirrored only at the edges | Keep Reflectivity moderate, raise **Fresnel strength** |
| Clear even at glancing angles | Lower **Fresnel strength** toward 1 |
| Tighter, smaller highlight | Raise **Specular power** (32 → 70 and up) |
| Broader, softer highlight | Lower **Specular power** |
| Coloured glass | Tick **Tint** and choose a colour |

---

## 4. The Foliage preset

Pressing **Foliage preset** ticks four flags:

> Lit · Alpha test · Two-sided · Translucent

and that is essentially the whole preset — foliage is about flags, not numbers.

**Lit** — leaves take scene lighting.

**Alpha test** — the texture is *cut out* rather than blended: transparent texels are
discarded outright. This is what you want for a leaf card, because it avoids the sorting
problems blending brings.

**Two-sided** — no backface culling. A leaf card must be visible from behind, because you
will be looking at the back of half of them.

**Translucent** — light bleeds *through* the surface, so a backlit leaf glows instead of
going black. This is the flag that makes a tree look like a tree when the sun is behind it,
and it is the one nobody thinks to look for.

**Translucency** (the number) sets how much. 0 is exactly off; raise it for thinner, more
paper-like leaves.

### Why there is no alpha-ref knob for you to turn

The format has a flag letting a material pick its own cut-off threshold instead of the
global one. **BinEdit deliberately does not offer it**, and the reason is worth knowing so
you don't go hunting for it.

MTM2's `.RAW` textures are palette-indexed, and their transparency is a **colour key** — a
texel is transparent when its palette entry is black. So the alpha arriving at the renderer
is only ever fully on or fully off. **There is nothing in between for a threshold to land
on.** Moving the cut-off cannot move a single pixel.

That was measured, not assumed: on a genuinely soft-alpha 512-pixel PNG built from the same
art, the *entire* usable threshold range shifts about 17% of the leaf mass — a one-to-two
texel change in the silhouette, invisible at any normal distance.

A related trap: **alpha-test edges are always hard.** The threshold moves *where* the cut
falls; it never softens it. A genuinely soft edge needs alpha **blend**, which brings back
exactly the sorting problem cutout exists to avoid.

The flag is still honoured by the engine, so art with a genuinely wide feathered edge can
opt in. It simply isn't exposed, because a knob that does nothing visible on every existing
asset is a trap rather than a feature.

---

## 5. The Mesh preset — glass with solid parts

Pressing **Mesh preset** ticks everything Glass does, plus one more:

> Lit · Gouraud · Blend · Reflect · Fresnel · No Z-write · **Texture alpha = solid**

and uses the same five numbers as Glass. It is Glass with one extra idea.

### What it is for

A window guard. A mesh grille over a rear window. A tint band across the top of a windscreen. A
sponsor decal printed on a side window.

All of those are **one face** where part of the surface should be solid and the rest should be glass
— and until this preset there was no way to author them, because the solid part and the see-through
part are a **pattern in the texture, not separate geometry**. There is nothing to select and give a
second material to.

Your only options were both wrong:

| | what you got |
|---|---|
| Alpha test (Foliage-style) | bars solid, gaps **open holes** — no glass at all |
| Glass preset | the whole thing translucent, **bars included** |

### How to author it

**The texture's alpha channel decides.** Paint the parts you want **solid** as opaque texels, and the
parts you want to stay **glass** as transparent ones. That is the whole workflow — one face, one
texture, one material.

On a legacy `.RAW` this needs no re-authoring at all: transparency there is the black colour key, so
a mesh texture that already works as a cut-out will work here unchanged. Tick the preset and the
holes become glass instead of holes.

### ⛔ Do not use this on a plain window

A normal window texture is **fully opaque** — every texel alpha 255, whether it is a `.RAW` with no
black in it or a PNG with no alpha channel. Apply Mesh to one of those and the entire pane goes
**solid**. The glass disappears completely.

If your window should be glass all over, that is the **Glass** preset. Mesh is only for a face that
genuinely has both.

### ⚠ On a `.RAW`, the glass half is always dark

Colour and alpha are the same thing in a `.RAW` — the colour key — so a texel that is transparent
*must* be black, and the glass renders as a **dark tint**. Over a dark cab interior that usually
looks right. If you want clear or coloured glass in the gaps, the texture has to be a **PNG with a
real alpha channel**, which lets a texel be any colour *and* transparent.

### ⚠ Use it on small things

The engine draws a Mesh face **twice** — once for the glass, once for the solid parts. That is what
lets the solid parts sit properly in front of whatever is behind them. It costs one extra draw and
double the fill **for that face**, which is nothing for a grille or a band, and is not something to
put on a whole truck body.

Everything without the preset costs exactly what it did before.

---
## 6. Every flag, briefly

| Flag | What it does |
|---|---|
| **Lit** | Take scene lighting at all. Off = ignores lights. |
| **Gouraud** | Smooth shading — **and the gate for specular and reflection**. |
| **Blend** | Alpha blended (genuinely see-through). Base alpha does nothing without it. |
| **Alpha test** | Cut-out. Transparent texels discarded. Edges are always hard. |
| **Additive blend** | Adds to what's behind instead of blending over it. Glows, flames, light shafts. Never darkens. |
| **Reflect** | Environment reflection, strength set by Reflectivity. |
| **Fresnel** | View-angle ramp driving both transparency and reflection. |
| **Two-sided** | Don't backface cull. Cards, leaves, flags — anything with no back. |
| **No Z-write** | Don't write depth. Needed for see-through surfaces to sort sanely. |
| **Emissive** | Self-lit. Puts a floor under the lighting so it never goes fully dark. |
| **Tint** | Multiply the texture by a colour, *before* lighting. |
| **Translucent** | Light bleeds through from behind. Backlit leaves, curtains, paper. |

Not every combination is meaningful. Blend and Alpha test are two different answers to the
same question — pick one. Specular power and Reflectivity do nothing without Gouraud.

---

## 7. Every number, briefly

| Parameter | Range | What moving it looks like |
|---|---|---|
| **Reflectivity** | 0–1 | How much environment shows in the surface. 0 = none, 1 = mirror. |
| **Fresnel bias** | 0–1 | The value **face-on**. Low = clear when looked at straight. |
| **Fresnel strength** | 0 and up | How fast it ramps to mirror/opaque as the angle shallows. 0 = Fresnel off. |
| **Base alpha** | 0–1 | Opacity face-on. Only used with **Blend**. Low = clear. |
| **Specular power** | 1 and up | Highlight tightness. Higher = smaller and sharper. Unset behaves as 32. |
| **Emissive** | 0–1 | Self-illumination floor. 0 = no effect. Raise so a surface never goes black. |
| **Tint** | R, G, B | Colour multiplier. White (unchanged) is the neutral value. |
| **Translucency** | 0–1 | How much light bleeds through from behind. 0 = exactly off. |

**Tint is applied before lighting**, so the lighting ramp and the reflection both act on the
tinted colour — which is why tinted glass looks genuinely tinted rather than like a coloured
film laid over the top.

---

## 8. Things that will catch you out

**The Mesh preset on a plain window makes it SOLID.** A normal window texture is opaque
everywhere, and Mesh reads opaque as "solid" - so the whole pane goes solid and the glass
disappears. Mesh is only for a face that genuinely has both, e.g. a grille. A plain window
wants Glass - section 5.

**Untick Gouraud and you lose your highlight and reflection.** It is not merely "smooth vs
flat" — the shaders use it as the gate for both.

**Base alpha does nothing without Blend.** If your glass is stubbornly opaque, check Blend
before you touch the number.

**Fresnel strength 0 turns Fresnel off** regardless of the checkbox, because zero strength
means the ramp never rises.

**See-through faces want No Z-write.** Without it a windscreen will hide things that should
be visible through it, depending on draw order.

**Applying a material changes the face's type.** That is expected, and is how the game knows
to use it. It also means the face is no longer one of the legacy face types.

**Emissive is a floor, not an addition.** It stops a surface going darker than the value; it
does not add brightness on top of an already well-lit surface.

**A normal map cannot show relief on a BLACK texture.** Relief works by moving the lighting,
and lighting multiplies the base colour - so black times anything is still black. Lift the
art a few points off zero (RGB 35 reads as black rubber) and the bump appears. Pure black is
also this engine's transparency colour key, so it is a value worth avoiding anyway.

**A greyscale image is not a normal map.** It decodes to negative Z and is ignored texel by
texel, so it reads as no bump at all rather than as a wrong one - section 9.

**Translucency 0 and Emissive 0 are exact no-ops.** Leaving them at zero costs nothing and
changes nothing.

---

## 9. Normal maps

A normal map is **not** part of the material record. It is found **by convention** from the
colour texture's name: if your face uses `GD-W1.RAW`, the engine probes for `GD-W1_N.PNG`
and then `GD-W1_N.TGA`. Drop the file in and it is used — no `.bin` edit, no flag to tick,
and it works on a legacy `.RAW` + `.act` texture exactly as it does on an HD `.PNG`.

`MRGL_MATERIAL2` exists only to **tune** the strength or **suppress** the map. It is not the
trigger, and you do not need one.

### What each channel means here

| channel | this engine reads it as |
|---|---|
| **R** | tangent X — the tilt across the texture |
| **G** | bitangent Y — the tilt down the texture |
| **B** | **surface Z**. Export it normally; the game rebuilds Z from R/G and reuses this channel internally for occlusion — see below. |
| **A** | the **specular mask** — see below. Optional; a map without an alpha channel behaves exactly as it always did. |

RGB is decoded as `tex * 2 - 1`.

### ⛔ Blue is Z — and you never touch it

If you have worked in an engine that packs **roughness into blue**, or that uses a **DXT5nm**-style
layout, **neither applies here.** Export a normal map the way your baker exports one: R, G and B
carrying X, Y and Z. That is all that is asked of you.

Behind the scenes the game reconstructs Z from X and Y (a normal is a unit vector, so Z is
redundant) and uses the freed blue channel for occlusion. **That is an internal detail and not a
format you author against.** Do not pre-pack it yourself — ship the two files below and the game
does the merge, correctly, every time.

### 📁 Occlusion: `<stem>_AO`

> **In short — everything you need to ship one**
>
> - Ship `<stem>_AO` beside your diffuse. **Greyscale: white = open, black = fully occluded.** No file = no occlusion.
> - **Separate file, not packed.** Export the normal map and the AO exactly as your baker gives them. The engine merges them internally — do not pre-pack anything.
> - Works **with or without** a `_N`. Occlusion alone is fine.
> - **Size needn't match** the `_N` or the diffuse. Matching is fine too.
> - Bake it into **the same UV layout as the diffuse** and it lines up by itself.
>
> **Two things that otherwise look like bugs:**
>
> 1. **It darkens ambient light only, never direct sun** — so it is strongest in shade and on overcast/dusk, and subtlest in bright sun. **Check it in shade before judging it.**
> 2. **Use it on unique skins, not tiling detail textures** — a tiled texture gets identical occlusion everywhere it appears.


**Working now.** A plain **greyscale** map beside the diffuse, same naming as `_N`:

| value | meaning |
|---|---|
| **white (255)** | fully open — no occlusion |
| **black (0)** | fully occluded |
| **no file** | no occlusion, exactly as before |

Bake it from your high-poly source the way you normally would. Nothing needs packing, and it works
**with or without** a `_N` — ship occlusion alone if that is all you want.

⭐ **It darkens AMBIENT light only, never direct sun.** A crevice reads dark because the sky cannot
reach into it; a surface the sun is actually hitting stays lit. That is why this looks like shading
rather than like dirt painted on your texture — and it is also why the effect is strongest in shade
and on overcast/dusk weather, and subtlest in full sun. That is correct, not a weak map.

⚠ **Size need not match the `_N` or the diffuse.** Occlusion is low-frequency, so a 256 AO beside a
512 normal is fine and costs nothing in quality. Matching sizes is equally fine — there is no reason
to go out of your way either way.

⭐ **`_AO` BELONGS TO A TEXTURE, NOT TO A PART OF THE MODEL** — and that decides where it is worth
using. It is per-texel, but it is attached to the texture, so it lands wherever that texture's UVs
land. Bake it into **the same UV layout as the diffuse** (which is what your baker already produces
beside the normal map) and it lines up by itself.

⛔ **SO USE IT ON UNIQUE SKINS, NOT ON TILING DETAIL TEXTURES.** A truck body skin is unique — each
part of the image maps to one place on the model — so baked occlusion means something there. A
tiling texture is the opposite: if the same small metal panel is used on twenty surfaces, one `_AO`
repeats the identical occlusion on all twenty, and real occlusion depends on where a surface
actually sits. It will be wrong nearly everywhere, and it reads as a repeating stain rather than
as shading.

⚠ This bites harder than it does for normal maps. A tiled *normal* map still looks like plausible
surface detail when it repeats; tiled *occlusion* looks like dirt in impossible places.

⚠ When the sizes differ, the AO is resampled to the normal map's grid **nearest-neighbour**. For a
baked map that is invisible, because occlusion is smooth by nature. If you have hand-painted an AO
with **deliberately hard edges** — a crisp mask rather than a bake — those edges will look slightly
chunky at a mismatched size. Author it at the `_N`'s size and the question does not arise.

### The alpha channel: a specular mask (2026-08-23)

**Alpha dims the shiny highlight, per texel, on Gouraud faces.**

| alpha | result |
|---|---|
| **no alpha channel at all** | exactly as before — full highlight. Every existing map is unchanged. |
| **black (0)** | full highlight, same as no channel |
| **shades between** | darker = shinier, lighter = flatter |
| **white (255)** | no highlight at all — the face reads like a flat-shaded one |

⭐ **Bumpiness is not affected.** RGB and alpha are read independently: the relief you get from
a map is identical whether or not you paint its alpha.

⚠ **Gouraud faces only.** A flat-shaded face has no highlight to dim, so alpha is simply ignored
there — which is deliberate: choosing flat already said "no shine", and the bump still shows.

⚠ **Black and "no channel" are the same on purpose**, so a legacy map cannot lose its highlight
by accident. If you want a whole surface flat, paint alpha **white**, not black.

### Which way is up: green-down (DirectX)

Export your maps in the **DirectX / green-down** convention — the one where green is high at the
*bottom* of a bump. Most tools offer this as a checkbox, often labelled "invert green", or as a
DirectX/OpenGL dropdown.

Get it backwards and nothing errors: the relief simply comes out **inverted**, so rivets read as
dimples and tread reads as grooves. If a map looks subtly wrong in a way you cannot name, flip the
green channel and look again.

### Two hard requirements

**1. It must be a real tangent-space normal map, not a height map.** A greyscale image is
rejected texel by texel: grey `102` decodes to `(-0.2, -0.2, -0.2)`, which has a negative Z
and is not a normal at all. The engine treats any texel with `Z <= 0` as *flat* and ignores
it, so a height map renders as no bump rather than as garbage — but it renders as no bump.
Convert it to a normal map first; most tools have a height-to-normal step.

> **Sanity check before you ship a map:** its blue channel should be `128` or above
> **everywhere**, and average somewhere north of `200`. A correct map looks predominantly
> lavender-blue. If it looks grey, it is a height map.

**2. It must be a DX11 or Vulkan renderer.** DX9 has no object normal-map path at all — see
the table below. Nothing else is required: **any texture size works**, including the 64×64
art most legacy trucks use for tyres, axles and small parts.

> **Changed 2026-08-21.** 64×64 and 32×32 textures are packed sixteen (or sixty-four) to a
> shared page, and until this change a normal map could not be addressed on one — so wheels
> and small parts silently got no bump, and the workaround was to supply a 128px+ colour
> texture to move the slot into its own page. **That is no longer necessary.** If you are
> following an older guide that tells you to add `GD-W1.PNG` beside `GD-W1.RAW` purely to
> unlock bump, you can skip it. A large colour texture is still worth having for its own
> sake — it is just no longer a prerequisite.

If you are unsure whether a map loaded, turn on `[Graphics] hdLog` and read `hdtex.txt`.

### Resolution: the map is independent of the colour texture

The normal map is registered at **its own** size, not the colour texture's. A 64×64 skin can
carry a 512×512 normal map at full 512. So do not down-res a map to "match" the diffuse —
tread, panel lines and knurling are high-frequency detail and benefit from the extra
resolution. Square powers of two from 32 to 1024; anything else is resampled and noted in
`hdtex.txt`.

### Where it does and does not apply

| surface | normal maps? |
|---|---|
| Truck and object faces | ✅ DX11, Vulkan |
| Instanced scenery props | ✅ DX11, Vulkan |
| Terrain | ✅ DX11, Vulkan, DX9 — **HD (256px) terrain art only**, not legacy packed tiles |
| Water | ⛔ never — its shader has no bump block |
| Sky | ⛔ never |
| Everything, on DX9 objects | ⛔ DX9 has no object normal-map path; terrain only |
| Menu 3D truck previews | ⛔ CPU path, no shaders |

Placing an `_N` beside art on one of the ⛔ rows is not harmless — it takes memory from the
shared HD budget and can evict colour textures that *are* being used. Only ship maps for
surfaces that read them.

---

## 10. Where this comes from

Everything above is derived from the shipping implementation rather than described from
intent:

- Flag meanings and the two preset definitions — `engine/3D.H`
- The Fresnel, blend, reflection, emissive and translucency maths — the GPU T&L shaders
  (`wincore/vkshaders/rdvk_gputnl.hlsl` and the D3D11 / D3D9 equivalents)
- The colour-key alpha finding — measured on real MTM2 art, recorded in `3D.H`
- The preset starting values — BinEdit's `CMaterial::SetGlassPreset` `SetFoliagePreset` and `SetMeshPreset`
- The Mesh two-pass behaviour — `MRGLMAT_TEXSOLID` in `engine/3D.H` and the deferred emit
  in `core/Ground.cpp`
- The normal-map channel decode, the `Z <= 0` rule and the cache-256 requirement — the
  same GPU T&L shaders, plus `engine/texture.cpp` and `engine/hdtex.cpp`

For the record format, the on-disk units and the glTF mapping, see `GLTF_EXTRAS_SPEC.md`.
