CesiumGS / CesiumGS/cesium

Model: interpolate per-vertex feature IDs

Open
#9,935 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

category - model/gltf
Dominant language
JavaScript
Stars
15.8k
Forks
3.9k
Avg merge
4d 6h
Merged PRs (30d)
34

Description

According to the EXT_mesh_features spec,

Implementation note: For a primitive with feature ID attributes, points in the interior of a triangle or line segment should be considered to belong to the feature associated with the nearest vertex.

Conceptually, that looks like this:

Capture

If we want to implement this here in WebGL, it would take a couple extra attributes to do this in the fragment shader: (below describes the case for triangles, lines would be similar but only 2 vertices)

  • barycentric coordinates - vec3 barycentric = (a, b, c) or a vec2 given that a + b + c = 1 by definition
  • uninterpolated feature IDs - vec3 (featureIdA, featureIdB, featureIdC) per feature ID set. All three vertices would get all three feature IDs. So for the diagram above, all three vertices would receive the value vec3(2, 4, 5).

This feels a bit wasteful, but in the fragment shader there's no way to get the original vertex values (at least as far as I know?).

This is not needed for per-face metadata with gl.TRIANGLES or per-edge for gl.LINES (as you can set all feature IDs to the same value), but in any other case you'd need the more general "nearest vertex" interpolation.


All this said, It would be best to see how often this is needed before implementing this part of the spec.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing Cesium’s existing WebGL handling for EXT_mesh_features and the vertex-attribute section of the linked specification. Determine how feature IDs are currently passed to fragment shaders for triangles and lines, and assess how often nearest-vertex interpolation is needed. Done means the supported cases follow the specification, with validation covering the resulting feature selection.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.