three.js icon indicating copy to clipboard operation
three.js copied to clipboard

PointLight/SpotLight: `distance` does not influence shadows anymore.

Open Mugen87 opened this issue 1 year ago • 1 comments

Fixes #27290. Closes #27345.

Description

The distance property is currently coupled to the far value of shadow cameras in context of spot and point lights. That's because the engine provides an automatism that configures a proper far values based on the light's distance. However, the current implementation is inconsistent and produces a buggy behavior like reported in #27290 or #27523.

Since there is no clean way to fix this I suggest to completely remove the coupling. That means distance does not affect shadows anymore.

Devs who rely on a physically correct workflow won't notice this change since they do not change the default distance value 0. Devs with a custom distance value might have to update their light.shadow.camera.far to an appropriate value after this change. So this change needs to be noted in the migration guide.

With this PR devs always have to configure the shadow camera's frustum like with directional lights or when distance is zero which should produce a more predictable engine behavior.

Mugen87 avatar Feb 10 '24 12:02 Mugen87

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
676.1 kB (168.2 kB) 676 kB (168.1 kB) -107 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
457.2 kB (111 kB) 457.2 kB (111 kB) +0 B

github-actions[bot] avatar Feb 10 '24 12:02 github-actions[bot]

After some more thinking I prefer #27345. It's in general a good thing when the engine tries to provide optimized shadow frustums based on light settings. This PR seems to be a step backward and makes the engine harder to use.

Mugen87 avatar Feb 20 '24 10:02 Mugen87