cesiumgs/cesiumjs-skills/cesiumjs-custom-shader
Claude Code and agent skill by cesiumgs/cesiumjs-skills
- community
Checking that the SKILL.md file is still in the repository.
CustomShader authoring — vertexShaderText and fragmentShaderText against VertexInput, FragmentInput, FeatureIds, Metadata, czm_modelMaterial. Use when reading EXT_mesh_features or EXT_structural_metadata property textures/tables, vertex displacement, or shading VoxelPrimitive.
Install
npx vskill@latest install cesiumgs/cesiumjs-skills/cesiumjs-custom-shaderSKILL.md
CesiumJS CustomShader
Version baseline: CesiumJS 1.144. All imports use ES module style.
CustomShader injects user GLSL into the Model / Cesium3DTileset / VoxelPrimitive rendering pipeline. It exposes glTF attributes, feature IDs, and EXT_structural_metadata to per-vertex and per-fragment code, and returns values through the built-in czm_modelVertexOutput and czm_modelMaterial structs.
Use this skill for writing the shader body. Use:
cesiumjs-materials-shaders— for FabricMaterial,ImageBasedLighting,PostProcessStage(bloom, SSAO, FXAA, tonemapping).cesiumjs-3d-tiles— for declarative per-feature coloring viaCesium3DTileStyle, and forVoxelPrimitivesetup/configuration.cesiumjs-models-particles— forModel.fromGltfAsync, animations,ModelFeature.getProperty().
Out of scope
- Fabric `Material` for entity polylines/polygons/walls — see
cesiumjs-materials-shaders. - `PostProcessStage` screen-space effects — see
cesiumjs-materials-shaders. - `ImageBasedLighting` — see
cesiumjs-materials-shaders. - `Cesium3DTileStyle` declarative JSON styling — see
cesiumjs-3d-tiles. Do not combine with CustomShader on the same tileset. - Authoring `EXT_structural_metadata` / `EXT_mesh_features` in glTF — tooling concern, not runtime.
Minimal example
Note: Writingmaterial.alpharequirestranslucencyMode: CustomShaderTranslucencyMode.TRANSLUCENT— see "Translucency" below. On opaque models with the defaultINHERITmode, alpha writes are silently ignored.
Visual eval framing: after adding a shaderedModel, wait until the modelis ready enough to render, then frame a known target point explicitly. Do notrely on the first post-load frame or on a tiny default-scale model. For publicmodel evals, setminimumPixelSize(usually 256-400), use a moderatescale,and add a silhouette or strong color tint when the shader effect is the thingbeing judged.
Applying a CustomShader
Model — constructor option or mutable property:
Cesium3DTileset — constructor option or mutable property. Only Model-backed tile content is affected (not native I3S or other formats):
Per theCesium3DTileset.customShaderJSDoc: "Using custom shaders with a `Cesium3DTileStyle` may lead to undefined behavior." The property is also marked@experimental— it uses 3D Tiles spec surface that is not final and may change without Cesium's standard deprecation policy.
VoxelPrimitive — fragment-only subset (see "VoxelPrimitive shader subset" below):
The engine calls customShader.update(frameState) automatically each frame. When finished with a CustomShader, call customShader.destroy() to release GPU texture resources owned by its TextureManager.
Constructor reference
Either vertexShaderText or fragmentShaderText is typically required. See REFERENCE.md for exhaustive enum values.
Shader function signatures
The runtime calls these from generated pipeline stages. Parameter names are part of the contract — renaming them breaks the shader.
Uniforms
Declare uniforms with { type, value }. The type is a UniformType value; the JS value type must match (e.g. VEC3 → Cartesian3). Uniforms are accessible in GLSL by their declared name.
TextureUniform accepts either url (string or Resource) or typedArray + width + height — exactly one (constructor throws otherwise). Other options: repeat (default true), pixelFormat, pixelDatatype, minificationFilter, magnificationFilter, maximumAnisotropy.
`SAMPLER_CUBE` is declared on `UniformType` but rejected at construction — throws DeveloperError("CustomShader does not support samplerCube uniforms"). Only SAMPLER_2D is supported.
Varyings
Declared varyings are emitted as out <type> <name> in the vertex shader and in <type> <name> in the fragment shader. Write in vertex, read in fragment.
VaryingType supports FLOAT, VEC2–VEC4, MAT2–MAT4. No INT/BOOL/SAMPLER variants.
Modes & lighting
`CustomShaderMode`:
MODIFY_MATERIAL(default) — runs after the material stage, before lighting.czm_modelMaterialis populated with PBR/texture results; the shader refines them.REPLACE_MATERIAL— skips the material stage entirely. Shader sets every field procedurally. Cheaper when the source material is not needed.
`LightingModel`:
UNLIT— skip lighting;material.diffusebecomes the final color (alpha still applied). Flat-shaded.PBR— physically-based with IBL when available.- Omitted — preserves the model's default lighting. Omit unless overriding intentionally.
Pair REPLACE_MATERIAL + UNLIT for pure procedural flat shading (no material sampling, no lighting).
Translucency
CustomShaderTranslucencyMode governs how alpha writes interact with the render pass:
INHERIT(default) — alpha is only honored if the source material is translucent.OPAQUE— force opaque pass.TRANSLUCENT— force translucent pass.
Pitfall: writing material.alpha on an opaque model with INHERIT silently does nothing. Set translucencyMode: CustomShaderTranslucencyMode.TRANSLUCENT to make alpha writes effective.
See examples/04-translucent-override.js.
Attributes
vsInput.attributes and fsInput.attributes expose glTF vertex attributes. Names are case-sensitive and coordinate-space suffixes are required — the constructor rejects bare position/normal/tangent/bitangent.
Common fields (full table in REFERENCE.md):
positionMC— model coords, valid in VS and FSpositionWC— world (ECEF) coords, fragment only, low-precisionpositionEC— eye coords, fragment onlynormalMC/normalEC— vertex / fragmenttangentMC/tangentEC,bitangentMC/bitangentECtexCoord_N,color_N,joints_N,weights_N
Coordinate-space validation. The constructor scans shader text and throwsDeveloperError("<name> is not available in the <stage> shader. Did you mean <alt> instead?")for invalid combinations. Examples:positionECin vertex,normalMCin fragment.
Custom underscore-prefixed glTF attributes (_FEATURE_ID_0, _SURFACE_TEMP) are lowercased and un-prefixed: fsInput.attributes.surface_temp.
FeatureIds
vsInput.featureIds / fsInput.featureIds unify three glTF sources into one struct:
featureId_N— feature ID attributes and implicit attributes fromEXT_mesh_features(N is the array index in the primitive'sfeatureIdsarray). Also covers feature ID textures, which are fragment-shader-only.instanceFeatureId_N— per-instance feature IDs fromEXT_instance_features+EXT_mesh_gpu_instancing.- Named aliases — if glTF specifies
"label": "perVertex", thenfeatureIds.perVertexis also available. - Legacy 3D Tiles 1.0
BATCH_ID/_BATCHID→ transparently renamed tofeatureId_0.
GLSL type is always int. WebGL 1 loses precision above 2^24.
See examples/03-feature-id-tileset.js.
Metadata
EXT_structural_metadata surfaces three source types (all addressable from shaders as of 1.139):
- Property attributes — per-vertex. Vertex and fragment shaders.
- Property textures — per-texel. Fragment only.
- Property tables — per-feature, keyed by feature ID. Added in 1.139 (#13124).
Property ID sanitization (GLSL identifier rules):
- Non-alphanumeric runs → single
_(temperature ℃→temperature_) - Leading
gl_stripped (gl_custom→custom) - Leading digit prefixed with
_(12345→_12345) - Post-sanitization collisions → undefined behavior
Sibling structs: metadataClass.<prop>.noData | defaultValue | minValue | maxValue (class-schema bounds) and metadataStatistics.<prop>.minValue | maxValue | mean | median | standardDeviation | variance | sum (populated only when tileset.json declares statistics).
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/cesiumjs-custom-shader/SKILL.md
Popularity
- Repository stars
- 44
- Repository forks
- 7
- 7-day trend score
- 19
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 20 May 2026, 5 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cesiumgs/cesiumjs-skills/cesiumjs-custom-shader)