Dear PlayCanvas Team,
As a developer working extensively with custom shaders in PlayCanvas, I’ve encountered significant challenges when using the shader chunk system—specifically the material.getShaderChunks(pc.SHADERLANGUAGE_GLSL).set(“chunkName”, “chunkCode”) method. While the chunk system offers powerful flexibility for modifying standard materials (e.g., adding animations without breaking PBR or shadows ), the lack of official documentation has forced the community to work in “blind mode” .
Key Documentation Gaps We Need Addressed:
- Step-by-Step Tutorials for Chunk Manipulation
Many developers struggle to override chunks without breaking core features. For example, modifying vertex shaders often inadvertently disables fragment shader effects like ambient lighting or shadows . A official guide explaining:
-
How to safely override chunks using getShaderChunks().set()
-
Best practices (e.g., modifying specific functions like getPosition() instead of full main() )
-
Uniform parameter integration (as in emission map animations )
- Complete Chunk Name Reference
The community has compiled partial chunk lists , but these are outdated (from 2019) and lack context. We need an official, versioned list of:
-
All chunk names (e.g., basePS, emissivePS, lightDiffuseLambertPS)
-
Their purpose (e.g., normalMapPS for normal mapping, fogLinearPS for fog effects)
-
Compatibility with material types (standard, particle, etc.)
- Shader Chunk Pipeline Explanation
Chunk compilation order directly impacts functionality—for instance, basePS must precede other fragments to define global variables . We need clarity on:
-
Vertex/fragment shader chunk concatenation sequences (e.g., fragment order: basePS → opacityPS → emissivePS → endPS )
-
Dependencies between chunks (e.g., why diffusePS relies on normalPS)