{"record":{"id":"4e1a89e7ec65fa2b","repo":"mrdoob/three.js","slug":"three-webglprogram-can-not-resolve-include","errorCode":null,"errorMessage":"THREE.WebGLProgram: Can not resolve #include <' + include + '>","messagePattern":"THREE\\.WebGLProgram: Can not resolve #include <' \\+ include \\+ '>","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderers/webgl/WebGLProgram.js","lineNumber":268,"sourceCode":"\nconst shaderChunkMap = new Map();\n\nfunction includeReplacer( match, include ) {\n\n\tlet string = ShaderChunk[ include ];\n\n\tif ( string === undefined ) {\n\n\t\tconst newInclude = shaderChunkMap.get( include );\n\n\t\tif ( newInclude !== undefined ) {\n\n\t\t\tstring = ShaderChunk[ newInclude ];\n\t\t\twarn( 'WebGLRenderer: Shader chunk \"%s\" has been deprecated. Use \"%s\" instead.', include, newInclude );\n\n\t\t} else {\n\n\t\t\tthrow new Error( 'THREE.WebGLProgram: Can not resolve #include <' + include + '>' );\n\n\t\t}\n\n\t}\n\n\treturn resolveIncludes( string );\n\n}\n\n// Unroll Loops\n\nconst unrollLoopPattern = /#pragma unroll_loop_start\\s+for\\s*\\(\\s*int\\s+i\\s*=\\s*(\\d+)\\s*;\\s*i\\s*<\\s*(\\d+)\\s*;\\s*i\\s*\\+\\+\\s*\\)\\s*{([\\s\\S]+?)}\\s+#pragma unroll_loop_end/g;\n\nfunction unrollLoops( string ) {\n\n\treturn string.replace( unrollLoopPattern, loopReplacer );\n\n}","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/mrdoob/three.js/blob/da05705fa31f02710c19772a2aa70c7454807f0c/src/renderers/webgl/WebGLProgram.js#L250-L286","documentation":"Thrown by WebGLProgram's resolveIncludes() when a `#include <name>` directive in a shader references a chunk not found in the ShaderChunk registry and not present in the deprecation shaderChunkMap. Three injects shader snippets by name at build time; an unresolved name means the chunk is missing, misspelled, or removed.","triggerScenarios":"Using ShaderMaterial/RTM with a custom shader string containing `#include <foo>` where 'foo' is not a registered ShaderChunk. Referring to a chunk that was renamed or removed in a three.js upgrade. Typing a chunk name wrong.","commonSituations":"Upgrading three.js and using a chunk that was renamed/deprecated beyond the deprecation map's coverage. Hand-written GLSL referencing internal chunks that no longer exist. Custom shaders ported from examples that depended on private chunks. Misspelling common chunks like `#include <encodings_fragment>` vs the current name.","solutions":["Check the chunk name against `THREE.ShaderChunk` keys (and ShaderLib) for the installed three.js version.","Replace removed/renamed chunks with the current equivalents; consult the migration notes for the version you upgraded across.","If the chunk is custom, register it first: `THREE.ShaderChunk.mychunk = '...glsl...';`.","Remove the `#include` and inline the GLSL manually if no equivalent chunk exists."],"exampleFix":"// before\nmaterial = new THREE.ShaderMaterial({\n  fragmentShader: '#include <tonemapping_fragment_old>' // removed/renamed\n});\n\n// after\nmaterial = new THREE.ShaderMaterial({\n  fragmentShader: '#include <tonemapping_fragment>' // current name\n});","handlingStrategy":"try-catch","validationCode":"function validateIncludes(glsl, ShaderChunk) {\n  const re = /#include\\s*<([\\w-]+)>/g;\n  let m, missing = [];\n  while ((m = re.exec(glsl))) if (!(m[1] in ShaderChunk)) missing.push(m[1]);\n  if (missing.length) throw new Error('Unknown shader chunks: ' + missing.join(', '));\n}","typeGuard":"function allIncludesResolve(glsl, ShaderChunk) {\n  const re = /#include\\s*<([\\w-]+)>/g;\n  let m;\n  while ((m = re.exec(glsl))) if (!(m[1] in ShaderChunk)) return false;\n  return true;\n}","tryCatchPattern":"try {\n  material = new THREE.ShaderMaterial({ fragmentShader });\n} catch (e) {\n  if (/Can not resolve #include/.test(e.message)) { /* list ShaderLib keys, fix chunk name, rebuild */ }\n  else throw e;\n}","preventionTips":["After upgrading three.js, audit custom ShaderMaterial strings against the current ShaderLib/ShaderChunk keys.","Register custom chunks in THREE.ShaderChunk before referencing them via #include.","Add a build-time check that greps your shader sources for unresolved include names."],"tags":["webgl","shader","shadermaterial","glsl","include","version-upgrade"],"backgroundTag":null,"analyzedSha":"da05705fa31f02710c19772a2aa70c7454807f0c","analyzedAt":"2026-08-12T22:51:37.160Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}