{"record":{"id":"edeb0eb9d359c38d","repo":"stride3d/stride","slug":"lightshaft-samplecount","errorCode":null,"errorMessage":"lightShaft.SampleCount","messagePattern":"lightShaft\\.SampleCount","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/Images/LightShafts/LightShafts.cs","lineNumber":229,"sourceCode":"                        DrawBoundingVolumeBackside(context, currentBoundingVolumes);\n                    }\n\n                    if (!lightBufferUsed)\n                    {\n                        // First pass: replace (avoid a clear and blend state)\n                        lightShaftsEffectShader.BlendState = BlendStates.Opaque;\n                        lightBufferUsed = true;\n                    }\n                    else\n                    {\n                        // Then: add\n                        var desc = BlendStates.Additive;\n                        desc.RenderTargets[0].ColorSourceBlend = Blend.One; // But without multiplying alpha\n                        lightShaftsEffectShader.BlendState = desc;\n                    }\n\n                    if (lightShaft.SampleCount < 1)\n                        throw new ArgumentOutOfRangeException(nameof(lightShaft.SampleCount));\n\n                    // Set min/max input\n                    lightShaftsEffectShader.SetInput(0, boundingBoxBuffer);\n                    lightShaftsEffectShader.SetInput(1, backSideRaycastBuffer);\n\n                    // Light accumulation pass (on low resolution buffer)\n                    DrawLightShaft(context, lightShaft);\n                }\n\n                // Everything was outside, skip\n                if (!lightBufferUsed)\n                    continue;\n\n                if (LightBufferDownsampleLevel != 1)\n                {\n                    // Blur the result\n                    blur.Radius = LightBufferDownsampleLevel;\n                    blur.SetInput(lightBuffer);","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/Images/LightShafts/LightShafts.cs#L211-L247","documentation":"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.","triggerScenarios":"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.","commonSituations":"Configuring light shafts with a sample count of 0 expecting 'fastest' quality preset, or deserializing old scene assets where the property defaulted to 0.","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"],"exampleFix":"// before\nlightShaft.SampleCount = 0;\n// after\nlightShaft.SampleCount = Math.Max(1, lightShaft.SampleCount);","handlingStrategy":"validation","validationCode":"if (lightShaft.SampleCount < 1)\n    lightShaft.SampleCount = 32; // safe default","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Expose SampleCount in UI with a minimum of 1","Validate sample counts when loading legacy scenes","Wrap quality-preset application to clamp values"],"tags":["csharp","rendering","argument-out-of-range"],"backgroundTag":"argument-out-of-range","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}