terminalCode Example
Scene lighting setup — DirectionalLight, PointLight, SpotLight, SkyBox, AmbientLight, and Fog
Scene Lighting Setup
s&box lighting is built from components. A typical scene needs a directional light (sun), ambient light, and a skybox.
Directional Light (Sun)
CSHARP
var sunGo = Scene.CreateObject();
sunGo.Name = "Sun";
sunGo.WorldRotation = Rotation.From( 45, -60, 0 ); // pitch, yaw, roll
var sun = sunGo.Components.Create<DirectionalLight>();
sun.LightColor = Color.FromHex( "#FFF5E0" );
sun.Brightness = 3f;
sun.ShadowsEnabled = true;Point Light
CSHARP
var lightGo = Scene.CreateObject();
lightGo.WorldPosition = new Vector3( 0, 0, 100 );
var point = lightGo.Components.Create<PointLight>();
point.LightColor = Color.FromHex( "#FF8800" );
point.Radius = 300f;
point.Attenuation = 1f;
point.ShadowsEnabled = false; // point light shadows are expensiveSpot Light
CSHARP
var spot = lightGo.Components.Create<SpotLight>();
spot.LightColor = Color.White;
spot.Radius = 500f;
spot.InnerConeAngle = 15f;
spot.OuterConeAngle = 30f;Sky Box
CSHARP
var skyGo = Scene.CreateObject();
skyGo.Name = "Sky";
var sky = skyGo.Components.Create<SkyBox2D>();
sky.SkyMaterial = Material.Load( "materials/skybox/skybox_day_01.vmat" );
sky.SkyIndirectLighting = true; // sky contributes to ambient GIAmbient Light
Flat fill light with no direction — prevents fully black shadows.
CSHARP
var ambientGo = Scene.CreateObject();
var ambient = ambientGo.Components.Create<AmbientLight>();
ambient.LightColor = Color.FromHex( "#404060" ); // cool dark fillDynamic Global Illumination (DDGI)
IndirectLightVolume places a probe grid for real-time bounce light.CSHARP
var ddgiGo = Scene.CreateObject();
var ddgi = ddgiGo.Components.Create<IndirectLightVolume>();
ddgi.ProbeDensity = 8f;
ddgi.Size = new Vector3( 512, 512, 512 );Fog
CSHARP
// Gradient fog (distance-based)
var fogGo = Scene.CreateObject();
var fog = fogGo.Components.Create<GradientFog>();
fog.StartDistance = 500f;
fog.EndDistance = 3000f;
fog.FogColor = Color.FromHex( "#C8D8E8" );
// Volumetric fog
var volFog = fogGo.Components.Create<VolumetricFogVolume>();
volFog.Strength = 0.5f;
Was this helpful?