Ped decorations: bake head makeup toward the skin tone #458

Manually merged
github merged 3 commits from github-bot/gh-458 into gh-pr/458/base 2026-11-27 05:54:52 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-27 04:43 UTC · original
holdmysocks:claude/tattoo-makeup-385 → master · +292 −56 · 13 files · 3 commits · merged 2026-11-27 05:52 UTC

Part of #385; follows #442. Head makeup is now baked. How the game tints a makeup ink, and where the skin tone comes from, are decoded from the exe.

Makeup inks

A makeup layer has an ink whose p3 row (dL, da, db, w) has w ≠ 0. Before packing, the game runs that ink through one function:

  1. If w is 0, the ink is unchanged.
  2. Otherwise the ink word (HSV bytes) goes to RGB with the game's HSV→RGB.
  3. The target colour is the skin tone word's R, G, B bytes / 255, taken to CIELAB (sRGB D65 matrix), shifted by (dL, da, db), then taken back to sRGB.
  4. The ink becomes lerp(ink, target, w) in sRGB.
  5. The result is repacked as HSV bytes with the ink's original alpha.

Then the ink is baked like any other ink (#442). So p3 = (0, 0, 0, 1) paints the plain skin tone, and (-30, 10, 12, 1) paints a darker, redder shade of it. Each ink of a makeup layer has its own row.

Skin tone

  • The tone record table is a PSO in the data archive. Each record has a name hash and a linear colour (vec3). The game sRGB-encodes that colour into the word the makeup function reads, with alpha ff.
  • A ped item names its tone with wardrobe tag 0d6de047. Ped looks now carry it per part (skin_tone), and the outfit export and the viewer pass it to the bake. With no tag, the game's default tone ac2315da is used.
  • The baked texture name includes the tone, so each tone gets its own texture.

Mirrored layers

The bake shader folds the part UV before the decal transform when flag 0x400 (U) or 0x800 (V) is set: u' = 0.5 − |u − 0.5|. One decal then lands on both halves of the texture. Eye make-up uses this, so it now shows on both eyes. The clip quad still uses the raw UV.

Confidence

  • High: the makeup function, the HSV↔RGB and Lab maths, and the order of the steps (read from the exe).
  • High: the U/V fold (the shader's abs modifier on u − 0.5, selected by those two bits).
  • Medium: the Lab white point. The exe fills it at start-up; the bake uses the matrix's row sums (D65).
  • Medium: the tone word. The game keeps three tone words per ped. Each defaults to the sRGB-encoded tone colour, and a part can override one with its own word scaled by the skin/reference ratio. That override is not implemented.

Still left out (counted in the export's decorations record)

  • Mask decals on a layer with no ink. Flag bits 0x4/0x8/0x10, which these layers carry, are not read by the bake shader, so the CPU decides what happens to them. Still being traced.
  • Flag 0x1000000 samples a second texture in the shader; not handled yet.

Checked

  • outfit g_f_m_san4san_00 --look 0: lipstick bakes red on the lips, eye make-up on both eyes, and the body ink tattoos as before.
  • The same outfit in the viewer on the RTX 4080.

Tests

  • Makeup moves an ink toward the skin tone; w = 0 leaves it unchanged.
  • The U/V fold.
  • The existing ink and bake tests.
**@⁠holdmysocks** on GitHub · 2026-11-27 04:43 UTC · [original](https://github.com/holdmysocks/SixNG/pull/458) `holdmysocks:claude/tattoo-makeup-385` → `master` · +292 −56 · 13 files · 3 commits · merged 2026-11-27 05:52 UTC Part of #385; follows #442. Head makeup is now baked. How the game tints a makeup ink, and where the skin tone comes from, are decoded from the exe. ## Makeup inks A makeup layer has an ink whose `p3` row `(dL, da, db, w)` has `w ≠ 0`. Before packing, the game runs that ink through one function: 1. If `w` is 0, the ink is unchanged. 2. Otherwise the ink word (HSV bytes) goes to RGB with the game's HSV→RGB. 3. The target colour is the skin tone word's R, G, B bytes / 255, taken to CIELAB (sRGB D65 matrix), shifted by `(dL, da, db)`, then taken back to sRGB. 4. The ink becomes `lerp(ink, target, w)` in sRGB. 5. The result is repacked as HSV bytes with the ink's original alpha. Then the ink is baked like any other ink (#442). So `p3 = (0, 0, 0, 1)` paints the plain skin tone, and `(-30, 10, 12, 1)` paints a darker, redder shade of it. Each ink of a makeup layer has its own row. ## Skin tone - The tone record table is a PSO in the data archive. Each record has a name hash and a linear colour (vec3). The game sRGB-encodes that colour into the word the makeup function reads, with alpha `ff`. - A ped item names its tone with wardrobe tag `0d6de047`. Ped looks now carry it per part (`skin_tone`), and the outfit export and the viewer pass it to the bake. With no tag, the game's default tone `ac2315da` is used. - The baked texture name includes the tone, so each tone gets its own texture. ## Mirrored layers The bake shader folds the part UV before the decal transform when flag `0x400` (U) or `0x800` (V) is set: `u' = 0.5 − |u − 0.5|`. One decal then lands on both halves of the texture. Eye make-up uses this, so it now shows on both eyes. The clip quad still uses the raw UV. ## Confidence - High: the makeup function, the HSV↔RGB and Lab maths, and the order of the steps (read from the exe). - High: the U/V fold (the shader's abs modifier on `u − 0.5`, selected by those two bits). - Medium: the Lab white point. The exe fills it at start-up; the bake uses the matrix's row sums (D65). - Medium: the tone word. The game keeps three tone words per ped. Each defaults to the sRGB-encoded tone colour, and a part can override one with its own word scaled by the skin/reference ratio. That override is not implemented. ## Still left out (counted in the export's `decorations` record) - Mask decals on a layer with no ink. Flag bits `0x4`/`0x8`/`0x10`, which these layers carry, are not read by the bake shader, so the CPU decides what happens to them. Still being traced. - Flag `0x1000000` samples a second texture in the shader; not handled yet. ## Checked - `outfit g_f_m_san4san_00 --look 0`: lipstick bakes red on the lips, eye make-up on both eyes, and the body ink tattoos as before. - The same outfit in the viewer on the RTX 4080. ## Tests - Makeup moves an ink toward the skin tone; `w = 0` leaves it unchanged. - The U/V fold. - The existing ink and bake tests.
Makeup inks (p3 w != 0) move toward the ped's skin tone shifted in CIELAB,
as the game's makeup function does. The skin tone comes from wardrobe tag
0d6de047 and the tone table (default ac2315da). Flags 0x400/0x800 fold U/V
about the middle before the decal transform.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 04:47:52 +00:00
github-bot changed target branch from master to gh-pr/458/base 2026-11-27 05:54:51 +00:00
github manually merged commit aedac92ef8 into gh-pr/458/base 2026-11-27 05:54:52 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.