CesiumGS/cesium

Feature ID Textures ignore sampler wrap mode

Open

#11.574 geöffnet am 19. Okt. 2023

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (3.324 Forks)batch import
category - model/gltfgood first issuetype - bug

Repository-Metriken

Stars
 (11.758 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 26T 3h) (26 gemergte PRs in 30 T)

Beschreibung

Feature ID textures are allowed to have any wrap mode, but CesiumJS incorrectly overrides this with CLAMP_TO_EDGE.

In GltfLoader there is this chunk of code for feature ID textures:

  const textureInfo = gltfFeatureIdTexture.texture;
  featureIdTexture.textureReader = loadTexture(
    loader,
    gltf,
    textureInfo,
    supportedImageFormats,
    frameState,
    Sampler.NEAREST // Feature ID textures require nearest sampling
  );

The last parameter for that function is samplerOverride, which replaces the original texture.sampler with the provided one. In Sampler.js:

Sampler.NEAREST = Object.freeze(
  new Sampler({
    wrapS: TextureWrap.CLAMP_TO_EDGE,
    wrapT: TextureWrap.CLAMP_TO_EDGE,
    minificationFilter: TextureMinificationFilter.NEAREST,
    magnificationFilter: TextureMagnificationFilter.NEAREST,
  })

Instead of completely replacing the old sampler with the new one, only the minificationFilter and magnificationFilter should be overriden.

Contributor Guide