{"record":{"id":"6ee73a168d6126ba","repo":"stride3d/stride","slug":"shader-name-could-not-be-found","errorCode":null,"errorMessage":"Shader {name} could not be found","messagePattern":"Shader (.+?) could not be found","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Compilers/ShaderLoaderBase.cs","lineNumber":67,"sourceCode":"            if (ValidateCachedHashes(buffer))\n                return true;\n            // A dependency changed — invalidate and recompile\n            isFromCache = false;\n        }\n\n        // Coordinate parallel compilations: only one thread compiles a given (name, macros) pair.\n        var macrosHash = ComputeMacrosHash(defines);\n        var macrosArray = defines.ToArray();\n        var key = (name, macrosHash);\n\n        var lazy = compilingShaders.GetOrAdd(key, _ => new Lazy<(ShaderBuffers, ObjectId)>(() =>\n        {\n            // Double-check cache (another thread may have finished between our check and this factory)\n            if (Cache.TryLoadFromCache(name, null, macrosArray, out var buf, out var h) && ValidateCachedHashes(buf))\n                return (buf, h);\n\n            if (!ExternalFileExists(name))\n                throw new InvalidOperationException($\"Shader {name} could not be found\");\n\n            if (!LoadExternalFileContent(name, out var filename, out var code, out h))\n                throw new InvalidOperationException($\"Shader {name} could not be loaded\");\n\n            if (!LoadFromCode(filename, code, h, macrosArray, out buf))\n                throw new InvalidOperationException($\"Shader {name} could not be compiled\");\n\n            return (buf, h);\n        }, LazyThreadSafetyMode.ExecutionAndPublication));\n\n        try\n        {\n            var result = lazy.Value;\n            buffer = result.Buffer;\n            hash = result.Hash;\n            isFromCache = false;\n            return true;\n        }","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Compilers/ShaderLoaderBase.cs#L49-L85","documentation":"ShaderLoaderBase.LoadExternalBuffer resolves a shader by name through a lazy factory. After re-checking the cache, it calls ExternalFileExists(name); if the named shader file is not present anywhere the loader looks, it throws InvalidOperationException \"Shader {name} could not be found\". It is the loader's explicit 'shader not found' signal, distinct from 'found but failed to load/compile'.","triggerScenarios":"Requesting a shader whose .sdsl file does not exist in any registered shader source directory; a typo in the shader name; requesting a shader that was never added to the shader source folders or SDSLC registry.","commonSituations":"Misspelled shader name in effect code; shader asset not copied to output / not in the asset dependency chain; differing shader directories between the editor and the compiled game.","solutions":["Verify the shader name spelling matches the .sdsl file name exactly (case-sensitive on some platforms).","Check the shader source directories/asset registry actually contain the .sdsl file and that ExternalFileExists would resolve it.","Ensure the shader file is included in the project so it is copied to the output directory.","Confirm the cache key/defines used are not aliasing a nonexistent combined shader name (name+macros)."],"exampleFix":"// before\nvar effect = new EffectCompiler().LoadExternalBuffer(\"MyShder\", macros, ...); // typo\n// after\nvar effect = new EffectCompiler().LoadExternalBuffer(\"MyShader\", macros, ...); // matches MyShader.sdsl","handlingStrategy":"validation","validationCode":"if (!File.Exists(Path.Combine(shaderDir, name + \".sdsl\")))\n    throw new FileNotFoundException($\"Shader source missing: {name}.sdsl\");","typeGuard":null,"tryCatchPattern":"try { loader.LoadExternalBuffer(name, macros, out var buf, out var h, out var cached); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"could not be found\")) {\n    ReportMissingShader(name); // surface asset pipeline problem\n}","preventionTips":["Keep shader names in constants/resources instead of raw strings to avoid typos.","Verify .sdsl files are included in build output / asset dependencies.","Run a pre-build validation that all referenced shaders resolve via ExternalFileExists."],"tags":["shader","file-not-found","shader-loader"],"backgroundTag":"resource-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}