s&box
RustCounter-Strike 2s&boxDeadlock
Wiki
Get s&box on Steam
Browse
OverviewGetting StartedCreating GamesEngine & ToolsDocumentationCommunity GamesResources
s&boxDocumentationRenderingShadersClassesAmbientlight
SOURCE 2 · C#
Build and play games with s&box.

Facepunch's game engine and creation platform — make games in C#, or jump straight into community games.

Get s&box on Steam

s&box Wiki

  • Overview
  • Getting Started
  • Creating Games
  • Engine & Tools
  • Documentation
  • Community Games
  • Resources

Tools & Community

  • Getting Started
  • Creating Games
  • Engine & Tools
  • Resources

Platforms

  • RustBattle
  • CSBattle
  • Rust Game Wiki
  • CS2 Skins Wiki
  • Deadlock Wiki

About

  • Official Site
  • Developer Wiki
  • GitHub
  • Get on Steam
NOT AFFILIATED WITH FACEPUNCH STUDIOS · © 2026 s&box Wiki (community)
Docs/Rendering
Rendering

AmbientLight

This class is part of the standard shading model, which allows fetching proper diffuse light contribution from appropriate sources on scene.

From

AmbientLight::From( float3 WorldPosition, float4 PositionSs, float3 WorldNormal )

  • WorldPosition: world-space pixel position, can get it with i.vPositionWithOffsetWs + g_vCameraPositionWs
  • PositionSs: screen-space position data, i.vPositionSs in standard pixel input struct
  • WorldNormal: world-space geometry normals

This method will return diffuse ambient light from one of the sources on scene in current order of priority:

  1. Indirect Light Volume (DDGI)
  2. Sky Color (directional light, controlled by alpha)
  3. Environment Probe/Sky Indirect Lighting (2D Skybox)
  4. Lightmap Probes

For example, if you have directional light and environment probe set up, ::From will return flat sky color first, which visibility can be controlled by adjusting the alpha. Set the sky color alpha to zero (or anything inbetween) to make envprobes/indirect sky lighting more visible. Everything outside environment probes will draw indirect sky lighting from 2D Skybox.

If there is indirect light volume present on scene, then ::From will always return it first. You can also sample different types of diffuse light sources separately using following functions below:

FromDDGI

Samples ambient light produced by Indirect Light Volume. If you don't have this component on scene, and it hasn't been baked yet, this will return 0. Everything outside of the volume (even when baked) will be always 0 too.

AmbientLight::FromDDGI( float3 WorldPosition, float3 WorldNormal )

FromEnvMapProbe

Samples ambient light from Environment Probe, Indirect Sky Lighting (2D Skybox) or Sky Color (Directional Light). Read the explanation in ::From section to see how exactly AmbientLight class selects the light source for sampling.

AmbientLight::FromEnvMapProbe( float3 WorldPosition, float4 PositionSs, float3 WorldNormal )

FromLightMapProbeVolume

This will draw ambient light produced from lightmap probes.

AmbientLight::FromLightMapProbeVolume( float3 WorldPosition, float3 WorldNormal )

Source: Facepunch/sbox-docs (CC-BY-4.0) · updated 2026-06-19. Read it rendered on the official docs.

More in Rendering

Animated Effects
Attributes and Variables
BeamEffect
Beams
Bindless API
C# Shader Nodes
Classes
Command Lists
← All documentation

Community wiki — not affiliated with Facepunch Studios. For the latest and most authoritative information, see the official developer wiki.