stride3d/stride · error · ArgumentOutOfRangeException
lightShaft.SampleCount
Error message
lightShaft.SampleCount
What it means
Each light shaft requires at least one ray-march sample; SampleCount < 1 would make the light accumulation pass a no-op or read invalid data. DrawCore throws ArgumentOutOfRangeException naming lightShaft.SampleCount before binding the effect inputs.
Solutions
- Set lightShaft.SampleCount to a positive value (e.g. 16-64)
- Clamp to at least 1 at configuration time
- Fix asset/serialization defaults that store 0
Example fix
// before lightShaft.SampleCount = 0; // after lightShaft.SampleCount = Math.Max(1, lightShaft.SampleCount);
Defensive patterns
Strategy: validation
Validate before calling
if (lightShaft.SampleCount < 1)
lightShaft.SampleCount = 32; // safe default Prevention
- Expose SampleCount in UI with a minimum of 1
- Validate sample counts when loading legacy scenes
- Wrap quality-preset application to clamp values
When it happens
Trigger: A LightShaft whose SampleCount was set to 0 or negative (e.g. initialized from an uninitialized int field or a UI slider at its minimum 0) being rendered in DrawCore.
Common situations: Configuring light shafts with a sample count of 0 expecting 'fastest' quality preset, or deserializing old scene assets where the property defaulted to 0.
Related errors
- BoundingVolumeBufferDownsampleLevel
- Unsupported format [ ] (must be not none, compressed…
- ArgumentOutOfRangeException
- ArgumentOutOfRangeException
- Asked for " + i + " but no more than 10 default textures…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/edeb0eb9d359c38d.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Rendering/Rendering/Images/LightShafts/LightShafts.cs:229
DrawBoundingVolumeBackside(context, currentBoundingVolumes);
}
if (!lightBufferUsed)
{
// First pass: replace (avoid a clear and blend state)
lightShaftsEffectShader.BlendState = BlendStates.Opaque;
lightBufferUsed = true;
}
else
{
// Then: add
var desc = BlendStates.Additive;
desc.RenderTargets[0].ColorSourceBlend = Blend.One; // But without multiplying alpha
lightShaftsEffectShader.BlendState = desc;
}
if (lightShaft.SampleCount < 1)
throw new ArgumentOutOfRangeException(nameof(lightShaft.SampleCount));
// Set min/max input
lightShaftsEffectShader.SetInput(0, boundingBoxBuffer);
lightShaftsEffectShader.SetInput(1, backSideRaycastBuffer);
// Light accumulation pass (on low resolution buffer)
DrawLightShaft(context, lightShaft);
}
// Everything was outside, skip
if (!lightBufferUsed)
continue;
if (LightBufferDownsampleLevel != 1)
{
// Blur the result
blur.Radius = LightBufferDownsampleLevel;
blur.SetInput(lightBuffer);View on GitHub (pinned to 96fad776d2)