Skip to content

CesiumGS/cesiumjs-skills / skills/cesiumjs-custom-shader

cesiumjs-custom-shader

Verified

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.

examples/06-metadata-ramp.js

View on GitHub
// 06-metadata-ramp.js — Fragment-shader color ramp driven by EXT_structural_metadata
// property texture (per-texel). The `insulation` property is UINT8 with normalized:true,
// so it arrives in GLSL as a float in [0, 1] — map directly through a color ramp.
// Asset: CesiumGS/3d-tiles-samples — SimplePropertyTexture (EXT_structural_metadata
// with three UINT8 scalar properties via propertyTextures).
//   https://raw.githubusercontent.com/CesiumGS/3d-tiles-samples/main/glTF/EXT_structural_metadata/SimplePropertyTexture/tileset.json
//
// Note on assets: public .glb files carrying EXT_structural_metadata are scarce. The skill
// documents this example on a Cesium3DTileset only; the shader surface is identical on Model.
//
// Note on types: after 1.139 (#13135), unsigned metadata preserves its signedness — for
// non-normalized UINT8 properties such as `insideTemperature` you would write
// `uint t = fsInput.metadata.insideTemperature; float f = float(t) / 255.0;`. `insulation`
// is declared `normalized: true`, so the runtime delivers a float in [0, 1] directly.

import { CustomShader, LightingModel, Cesium3DTileset } from "cesium";

const rampShader = new CustomShader({
  lightingModel: LightingModel.UNLIT,
  fragmentShaderText: `
    void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {
      float t = fsInput.metadata.insulation;   // normalized UINT8 → float in [0, 1]
      // cool → warm ramp: thin insulation (0) is cold/blue, thick (1) is warm/red
      material.diffuse = mix(vec3(0.1, 0.3, 0.9), vec3(1.0, 0.3, 0.1), t);
    }
  `,
});

const tileset = await Cesium3DTileset.fromUrl(
  "https://raw.githubusercontent.com/CesiumGS/3d-tiles-samples/main/glTF/EXT_structural_metadata/SimplePropertyTexture/tileset.json",
  { customShader: rampShader },
);
viewer.scene.primitives.add(tileset);
viewer.zoomTo(tileset);
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall