Brown–Conrady lens-distortion math for the picking system.
TypeScript port of the GLSL applyDistortion function in
rendering/post-processing/mega/shader.glsl.ts:117-128 (and its
TSL counterpart in mega/shader.tsl.ts). Uses the green-channel
distortion (the reference channel — no chromatic offset).
Maps from distorted screen space back into undistorted source space.
The picking system applies it to mouse coords so they index into the
undistorted pick buffer correctly when post-processing distortion is
active.
Extracted from PickingSystem so the parity contract with the
shader can be unit-tested directly. The caller supplies a scratch
{ x, y } so the hot path stays allocation-free.
Brown–Conrady lens-distortion math for the picking system.
TypeScript port of the GLSL
applyDistortionfunction inrendering/post-processing/mega/shader.glsl.ts:117-128(and its TSL counterpart inmega/shader.tsl.ts). Uses the green-channel distortion (the reference channel — no chromatic offset).Maps from distorted screen space back into undistorted source space. The picking system applies it to mouse coords so they index into the undistorted pick buffer correctly when post-processing distortion is active.
Extracted from
PickingSystemso the parity contract with the shader can be unit-tested directly. The caller supplies a scratch{ x, y }so the hot path stays allocation-free.