stride3d/stride · error · InvalidOperationException

Unsupported light type

Error message

Unsupported light type

What it means

UpdateRenderData (via SetupLight) only supports light shafts attached to SpotLight, PointLight, or LightDirectional components. Any other ILight implementation has no group renderer, so an InvalidOperationException('Unsupported light type') is thrown.

Solutions

  1. Attach the light shaft component only to spot, point, or directional lights
  2. Check lightShaft.Light2.GetType() before enabling light shafts
  3. Implement a custom group renderer if you must support a custom light type

Example fix

// before
myCustomLight.LightShaft = lightShaft; // throws
// after
if (light is LightDirectional || light is LightSpot || light is LightPoint)
    myCustomLight.LightShaft = lightShaft;
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(light is LightDirectional || light is LightSpot || light is LightPoint))
    return; // skip light shafts for this light

Type guard

bool SupportsLightShafts(ILight light) =>
    light is LightDirectional || light is LightSpot || light is LightPoint;

Try / catch

try { SetupLight(lightShaft); }
catch (InvalidOperationException) { logger.Warning("Light shafts unsupported for this light type"); }

Prevention

When it happens

Trigger: Assigning a light shaft to a light whose runtime type is not LightDirectional (and not the spot/point cases handled earlier in the if/else chain) — e.g. a custom ILight subclass or an ambient/environment light.

Common situations: Users attaching the LightShaft component to the wrong light entity type in a scene, or writing a custom light type that LightShafts does not recognize.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/6289e4a49f8a2652. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Rendering/Rendering/Images/LightShafts/LightShafts.cs:297

        }

        private void UpdateRenderData(RenderDrawContext context, LightShaftRenderData data, RenderLightShaft lightShaft, LightShadowMapTexture shadowMapTexture)
        {
            if (lightShaft.Light2 is LightPoint)
            {
                data.GroupRenderer = new LightPointGroupRenderer();
            }
            else if (lightShaft.Light2 is LightSpot)
            {
                data.GroupRenderer = new LightSpotGroupRenderer();
            }
            else if (lightShaft.Light2 is LightDirectional)
            {
                data.GroupRenderer = new LightDirectionalGroupRenderer();
            }
            else
            {
                throw new InvalidOperationException("Unsupported light type");
            }

            ILightShadowMapShaderGroupData shadowGroup = null;
            if (shadowMapTexture != null)
            {
                data.ShadowType = shadowMapTexture.ShadowType;
                data.ShadowMapRenderer = shadowMapTexture.Renderer;
                shadowGroup = data.ShadowMapRenderer.CreateShaderGroupData(data.ShadowType);
            }
            else
            {
                data.ShadowType = 0;
                data.ShadowMapRenderer = null;
            }
            data.ShaderGroup = data.GroupRenderer.CreateLightShaderGroup(context, shadowGroup);   // TODO: Implement support for texture projection and attenuation?
        }

        private void SetupLight(RenderDrawContext context, RenderLightShaft lightShaft, LightShadowMapTexture shadowMapTexture, ParameterCollection lightParameterCollection)

View on GitHub (pinned to 96fad776d2)