mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.76k stars 35.38k forks source link

HemisphereLight direction uniform #23891

Open sunag opened 2 years ago

sunag commented 2 years ago

We are using a HemisphereLight.position property to define a direction to HemisphereLight normals, but that doesn't seem entirely appropriate to me, since it's an angle, and angle is .rotation/.euler.

I think that we could use .getWorldDirection() instead of .position?

Can I start like this on WebGPU?

WebGL Code: https://github.com/mrdoob/three.js/blob/8db7a598ed6e71538e286e5c56c02cc5823157dc/src/renderers/webgl/WebGLLights.js#L530-L532

WestLangley commented 2 years ago

Yes, using the position property to define the orientation of the HemisphereLight is unusual.

If a change is desired, I think the most logical API would be to use the .up property instead, but I am not sure it is worth changing.

WestLangley commented 2 years ago

This line is redundant.

uniforms.direction.normalize(); 
Mugen87 commented 2 years ago

Related #16555.

Mugen87 commented 2 years ago

It seems users find it confusing that HemisphereLight does not react when changing its rotation properties. On the other hand, #16555 pointed out that ambient and hemisphere lights are in fact simplified light probes which do not have a rotation by definition.

BabylonJS uses a separate direction vector for the definition of a hemispheric light. It seems using Object3D.up could be indeed a proper alternative.

makc commented 2 years ago

so you find using hemi.position weird, but directional light is fine lol

Mugen87 commented 2 years ago

It was previously discussed to remove the target property and orient directional and spot lights as you would expect. There is an existing PR but I've lately implemented this feature by myself to better understand the change: https://github.com/Mugen87/three.js/commit/a2a8005d18012f90929060ddd9d5b288c4e6da60

Unfortunately, such a change will noticeably impact user code. You can easily see this at the number of examples that break which the PR.