stride3d/stride · error · ArgumentOutOfRangeException
Tried to access attribute index
Error message
Tried to access attribute index
What it means
LightVoxelRenderer's GetTraceAttr throws ArgumentOutOfRangeException when the light's AttributeIndex is >= the number of entries in processedVolume.OutputAttributes. The index is zero-based and must select one of the voxel volume's output attributes for the light's trace. Typically this means the volume produces fewer attributes than the light expects.
Solutions
- Set AttributeIndex to a valid zero-based index within the volume's output attribute count.
- Re-select the correct attribute in the light component after changing the voxel volume's configuration.
- Before querying, check AttributeIndex < processedVolume.OutputAttributes.Count and clamp or fall back.
Example fix
// before
var light = new LightVoxel { Volume = volume, AttributeIndex = 3 }; // volume has 2 attributes
// after
var count = volume.OutputAttributes.Count; // ensure <= count-1
var light = new LightVoxel { Volume = volume, AttributeIndex = Math.Min(3, count - 1) }; Defensive patterns
Strategy: validation
Validate before calling
if (lightVoxel.AttributeIndex >= processedVolume.OutputAttributes.Count)
{
lightVoxel.AttributeIndex = 0; // clamp to a valid zero-based index
} Type guard
bool HasValidAttributeIndex(LightVoxel lv, ProcessedVoxelVolume vol) =>
lv.AttributeIndex >= 0 && lv.AttributeIndex < vol.OutputAttributes.Count; Try / catch
try { attr = GetTraceAttr(); }
catch (ArgumentOutOfRangeException) { attr = processedVolume.OutputAttributes.FirstOrDefault(); } Prevention
- Re-check AttributeIndex whenever a voxel volume's attribute set changes.
- Clamp indices to OutputAttributes.Count - 1 instead of hardcoding.
- Prefer selecting attributes by name/lookup rather than raw index.
When it happens
Trigger: Setting LightVoxel.AttributeIndex to a value equal to or larger than the voxel volume's OutputAttributes.Count, often after changing the volume's attribute configuration.
Common situations: Changing a voxel volume's baked attributes so a previously chosen index no longer exists; copying a light from another scene with a different volume; setting index 1 on a volume that only outputs one attribute.
Related errors
- No Voxel Volume Component selected for voxel light.
- Custom strides is not supported with packed PixelFormats
- PerView VoxelizerStorer layout differs between different…
- Graphics Profile Level 11 or higher required for…
- Render Stages required for voxelization, only
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/379e642f55f32f22.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Voxels/Voxels/Light/LightVoxelRenderer.cs:130
ProcessedVoxelVolume processedVolume = voxelVolumeProcessor.GetProcessedVolumeForComponent(lightVoxel.Volume);
return processedVolume;
}
VoxelAttribute GetTraceAttr()
{
var lightVoxel = ((LightVoxel)Light.Type);
ProcessedVoxelVolume processedVolume = GetProcessedVolume();
if (processedVolume == null)
return null;
if (processedVolume.OutputAttributes.Count > lightVoxel.AttributeIndex)
{
return processedVolume.OutputAttributes[lightVoxel.AttributeIndex];
}
else
{
throw new ArgumentOutOfRangeException("Tried to access attribute index " + lightVoxel.AttributeIndex.ToString() + " (zero-indexed) when the Voxel Volume Component has only " + processedVolume.OutputAttributes.Count.ToString() + " attributes.");
}
}
public override void UpdateLayout(string compositionName)
{
base.UpdateLayout(compositionName);
traceAttribute = GetTraceAttr();
intensityKey = LightVoxelShaderKeys.Intensity.ComposeWith(compositionName);
specularIntensityKey = LightVoxelShaderKeys.SpecularIntensity.ComposeWith(compositionName);
diffuseMarcherKey = LightVoxelShaderKeys.diffuseMarcher.ComposeWith(compositionName);
specularMarcherKey = LightVoxelShaderKeys.specularMarcher.ComposeWith(compositionName);
attributeSamplersKey = MarchAttributesKeys.AttributeSamplers.ComposeWith(compositionName);
if (traceAttribute != null)
{
if (((LightVoxel)Light.Type).DiffuseMarcher != null)View on GitHub (pinned to 96fad776d2)