Tattoos: decoration catalogue, placement and full-colour bake (#385, part 1) #429

Manually merged
github merged 2 commits from github-bot/gh-429 into gh-pr/429/base 2026-11-27 03:03:01 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-27 00:58 UTC · original
holdmysocks:claude/tattoos-385 → master · +700 −22 · 13 files · 2 commits · merged 2026-11-27 02:57 UTC

Part of #385. Ped decorations (tattoos and other skin decals) are now baked into skin colour textures. This covers the parts that are decoded: the catalogue, the outfit link, placement and coverage, and full-colour decals. Ink-coloured tattoos are left out, because the ink encoding is not decoded yet; see "Not decoded" below.

What changes

  • New peddeco module:
    • Reads the decoration catalogue in data.rpf: 7,509 records, struct 40e79f52, with layers of struct 77f0121d, read by the member offsets in the file's own schema.
    • Caches it as index/ped_decorations.json.
    • Bakes layers into a part's colour texture.
  • Wardrobe and outfits: an item's tag d9f1087b lists decoration names.
    • Every item of an outfit's variations counts, including the tattoo items that have no model.
    • A decoration goes on the outfit part whose item category is the decoration's category (3817131d body upper, 44925bfd body lower, 378ad10c head). If no part has that category, it goes on the part in that slot.
    • Garment prints (other categories) are not applied yet.
  • Export: ExportOptions::part_decorations. The base colour of the part is baked into a new texture that sits next to the plain one, so a skin mesh shared by many characters keeps one file per decoration list.
    • Each material records what went in under decorations in model.json.
    • The CLI outfit --look and the viewer's outfit view both pass the lists, so the 3D view and the GLB export match.

How the bake works

From the game's bake shader (PS_BakeDecorations), checked on a full-body decal:

  • Decal UV = (u, v, 1) × the layer's 3×3 matrix, divided by the third column.
  • The layer's four-edge clip quad applies in part UV. A pixel is dropped when (u − x0)(y1 − y0) − (v − y0)(x1 − x0) < 0 for any edge.
  • Saturation goes through HSV the way the shader does it, and is skipped at 1.0.
  • Coverage = decal alpha × layer opacity, blended in linear light.

Not decoded (left out, and recorded in model.json decorations.ink_rule)

  • Ink words. Layers coloured by ink are not baked: a layer that sets an ink, or one whose decal is a mask (alpha is line art; red and blue about 0 and green flat where it covers). BC3 masks whose ink words have alpha 0 exist, so the decal itself is checked as well. Most tattoos are ink-coloured, and a colour tattoo's black outlines are often a separate ink layer, so for now many tattoos are missing or show only their colour fill. The words are not plain RGB: most body inks read as mint or teal. The code that turns them into the shader's colour stops was not found.
  • Head makeup. Codes such as ff00ff00 are not decoded. Makeup layers all set an ink, so they are left out too.
  • Other layer fields. The layer mode (0–5), the flag bits and the p3 parameters are not decoded.

Follow-up PRs will cover the CPU packer, the ink encoding and the makeup codes.

Checked

  • outfit g_m_m_guardia_00 --look 5: the chest and back colour tattoos land on the upper-body skin texture.
  • The same outfit in the viewer on the RTX 4080 shows the chest tattoo under the V-neck.
  • ped-look g_m_m_koltandassoc_00: decorations are assigned to the head, body upper and body lower parts of every outfit.

Tests

  • Record and layer decode from a PSO laid out as the game's.
  • UV transform: affine, off-diagonal and projective.
  • Clip quad: "no clip" edges, a box from the data, and the degenerate edge.
  • Full-colour shading, the ink test and the mask test.
  • HSV saturation.
  • Bake blending, with missing and ink layers left out.
**@⁠holdmysocks** on GitHub · 2026-11-27 00:58 UTC · [original](https://github.com/holdmysocks/SixNG/pull/429) `holdmysocks:claude/tattoos-385` → `master` · +700 −22 · 13 files · 2 commits · merged 2026-11-27 02:57 UTC Part of #385. Ped decorations (tattoos and other skin decals) are now baked into skin colour textures. This covers the parts that are decoded: the catalogue, the outfit link, placement and coverage, and full-colour decals. Ink-coloured tattoos are left out, because the ink encoding is not decoded yet; see "Not decoded" below. ## What changes - New `peddeco` module: - Reads the decoration catalogue in data.rpf: 7,509 records, struct `40e79f52`, with layers of struct `77f0121d`, read by the member offsets in the file's own schema. - Caches it as `index/ped_decorations.json`. - Bakes layers into a part's colour texture. - Wardrobe and outfits: an item's tag `d9f1087b` lists decoration names. - Every item of an outfit's variations counts, including the tattoo items that have no model. - A decoration goes on the outfit part whose item category is the decoration's category (`3817131d` body upper, `44925bfd` body lower, `378ad10c` head). If no part has that category, it goes on the part in that slot. - Garment prints (other categories) are not applied yet. - Export: `ExportOptions::part_decorations`. The base colour of the part is baked into a new texture that sits next to the plain one, so a skin mesh shared by many characters keeps one file per decoration list. - Each material records what went in under `decorations` in model.json. - The CLI `outfit --look` and the viewer's outfit view both pass the lists, so the 3D view and the GLB export match. ## How the bake works From the game's bake shader (`PS_BakeDecorations`), checked on a full-body decal: - Decal UV = (u, v, 1) × the layer's 3×3 matrix, divided by the third column. - The layer's four-edge clip quad applies in part UV. A pixel is dropped when (u − x0)(y1 − y0) − (v − y0)(x1 − x0) < 0 for any edge. - Saturation goes through HSV the way the shader does it, and is skipped at 1.0. - Coverage = decal alpha × layer opacity, blended in linear light. ## Not decoded (left out, and recorded in model.json `decorations.ink_rule`) - **Ink words.** Layers coloured by ink are not baked: a layer that sets an ink, or one whose decal is a mask (alpha is line art; red and blue about 0 and green flat where it covers). BC3 masks whose ink words have alpha 0 exist, so the decal itself is checked as well. Most tattoos are ink-coloured, and a colour tattoo's black outlines are often a separate ink layer, so for now many tattoos are missing or show only their colour fill. The words are not plain RGB: most body inks read as mint or teal. The code that turns them into the shader's colour stops was not found. - **Head makeup.** Codes such as `ff00ff00` are not decoded. Makeup layers all set an ink, so they are left out too. - **Other layer fields.** The layer mode (0–5), the flag bits and the `p3` parameters are not decoded. Follow-up PRs will cover the CPU packer, the ink encoding and the makeup codes. ## Checked - `outfit g_m_m_guardia_00 --look 5`: the chest and back colour tattoos land on the upper-body skin texture. - The same outfit in the viewer on the RTX 4080 shows the chest tattoo under the V-neck. - `ped-look g_m_m_koltandassoc_00`: decorations are assigned to the head, body upper and body lower parts of every outfit. ## Tests - Record and layer decode from a PSO laid out as the game's. - UV transform: affine, off-diagonal and projective. - Clip quad: "no clip" edges, a box from the data, and the degenerate edge. - Full-colour shading, the ink test and the mask test. - HSV saturation. - Bake blending, with missing and ink layers left out.
Read the decoration catalogue of data.rpf (struct 40e79f52, layers
77f0121d) and the wardrobe tag that lists an item's decorations, carry them
to the outfit's skin parts, and bake them into the body and head colour
textures for the viewer and the outfit GLB.

Placement, clip quad, saturation and coverage follow the game's bake
shader. Layers coloured by ink (the ink words are not decoded) are left out
and counted in model.json.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:27:35 +00:00
github-bot changed target branch from master to gh-pr/429/base 2026-11-27 03:03:01 +00:00
github manually merged commit 997524e10b into gh-pr/429/base 2026-11-27 03:03:01 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.