playcanvas/skills

override-shader-chunks

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.

Trending #8786

Installation

$ npx skills add playcanvas/skills --skill override-shader-chunks

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from playcanvas/skills · top by installs.

npx skills add playcanvas/skills

Browse all from playcanvas/skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 14
License LICENSE
Default branch main
Open issues 1
Status Active

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 3,684 B
  • docs SUMMARY.md 262 B

History

  1. First recorded snapshot · 50 installs

SKILL.md

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 shaderChunks maps, which are internal. Call material.update() after any change so cached shader variants are cleared.

Emissive-only overrides

An emissivePS override implements void getEmission(), writing the result into dEmission. When the override is meant to fully drive the visible color, zero the material's diffuse/specular and disable useSkybox so no other lighting term still contributes underneath it.

Uniforms are raw

setParameter uploads exactly what it is given, with no color-space conversion. Convert any authored sRGB color with Color#linear() before calling setParameter; an sRGB color passed straight through renders visibly darker and less saturated than it was authored.

Keep vertex chunks instancing-aware

A custom transformCoreVS (or any vertex chunk reading the model matrix) must keep the engine's INSTANCING define path — pulling the per-instance matrix under that define — with a non-instanced fallback that uses matrix_model directly, matching the stock chunk's structure. Dropping this path silently breaks instancing for any mesh instance using the material.

Provide GLSL and WGSL, or pin to WebGL

Override both SHADERLANGUAGEGLSL and SHADERLANGUAGEWGSL chunks for anything touched. On a WebGPU device, a chunk supplied only in GLSL forces the material's entire shader — not just that chunk — onto a GLSL-compiled-then-transpiled path; without the optional transpiler modules loaded (the common case), that shader fails to compile. Supply both languages, or explicitly pin the graphics device to WebGL if WGSL support is not required.

Expand bounds for vertex displacement

If the override displaces vertices, expand the mesh's bounds by the maximum displacement (see apply-conventions) — CPU-computed bounds never observe shader-side deformation, so culling breaks silently otherwise.