Add attribute and feature ID set counts to custom shaders
- Dominant language
- JavaScript
- Stars
- 15.7k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
Given that a tileset may have many glTF files and each glTF model may have multiple primitives, it's easily possible for the number of attribute sets (e.g. `TEXCOORD_n`, `COLOR_n`, `FEATURE_ID_n`) to vary. This makes it difficult to write a custom shader that works across an entire tileset.
Custom Shaders does set a default for common attributes that are not available in a given primitive, though it would be useful if there was a way to determine when the default is used.
I was talking with @lilleyse, and we proposed adding two structs to the input:
* `float fsInput.attributeCounts.` -- a count of how many of each semantic are available. For example, `fsInput.attributeCounts.texCoord` would store 0 if a primitive had no texture coordinates, 1 if there was only `TEXCOORD_0`, 2 if there was also `TEXCOORD_1`, and so on. For something like `NORMAL`, the count would either be 0 (not present) or 1 (present).
* `float fsInput.featureIds.featureIdSetCount` would store the number of feature Id sets listed in the `featureIds` array for a given primitive. Note that this is different than `fsInput.attributeCounts.featureId`, which is only for the explicit feature ID attributes (stored as `FEATURE_ID_n`).
* `float fsInput.featureIds.instanceFeatureIdSetCount` would store the number of feature ID sets listed in the `featureIds` array in the `EXT_gpu_mesh_instancing` extension.
Contributor guide
Research direction
No source files or tests are named. Start by locating the Custom Shader input handling and the existing glTF primitive attribute and feature ID tests, then trace how defaults are provided. Done means exposing the requested attribute and feature ID set counts with the specified values across primitives, including instanced feature IDs, and covering those cases with tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100