Tattoos: decode the ink words and bake ink-coloured decorations #442

Manually merged
github merged 4 commits from github-bot/gh-442 into gh-pr/442/base 2026-11-27 03:42:04 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-27 03:00 UTC · original
holdmysocks:claude/tattoo-ink-385 → master · +275 −65 · 2 files · 4 commits · merged 2026-11-27 03:40 UTC

Part of #385; follows #429. Ink-coloured tattoos are now baked. The ink words and the way the game turns them into colours are decoded from the game's CPU packer and its bake shader.

Ink words

An ink word is 0xAAVVSSHH: hue, saturation, value and alpha bytes, each / 255. With ramp = hue(H) (the game's HSV ramp), the packer makes three stops in sRGB:

  • stop 0 (dark): 0.1 V × lerp(1, ramp, S), alpha 1
  • stop 1 (the ink): V × lerp(1, ramp, S), alpha A
  • stop 2 (light): (0.45 + 0.55 V) × lerp(1, ramp, 0.55 S), alpha 1

Each stop goes to linear light and is quantised to a byte. An ink with alpha 0 is off. The common body ink ff438982 is a dark teal, sRGB about (0.12, 0.25, 0.26).

Shading (from the bake shader)

  • Ink 0 colours the decal: its stops at the decal's green (0 → stop 0, 0.5 → stop 1, 1 → stop 2), times ink 0's alpha. With ink 0 off, the decal keeps its own colour.
  • Ink 1 covers that by alpha × red, ink 2 by alpha × blue, each with its own stops at green.
  • Then saturation, then the blend the flag bits select: 0x4000000 multiply, 0x8000000 screen, 0x10000000 overlay, otherwise normal. All in linear light; coverage is decal alpha × opacity as before.
  • sRGB decals are sampled as linear, the way the GPU sampler reads them.

Still left out (counted in model.json decorations)

  • Head makeup: a layer with an ink whose p3 row has a non-zero fourth value. The game moves that ink toward a colour from a lookup in another colour space, which is not decoded yet. That is the makeup follow-up.
  • Mask decals on a layer with no ink: the game colours them at run time.
  • The layer mode (0–5) is a target index the game matches against the record it bakes into, not a blend mode. It is recorded but not used.

Confidence

  • High: the ink word decode (exe packer), the stops, and the shader's gradient and channel weights.
  • Medium: that the catalogue's blend flag bits reach the shader unchanged. The packer copies the layer flags raw, but the step between its record and the shader's record is not mapped.

Other changes

  • The layer now keeps p3. Catalogue cache version 2.
  • The baked texture name includes a bake-rule version, so earlier bakes are not reused.
  • The rule and ink_rule strings in model.json describe the decoded rule.

Checked

  • outfit g_m_m_guardia_00 --look 5: the ink tattoos (crow, moka pot, eye and dagger, and the outlines of the colour pieces) now bake in dark teal ink next to the full-colour car.
  • The same outfit in the viewer on the RTX 4080 shows the arm and chest tattoos.

Tests

  • Ink words: white, off, the teal body ink, and red with its desaturated light stop.
  • Ink 0/1/2 follow green, red and blue; ink 0 is scaled by its alpha.
  • Blend flags and blend maths; the makeup test.
  • Bake: missing decal, uncoloured mask, makeup left out, multiply with a black ink.
  • p3 read from a PSO laid out as the game's.
**@⁠holdmysocks** on GitHub · 2026-11-27 03:00 UTC · [original](https://github.com/holdmysocks/SixNG/pull/442) `holdmysocks:claude/tattoo-ink-385` → `master` · +275 −65 · 2 files · 4 commits · merged 2026-11-27 03:40 UTC Part of #385; follows #429. Ink-coloured tattoos are now baked. The ink words and the way the game turns them into colours are decoded from the game's CPU packer and its bake shader. ## Ink words An ink word is `0xAAVVSSHH`: hue, saturation, value and alpha bytes, each / 255. With `ramp = hue(H)` (the game's HSV ramp), the packer makes three stops in sRGB: - stop 0 (dark): `0.1 V × lerp(1, ramp, S)`, alpha 1 - stop 1 (the ink): `V × lerp(1, ramp, S)`, alpha A - stop 2 (light): `(0.45 + 0.55 V) × lerp(1, ramp, 0.55 S)`, alpha 1 Each stop goes to linear light and is quantised to a byte. An ink with alpha 0 is off. The common body ink `ff438982` is a dark teal, sRGB about (0.12, 0.25, 0.26). ## Shading (from the bake shader) - Ink 0 colours the decal: its stops at the decal's green (0 → stop 0, 0.5 → stop 1, 1 → stop 2), times ink 0's alpha. With ink 0 off, the decal keeps its own colour. - Ink 1 covers that by `alpha × red`, ink 2 by `alpha × blue`, each with its own stops at green. - Then saturation, then the blend the flag bits select: `0x4000000` multiply, `0x8000000` screen, `0x10000000` overlay, otherwise normal. All in linear light; coverage is decal alpha × opacity as before. - sRGB decals are sampled as linear, the way the GPU sampler reads them. ## Still left out (counted in model.json `decorations`) - **Head makeup**: a layer with an ink whose `p3` row has a non-zero fourth value. The game moves that ink toward a colour from a lookup in another colour space, which is not decoded yet. That is the makeup follow-up. - **Mask decals on a layer with no ink**: the game colours them at run time. - The layer `mode` (0–5) is a target index the game matches against the record it bakes into, not a blend mode. It is recorded but not used. ## Confidence - High: the ink word decode (exe packer), the stops, and the shader's gradient and channel weights. - Medium: that the catalogue's blend flag bits reach the shader unchanged. The packer copies the layer flags raw, but the step between its record and the shader's record is not mapped. ## Other changes - The layer now keeps `p3`. Catalogue cache version 2. - The baked texture name includes a bake-rule version, so earlier bakes are not reused. - The `rule` and `ink_rule` strings in model.json describe the decoded rule. ## Checked - `outfit g_m_m_guardia_00 --look 5`: the ink tattoos (crow, moka pot, eye and dagger, and the outlines of the colour pieces) now bake in dark teal ink next to the full-colour car. - The same outfit in the viewer on the RTX 4080 shows the arm and chest tattoos. ## Tests - Ink words: white, off, the teal body ink, and red with its desaturated light stop. - Ink 0/1/2 follow green, red and blue; ink 0 is scaled by its alpha. - Blend flags and blend maths; the makeup test. - Bake: missing decal, uncoloured mask, makeup left out, multiply with a black ink. - `p3` read from a PSO laid out as the game's.
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.
Ink words are HSV plus alpha (0xAAVVSSHH). The game's CPU packer turns
each into three linear colour stops, and the bake shader picks along
them by the decal's green: ink 0 colours the decal, ink 1 covers it by
red and ink 2 by blue. Layers blend by the multiply, screen and overlay
flag bits in linear light. sRGB decals are sampled as linear.

Head makeup (an ink with a non-zero p3 w) and masks on layers with no
ink are still left out and counted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:02:49 +00:00
# Conflicts:
#	crates/sixng-core/src/export.rs
#	crates/sixng-core/src/peddeco.rs
github-bot changed target branch from master to gh-pr/442/base 2026-11-27 03:42:03 +00:00
github manually merged commit d8b49d50e9 into gh-pr/442/base 2026-11-27 03:42:04 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.