@anov/gis-skills-cli 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +618 -0
- package/INSTALL.md +478 -0
- package/LICENSE +15 -0
- package/README.md +148 -2
- package/RELEASING.md +160 -0
- package/bin/anov-gis-skills.mjs +408 -0
- package/lib/mcp-config.mjs +273 -0
- package/package.json +42 -4
- package/skills/anovgis-analysis/SKILL.md +585 -0
- package/skills/anovgis-effects/SKILL.md +260 -0
- package/skills/anovgis-imagery-terrain/SKILL.md +505 -0
- package/skills/anovgis-layers/SKILL.md +627 -0
- package/skills/anovgis-materials/SKILL.md +635 -0
- package/skills/anovgis-models-3dtiles/SKILL.md +448 -0
- package/skills/anovgis-pitfalls/SKILL.md +561 -0
- package/skills/anovgis-popup-widget/SKILL.md +474 -0
- package/skills/anovgis-primitives/SKILL.md +482 -0
- package/skills/anovgis-vector-graphics/SKILL.md +602 -0
- package/skills/anovgis-viewer/SKILL.md +618 -0
- package/skills/using-anovgis/DEMO-MAP.md +64 -0
- package/skills/using-anovgis/DEMO-SKILL-MAP.md +248 -0
- package/skills/using-anovgis/DOMAINS.md +183 -0
- package/skills/using-anovgis/REFERENCE.md +114 -0
- package/skills/using-anovgis/SKILL.md +392 -0
- package/skills/using-anovgis/templates/README.md +154 -0
- package/skills/using-anovgis/templates/combo1-vue3-vite.md +295 -0
- package/skills/using-anovgis/templates/combo2-vue2-cli.md +119 -0
- package/skills/using-anovgis/templates/combo3-html-cdn.md +107 -0
- package/skills/using-anovgis/templates/combo4-vanilla-webpack.md +91 -0
- package/skills/using-anovgis/templates/wizard-profiles.md +105 -0
- package/vendor/cesiumjs-skills/LICENSE +201 -0
- package/vendor/cesiumjs-skills/NOTICE +18 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-3d-tiles/SKILL.md +465 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-camera/SKILL.md +500 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-core-utilities/SKILL.md +403 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/REFERENCE.md +397 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/SKILL.md +351 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/01-diffuse-tint.js +38 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/02-texture-swap.js +42 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/03-feature-id-tileset.js +29 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/04-translucent-override.js +37 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/05-vertex-displacement.js +49 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/06-metadata-ramp.js +34 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/07-voxel-shader.js +27 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/README.md +19 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/_sandcastle-template.html +9 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-entities/SKILL.md +389 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-imagery/SKILL.md +471 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-interaction/SKILL.md +423 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-materials-shaders/SKILL.md +292 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-models-particles/SKILL.md +423 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-primitives/SKILL.md +537 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-spatial-math/SKILL.md +358 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-terrain-environment/SKILL.md +401 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-time-properties/SKILL.md +353 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-viewer-setup/SKILL.md +434 -0
- package/vendor/cesiumjs-skills/skills/using-cesiumjs-skills/SKILL.md +35 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
# CustomShader Reference
|
|
2
|
+
|
|
3
|
+
Exhaustive struct/enum tables and built-in uniform catalog for the `cesiumjs-custom-shader` skill. Updated for the CesiumJS 1.142 public API.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Attributes struct
|
|
8
|
+
|
|
9
|
+
Auto-generated per primitive from glTF attributes. Access via `vsInput.attributes.<name>` or `fsInput.attributes.<name>`.
|
|
10
|
+
|
|
11
|
+
| glTF attribute | Shader field | GLSL type | Vertex | Fragment | Notes |
|
|
12
|
+
|---|---|---|---|---|---|
|
|
13
|
+
| `POSITION` | `positionMC` | `vec3` | Yes | Yes | Model coordinates |
|
|
14
|
+
| `POSITION` | `positionWC` | `vec3` | — | Yes | World (ECEF) coordinates, low precision |
|
|
15
|
+
| `POSITION` | `positionEC` | `vec3` | — | Yes | Eye coordinates |
|
|
16
|
+
| `NORMAL` | `normalMC` | `vec3` | Yes | — | Unit normal, model coordinates |
|
|
17
|
+
| `NORMAL` | `normalEC` | `vec3` | — | Yes | Unit normal, eye coordinates |
|
|
18
|
+
| `TANGENT` | `tangentMC` | `vec3` | Yes | — | `w` stripped after bitangent computation |
|
|
19
|
+
| `TANGENT` | `tangentEC` | `vec3` | — | Yes | Same as above, eye space |
|
|
20
|
+
| `NORMAL` + `TANGENT` | `bitangentMC` | `vec3` | Yes | — | Only when both N + T present |
|
|
21
|
+
| `NORMAL` + `TANGENT` | `bitangentEC` | `vec3` | — | Yes | Same |
|
|
22
|
+
| `TEXCOORD_N` | `texCoord_N` | `vec2` | Yes | Yes | N = 0, 1, 2, … |
|
|
23
|
+
| `COLOR_N` | `color_N` | `vec4` | Yes | Yes | Alpha defaults to 1 when absent |
|
|
24
|
+
| `JOINTS_N` | `joints_N` | `ivec4` | Yes | Yes | Skin joint indices |
|
|
25
|
+
| `WEIGHTS_N` | `weights_N` | `vec4` | Yes | Yes | Skin weights |
|
|
26
|
+
|
|
27
|
+
**Custom underscore-prefixed attributes.** glTF attributes starting with `_` are lowercased and un-prefixed: `_SURFACE_TEMPERATURE` → `fsInput.attributes.surface_temperature`.
|
|
28
|
+
|
|
29
|
+
**Fallback when missing.** If a primitive lacks a requested attribute (e.g. no `TEXCOORD_0`), the runtime either synthesizes a default or, when no sensible default exists, disables the custom shader stage *just for that primitive*. Other primitives in the same model/tile continue to use the shader.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Coordinate-space validation errors
|
|
34
|
+
|
|
35
|
+
The `CustomShader` constructor scans shader text and throws `DeveloperError` for ambiguous or wrong-stage attribute names. Error format:
|
|
36
|
+
|
|
37
|
+
> `<name> (<coord-space>) is not available in the <stage> shader. Did you mean <alternative> (<coord-space>) instead?`
|
|
38
|
+
|
|
39
|
+
Suffix expansion: `MC` → "(model coordinates)", `WC` → "(Cartesian world coordinates)", `EC` → "(eye coordinates)". Bare names are not expanded.
|
|
40
|
+
|
|
41
|
+
| Name | Rejected in | Suggested alternative |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| `position` | vertex | `positionMC` |
|
|
44
|
+
| `position` | fragment | `positionEC` |
|
|
45
|
+
| `normal` | vertex | `normalMC` |
|
|
46
|
+
| `normal` | fragment | `normalEC` |
|
|
47
|
+
| `tangent` | vertex | `tangentMC` |
|
|
48
|
+
| `tangent` | fragment | `tangentEC` |
|
|
49
|
+
| `bitangent` | vertex | `bitangentMC` |
|
|
50
|
+
| `bitangent` | fragment | `bitangentEC` |
|
|
51
|
+
| `positionWC` | vertex | `positionMC` |
|
|
52
|
+
| `positionEC` | vertex | `positionMC` |
|
|
53
|
+
| `normalEC` | vertex | `normalMC` |
|
|
54
|
+
| `tangentEC` | vertex | `tangentMC` |
|
|
55
|
+
| `bitangentEC` | vertex | `bitangentMC` |
|
|
56
|
+
| `normalMC` | fragment | `normalEC` |
|
|
57
|
+
| `tangentMC` | fragment | `tangentEC` |
|
|
58
|
+
| `bitangentMC` | fragment | `bitangentEC` |
|
|
59
|
+
|
|
60
|
+
**Note:** `positionMC` is **not** rejected in the fragment shader — it is valid in both stages.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Enums
|
|
65
|
+
|
|
66
|
+
### CustomShaderMode
|
|
67
|
+
Frozen string enum. String value is used directly in the `CUSTOM_SHADER_<MODE>` GLSL define.
|
|
68
|
+
|
|
69
|
+
| JS constant | String value | Pipeline |
|
|
70
|
+
|---|---|---|
|
|
71
|
+
| `MODIFY_MATERIAL` (default) | `"MODIFY_MATERIAL"` | material → custom shader → lighting |
|
|
72
|
+
| `REPLACE_MATERIAL` | `"REPLACE_MATERIAL"` | custom shader → lighting (skips material stage) |
|
|
73
|
+
|
|
74
|
+
### LightingModel
|
|
75
|
+
Frozen numeric enum. When omitted from the constructor, the model's default lighting is preserved.
|
|
76
|
+
|
|
77
|
+
| JS constant | Value | Behavior |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| `UNLIT` | `0` | Skip lighting; `material.diffuse` used directly as output (alpha still applied) |
|
|
80
|
+
| `PBR` | `1` | Physically-based with IBL when available |
|
|
81
|
+
|
|
82
|
+
### CustomShaderTranslucencyMode
|
|
83
|
+
Frozen numeric enum. Default `INHERIT`.
|
|
84
|
+
|
|
85
|
+
| JS constant | Value | Effect |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| `INHERIT` | `0` | Honor the source material's translucency |
|
|
88
|
+
| `OPAQUE` | `1` | Force opaque render pass |
|
|
89
|
+
| `TRANSLUCENT` | `2` | Force translucent render pass |
|
|
90
|
+
|
|
91
|
+
### UniformType
|
|
92
|
+
Frozen string enum. String values are GLSL type names.
|
|
93
|
+
|
|
94
|
+
| JS constant | GLSL type | JS value type |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| `FLOAT` | `float` | `Number` |
|
|
97
|
+
| `VEC2` | `vec2` | `Cartesian2` |
|
|
98
|
+
| `VEC3` | `vec3` | `Cartesian3` |
|
|
99
|
+
| `VEC4` | `vec4` | `Cartesian4` |
|
|
100
|
+
| `INT` | `int` | `Number` |
|
|
101
|
+
| `INT_VEC2` | `ivec2` | `Cartesian2` |
|
|
102
|
+
| `INT_VEC3` | `ivec3` | `Cartesian3` |
|
|
103
|
+
| `INT_VEC4` | `ivec4` | `Cartesian4` |
|
|
104
|
+
| `BOOL` | `bool` | `Boolean` |
|
|
105
|
+
| `BOOL_VEC2` | `bvec2` | `Cartesian2` |
|
|
106
|
+
| `BOOL_VEC3` | `bvec3` | `Cartesian3` |
|
|
107
|
+
| `BOOL_VEC4` | `bvec4` | `Cartesian4` |
|
|
108
|
+
| `MAT2` | `mat2` | `Matrix2` |
|
|
109
|
+
| `MAT3` | `mat3` | `Matrix3` |
|
|
110
|
+
| `MAT4` | `mat4` | `Matrix4` |
|
|
111
|
+
| `SAMPLER_2D` | `sampler2D` | `TextureUniform` |
|
|
112
|
+
| `SAMPLER_CUBE` | `samplerCube` | **Rejected** — throws `DeveloperError("CustomShader does not support samplerCube uniforms")` at construction |
|
|
113
|
+
|
|
114
|
+
### VaryingType
|
|
115
|
+
Frozen string enum. Floating-point types only.
|
|
116
|
+
|
|
117
|
+
| JS constant | GLSL type |
|
|
118
|
+
|---|---|
|
|
119
|
+
| `FLOAT` | `float` |
|
|
120
|
+
| `VEC2` | `vec2` |
|
|
121
|
+
| `VEC3` | `vec3` |
|
|
122
|
+
| `VEC4` | `vec4` |
|
|
123
|
+
| `MAT2` | `mat2` |
|
|
124
|
+
| `MAT3` | `mat3` |
|
|
125
|
+
| `MAT4` | `mat4` |
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## TextureUniform options
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
new TextureUniform({
|
|
133
|
+
url, // string | Resource — mutually exclusive with typedArray
|
|
134
|
+
typedArray, // Uint8Array — mutually exclusive with url
|
|
135
|
+
width, height, // required when typedArray is used
|
|
136
|
+
pixelFormat, // default PixelFormat.RGBA
|
|
137
|
+
pixelDatatype, // default PixelDatatype.UNSIGNED_BYTE
|
|
138
|
+
repeat, // default true → REPEAT; false → CLAMP_TO_EDGE (both axes)
|
|
139
|
+
minificationFilter, // default LINEAR
|
|
140
|
+
magnificationFilter, // default LINEAR
|
|
141
|
+
maximumAnisotropy, // default 1.0
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Construction errors:**
|
|
146
|
+
- `"exactly one of options.typedArray, options.url must be defined"`
|
|
147
|
+
- `"options.width and options.height are required when options.typedArray is defined"`
|
|
148
|
+
|
|
149
|
+
Texture memory uses row-major storage with WebGL's bottom-up Y convention.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## FeatureIds struct
|
|
154
|
+
|
|
155
|
+
Auto-generated from the primitive's `featureIds` array. All values are GLSL `int` (not `uint`).
|
|
156
|
+
|
|
157
|
+
| Access | Source | Notes |
|
|
158
|
+
|---|---|---|
|
|
159
|
+
| `featureId_N` | `EXT_mesh_features` attribute or implicit | `N` is position in `featureIds` array |
|
|
160
|
+
| `featureId_N` | `EXT_mesh_features` feature ID texture | **Fragment shader only** |
|
|
161
|
+
| `<label>` | `EXT_mesh_features` with `"label": "..."` | Alias for `featureId_N`, e.g. `featureIds.perVertex` |
|
|
162
|
+
| `featureId_0` | 3D Tiles 1.0 `BATCH_ID` / `_BATCHID` | Legacy batch IDs transparently remapped |
|
|
163
|
+
| `instanceFeatureId_N` | `EXT_instance_features` + `EXT_mesh_gpu_instancing` | Per-instance; no feature ID textures at instance level |
|
|
164
|
+
| `featureId_N` | Legacy `EXT_feature_metadata` | `featureIdAttributes` and `featureIdTextures` arrays concatenated |
|
|
165
|
+
|
|
166
|
+
**WebGL 1 precision:** integer precision is 24 bits via floating-point backing; IDs above 2^24 (~16M) lose precision. WebGL 2 would permit `uint` but CustomShader does not surface it.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Metadata struct
|
|
171
|
+
|
|
172
|
+
Addressable via `vsInput.metadata.<prop>` and `fsInput.metadata.<prop>`. Sources supported in 1.142:
|
|
173
|
+
|
|
174
|
+
1. **Property attributes** — per-vertex (vertex and fragment).
|
|
175
|
+
2. **Property textures** — per-texel (**fragment only**).
|
|
176
|
+
3. **Property tables** — per-feature, keyed by feature ID (added in 1.139 via #13124).
|
|
177
|
+
|
|
178
|
+
### Type support matrix
|
|
179
|
+
|
|
180
|
+
| Metadata type | WebGL 1 | WebGL 2 |
|
|
181
|
+
|---|---|---|
|
|
182
|
+
| `UINT8` (scalar/vector) | Supported | Supported |
|
|
183
|
+
| Other integer types (`INT8`, `INT16`, `UINT16`, `INT32`, `UINT32`) | Not supported | Supported (signedness preserved post-1.139) |
|
|
184
|
+
| `FLOAT32` | Limited | Supported |
|
|
185
|
+
| `FLOAT64`, `INT64`, `UINT64` | Not supported | Limited support via downcasting (1.140+) |
|
|
186
|
+
| `BOOLEAN` | — | — |
|
|
187
|
+
| `STRING` | — | — |
|
|
188
|
+
| `ENUM` | Supported (as integer) | Supported |
|
|
189
|
+
| Variable-length arrays | — | — |
|
|
190
|
+
| Matrix types | — | — |
|
|
191
|
+
| Items > 4 bytes | — | — |
|
|
192
|
+
|
|
193
|
+
### Normalized values + offset/scale
|
|
194
|
+
|
|
195
|
+
If the class schema declares `"normalized": true`, the value arrives in-shader as `float` (or floating vector) in `[0, 1]` (unsigned) or `[-1, 1]` (signed). If `offset` and `scale` are also declared, they are applied **after** normalization: stored UINT32 with `normalized: true, offset: 32, scale: 180` arrives as a float in `[32, 212]`.
|
|
196
|
+
|
|
197
|
+
### Property ID sanitization
|
|
198
|
+
|
|
199
|
+
GLSL identifiers are restricted. The pipeline:
|
|
200
|
+
|
|
201
|
+
1. Non-alphanumeric runs collapse to a single `_`.
|
|
202
|
+
2. Leading `gl_` prefix is stripped (reserved by GLSL).
|
|
203
|
+
3. If the result starts with a digit, prefix with `_`.
|
|
204
|
+
|
|
205
|
+
| Source name | Sanitized | Access |
|
|
206
|
+
|---|---|---|
|
|
207
|
+
| `temperature ℃` | `temperature_` | `fsInput.metadata.temperature_` |
|
|
208
|
+
| `custom__property` | `custom_property` | `fsInput.metadata.custom_property` |
|
|
209
|
+
| `gl_customProperty` | `customProperty` | `fsInput.metadata.customProperty` |
|
|
210
|
+
| `12345` | `_12345` | `fsInput.metadata._12345` |
|
|
211
|
+
| `temperature ℃` + `temperature ℉` | both → `temperature_` | **Undefined behavior (collision)** |
|
|
212
|
+
| `✖️✖️✖️` | empty string | **Undefined behavior** |
|
|
213
|
+
|
|
214
|
+
### 1.139 breaking change (#13135)
|
|
215
|
+
|
|
216
|
+
Unsigned integer metadata is no longer cast to signed `int`. Existing shaders using `int x = fsInput.metadata.myUintProperty;` stop compiling in 1.139. Switch to the matching unsigned type (e.g., `uint x = ...;`) or cast explicitly.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## MetadataClass struct
|
|
221
|
+
|
|
222
|
+
One sub-struct per property. Access via `vsInput.metadataClass.<prop>.<field>`.
|
|
223
|
+
|
|
224
|
+
| Field | Type | Description |
|
|
225
|
+
|---|---|---|
|
|
226
|
+
| `noData` | same as property | Value indicating no data |
|
|
227
|
+
| `defaultValue` | same as property | Default value (GLSL reserves `default` — field is `defaultValue`) |
|
|
228
|
+
| `minValue` | same as property | Schema-declared minimum (GLSL reserves `min` — field is `minValue`) |
|
|
229
|
+
| `maxValue` | same as property | Schema-declared maximum |
|
|
230
|
+
|
|
231
|
+
Example GLSL for a `FLOAT32` property named `temperature`:
|
|
232
|
+
```glsl
|
|
233
|
+
struct floatMetadataClass {
|
|
234
|
+
float noData; float defaultValue; float minValue; float maxValue;
|
|
235
|
+
};
|
|
236
|
+
struct MetadataClass { floatMetadataClass temperature; };
|
|
237
|
+
// Access: vsInput.metadataClass.temperature.minValue
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## MetadataStatistics struct
|
|
243
|
+
|
|
244
|
+
Populated only when the parent tileset's `tileset.json` carries a `statistics` object. Access via `fsInput.metadataStatistics.<prop>.<field>`.
|
|
245
|
+
|
|
246
|
+
| Field | Type | Description |
|
|
247
|
+
|---|---|---|
|
|
248
|
+
| `minValue` | same as property | Observed minimum |
|
|
249
|
+
| `maxValue` | same as property | Observed maximum |
|
|
250
|
+
| `median` | same as property | Median |
|
|
251
|
+
| `sum` | same as property | Sum |
|
|
252
|
+
| `mean` | floating-point of same dimension | Mean |
|
|
253
|
+
| `standardDeviation` | floating-point of same dimension | σ |
|
|
254
|
+
| `variance` | floating-point of same dimension | σ² |
|
|
255
|
+
|
|
256
|
+
Enum properties note: an `occurrence` field is documented as TODO.
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## czm_modelVertexOutput
|
|
261
|
+
|
|
262
|
+
Source: `packages/engine/Source/Shaders/Builtin/Structs/modelVertexOutput.glsl`.
|
|
263
|
+
|
|
264
|
+
```glsl
|
|
265
|
+
struct czm_modelVertexOutput {
|
|
266
|
+
vec3 positionMC; // Initialized to vsInput.attributes.positionMC. Mutate to displace vertices.
|
|
267
|
+
float pointSize; // Overrides gl_PointSize for point primitives; overrides Cesium3DTileStyle point size.
|
|
268
|
+
};
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
No `#ifdef`-guarded fields.
|
|
272
|
+
|
|
273
|
+
**Gotcha:** modifying `positionMC` does **not** update the primitive's bounding sphere. Heavily displaced vertices can be frustum-culled even when visually on-screen.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## czm_modelMaterial
|
|
278
|
+
|
|
279
|
+
Source: `packages/engine/Source/Shaders/Builtin/Structs/modelMaterial.glsl`.
|
|
280
|
+
|
|
281
|
+
```glsl
|
|
282
|
+
struct czm_modelMaterial {
|
|
283
|
+
vec4 baseColor; // Base color of the material.
|
|
284
|
+
vec3 diffuse; // Incoming light that scatters evenly.
|
|
285
|
+
float alpha; // 0.0 fully transparent, 1.0 fully opaque.
|
|
286
|
+
vec3 specular; // f0 — reflected light at normal incidence (PBR).
|
|
287
|
+
float roughness; // 0.0 glossy, 1.0 rough.
|
|
288
|
+
vec3 normalEC; // Surface normal in eye coordinates (for normal mapping).
|
|
289
|
+
float occlusion; // Ambient occlusion (1.0 fully lit, 0.0 fully occluded).
|
|
290
|
+
vec3 emissive; // Light emitted equally in all directions.
|
|
291
|
+
#ifdef USE_SPECULAR
|
|
292
|
+
float specularWeight;
|
|
293
|
+
#endif
|
|
294
|
+
#ifdef USE_ANISOTROPY
|
|
295
|
+
vec3 anisotropicT;
|
|
296
|
+
vec3 anisotropicB;
|
|
297
|
+
float anisotropyStrength;
|
|
298
|
+
#endif
|
|
299
|
+
#ifdef USE_CLEARCOAT
|
|
300
|
+
float clearcoatFactor;
|
|
301
|
+
float clearcoatRoughness;
|
|
302
|
+
vec3 clearcoatNormal;
|
|
303
|
+
// clearcoatF0 added when KHR_materials_ior is implemented
|
|
304
|
+
#endif
|
|
305
|
+
};
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**All color values are linear RGB** — including for `UNLIT` shaders. sRGB conversion happens after the pipeline unless `scene.highDynamicRange === true`.
|
|
309
|
+
|
|
310
|
+
Conditional fields appear only when the corresponding glTF extension is active on the primitive: `KHR_materials_specular` → `USE_SPECULAR`, `KHR_materials_anisotropy` → `USE_ANISOTROPY`, `KHR_materials_clearcoat` → `USE_CLEARCOAT`. Do not rely on these unconditionally.
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Built-in czm_* automatic uniforms
|
|
315
|
+
|
|
316
|
+
Available in custom shaders without declaration. The full list lives in `packages/engine/Source/Renderer/AutomaticUniforms.js`. The subset most useful for CustomShader:
|
|
317
|
+
|
|
318
|
+
### Frame & animation
|
|
319
|
+
`czm_frameNumber`, `czm_morphTime`, `czm_pixelRatio`, `czm_pass`, `czm_passTranslucent`
|
|
320
|
+
|
|
321
|
+
### Matrices
|
|
322
|
+
`czm_model`, `czm_inverseModel`, `czm_view`, `czm_inverseView`, `czm_view3D`, `czm_inverseView3D`, `czm_projection`, `czm_inverseProjection`, `czm_infiniteProjection`, `czm_modelView`, `czm_modelView3D`, `czm_inverseModelView`, `czm_inverseModelView3D`, `czm_modelViewProjection`, `czm_modelViewProjectionRelativeToEye`, `czm_modelViewRelativeToEye`, `czm_viewProjection`, `czm_inverseViewProjection`, `czm_normal`, `czm_normal3D`, `czm_inverseNormal`, `czm_inverseNormal3D`, `czm_modelToWindowCoordinates`, `czm_enuToModel`, `czm_modelToEnu`, `czm_viewportTransformation`
|
|
323
|
+
|
|
324
|
+
### Viewport & camera
|
|
325
|
+
`czm_viewport`, `czm_viewerPositionWC`, `czm_encodedCameraPositionMCHigh`, `czm_encodedCameraPositionMCLow`, `czm_eyeHeight`, `czm_eyeHeight2D`, `czm_currentFrustum`, `czm_entireFrustum`, `czm_frustumPlanes`, `czm_globeDepthTexture`, `czm_packDepth`, `czm_unpackDepth`, `czm_orthographicIn3D`
|
|
326
|
+
|
|
327
|
+
### Scene mode
|
|
328
|
+
`czm_sceneMode`, `czm_sceneMode2D`, `czm_sceneMode3D`, `czm_sceneModeColumbusView`, `czm_sceneModeMorphing`, `czm_columbusViewMorph`
|
|
329
|
+
|
|
330
|
+
### Lighting & environment
|
|
331
|
+
`czm_lightColor`, `czm_lightColorHdr`, `czm_lightDirectionEC`, `czm_lightDirectionWC`, `czm_sunDirectionEC`, `czm_sunDirectionWC`, `czm_sunPositionWC`, `czm_moonDirectionEC`, `czm_environmentMap`, `czm_specularEnvironmentMaps`, `czm_specularEnvironmentMapsMaximumLOD`, `czm_sphericalHarmonicCoefficients`, `czm_brdfLut`, `czm_gamma`, `czm_backgroundColor`
|
|
332
|
+
|
|
333
|
+
### Atmosphere & fog
|
|
334
|
+
`czm_atmosphereAnisotropy`, `czm_atmosphereDynamicLighting`, `czm_atmosphereHsbShift`, `czm_atmosphereLightIntensity`, `czm_atmosphereMieAnisotropy`, `czm_atmosphereMieCoefficient`, `czm_atmosphereMieScaleHeight`, `czm_atmosphereRayleighCoefficient`, `czm_atmosphereRayleighScaleHeight`, `czm_fog`, `czm_fogDensity`, `czm_fogMinimumBrightness`, `czm_fogVisualDensityScalar`
|
|
335
|
+
|
|
336
|
+
### Ellipsoid
|
|
337
|
+
`czm_ellipsoidRadii`, `czm_ellipsoidInverseRadii`, `czm_eyeEllipsoidCurvature`, `czm_eyeEllipsoidNormalEC`
|
|
338
|
+
|
|
339
|
+
### Post-processing & splitting
|
|
340
|
+
`czm_edgeColorTexture`, `czm_edgeDepthTexture`, `czm_edgeIdTexture`, `czm_invertClassificationColor`, `czm_splitPosition`, `czm_geometricToleranceOverMeter`
|
|
341
|
+
|
|
342
|
+
### Math constants
|
|
343
|
+
`czm_pi`, `czm_twoPi`, `czm_piOverTwo`, `czm_piOverThree`, `czm_piOverFour`, `czm_piOverSix`, `czm_oneOverPi`, `czm_oneOverTwoPi`, `czm_radiansPerDegree`, `czm_degreesPerRadian`, `czm_epsilon1`..`czm_epsilon7`
|
|
344
|
+
|
|
345
|
+
The full library of built-in GLSL functions lives in `packages/engine/Source/Shaders/Builtin/Functions/`.
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## CustomShader public API surface
|
|
350
|
+
|
|
351
|
+
Constructor: see skill SKILL.md § "Constructor reference".
|
|
352
|
+
|
|
353
|
+
Public instance methods:
|
|
354
|
+
|
|
355
|
+
| Method | Description |
|
|
356
|
+
|---|---|
|
|
357
|
+
| `setUniform(name, value)` | Update a declared uniform. Cartesian/Matrix values are cloned into existing storage via `value.clone(uniform.value)`. `SAMPLER_2D` values trigger an async texture reload through the internal `TextureManager`. Throws `DeveloperError` if `name` is not declared. |
|
|
358
|
+
| `update(frameState)` | Called by `Model` / `Cesium3DTileset` / `VoxelPrimitive` each frame. Applications do not call this directly. |
|
|
359
|
+
| `isDestroyed()` | Returns `true` after `destroy()`; otherwise `false`. |
|
|
360
|
+
| `destroy()` | Releases the `TextureManager` and its GPU resources. Call when discarding a CustomShader that owns texture uniforms. |
|
|
361
|
+
|
|
362
|
+
Readonly instance fields: `mode`, `lightingModel`, `translucencyMode`, `uniforms`, `varyings`, `vertexShaderText`, `fragmentShaderText`, `uniformMap` (private wiring for the pipeline stage).
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
## Variable-usage detection regex
|
|
367
|
+
|
|
368
|
+
`CustomShader` scans the user's shader text to pre-compute which attributes/feature-IDs/metadata/material fields are referenced. The regexes (from `findUsedVariables`):
|
|
369
|
+
|
|
370
|
+
```
|
|
371
|
+
[vf]sInput\.attributes\.(\w+)
|
|
372
|
+
[vf]sInput\.featureIds\.(\w+)
|
|
373
|
+
[vf]sInput\.(?:metadata|metadataClass|metadataStatistics)\.(\w+)
|
|
374
|
+
material\.(\w+)
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Accessing these structs through an aliased local variable bypasses detection — the optimization will not include the field, and the shader may fail at link time. Access `vsInput`/`fsInput`/`material` directly rather than passing them through local references.
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
## Source material
|
|
382
|
+
|
|
383
|
+
Everything in this reference is sourced from the following `main`-branch files:
|
|
384
|
+
|
|
385
|
+
- `packages/engine/Source/Scene/Model/CustomShader.js`
|
|
386
|
+
- `packages/engine/Source/Scene/Model/CustomShaderMode.js`
|
|
387
|
+
- `packages/engine/Source/Scene/Model/CustomShaderTranslucencyMode.js`
|
|
388
|
+
- `packages/engine/Source/Scene/Model/LightingModel.js`
|
|
389
|
+
- `packages/engine/Source/Scene/Model/UniformType.js`
|
|
390
|
+
- `packages/engine/Source/Scene/Model/VaryingType.js`
|
|
391
|
+
- `packages/engine/Source/Scene/Model/TextureUniform.js`
|
|
392
|
+
- `packages/engine/Source/Shaders/Builtin/Structs/modelMaterial.glsl`
|
|
393
|
+
- `packages/engine/Source/Shaders/Builtin/Structs/modelVertexOutput.glsl`
|
|
394
|
+
- `packages/engine/Source/Renderer/AutomaticUniforms.js`
|
|
395
|
+
- `packages/engine/Source/Scene/Cesium3DTileset.js` (for the `@experimental` + style-interaction JSDoc)
|
|
396
|
+
- `Documentation/CustomShaderGuide/README.md` (canonical guide)
|
|
397
|
+
- `CHANGES.md` (version notes)
|