Scripting Support (C#)

advanced scripting

Radiant GI (Built-in) · Scripting Support (C#)

Class: RadiantGlobalIllumination — a MonoBehaviour in the RadiantGI namespace. Attach it to the camera game object.

Getting Started

Add using RadiantGI; at the top of your script. Get the component from your camera:

using RadiantGI;

RadiantGlobalIllumination gi = Camera.main.GetComponent<RadiantGlobalIllumination>();
gi.indirectIntensity = 1.5f;
gi.rayCount = 2;

RadiantGlobalIllumination

Indirect Lighting

float indirectIntensity

Intensity of the indirect lighting. Set to 0 to disable the effect.

float indirectMaxSourceBrightness

Maximum brightness of the indirect source (default 8).

float indirectDistanceAttenuation

Distance attenuation applied to indirect lighting (0–1). Reduces indirect contribution at distance.

float normalMapInfluence

Influence of the surface normal map when receiving indirect lighting (0–1, default 1).

float lumaInfluence

In forward rendering, uses pixel luma to enhance results based on perceptual brightness. Set to 0 to disable.

bool includeForward

Include forward rendering path materials that render in opaque queue when camera is rendering in deferred.

Near Field Obscurance (NFO)

float nearFieldObscurance

Intensity of the near field obscurance effect. Darkens surfaces occluded by other nearby surfaces.

float nearFieldObscuranceSpread

Spread / radius of the NFO effect (0.01–1, default 0.2).

float nearFieldObscuranceMaxCameraDistance

Maximum camera distance of the NFO effect (default 125).

float nearFieldObscuranceOccluderDistance

Distance threshold of the occluder (0–1, default 0.825).

Color nearFieldObscuranceTintColor

Tint color of the NFO effect (default black).

Organic Light

float organicLight

Intensity of organic light (0–1). Injects procedural light variations into G-buffers for a more natural lit environment.

float organicLightThreshold

Threshold of organic light noise calculation (0–1, default 0.5).

float organicLightSpread

Organic light spread (0.9–1, default 0.98).

float organicLightNormalsInfluence

Preserves normal map effect on textures under organic light (0–1, default 0.95).

Color organicLightTintColor

Tint color of organic light (default white).

Vector3 organicLightAnimationSpeed

Animation speed of the organic light pattern along each axis.

bool organicLightDistanceScaling

Reduces organic light pattern repetition at distance.

Ray Marching

int rayCount

Number of rays per pixel (1–4, default 1).

float rayMaxLength

Maximum ray length (default 8). Increasing may require more samples to maintain quality.

int rayMaxSamples

Maximum samples taken during ray march (default 32).

float rayJitter

Random offset added to ray direction to reduce banding. Useful with low sample counts.

float thickness

Assumed thickness for any geometry, used to determine if a ray crosses a surface (default 1).

bool rayBinarySearch

Improves ray march accuracy by using binary search (default true).

bool rayBounce

Add one additional ray bounce for more accurate GI.

Fallback & Emitters

bool fallbackReuseRays

If a ray misses a target, reuse rays from previous frames.

float rayReuse

Intensity of the previous color used when a ray misses (0–1).

bool fallbackReflectionProbes

If a ray misses, use nearby reflection probes as fallback.

float probesIntensity

Global probe intensity multiplier (default 1). Each probe also has its own intensity.

bool fallbackReflectiveShadowMap

If a ray misses, use reflective shadow map data from the main directional light. Requires RadiantShadowMap script on the light.

float reflectiveShadowMapIntensity

Intensity of the reflective shadow map fallback (0–1, default 0.8).

bool virtualEmitters

Enable user-defined light emitters in the scene.

Performance

float downsampling

Reduces resolution of all GI stages (1–4, default 1). Higher values improve performance at the cost of quality.

int raytracerAccuracy

Raytracing accuracy (1–8, default 8). Lower values shrink the depth buffer used during raytracing.

int smoothing

Number of extra blur passes (0–4, default 3).

NormalsQuality normalsQuality

Controls normals quality: High (default) or ApproximatedFromDepth.

Temporal Reprojection

bool temporalReprojection

Uses motion vectors to blend into a history buffer to reduce flickering. Only applies in play mode (default true).

float temporalResponseSpeed

Reaction speed to screen changes (default 12). Higher values reduce ghosting but also smoothing.

float temporalCameraTranslationResponse

Reaction speed to camera position changes (default 100). Higher values reduce ghosting when the camera moves.

float temporalDepthRejection

Depth difference threshold to discard history buffer when reusing rays (default 1).

float temporalChromaThreshold

Allowed color difference between history and current GI buffers (0–2, default 0.2).

Output

float brightnessThreshold

Computes GI emitted by objects with a minimum luminosity.

float brightnessMax

Maximum GI brightness (default 8).

float specularContribution

Amount of GI added to specular surfaces (0–1, default 0.5). Reduce to avoid overexposure of shiny materials.

float sourceBrightness

Brightness of the original image (0–2, default 1). Reduce to make GI more prominent.

float giWeight

Increases final GI contribution versus source color pixel. Higher values reduce source pixel intensity based on received GI.

float nearCameraAttenuation

Attenuates GI brightness from nearby surfaces.

float saturation

Adjusted color saturation for the computed GI (0–2, default 1).

Volume & Stencil

LayerMask volumeMask

Used to filter which RadiantVolume should be used with this camera.

bool limitToVolumeBounds

Applies GI only inside the post-processing volume bounds. Use only if the volume is local.

bool stencilCheck

Enables stencil check during GI composition. Lets you exclude GI over objects that use the stencil buffer.

int stencilValue

Stencil reference value used during the stencil check.

CompareFunction stencilCompareFunction

Stencil comparison function (default NotEqual).

Debug & Compare

DebugView debugView

Selects debug visualization mode: None, Albedo, Normals, Specular, Depth, DownscaledHalf, DownscaledQuarter, UpscaleToHalf, Raycast, FinalGI, ReflectiveShadowMap, TemporalAccumulationBuffer.

float debugDepthMultiplier

Depth values multiplier for the Depth debug view (default 10).

bool compareMode

Enable split-screen comparison mode.

bool compareSameSide

Whether the comparison shows on the same side.

float comparePanning

Panning offset for the compare view (0–0.5, default 0.25).

float compareLineAngle

Angle of the compare divider line (default 1.4).

float compareLineWidth

Width of the compare divider line (0.0001–0.05, default 0.002).

bool showInEditMode

Renders the effect in edit mode when not in play mode (default true).

bool showInSceneView

Renders the effect in the Scene View (default true).

Static Members

static int computedGIRT

Identifier for the computed GI render texture.

static bool needRTRefresh

Set to true to force render target refresh on the next frame.

static bool isRenderingInDeferred

Whether the current camera is rendering in deferred mode.

Methods

bool IsActive()

Returns true if indirectIntensity > 0 or compareMode is enabled.

static void RegisterReflectionProbe(ReflectionProbe probe)

Registers a reflection probe for fallback use when rays miss.

static void UnregisterReflectionProbe(ReflectionProbe probe)

Unregisters a previously registered reflection probe.

static void RegisterVirtualEmitter(RadiantVirtualEmitter emitter)

Registers a virtual emitter for GI contribution.

static void UnregisterVirtualEmitter(RadiantVirtualEmitter emitter)

Unregisters a virtual emitter.

static void RegisterVolume(RadiantVolume volume)

Registers a RadiantVolume for this camera.

static void UnregisterVolume(RadiantVolume volume)

Unregisters a RadiantVolume.

Code Examples

using RadiantGI;

// Get the component from camera
var gi = Camera.main.GetComponent<RadiantGlobalIllumination>();

// Enable indirect lighting
gi.indirectIntensity = 1.5f;
gi.rayCount = 2;
gi.rayMaxSamples = 48;

// Enable near field obscurance
gi.nearFieldObscurance = 0.5f;
gi.nearFieldObscuranceSpread = 0.3f;

// Enable organic light
gi.organicLight = 0.4f;
gi.organicLightTintColor = new Color(1f, 0.95f, 0.9f);
gi.organicLightAnimationSpeed = new Vector3(0.1f, 0.05f, 0.1f);

// Register a custom reflection probe
RadiantGlobalIllumination.RegisterReflectionProbe(myProbe);

// Register a virtual emitter
RadiantGlobalIllumination.RegisterVirtualEmitter(myEmitter);
Was this page helpful?