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/07-voxel-shader.js

View on GitHub
// 07-voxel-shader.js — Fragment-only custom shader on a VoxelPrimitive.
// Reduced struct availability: attributes.positionEC and attributes.normalEC only,
// no FeatureIds, no MetadataClass, metadataStatistics has only min/max.
// Asset: CesiumGS/cesium Specs — VoxelBox3DTiles (SCALAR FLOAT32 property `a`).
//   https://raw.githubusercontent.com/CesiumGS/cesium/main/Specs/Data/Cesium3DTiles/Voxel/VoxelBox3DTiles/tileset.json

import { CustomShader, Cesium3DTilesVoxelProvider, VoxelPrimitive } from "cesium";

const voxelShader = new CustomShader({
  fragmentShaderText: `
    void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {
      float v = fsInput.metadata.a;
      // cool → warm gradient, semi-transparent so raymarching accumulates
      material.diffuse = mix(vec3(0.1, 0.2, 0.8), vec3(1.0, 0.6, 0.1), v);
      material.alpha = 0.3 * v;
    }
  `,
});

const provider = await Cesium3DTilesVoxelProvider.fromUrl(
  "https://raw.githubusercontent.com/CesiumGS/cesium/main/Specs/Data/Cesium3DTiles/Voxel/VoxelBox3DTiles/tileset.json",
);

const voxelPrimitive = new VoxelPrimitive({ provider, customShader: voxelShader });
viewer.scene.primitives.add(voxelPrimitive);
voxelPrimitive.nearestSampling = true;
viewer.camera.flyToBoundingSphere(voxelPrimitive.boundingSphere, { duration: 0 });
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