{"record":{"id":"219d231123ba6632","repo":"BabylonJS/Babylon.js","slug":"framegraphhighlightlayertask-this-name-objec-219d23","errorCode":null,"errorMessage":"FrameGraphHighlightLayerTask \"${this.name}\": objectRendererTask depthTexture must have a stencil aspect","messagePattern":"FrameGraphHighlightLayerTask \"(.+?)\": objectRendererTask depthTexture must have a stencil aspect","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/FrameGraph/Tasks/Layers/highlightLayerTask.ts","lineNumber":49,"sourceCode":"            1,\r\n            alphaBlendingMode === Constants.ALPHA_COMBINE ? FrameGraphBaseLayerBlurType.Glow : FrameGraphBaseLayerBlurType.Standard,\r\n            true,\r\n            true\r\n        );\r\n    }\r\n\r\n    public override getClassName(): string {\r\n        return \"FrameGraphHighlightLayerTask\";\r\n    }\r\n\r\n    public override record() {\r\n        if (!this.objectRendererTask.depthTexture) {\r\n            throw new Error(`FrameGraphHighlightLayerTask \"${this.name}\": objectRendererTask must have a depthTexture input`);\r\n        }\r\n\r\n        const depthTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.objectRendererTask.depthTexture);\r\n        if (!depthTextureCreationOptions.options.formats || !HasStencilAspect(depthTextureCreationOptions.options.formats[0])) {\r\n            throw new Error(`FrameGraphHighlightLayerTask \"${this.name}\": objectRendererTask depthTexture must have a stencil aspect`);\r\n        }\r\n\r\n        super.record();\r\n\r\n        this.layer._mainObjectRendererRenderPassId = this.objectRendererTask.objectRenderer.renderPassId;\r\n    }\r\n}\r\n","sourceCodeStart":31,"sourceCodeEnd":57,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/FrameGraph/Tasks/Layers/highlightLayerTask.ts#L31-L57","documentation":"FrameGraphHighlightLayerTask requires the objectRendererTask's depthTexture input to be created with a texture format that includes a stencil aspect (e.g. DEPTH24STENCIL8 or DEPTH32FLOAT_STENCIL8). During record(), the task inspects the depth texture's creation options and throws if the first format lacks stencil, because the highlight layer renders object IDs into a stencil-based mask. This guards against silent visual corruption when the stencil buffer is missing.","triggerScenarios":"Calling highlightLayerTask.record() when objectRendererTask.depthTexture exists but was created with formats whose first entry lacks a stencil aspect (e.g. DEPTH16, DEPTH24, DEPTH32FLOAT without stencil).","commonSituations":"Creating the depth texture for the object renderer task with a plain depth-only format, or letting texture creation options omit/reorder formats so index 0 is stencil-less; copy-pasted task setup code from samples using non-stencil depth formats.","solutions":["Recreate the depth texture used by objectRendererTask with a stencil-bearing format such as Constants.TEXTUREFORMAT_DEPTH24STENCIL8 (or DEPTH32FLOAT_STENCIL8) as the first entry in options.formats.","Verify via frameGraph.textureManager.getTextureCreationOptions(depthTexture).options.formats[0] and HasStencilAspect() before recording the task.","Ensure the depthTexture handle actually points to the intended texture (not an intermediate depth target created elsewhere with a depth-only format)."],"exampleFix":"// before\nconst depthTex = frameGraph.createTexture({ size: { width, height }, options: { formats: [Constants.TEXTUREFORMAT_DEPTH32FLOAT] } });\nobjectRendererTask.depthTexture = depthTex;\n// after\nconst depthTex = frameGraph.createTexture({ size: { width, height }, options: { formats: [Constants.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8] } });\nobjectRendererTask.depthTexture = depthTex;","handlingStrategy":"validation","validationCode":"const opts = frameGraph.textureManager.getTextureCreationOptions(task.objectRendererTask.depthTexture);\nif (!opts.options.formats || !HasStencilAspect(opts.options.formats[0])) {\n  throw new Error(\"highlightLayer depth texture must use a stencil format\");\n}","typeGuard":"function hasStencilDepth(tex: ReturnType<typeof frameGraph.createTexture> | undefined): boolean {\n  if (!tex) return false;\n  const opts = frameGraph.textureManager.getTextureCreationOptions(tex);\n  return !!opts.options.formats && HasStencilAspect(opts.options.formats[0]);\n}","tryCatchPattern":"try {\n  highlightLayerTask.record();\n} catch (e) {\n  if (String(e).includes(\"stencil aspect\")) {\n    // recreate depth texture with DEPTH24STENCIL8 / DEPTH32FLOAT_STENCIL8 and retry\n  } else throw e;\n}","preventionTips":["Always create depth textures consumed by highlight layers with DEPTH24STENCIL8 or DEPTH32FLOAT_STENCIL8.","Centralize depth-texture creation in a helper that enforces stencil formats.","Assert format options at task-wiring time, not at record time."],"tags":["frame-graph","depth-texture","stencil","validation"],"backgroundTag":"missing-stencil-aspect","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}