static class Lighting
Scene lighting! StereoKit’s lighting is entirely environment
based. An ambient lighting probe (Ambient) provides soft directional
light, a specular reflection cubemap (Reflection) provides shiny
highlights and mirror surfaces, and a dominant directional light
(MainLight) is derived from it all for effects like shadows.
SetEnvironment fills in all of this from a single cubemap, and is
the easiest place to start!
On devices that can estimate lighting from their surroundings, the
world source keeps all of this matched to the user’s real room
instead, see Source.
Static Fields and Properties
| SphericalHarmonics Ambient | The scene’s ambient light probe, as spherical harmonics! This is soft omnidirectional light, the color and intensity arriving from each direction rather than a discrete source. Build one with SphericalHarmonics.FromLights, or let SetEnvironment derive it from a cubemap. Assignments apply exactly as provided, and win over a SetEnvironment that’s still loading, even once it finishes. Later environment lighting replaces them: a new SetEnvironment, or world source estimates, where assignments are ignored entirely. A Mode change re-shapes the newest lighting, assigned or not. |
| SHLight MainLight | The scene’s dominant directional light, ideal as a shadow direction! Environment lighting keeps this derived, and the direction is always normalized. Check Mode before shading with it, since in Ambient mode this light’s energy is also inside the Ambient probe. A black color means no light. Assignments follow the same rules as Ambient: applied as-is until the next environment lighting replaces them. Built-in shaders don’t consume this, it’s for your own shaders and effects. |
| LightingMode Mode | How environment lighting is delivered! Ambient folds all light into the Ambient SH, while MainLight splits the dominant directional light out into MainLight, leaving Ambient the remainder. NOTE: StereoKit builtin shaders do not yet account for directional light, you will need your own shaders for MainLight mode to work. Changing Mode will ALSO change your current Ambient SH, adding or subtracting the MainLight’s energy. |
| Tex Reflection | The specular reflection cubemap used by PBR shading: GGX convolved radiance, one roughness level per mip. Generate one with Tex.GenCubemapReflection, and null restores the built-in default. A cubemap without a convolved mip chain still binds, but reads mirror-sharp at every roughness. In the world source this is fed by estimation, and assignments are ignored. |
| LightingSource Source | Where scene lighting comes from right now? The application (Manual, the default), or estimated live from the user’s surroundings (World). This never changes on its own, the world source is an opt-in via RequestSource. A request that’s still settling reads as its previous value here, see SourcePending. |
| bool SourcePending | True while a RequestSource is still settling, which is typically a permission dialog. Resolves within moments, with the outcome in Source. |
Static Methods
| RequestSource | Requests a switch to a lighting source! Manual applies immediately, while World may show a permission dialog the user can decline, watch SourcePending and Source for the result. |
| SetEnvironment | Sets up the whole scene’s lighting from a single cubemap! This includes the Renderer.SkyboxTex, a generated Lighting.Reflection, and once that’s finished generating, Ambient and MainLight too. Raw radiance cubemaps like Tex.FromCubemap provides are perfect here, no mip chain needed. Anything you assign to those properties afterwards overrides that piece. Null resets all of it to StereoKit’s defaults. Ignored when using World as a lighting source. |
| SourceAvailable | Check if a lighting source is supported on this device, without switching to it! Manual is always available, while world needs light estimation support from the XR runtime, and may still need a permission the user can decline at RequestSource time. |
Found an issue with these docs, or have some additional questions? Create an Issue on Github!