{"record":{"id":"c0ae4af93a367926","repo":"stride3d/stride","slug":"can-t-generate-lightprobes-if-less-than-4-of-them-exists","errorCode":null,"errorMessage":"Can't generate lightprobes if less than 4 of them exists.","messagePattern":"Can't generate lightprobes if less than 4 of them exists\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Engine/Rendering/LightProbes/LightProbeGenerator.cs","lineNumber":120,"sourceCode":"\n                    // Copy coefficients\n                    if (lightProbe?.Coefficients != null)\n                    {\n                        var lightProbeCoefStart = lightProbeIndex * LambertHamonicOrder * LambertHamonicOrder;\n                        for (var index = 0; index < LambertHamonicOrder * LambertHamonicOrder; index++)\n                        {\n                            destColors[lightProbeCoefStart + index] = index < lightProbe.Coefficients.Count ? lightProbe.Coefficients[index] : new Color3();\n                        }\n                    }\n                }\n            }\n        }\n\n        public static unsafe LightProbeRuntimeData GenerateRuntimeData(List<LightProbeComponent> lightProbes)\n        {\n            // TODO: Better check: coplanar, etc... (maybe the check inside BowyerWatsonTetrahedralization might be enough -- tetrahedron won't be in positive order)\n            if (lightProbes.Count < 4)\n                throw new InvalidOperationException(\"Can't generate lightprobes if less than 4 of them exists.\");\n\n            var lightProbePositions = new List<Vector3>();\n            var lightProbeCoefficients = new Color3[lightProbes.Count * LambertHamonicOrder * LambertHamonicOrder];\n            var destColors = lightProbeCoefficients.AsSpan();\n            #if false\n            ref var destColorsOrigin = ref destColors.GetPinnableReference();\n            #endif\n\n            for (var lightProbeIndex = 0; lightProbeIndex < lightProbes.Count; lightProbeIndex++)\n            {\n                var lightProbe = lightProbes[lightProbeIndex];\n\n                // Copy light position\n                lightProbePositions.Add(lightProbe.Entity.Transform.WorldMatrix.TranslationVector);\n\n                // Copy coefficients\n                if (lightProbe.Coefficients != null)\n                {","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Engine/Rendering/LightProbes/LightProbeGenerator.cs#L102-L138","documentation":"LightProbeGenerator.GenerateRuntimeData requires at least 4 light probes because it builds a tetrahedralization (Bowyer-Watson) of probe positions, and a tetrahedron needs 4 non-coplanar points. With fewer probes, no valid tetrahedral mesh can be generated, so it throws InvalidOperationException.","triggerScenarios":"Calling GenerateRuntimeData (directly or via light probe processing at scene build/cooking time) with a List<LightProbeComponent> containing 0-3 probes.","commonSituations":"A scene where only a few light probe entities were placed; probes accidentally deleted or filtered out by a volume query; automated tooling generating probes sparsely on small test scenes.","solutions":["Add at least 4 light probes (ideally more, non-coplanar) to the volume/scene before generating runtime data.","Guard the generation call: only run probe baking/generation when probe count >= 4.","If the scene is too small for 4 probes, disable light probes or use ambient light instead of probe-based GI.","Fix volume/selection logic that filters probes down below the threshold unintentionally."],"exampleFix":"// before\nLightProbeGenerator.GenerateRuntimeData(probes); // throws if probes.Count < 4\n// after\nif (probes.Count >= 4)\n    LightProbeGenerator.GenerateRuntimeData(probes);","handlingStrategy":"validation","validationCode":"bool canGenerateProbes(List<LightProbeComponent> probes) => probes != null && probes.Count >= 4;","typeGuard":null,"tryCatchPattern":"try { LightProbeGenerator.GenerateRuntimeData(probes); } catch (InvalidOperationException ex) { log.Error($\"Probe bake skipped: {ex.Message}\"); }","preventionTips":["Place at least 4 non-coplanar probes before baking","Check probe count in build/cook scripts","Fall back to ambient lighting on tiny scenes","Verify volume queries don't filter probes below the threshold"],"tags":["lighting","light-probes","validation"],"backgroundTag":"invalid-argument-value","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"}