cesium icon indicating copy to clipboard operation
cesium copied to clipboard

Multiple light sources and light types

Open lilleyse opened this issue 5 years ago • 12 comments

Custom light sources were added in https://github.com/AnalyticalGraphicsInc/cesium/pull/8493 but there are still some limitations: only one light is supported and it must be a directional light.

It would awesome to have a scene with sun lighting, moon lighting, street lamps, and car headlights all working together. This could really open up new rendering possibilities for Cesium.

I see these being the main API changes:

  • Add LightingCollection class
  • Deprecate and remove scene.light in favor of scene.lights
  • Add PointLight, SpotLight, and other new light types
  • Deprecate and remove lightColor from models and 3D Tiles

Some questions:

  • How does this affect our rendering architecture? Do we care about supporting hundreds of lights efficiently? Do we need to move to deferred rendering or forward plus rendering, or whatever else is now state-of-the-art.
  • Would this also be the time to switch to PBR everywhere? The globe, moon, and geometries are still using phong shading.
  • Would we support light links? This would let you chose which primitives are lit by which light source. If implemented this would make an even better case for removing lightColor from models and 3D Tiles.
  • How does this all work with the shadow system? We already support directional, point, and spot light shadows but the scene only has a single shadow map.
  • How do we specify which light source affects globe lighting such as atmosphere and fog? See @IanLilleyT's comment in https://github.com/AnalyticalGraphicsInc/cesium/pull/8493:

    My main API confusion is Globe.dynamicAtmosphereLightingFromSun, since the light source is the sun in most cases anyway, and so users might think they must set this property too. I can't think of a better name though. This isn't a big deal as it might be solved in the future by giving the atmosphere system its own light source, and then we can remove this custom behavior for the sun.

  • Which light types would we support? Here's what some other engines support:
    • Babylon JS
      • PointLight
      • DirectionalLight
      • SpotLight
      • HemisphericLight
    • ThreeJS
      • AmbientLight
      • DirectionalLight
      • HemisphereLight
      • PointLight
      • RectAreaLight
      • SpotLight

lilleyse avatar Jan 08 '20 15:01 lilleyse

For reference, STK supports:

  • Directional
  • Positional (Point light)
  • Spot

Spot and Positional each have a position that can be specified in any of STK's various coordinate frames, allowing for example headlights on a vehicle to ride along with it, etc. These also offer constant, linear, and quadratic falloff.

Spot and Directional can be aimed from one frame to another (for example Sun to Earth, or one moving vehicle to another like a helicopter search light tracking a car).

For glTF 2.0 models, it's worth considering IBL as an additional form of lighting.

emackey avatar Jan 08 '20 15:01 emackey

Please ask when multi light source can support, thank you

weiyinggh avatar Mar 24 '21 07:03 weiyinggh

Babylon JS

  • PointLight
  • DirectionalLight
  • SpotLight
  • HemisphericLight

ThreeJS

  • AmbientLight
  • DirectionalLight
  • HemisphereLight
  • PointLight
  • RectAreaLight
  • SpotLight

Above the light can be supported ?

hugcoday avatar May 25 '22 03:05 hugcoday

Requested on the forum: https://community.cesium.com/t/point-light-sources/21306/2

ggetz avatar Dec 09 '22 19:12 ggetz

Point light sources requested in https://github.com/CesiumGS/cesium/issues/11431.

ggetz avatar Jul 31 '23 18:07 ggetz

I just wanted to put in another +1 for this — if Cesium allowed for the rendering of actual light sources, it would DRAMATICALLY increase its usability for a million different applications. Being limited to essentially a single light source is very limiting. Obviously this is non-trivially difficult to implement. But it would be HUGE if it could be. HUGE! :-)

nuclearsecrecy avatar Dec 01 '23 20:12 nuclearsecrecy

My $0.02: From the PBR 3D model point of view, having robust support for HDRI / IBL environment lighting can dramatically improve the look of models, to the point where all the various ThreeJS/BabylonJS/STK light source types described above are actually discouraged as they interfere and/or compete with natural IBL lighting.

It might be interesting to light an entire set of 3D Tiles from an IBL, and see if that yields better results than the default or a point light someplace.

emackey avatar Dec 01 '23 21:12 emackey

I imagine it depends on what one is trying to do with it, yes? I am interested in being able to bring 3D models into a Cesium JS environment, and am not worried so much about the appearance of 3D Tiles. Being able to model multiple light sources, and/or having a real emission property for objects, is absolutely necessary if one wants flexibility for modeling anything other than a building. I'm interested in being able to render non-Sun lights, night scenes, better clouds, fog, smoke, glowing things, etc. Some of these things require more than multiple point or directional light sources to work well, of course, but you can fake a lot of them if you had them (and it's hard to fake them without them).

nuclearsecrecy avatar Dec 01 '23 21:12 nuclearsecrecy

I really hope to see multiple light sources in Cesium, it would make the virtual earth scenes more realistic. I hope you can consider this suggestion, thank you!

JensonMiao avatar Jan 24 '24 08:01 JensonMiao

Hi @lilleyse, @ggetz, I see there is an example of multiple shadows in Cesium, but when I tried it, only the first shadowmap in the list is rendered in the view scene. Do you have any idea why or how can I add multiple shadowmaps in the scene? Thanks alot!

nghiajenius-dev avatar Apr 03 '24 08:04 nghiajenius-dev

@nghiajenius-dev In that example, only multiple shadow maps were created, but only one shadow map can take effect, and it is currently not possible to add multiple shadow maps to the scene.

syzdev avatar Jun 19 '24 06:06 syzdev