Tattoo bake: limit a region-flagged record to the part's mesh #539

Manually merged
github merged 1 commit from github-bot/gh-539 into gh-pr/539/base 2026-11-28 05:25:14 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-28 05:13 UTC · original
holdmysocks:claude/tattoo-region-mask-385 → master · +197 −5 · 2 files · 1 commits · merged 2026-11-28 05:23 UTC

Part of #385: the per-texel region mask for decorations.

A decoration record with a layer flagged 0x2 limits every layer to the part's own mesh. I traced this through the game's bake.

  • CPU side. Before the decorations are drawn, the bake draws the ped's mesh into a mask texture, once per needed group. That mask is the mesh's UV coverage.
  • Mesh shader (MSNC_VS_BakeDecorations). If any layer in the record has 0x2, it sets a per-vertex z: 1 when the mask texels at (x-1, y-1), (x-1, y), (x, y+1) and (x+1, y+1) all lie on the mesh, else 0. z is interpolated over each triangle.
  • Pixel shader (PS_BakeDecorations). A layer's coverage starts at min(opacity, z).

What changes:

  • peddeco::region_cap builds that cap from the part's triangles, in the layout the texture is baked in (TEXCOORD_1 on the upper body, from #530). Gutter texels take their covered neighbours' value.
  • bake_capped lowers a layer's coverage only where the cap is below its opacity. bake is unchanged for records without the flag.
  • The export's record notes describe the rule and count the capped layers. The bake rule version is bumped.

Left out: flag 0x40. In a record without 0x2, it has the shader take z from a vertex colour channel picked by the layer's group. On the characters checked, applying it faded a whole tattoo (the guardia's teal torso piece in outfits 17 and 37) to about 6%, so I'm not confident it's read correctly. It is not applied.

Reach: 3 of the 7,509 records carry 0x2. All three are head records (85 layers) on mesh-less face items in four generic ped wardrobes. Andy, Viper and the guardia (outfit 17) bake byte-identical textures before and after.

Tests:

  • the flag marks the record (0x40 alone does not);
  • the mask cap is 1 where the mesh covers a vertex's texels and 0 at a vertex whose texels fall off the mesh;
  • a cap lowers coverage only below the layer's opacity.

Still open on #385:

  • flag 0x40;
  • which stream the CPU binds to the bake shader's UV slot;
  • Vicki's and Lucia's tattoos from outside the wardrobe data.
**@⁠holdmysocks** on GitHub · 2026-11-28 05:13 UTC · [original](https://github.com/holdmysocks/SixNG/pull/539) `holdmysocks:claude/tattoo-region-mask-385` → `master` · +197 −5 · 2 files · 1 commits · merged 2026-11-28 05:23 UTC Part of #385: the per-texel region mask for decorations. A decoration record with a layer flagged 0x2 limits every layer to the part's own mesh. I traced this through the game's bake. - **CPU side.** Before the decorations are drawn, the bake draws the ped's mesh into a mask texture, once per needed group. That mask is the mesh's UV coverage. - **Mesh shader** (`MSNC_VS_BakeDecorations`). If any layer in the record has 0x2, it sets a per-vertex z: 1 when the mask texels at (x-1, y-1), (x-1, y), (x, y+1) and (x+1, y+1) all lie on the mesh, else 0. z is interpolated over each triangle. - **Pixel shader** (`PS_BakeDecorations`). A layer's coverage starts at min(opacity, z). What changes: - `peddeco::region_cap` builds that cap from the part's triangles, in the layout the texture is baked in (TEXCOORD_1 on the upper body, from #530). Gutter texels take their covered neighbours' value. - `bake_capped` lowers a layer's coverage only where the cap is below its opacity. `bake` is unchanged for records without the flag. - The export's record notes describe the rule and count the capped layers. The bake rule version is bumped. **Left out:** flag 0x40. In a record without 0x2, it has the shader take z from a vertex colour channel picked by the layer's group. On the characters checked, applying it faded a whole tattoo (the guardia's teal torso piece in outfits 17 and 37) to about 6%, so I'm not confident it's read correctly. It is not applied. **Reach:** 3 of the 7,509 records carry 0x2. All three are head records (85 layers) on mesh-less face items in four generic ped wardrobes. Andy, Viper and the guardia (outfit 17) bake byte-identical textures before and after. **Tests:** - the flag marks the record (0x40 alone does not); - the mask cap is 1 where the mesh covers a vertex's texels and 0 at a vertex whose texels fall off the mesh; - a cap lowers coverage only below the layer's opacity. **Still open on #385:** - flag 0x40; - which stream the CPU binds to the bake shader's UV slot; - Vicki's and Lucia's tattoos from outside the wardrobe data.
A record with a layer flagged 0x2 has the bake mesh shader cap every
layer's coverage by the mesh's own coverage: z = 1 at a vertex whose four
mask texels lie on the mesh, else 0, interpolated over the triangles, and
coverage starts at min(opacity, z). The cap is built in the layout the
texture is baked in (TEXCOORD_1 on the upper body). Flag 0x40 (a vertex
colour channel as z) is left out.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 05:13:33 +00:00
github-bot changed target branch from master to gh-pr/539/base 2026-11-28 05:25:12 +00:00
github manually merged commit 4a4db7f658 into gh-pr/539/base 2026-11-28 05:25:14 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.