← ClaudeAtlas

override-shader-chunkslisted

Use when a PlayCanvas StandardMaterial needs custom shading its properties cannot express — procedural or stylized looks, custom vertex displacement, per-material screen effects — before writing a standalone shader from scratch.
playcanvas/skills · ★ 15 · Code & Development · score 80
Install: claude install-skill playcanvas/skills
# Override shading through chunks A `StandardMaterial`'s shader is assembled from named chunks (lighting, combine, transform, and more). Overriding one keeps the rest of the pipeline — fog, tonemapping, shadows, skinning, instancing — intact. Reach for a fully custom `ShaderMaterial` only when the look needs a stage the chunk system does not expose at all (its own vertex/fragment pair and attribute layout); a chunk override is the default for everything else, since it is cheaper and stays integrated. ## Pin the version, read the source Set `material.shaderChunksVersion` to the installed engine's major.minor (for example `'2.22'`) before shipping any override. Chunk names and their contracts — what a chunk defines, what globals it reads or writes — are version-keyed and change between releases. Read the installed `playcanvas` source for the exact chunk being touched; do not recall its contract from memory or an older version's documentation. ## Clone before overriding a shared material Clone a material that other mesh instances share — including default and asset-imported materials — before changing its chunks, properties, or material-level parameters for only some meshes, and assign the clone. For per-mesh uniforms, use `meshInstance.setParameter()` without cloning the material. ## Set chunks through the documented accessor Use `material.getShaderChunks(SHADERLANGUAGE_GLSL).set(name, source)`, and the WGSL equivalent — the public, documented method — not the underlying