engine icon indicating copy to clipboard operation
engine copied to clipboard

Implement support for physically based light intensity units

Open mvaligursky opened this issue 4 years ago • 6 comments

The engine is currently not using physically based units to specify light intensity, which would allow an easy way to realistically set up lights in the scene.

some references:

  • filament (lighting section) https://google.github.io/filament/Filament.md.html
  • frostbite, light units section https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
  • unreal engine https://docs.unrealengine.com/4.26/en-US/BuildingWorlds/LightingAndShadows/PhysicalLightUnits/
  • unity engine https://docs.unity3d.com/Packages/[email protected]/manual/Physical-Light-Units.html

This would be useful when implementing support for punctual lights https://github.com/playcanvas/engine/issues/2061 which specifies light intensities in physical units.

Note that Blender does not correctly export light intensities into gltf format, as it exports them in watts instead of expected lumens. https://github.com/KhronosGroup/glTF-Blender-IO/issues/564

mvaligursky avatar Jun 21 '21 14:06 mvaligursky

Bump priority up on this.

slimbuck avatar Oct 28 '21 16:10 slimbuck

Bump! It might not be physically based but does anyone know what the units currently are?

MAG-AdrianMeredith avatar Jul 26 '22 08:07 MAG-AdrianMeredith

Is this something @GSterbrant might want to investigate?

slimbuck avatar Jul 26 '22 08:07 slimbuck

It's actually a bit complicated, since it's different for different types of lights. Filament describes it very well here: https://google.github.io/filament/Filament.md.html#lighting/units

Of course this puts even more emphasis on the importance of it. Using 1 for the sun intensity doesn't really translate to using 1 as intensity for a spotlight.

GSterbrant avatar Jul 26 '22 09:07 GSterbrant

This might help https://docs.google.com/spreadsheets/d/1Ce9XCC2Ub9eVjAQdYbYdLvlkDBJ_0GtAyRbSF0KJWzE/edit#gid=0

Basically, different lights use different units. GLTF spec is the one that probably makes sense. I think threejs had a nasty flag like usePhysicalLights to enable the change

MAG-AdrianMeredith avatar Jul 26 '22 10:07 MAG-AdrianMeredith

We'd probably a flag like that too, to not break old projects...

GSterbrant avatar Jul 26 '22 11:07 GSterbrant

closing as its fixed in https://github.com/playcanvas/engine/pull/4618

mvaligursky avatar Sep 23 '22 11:09 mvaligursky