Revert texture tinting by the lit-color plane -- it double-colours
Found my own prior documentation (IG-SHADING-MODEL.md sec 2, written earlier this session before compaction) that already establishes: the wire's 0x1a texture uploads arrive ALREADY colourised (the material ramp is pre-baked on this path, per the shipped libDPL header model cross-referenced against BT411's context/rendering.md). Tinting them again with the lit-color plane double-colours the result -- exactly the "more colors but neither correct" outcome reported live (sky/ground now differ, but neither right). Keep the lit-color plane for FLAT (untextured) polys only, where it replaces a hardcoded placeholder with real per-polygon data; textured polys sample unmodified, as documented. The underlying r24/g24/b24 mechanism itself is still real and worth understanding precisely (see open-questions tracking), but applying it as a texture tint was the wrong model. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -176,9 +176,13 @@ class Renderer:
|
||||
tid = raw[..., 4].view(np.float32).astype(np.int64)
|
||||
hasuv = raw[..., 5].view(np.float32)
|
||||
# lit color (dvpx_r24/g24/b24 -> TREEclmpintoMEM): the polygon's
|
||||
# computed lighting, clamped to [0,255] -- see build_prims. Used as
|
||||
# the direct color for flat polys, and as a multiplicative tint on
|
||||
# sampled texture color for textured ones.
|
||||
# computed lighting, clamped to [0,255] -- see build_prims. Used ONLY
|
||||
# for flat (untextured) polys. NOT applied to textured polys: per
|
||||
# IG-SHADING-MODEL.md sec 2 (established from IG-board ground truth
|
||||
# BEFORE this session's misstep), the wire's 0x1a texture uploads
|
||||
# arrive ALREADY colourised (the ramp is pre-baked on this path) --
|
||||
# tinting them again double-colours, which is exactly the "more
|
||||
# colors but neither correct" result the user reported live.
|
||||
lit = np.stack([raw[..., 6].view(np.float32),
|
||||
raw[..., 7].view(np.float32),
|
||||
raw[..., 8].view(np.float32)], axis=-1)
|
||||
@@ -204,6 +208,5 @@ class Renderer:
|
||||
# texture, so full-frame sampling here was O(ntex x W x H))
|
||||
ui = wrap_index((ucoord[sel] * tu) >> 8, tu, wrap_u)
|
||||
vi = wrap_index((vcoord[sel] * tv) >> 8, tv, wrap_v)
|
||||
samp = arr[vi, ui].astype(np.float64) * (lit[sel] / 255.0)
|
||||
composite_masked(img, sel, np.clip(samp, 0, 255).astype(np.uint8), cut_mode)
|
||||
composite_masked(img, sel, arr[vi, ui], cut_mode)
|
||||
return img
|
||||
|
||||
Reference in New Issue
Block a user