override-shader-chunks
Use when a PlayCanvas StandardMaterial needs custom shading its properties cannot express, such as stylized looks or vertex displacement, before writing a ShaderMaterial.
Install
npx skills add https://github.com/playcanvas/skills/tree/main/skills/override-shader-chunks
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install playcanvas-skills@llmmart
git clone https://github.com/playcanvas/skills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole playcanvas/skills collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
Override shader chunks
Overriding a StandardMaterial chunk keeps fog, tone mapping, shadows, skinning, and instancing
intact. Use a ShaderMaterial only when the look needs its own vertex and fragment pair.
- Set
material.shaderChunksVersionto the installed major.minor, such as'2.24'. Chunk names and contracts change between versions, so read the installed chunk source, not memory. - Set chunks with
material.getShaderChunks(SHADERLANGUAGE_GLSL).set(name, source)and the WGSL equivalent, then callmaterial.update(). For every material on a device, useShaderChunks.get(device, language); the globalshaderChunksobject is deprecated. - Supply both GLSL and WGSL. On WebGPU, one GLSL-only chunk sends the whole shader through a transpiler that is usually not loaded, so it fails to compile. Otherwise pin the device to WebGL.
- Clone shared materials, including imported ones, before overriding them for only some meshes.
Per-mesh uniforms use
meshInstance.setParameter(). - Uniforms are raw; convert sRGB colours with
Color#linear(). - Vertex chunks that read the model matrix, such as
transformCoreVS, must keep theINSTANCINGpath with amatrix_modelfallback, like the stock chunk. - Expand mesh bounds by the maximum displacement; CPU bounds do not see shader deformation.
- For an emissive-only look, implement
getEmission()writingdEmission, zerodiffuseandspecular, and disableuseSkybox.
Files (skills)
-
SKILL.md 1.6 KB
--- name: override-shader-chunks description: Use when a PlayCanvas StandardMaterial needs custom shading its properties cannot express, such as stylized looks or vertex displacement, before writing a ShaderMaterial. --- # Override shader chunks Overriding a `StandardMaterial` chunk keeps fog, tone mapping, shadows, skinning, and instancing intact. Use a `ShaderMaterial` only when the look needs its own vertex and fragment pair. - Set `material.shaderChunksVersion` to the installed major.minor, such as `'2.24'`. Chunk names and contracts change between versions, so read the installed chunk source, not memory. - Set chunks with `material.getShaderChunks(SHADERLANGUAGE_GLSL).set(name, source)` and the WGSL equivalent, then call `material.update()`. For every material on a device, use `ShaderChunks.get(device, language)`; the global `shaderChunks` object is deprecated. - Supply both GLSL and WGSL. On WebGPU, one GLSL-only chunk sends the whole shader through a transpiler that is usually not loaded, so it fails to compile. Otherwise pin the device to WebGL. - Clone shared materials, including imported ones, before overriding them for only some meshes. Per-mesh uniforms use `meshInstance.setParameter()`. - Uniforms are raw; convert sRGB colours with `Color#linear()`. - Vertex chunks that read the model matrix, such as `transformCoreVS`, must keep the `INSTANCING` path with a `matrix_model` fallback, like the stock chunk. - Expand mesh bounds by the maximum displacement; CPU bounds do not see shader deformation. - For an emissive-only look, implement `getEmission()` writing `dEmission`, zero `diffuse` and `specular`, and disable `useSkybox`.
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.