# Player swatch and reflection color spaces (r331)

The r330 display encoding exposed two renderer inconsistencies. CSS hex paint
and vinyl colors still entered the shader as their sRGB byte values, despite
being combined with linear texture samples. The local reflection cube also
stored the shader's display-encoded output in an ordinary RGBA texture and
then sampled those values as linear light. These operations brightened the
chosen paint and its reflections twice.

`playerColorRgb` now applies the inverse sRGB transfer function to paint/vinyl
swatches before sending their RGB uniforms. The existing `#858c94` default and
all selected/stored colors are preserved. `debugLinearOutput` retains the
legacy byte-value path. Reflection capture disables display encoding while
writing the linear RGBA cube, then restores the previous uniform; the final
screen pass retains r330's sRGB output.

## Same-view packaged evidence

Both Chrome captures use the packaged viewer at Route 450, distance 550,
radius 120, the 240SX, and a 1280×720 viewport. Both reached `City scene ready`
with 22,508 nearby triangles, 128 textures, 832 routes, a ready 64-pixel local
reflection cube, and an empty page error readout. The player and probe origin
were identical. Ambient traffic advanced independently between the captures.

| Evidence | Before | After |
| --- | --- | --- |
| `#858c94` paint RGB uniform | (0.521569, 0.549020, 0.580392) | (0.234551, 0.262251, 0.296138) |
| Rear bumper crop mean RGB | (210.87, 216.42, 222.89) | (150.84, 159.30, 169.27) |
| Road crop mean RGB | (62.76, 65.57, 66.24) | (62.76, 65.57, 66.24) |

The bumper crop is x549–687, y433–460; the road crop is x910–1100, y355–450.
The uniform change is the exact inverse transfer of the existing swatch,
not a new paint choice. The car now reads gray with visible shading instead
of almost white; the road crop is byte-identical. Source and packaged viewer
files match.

- [Before](../webgl-city/review/images/473-r331-player-color-before.png)
- [After](../webgl-city/review/images/474-r331-player-color-after.png)

## Remaining limits

This corrects the viewer's chosen preview paint. It does not recover the
retail player's selected paint, harmonic coefficients, or material bindings.
Traffic paint remains its existing unresolved fallback. Exported glTF material
factors and vertex colors retain their current interpretations; no evidence
here establishes alternate transfer functions for the legacy source records.
The rear glass still lacks its retail pane texture/state, and its defroster
lines remain the source image. No opacity, lighting coefficient, transform,
road material, building placement, or stream selection was changed.

The [r332 contribution comparison](player-gray-brightness-r332.md) confirms
that the selected swatch now round-trips exactly; the remaining brighter
panels come from the existing approximate lighting and coat terms.
