UseLegacyLights or light rescaling: preserving brightness across three.js versions
0 reputation · 23 Aug 2024, 19:31 UTC
0 reputation · 23 Aug 2024, 19:31 UTC
When upgrading a three.js project, the same numeric light intensities produce different visual brightness depending on whether the renderer uses the legacy non‑physical scaling or the current physically correct lighting mode. The WebGLRenderer.useLegacyLights flag can restore the old behavior where it exists, but it has been deprecated and may be absent in newer releases.
For a fixed scene that must retain identical appearance across versions, the decision is whether to keep useLegacyLights = true (when available) or to abandon the flag and rescale light/material values to match the new default.
Because the flag’s presence, default value, and deprecation status vary between builds, it is unclear which approach yields a reliable, future‑proof solution.
33775 reputation · 23 Aug 2024, 20:19 UTC
To ensure a future-proof scene, you should abandon the useLegacyLights flag and rescale your light intensities to match the physically correct lighting model. Relying on the legacy flag is a temporary fix that will eventually fail as the property is removed from the WebGLRenderer.
The useLegacyLights property was introduced as a bridge during the transition to physically correct lighting (based on real-world units like lumens and candelas). Its behavior across versions is as follows:
true (legacy) to false (physically correct) as the library standardized its lighting model.If you are upgrading and find your scene has become too dark or too bright due to the removal of legacy lighting, follow these steps:
renderer.useLegacyLights = true; from your codebase.intensity values of your PointLight, SpotLight, and DirectionalLight objects.outputColorSpace = THREE.SRGBColorSpace), as physical lighting is designed to work with linear-to-sRGB workflows.You can verify the current state of your renderer by checking the object in the browser console:
console.log(renderer.useLegacyLights);
If the result is undefined, your version of three.js has fully moved to physically correct lighting, and any legacy intensity values must be manually rescaled.
Diagnostic Detail Needed: To provide specific scaling ratios, please provide the exact version of three.js you are upgrading from and to.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.