Lumen Effect Player

The LumenEffectPlayer class is the core runtime component for displaying and controlling stylized light effects in Lumen: Stylized Light FX 2. It manages effect profiles, handles effect instantiation, updates, fading, and provides a flexible API for both editor and runtime use.

You can create a new Lumen Effect Player in the editor by

  • Adding a Lumen Effect Player to your scene via:

    • GameObject → Effects → Empty Lumen Player

  • Assigning a LumenEffectProfile in the Inspector.

Once created, assign a new Lumen Effect to your player to see the changes in realtime in your scene.

API Documentation

Key Public Fields & Properties

Field/Property
Type
Description

LumenEffectProfile

The effect profile asset assigned to this player.

float

Uniform scale modifier for all effect layers.

float

Uniform brightness modifier for all effect layers.

Color

Uniform color modifier for all effect layers.

UpdateFrequency (enum)

How often the effect updates: Always, OnChanges, or ViaScripting.

InitializationBehavior (enum)

How the effect appears when enabled (immediate, fade, skip, etc.).

DeinitializationBehavior (enum)

How the effect disappears when disabled (immediate, fade, etc.).

float

Duration for fade-in/out transitions.

bool

Automatically assign the sun direction from the brightest directional light. Only applies to dynamic rays

bool

Use the direction from a LumenSun script if present. Only applies to dynamic rays

Vector3

Manually set the sun direction (if not auto-assigned). Only applies to dynamic rays

bool

Show/hide effect layers in the hierarchy for debugging.

List<InstantiatedLumenLayer>

References to the currently instantiated effect layers.

Methods

Effect Control

public void RedoEffect()

Redraws the effect stack. Call this after changing properties or the profile.

public void ClearEffect()
public void ClearEffect(float delay)

Removes all effect layers immediately or after a delay.


Fading

public void FadeBrightness(float brightness, float time)
public void FadeScale(float scale, float time)
public void FadeColor(Color color, float time)

Smoothly transitions the effect’s brightness, scale, or color over a set duration.


Update Frequency

  • Always: Effect updates every frame.

  • OnChanges: Effect updates only when a change is detected in the editor.

  • ViaScripting: Effect updates only when RedoEffect() is called.


Initialization & Deinitialization Behaviors

  • InitializationBehavior:

    • Immediate

    • FadeToTargetBrightness

    • FadeToTargetScale

    • FadeToTargetColor

    • SkipInitialization

  • DeinitializationBehavior:

    • Immediate

    • FadeBrightnessToZero

    • FadeScaleToZero

    • FadeColorToBlack

Example Usage

// Create and configure a player at runtime
var player = LumenEffectPlayer.CreatePlayer(myProfile, new Vector3(0, 2, 0));
player.scale = 2.0f;
player.brightness = 0.8f;
player.color = Color.cyan;
player.updateFrequency = LumenEffectPlayer.UpdateFrequency.Always;
player.initializationBehavior = LumenEffectPlayer.InitializationBehavior.FadeToTargetBrightness;
player.fadingTime = 1.5f;
player.RedoEffect();

Advanced

  • Layer Management: The player manages a pool of instantiated layers for performance. Use UpdateMeshPool() to force a refresh if you change the profile structure at runtime.

  • Sun Direction: By default, the sun direction is auto-assigned. You can override this by setting autoAssignSun = false and specifying localSunDirection.

  • Hierarchy Display: Set displayLayersInHierarchy = true to see all effect layers as child objects in the hierarchy (useful for debugging).


Editor Context Menu

  • Refresh Effect: Right-click the component and select Refresh Effect to manually redraw the effect.

  • Toggle Display: Right-click and select Toggle Display to show/hide layers in the hierarchy.


Notes

  • The effect will not render if no profile is assigned or if the profile contains no active layers.

  • For best results, ensure your project and URP settings meet the Lumen requirements (see the Setup Helper).

Last updated