Class LightUtil
Provides factory methods for creating Unity UnityEngine.Light GameObjects (directional, point, and spot) and a pipeline-agnostic API for configuring shadow resolution via ScyllaShadowResolution. All creation methods accept optional parameters so callers need only specify the values that differ from sensible defaults.
Inherited Members
Namespace: Scylla.Core.Util
Assembly: ScyllaCore.dll
Syntax
public static class LightUtil
Remarks
Shadow resolution configuration adapts to the render pipeline detected at runtime. The URP
and HDRP paths are applied through reflection (see RenderPipelineInterop), so this
assembly references no render-pipeline type and one build serves every pipeline:
- URP: Ensures the required
UniversalAdditionalLightDatacomponent is present. Per-light shadow resolution is not settable in URP; configure it globally via the URP Asset. - HDRP: Maps ScyllaShadowResolution to HDRP pixel tile sizes (256/512/1024/2048) via
HDAdditionalLightData.SetShadowResolution. - Built-in pipeline: Casts the enum value directly to
LightShadowResolution.
Methods
ApplyUniformReflectionEnvironment()
Configures scene-level UnityEngine.RenderSettings so 3D lit demos render with a consistent, tinted ambient and a uniform reflection-probe input - regardless of what skybox / ambient settings happen to be saved in the .unity scene file.
Declaration
public static void ApplyUniformReflectionEnvironment()
Remarks
Two distinct paths feed URP / HDRP Lit's lighting model from the scene:
the SH ambient term (indirect diffuse) and the reflection probe (indirect
specular). Both default to sampling the scene's skybox material. Demo scenes
that don't ship a skybox - or that strip it because the camera uses
SolidColor clear - get black SH ambient and a hard sky-to-floor
gradient in the reflection probe. On doubly-curved meshes (sphere, capsule
caps) the reflection-probe gradient sweeps the whole normal hemisphere and
reads as a top-to-bottom two-tone wash that misreads as transparency.
This helper forces:
- UnityEngine.Rendering.AmbientMode.Trilight with explicit sky / equator / ground colors so SH is directional and tinted (cool from above, warm from below) without being a desaturating flat grey. Tints retain their saturation because zero-channel albedo components only receive sky-blue or warm fill, not white-grey contamination.
- A custom near-black reflection cubemap. Curved shapes no longer sample the skybox gradient; they sample a uniform tone, so they read as solid. Direct specular highlights from scene lights are unaffected (they come from the light, not the probe), so the surface keeps its lit shimmer.
Safe to call multiple times - the cubemap is cached statically and reused. The settings are global to UnityEngine.RenderSettings; demos that need different appearance can override after this call returns.
CreateDirectionalLight(Transform, Vector3?, Quaternion?, Color?, float, LightShadows, ScyllaShadowResolution)
Creates a new directional light GameObject and returns its fully configured UnityEngine.Light
component. A directional light illuminates the entire scene from a given direction with parallel
rays, making it ideal for simulating sunlight or moonlight. When shadows is not
UnityEngine.LightShadows.None, SetShadowResolution(Light, ScyllaShadowResolution) is applied using pipeline-
aware logic via ScyllaShadowResolution.
Declaration
public static Light CreateDirectionalLight(Transform parent, Vector3? position = null, Quaternion? rotation = null, Color? color = null, float intensity = 1, LightShadows shadows = LightShadows.Soft, ScyllaShadowResolution shadowResolution = ScyllaShadowResolution.Medium)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | parent | Parent transform the light GameObject is attached to. Can be |
| Vector3? | position | World-space position of the light. When |
| Quaternion? | rotation | World-space rotation of the light, which determines the direction of the rays. When |
| Color? | color | Light color. When |
| float | intensity | Linear light intensity multiplier. Default is |
| LightShadows | shadows | Shadow casting mode. Default is UnityEngine.LightShadows.Soft. |
| ScyllaShadowResolution | shadowResolution | Pipeline-agnostic shadow resolution level. Default is Medium. Has no per-light effect on URP (shadow resolution is global in URP). |
Returns
| Type | Description |
|---|---|
| Light | The UnityEngine.Light component on the newly created directional light GameObject. |
See Also
CreatePointLight(Transform, Vector3?, Color?, float, float, LightShadows, ScyllaShadowResolution)
Creates a new point light GameObject and returns its fully configured UnityEngine.Light
component. A point light emits light equally in all directions from a single position, like a
light bulb. It has no rotation because the direction is omnidirectional; the GameObject is
placed at position with UnityEngine.Quaternion.identity rotation.
Declaration
public static Light CreatePointLight(Transform parent, Vector3? position = null, Color? color = null, float intensity = 1, float range = 10, LightShadows shadows = LightShadows.None, ScyllaShadowResolution shadowResolution = ScyllaShadowResolution.Medium)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | parent | Parent transform the light GameObject is attached to. Can be |
| Vector3? | position | World-space position. When |
| Color? | color | Light color. When |
| float | intensity | Linear light intensity multiplier. Default is |
| float | range | Maximum distance in world units that the light illuminates. Beyond this distance the
contribution falls to zero. Default is |
| LightShadows | shadows | Shadow casting mode. Default is UnityEngine.LightShadows.None since omnidirectional shadows are expensive. |
| ScyllaShadowResolution | shadowResolution | Pipeline-agnostic shadow resolution level. Default is Medium. Has no per-light effect on URP. |
Returns
| Type | Description |
|---|---|
| Light | The UnityEngine.Light component on the newly created point light GameObject. |
See Also
CreateSpotLight(Transform, Vector3?, Quaternion?, Color?, float, float, float, LightShadows, ScyllaShadowResolution)
Creates a new spot light GameObject and returns its fully configured UnityEngine.Light
component. A spot light emits light in a cone shape defined by spotAngle,
pointing in the forward direction of the GameObject's rotation. It is suitable for torches,
headlights, and focused illumination effects.
Declaration
public static Light CreateSpotLight(Transform parent, Vector3? position = null, Quaternion? rotation = null, Color? color = null, float intensity = 1, float range = 10, float spotAngle = 30, LightShadows shadows = LightShadows.None, ScyllaShadowResolution shadowResolution = ScyllaShadowResolution.Medium)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | parent | Parent transform the light GameObject is attached to. Can be |
| Vector3? | position | World-space position. When |
| Quaternion? | rotation | World-space rotation determining the cone direction. When |
| Color? | color | Light color. When |
| float | intensity | Linear light intensity multiplier. Default is |
| float | range | Maximum reach of the cone in world units. Default is |
| float | spotAngle | Full cone angle in degrees. Smaller values produce a tighter, more focused beam.
Default is |
| LightShadows | shadows | Shadow casting mode. Default is UnityEngine.LightShadows.None. |
| ScyllaShadowResolution | shadowResolution | Pipeline-agnostic shadow resolution level. Default is Medium. Has no per-light effect on URP. |
Returns
| Type | Description |
|---|---|
| Light | The UnityEngine.Light component on the newly created spot light GameObject. |
See Also
SetShadowResolution(Light, ScyllaShadowResolution)
Sets the shadow resolution on a light using pipeline-agnostic ScyllaShadowResolution.
On HDRP, maps to pixel-based shadow resolution. On Built-in, maps to LightShadowResolution.
URP does not support per-light shadow resolution; it is controlled globally via the URP Asset.
Declaration
public static void SetShadowResolution(Light light, ScyllaShadowResolution resolution)
Parameters
| Type | Name | Description |
|---|---|---|
| Light | light | The light to configure. |
| ScyllaShadowResolution | resolution | The shadow resolution level to apply. |