Uninomicon

Documenting the dark corners of the Unity Engine.

User Tools

Site Tools


lightmapsettings.lightprobes

This is an old revision of the document!


Light Probes

  • Unity stores the probes for all loaded scenes into the LightingData.asset file, even when baking only a single scene.

LightmapSettings.lightProbes

Honestly, I'm still fairly fuzzy on how this field works. Here's the best of my knowledge.

  • The LightmapSettings.lightProbes stores the light probes all scenes currently loaded. It is a single merged array of lightProbes, which is updated whenever a scene is additively loaded or removed.
  • When a scene is unloaded, LightmapSettings.lightProbes will still
  • Presumably, the values in LightingData.asset are baked into the scene during standalone build.
  • The Object LightmapSettings.lightProbes lives within the active scene's LightingData.asset lighting asset.
  • Changing the active scene in the Editor changes the LightmapSettings.lightProbes reference to the active scene's lighting data. If the active scene does not have valid lighting data, the old light probes are left in the lighting cache.

There is no way to manually specify light probes, as far as I'm aware. The only mutable field on LightmapSettings.lightProbes are the spherical harmonic values (LightmapSettings.lightProbes.bakedProbes). You can blend and modify the lighting values of the probes, but there is no way to fully create new probes at runtime, even if you have the positions and values. Probes cannot be moved at runtime, because the positions array has no setter.

LightmapSettings.lightProbes will be null if there is no valid lighting data in the active scene.

''pred(*previous, *i)''

Sometimes when messing with light probe values, at least in the editor, this can result in an error “pred(*previous, *i)”. The error will occur whenever a scene is loaded additively. An assertion fails while Unity is applying the lighting data for that scene.

You can avoid this error by saving your scenes without a LightingData.asset1). However, this is only helpful if you are already applying lightmapping and lightprobes yourself at runtime. (This saves the scene without *any* lighting data).

1)
I did this by nulling the Lightmapping.lightingDataAsset in EditorSceneManager.sceneSaving
lightmapsettings.lightprobes.1620675132.txt.gz · Last modified: 2021/05/10 19:32 by 54.223.114.109