Ped lenses: tinted glass with the game's dual-source blend #503

Manually merged
github merged 1 commit from github-bot/gh-503 into gh-pr/503/base 2026-11-27 20:27:01 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-27 20:10 UTC · original
holdmysocks:claude/people-lens → master · +336 −8 · 11 files · 1 commits · merged 2026-11-27 20:23 UTC

Sunglasses and spectacle lenses (ped_standard_muv_alpha) were drawn opaque and in the frame's colour. They now draw as tinted glass, using the game's own blend and per-sub-material values.

What was wrong

  1. Wrong sub-material. The fabric bake took the lens's sub-material from the frame's materialid map, so lenses got the frame's sub 0 (pink) instead of their glass sub-materials (3/5/6 on Connie's cs_iris_specssquare_fr1_000_large). Materials without a materialid map of their own now take the vertex part number, even where they share the frame's texture.
  2. No glass blend. The viewer used plain alpha blending. The game blends these programs dual-source: dst' = RT0 + dst × RT1.

What is built (traced from the shader archive work, notes 42es and follow-ups 1–4)

  • matlib::Library::transmission: the per-sub-material record as the game's parser fills it. It starts from the parameter defaults, then applies the profile's fields at index 255 or the field's own index. Fields:

    • Absorption σA and f1088873 wA
    • scattering σB and 000482aa wB
    • 5ba33632 d_base, 95f8d114 d_mask, a14dce4e d_max
    • thicknessanisotropy p, 0604e865 h0
    • c391fd51 k, f920ffb1 t

    Covered by a test against the lens profile d53758cd.

  • Opacity a0 = the tile material map alpha, baked into the lens texels' base alpha. Then α = sat(a0/k) and o = sat((a0−t)/(1−t)).

  • Absorption: σ = σA(1 − b·wA) + σB(1 + (b−1)·wB).

  • View path:

    • d0 = d1, or lerp(h0, d1, _COLOR0.a) when h0 ≥ 0
    • c = max(1e-4, |N·V|)
    • r = 1/c (p > 0) or c
    • d = max(0, d0 + |p|(min(d_max, r·d0) − d0))
    • T = exp(−σd)
  • Blend:

    • RT1 = (1−o)(1 − α + αT(1 − αF)); RT1.a = the max of its rgb
    • RT0 = o × diffuse + α × specular
    • Drawn through a dual-source pipeline (glass.wgsl, a separate module built only when the device has DUAL_SOURCE_BLENDING). The feature is requested when the adapter has it.
  • Connie's lens values:

    • σA = 5, σB = 0.01, wA = wB = 0
    • d_base = 0.02, d_max = 11.67, p = 10.79, h0 = −0.1
    • k = 0.1, t = 0.9
    • tile alpha 64/255, which gives α = 1 and o = 0
    • Face-on T ≈ 0.90, darker toward the slanted edges

Not traced, so left out or approximated

  • Fade factor: drawn fully shown.
  • Mask m on d_mask: taken as 0. Exact for the lens, where d_mask = 0.
  • speculartex alpha in a0: taken as 255 (it is 255 on the lens looked at; the export does not keep it).
  • The light carried through in RT0: left out.
  • The refraction pass: whether it runs is not traced.
  • Fog: applied to RT0 as on other blended draws.
  • F0 inputs: F and the lighting use the viewer's own F0 and environment table. The table has the game's split-sum form.
  • Static vs skinned technique: chosen by the CPU, not traced. Both give A9 = 1 with the default extinction colours.
  • One record per lens material: the record of the sub-material most of its vertices name.
  • Tone mapping: the model viewer tone-maps per material, so the multiply acts on tone-mapped colour, as all its blending does.
  • Devices without dual-source blending: keep the old alpha blend.

Checks

  • cargo test --release -p sixng-core -p sixng-gui --lib --bins
  • Connie close-up rendered on the RTX 4080: lenses show the eyes through tinted glass. Before, they were opaque pink.
**@⁠holdmysocks** on GitHub · 2026-11-27 20:10 UTC · [original](https://github.com/holdmysocks/SixNG/pull/503) `holdmysocks:claude/people-lens` → `master` · +336 −8 · 11 files · 1 commits · merged 2026-11-27 20:23 UTC Sunglasses and spectacle lenses (`ped_standard_muv_alpha`) were drawn opaque and in the frame's colour. They now draw as tinted glass, using the game's own blend and per-sub-material values. ## What was wrong 1. **Wrong sub-material.** The fabric bake took the lens's sub-material from the frame's `materialid` map, so lenses got the frame's sub 0 (pink) instead of their glass sub-materials (3/5/6 on Connie's `cs_iris_specssquare_fr1_000_large`). Materials without a `materialid` map of their own now take the vertex part number, even where they share the frame's texture. 2. **No glass blend.** The viewer used plain alpha blending. The game blends these programs dual-source: dst' = RT0 + dst × RT1. ## What is built (traced from the shader archive work, notes 42es and follow-ups 1–4) - **`matlib::Library::transmission`**: the per-sub-material record as the game's parser fills it. It starts from the parameter defaults, then applies the profile's fields at index 255 or the field's own index. Fields: - `Absorption` σA and `f1088873` wA - `scattering` σB and `000482aa` wB - `5ba33632` d_base, `95f8d114` d_mask, `a14dce4e` d_max - `thicknessanisotropy` p, `0604e865` h0 - `c391fd51` k, `f920ffb1` t Covered by a test against the lens profile `d53758cd`. - **Opacity** a0 = the tile material map alpha, baked into the lens texels' base alpha. Then α = sat(a0/k) and o = sat((a0−t)/(1−t)). - **Absorption**: σ = σA(1 − b·wA) + σB(1 + (b−1)·wB). - **View path**: - d0 = d1, or lerp(h0, d1, `_COLOR0.a`) when h0 ≥ 0 - c = max(1e-4, |N·V|) - r = 1/c (p > 0) or c - d = max(0, d0 + |p|(min(d_max, r·d0) − d0)) - T = exp(−σd) - **Blend**: - RT1 = (1−o)(1 − α + αT(1 − αF)); RT1.a = the max of its rgb - RT0 = o × diffuse + α × specular - Drawn through a dual-source pipeline (`glass.wgsl`, a separate module built only when the device has `DUAL_SOURCE_BLENDING`). The feature is requested when the adapter has it. - **Connie's lens values**: - σA = 5, σB = 0.01, wA = wB = 0 - d_base = 0.02, d_max = 11.67, p = 10.79, h0 = −0.1 - k = 0.1, t = 0.9 - tile alpha 64/255, which gives α = 1 and o = 0 - Face-on T ≈ 0.90, darker toward the slanted edges ## Not traced, so left out or approximated - **Fade factor:** drawn fully shown. - **Mask m on d_mask:** taken as 0. Exact for the lens, where d_mask = 0. - **speculartex alpha in a0:** taken as 255 (it is 255 on the lens looked at; the export does not keep it). - **The light carried through in RT0:** left out. - **The refraction pass:** whether it runs is not traced. - **Fog:** applied to RT0 as on other blended draws. - **F0 inputs:** F and the lighting use the viewer's own F0 and environment table. The table has the game's split-sum form. - **Static vs skinned technique:** chosen by the CPU, not traced. Both give A9 = 1 with the default extinction colours. - **One record per lens material:** the record of the sub-material most of its vertices name. - **Tone mapping:** the model viewer tone-maps per material, so the multiply acts on tone-mapped colour, as all its blending does. - **Devices without dual-source blending:** keep the old alpha blend. ## Checks - `cargo test --release -p sixng-core -p sixng-gui --lib --bins` - Connie close-up rendered on the RTX 4080: lenses show the eyes through tinted glass. Before, they were opaque pink.
Lenses that share their frame's texture take their sub-material from the
vertex part number, not the frame's materialid map. ped_standard_muv_alpha
lenses get the material library's transmission record and draw with the
game's dual-source blend (dst' = RT0 + dst x RT1), opacity from the tile
material map alpha.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 20:16:28 +00:00
github-bot changed target branch from master to gh-pr/503/base 2026-11-27 20:26:59 +00:00
github manually merged commit 0d3c5387b8 into gh-pr/503/base 2026-11-27 20:27:01 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.