# override-shader-chunks

Shows how to customise a PlayCanvas StandardMaterial's shading with chunk overrides before writing a full custom shader.

Skill by PlayCanvas. Category: Design and frontend.

## Install

Project (for this project only):

```sh
npx skills add playcanvas/skills --skill override-shader-chunks
```

Works with: Claude Code, Codex CLI, Cursor, Antigravity, Copilot CLI, opencode.

Global (for every project on this machine):

```sh
npx skills add playcanvas/skills --skill override-shader-chunks -g
```

Works with: Claude Code, Codex CLI, Cursor, Antigravity, Copilot CLI, opencode.

## Tags

- Runs on your computer: It runs as a program on your machine, with your access.

## Security audits

- Gen Agent Trust Hub: Pass
- Socket: Pass
- Snyk: Pass

Installs: 201. Installs counted by skills.sh. [Open on skills.sh](https://www.skills.sh/playcanvas/skills/override-shader-chunks)

## Source

[Open the source](https://github.com/playcanvas/skills/tree/HEAD/skills/override-shader-chunks). Checked 2026-10-10. This summary may contain AI-generated text, so it can be wrong. Check the source before you rely on it.

## SKILL.md

````markdown
---
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.23'`. 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`.
````

- Previous: [bake-lighting](https://syn4pse.dev/terminal/playcanvas-bake-lighting.md)
- Next: [vps](https://syn4pse.dev/terminal/hostinger-vps.md)
- [Terminal](https://syn4pse.dev/terminal.md)
- [Suggest a change](mailto:terminal@syn4pse.dev?subject=Terminal%20suggestion)
