Scripting Support (C#)

advanced scripting

Radiant GI (URP) · Scripting Support (C#)

Class: RadiantGlobalIllumination — a URP VolumeComponent in the RadiantGI.Universal namespace. Add it as a Volume override and control all GI settings at runtime.

Getting Started

Add a RadiantGlobalIllumination override to a URP Volume in your scene. Access it via script using the standard Volume API:

using UnityEngine.Rendering;
using RadiantGI.Universal;

var volume = GetComponent<Volume>();
if (volume.profile.TryGet<RadiantGlobalIllumination>(out var rgi)) {
    rgi.indirectIntensity.Override(1.5f);
    rgi.rayCount.Override(2);
}

Indirect Lighting

FloatParameter indirectIntensity

Intensity of the indirect lighting. Default: 0 (disabled).

ClampedFloatParameter indirectDistanceAttenuation

Distance attenuation applied to indirect lighting. Reduces intensity by square of distance (0–1). Default: 0.

FloatParameter indirectMaxSourceBrightness

Clamps maximum brightness of surfaces emitting indirect light. Default: 15.

ClampedFloatParameter normalMapInfluence

How much the surface normal map influences received indirect lighting (0–1). Default: 0.2.

BoolParameter rayBounce

Add one extra ray bounce using the previous frame’s GI result. Default: false.

Near Field Obscurance

FloatParameter nearFieldObscurance

Intensity of the near field obscurance effect. Darkens surfaces occluded by nearby geometry. Default: 0 (disabled).

ClampedFloatParameter nearFieldObscuranceSpread

Spread / radius of the effect (0.01–1). Default: 0.2.

FloatParameter nearFieldObscuranceMaxCameraDistance

Maximum distance from the camera at which the effect is visible. Default: 125.

ClampedFloatParameter nearFieldObscuranceOccluderDistance

Distance threshold of the occluder (0–1). Default: 0.825.

ColorParameter nearFieldObscuranceTintColor

Tint color of the obscurance effect. Default: black.

Organic Light

ClampedFloatParameter organicLight

Intensity of organic/procedural light. Injects artificial light variations into g-buffers for a more natural-looking environment (0–1). Default: 0 (disabled).

ClampedFloatParameter organicLightThreshold

Threshold of organic light noise calculation (0–1). Default: 0.5.

ClampedFloatParameter organicLightSpread

Organic light spread (0.9–1). Default: 0.98.

ClampedFloatParameter organicLightNormalsInfluence

Preserves normal map effect on textures when organic light is applied (0–1). Default: 0.95.

ColorParameter organicLightTintColor

Tint color for organic light. Default: white.

Vector3Parameter organicLightAnimationSpeed

Animation speed of the organic light pattern. Default: Vector3.zero.

BoolParameter organicLightDistanceScaling

Reduces organic light pattern repetition at distance. Default: false.

Ambient

ClampedFloatParameter unityAmbientLighting

Controls how much Unity ambient light is preserved. 0 = full subtraction, 1 = keep all ambient (0–1). Default: 1.

ClampedFloatParameter fallbackAmbient

Amount of ambient lighting from Adaptive Probe Volumes and Sky. 0 = disabled (0–1). Default: 0.

Ray Marching

ClampedIntParameter rayCount

Number of rays per pixel (1–4). More rays = less noise but slower. Default: 1.

FloatParameter rayMaxLength

Maximum ray length. Increasing may require higher rayMaxSamples. Default: 8.

IntParameter rayMaxSamples

Maximum samples along the ray-march loop. Values of 24–32 usually give good results. Default: 32.

FloatParameter rayJitter

Randomization of the ray starting position to reduce banding. Default: 0.3.

FloatParameter thickness

Depth tolerance for determining ray hits. Values of 0.1–0.3 work best. Default: 0.25.

Fallbacks

BoolParameter fallbackReuseRays

Reuse rays from previous frames when a ray misses its target. Default: false.

ClampedFloatParameter rayReuse

Intensity of previous-frame color reuse on ray miss (0–1). 0 = disabled. Default: 0.

BoolParameter fallbackReflectionProbes

Use nearby reflection probes when a ray misses. Default: false.

MinFloatParameter probesIntensity

Global probe intensity multiplier (each probe also has its own intensity). Default: 0.2.

BoolParameter fallbackReflectiveShadowMap

Use reflective shadow map data from the main directional light on ray miss. Requires a RadiantShadowMap component on the directional light. Default: false.

ClampedFloatParameter reflectiveShadowMapIntensity

Intensity multiplier for the reflective shadow map fallback (0–1). Default: 0.8.

ColorParameter fallbackDefaultAmbient

Default color used when all other fallbacks fail. Default: black.

Quality & Performance

ClampedFloatParameter downsampling

Downscales the input image for all render passes (1–4). 1 = full resolution. Default: 1.

ClampedIntParameter raytracerAccuracy

Raytracer accuracy level (1–8). Lower values downscale the depth buffer for better GPU cache efficiency. Default: 8.

ClampedFloatParameter blurSpread

Multiplier for spatial blur spread. Increase to reduce flickering at lower resolutions (1–2). Default: 1.

Temporal Filter

ClampedIntParameter temporalStabilization

Maximum frames to accumulate in temporal history (6–16). Higher = more stable but may ghost. Default: 8.

FloatParameter temporalResponseSpeed

How fast the spatio-temporal filter reacts to screen changes. Lower = softer but more ghosting, higher = less smoothing. Default: 12.

MinFloatParameter darkThreshold

Brightness threshold below which extra noise stabilization is applied. Default: 0.2.

MinFloatParameter darkThresholdMultiplier

Stability multiplier in dark areas. Higher = more stable darks. Default: 10.

Output & Brightness

MinFloatParameter sourceBrightness

Brightness of the original image. Reduce to make GI more visible. Default: 1.

FloatParameter brightnessThreshold

Minimum brightness for a pixel to be considered as indirect light source. Default: 0.

FloatParameter brightnessMax

Clamps the maximum brightness of the resulting GI contribution. Default: 8.

FloatParameter giWeight

Increases GI contribution vs source pixel color. Higher values reduce source pixel intensity based on received GI. Default: 0.

FloatParameter nearCameraAttenuation

Attenuates GI brightness from nearby surfaces. Default: 0.

ClampedFloatParameter saturation

Color saturation of the computed GI. 0 = grayscale (0–2). Default: 1.

Volume, Stencil & AO

BoolParameter limitToVolumeBounds

Only apply GI within the boundaries of the current local volume. Useful for interior rooms. Default: false.

BoolParameter stencilCheck

Enable stencil mask to exclude specific pixels from GI (e.g. UI, FPS weapons). Default: false.

IntParameter stencilValue

Stencil reference value for the stencil test. Default: 1.

CompareFunctionParameter stencilCompareFunction

Comparison function for stencil testing. Default: NotEqual.

ClampedFloatParameter aoInfluence

How much URP SSAO (or HBAO) influences indirect lighting (0–1). Default: 0.

ClampedFloatParameter occlusionIntensity

Intensity of occlusion maps used to attenuate GI (0–1). Default: 0.5.

Transparency

BoolParameter transparencySupport

Include transparent objects in GI calculations. Choose by layer mask or add a RadiantTransparentSupport component to individual objects. Default: false.

LayerMaskParameter transparentLayerMask

Which layers are considered transparent for GI. Default: 0 (none).

BoolParameter virtualEmitters

Enable virtual emitter support. When enabled, RadiantVirtualEmitter components in the scene contribute indirect light. Default: false.

Debug & Compare

BoolParameter showInEditMode

Render the effect while not in play mode (noisy without temporal reprojection). Default: true.

BoolParameter showInSceneView

Render the effect in the Scene View. Default: false.

BoolParameter compareMode

Show a split-screen comparison of the scene with and without GI. Default: false.

ClampedFloatParameter comparePanning

Panning position of the comparison line (0–0.5). Default: 0.25.

ClampedFloatParameter compareLineWidth

Width of the comparison line (0.0001–0.05). Default: 0.002.

DebugViewParameter debugView

Selects which debug buffer to visualize (None, Albedo, Normals, Depth, MotionVectors, Raycast, etc.). Default: None.

FloatParameter debugDepthMultiplier

Depth values multiplier for the depth debug view. Default: 10.

FloatParameter debugMotionVectorMultiplier

Motion vectors multiplier for the motion vectors debug view. Default: 1.

BoolParameter compareSameSide

When enabled, shows the comparison on the same side instead of split screen. Default: false.

ClampedFloatParameter compareLineAngle

Angle of the comparison line for split screen mode. Default: 1.4.

field debugView DebugViewParameter — default: None

Selects which debug buffer to visualize (None, Albedo, Normals, Depth, MotionVectors, Raycast, RaycastAccumulated, Downscaled, ReflectiveShadowMap, TemporalAccumulationBuffer, FinalGI).

field debugDepthMultiplier FloatParameter — default: 10

Multiplier for depth values in the depth debug view.

field debugMotionVectorMultiplier FloatParameter — default: 1

Multiplier for motion vectors in the motion vectors debug view.

field compareSameSide BoolParameter — default: false

When enabled, shows the comparison on the same side instead of split screen.

field compareLineAngle ClampedFloatParameter — default: 1.4

Angle of the comparison split line (-PI to PI).

Code Examples

Modify GI at Runtime

using UnityEngine.Rendering;
using RadiantGI.Universal;

var volume = GetComponent<Volume>();
if (volume.profile.TryGet<RadiantGlobalIllumination>(out var rgi)) {
    // Increase indirect lighting
    rgi.indirectIntensity.Override(2f);
    rgi.rayCount.Override(2);

    // Enable near field obscurance
    rgi.nearFieldObscurance.Override(0.5f);
    rgi.nearFieldObscuranceSpread.Override(0.3f);

    // Enable organic light
    rgi.organicLight.Override(0.4f);
    rgi.organicLightTintColor.Override(Color.yellow);
}

Quality Presets

using UnityEngine.Rendering;
using RadiantGI.Universal;

void SetQuality(Volume volume, string quality) {
    if (!volume.profile.TryGet<RadiantGlobalIllumination>(out var rgi)) return;

    switch (quality) {
        case "low":
            rgi.rayCount.Override(1);
            rgi.rayMaxSamples.Override(16);
            rgi.downsampling.Override(2f);
            rgi.raytracerAccuracy.Override(4);
            break;
        case "high":
            rgi.rayCount.Override(2);
            rgi.rayMaxSamples.Override(32);
            rgi.downsampling.Override(1f);
            rgi.raytracerAccuracy.Override(8);
            break;
    }
}
Was this page helpful?