Skip to content

Implement constant LOD glTF extension#8882

Merged
eringram merged 32 commits into
masterfrom
eringram/constant-lod-gltf
Jan 23, 2026
Merged

Implement constant LOD glTF extension#8882
eringram merged 32 commits into
masterfrom
eringram/constant-lod-gltf

Conversation

@eringram

@eringram eringram commented Dec 31, 2025

Copy link
Copy Markdown
Member

This is ready for review, but likely waiting to merge until extension spec is finalized: CesiumGS/glTF#92

This PR adds support for reading glTF models that use the new EXT_textureInfo_constant_lod extension. Constant LOD texture mapping mode is already supported for textures in iModels, so this PR just passes the required properties to render material creation from the GltfReader.

I also added unit tests to GltfReader.test.ts, and a new file TextureMapping.test.ts with tests to ensure TextureMapping uses the constant LOD default values when they are not provided.

Simple test model that uses EXT_textureInfo_constant_lod: constant_lod_example.zip

This is what the effect looks like for this test model:

constant_lod

With a normal map of a bumpy texture:

constant_lod_normal_map

Screenshot 2026-01-22 125531

Image tests didn't produce any side effects (test cases for this new feature aren't there yet but will be added in the future).

@eringram eringram changed the title Implement constant LOD glTF extension (WIP) Implement constant LOD glTF extension Jan 9, 2026
@eringram eringram marked this pull request as ready for review January 9, 2026 17:14
@aruniverse aruniverse requested a review from Copilot January 9, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements support for the EXT_textureInfo_constant_lod glTF extension, enabling glTF models to use the constant LOD texture mapping mode already supported for iModel textures. The extension properties (repetitions, offset, minDistClamp, maxDistClamp) are extracted from glTF materials and passed through to render material creation.

Changes:

  • Added extension parsing logic in GltfReader to extract constant LOD parameters from baseColorTexture, emissiveTexture, and normalTexture
  • Extended MeshArgs interface to include useConstantLod and constantLodParams fields
  • Added comprehensive test coverage for the extension including property validation, fallback behavior, and normal map support

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
core/frontend/src/tile/GltfReader.ts Parses EXT_textureInfo_constant_lod extension from materials and converts to MaterialTextureMappingProps
core/frontend/src/test/tile/GltfReader.test.ts Adds test suite covering extension parsing with various configurations
core/frontend/src/render/MeshArgs.ts Extends MeshArgs interface with constant LOD properties
core/frontend/src/common/internal/render/MeshPrimitives.ts Passes constant LOD parameters from displayParams to MeshArgs
core/frontend/src/common/gltf/GltfSchema.ts Defines TypeScript interface for the extension in GltfTextureInfo
core/common/src/test/TextureMapping.test.ts Tests TextureMapping.Params constructor default value handling
common/changes/@itwin/core-frontend/eringram-constant-lod-gltf_2026-01-09-17-16.json Changelog entry for core-frontend
common/changes/@itwin/core-common/eringram-constant-lod-gltf_2026-01-09-17-16.json Changelog entry for core-common
common/api/core-frontend.api.md Updates API documentation for modified method signatures

Comment thread core/frontend/src/tile/GltfReader.ts Outdated
Comment thread core/frontend/src/render/MeshArgs.ts
Comment thread core/frontend/src/render/MeshArgs.ts
Comment thread core/frontend/src/tile/GltfReader.ts Outdated
Comment thread core/frontend/src/tile/GltfReader.ts
eringram and others added 7 commits January 12, 2026 16:39
Co-authored-by: Mark Schlosser <47000437+markschlosseratbentley@users.noreply.github.com>
Co-authored-by: Mark Schlosser <47000437+markschlosseratbentley@users.noreply.github.com>
@eringram eringram requested a review from a team as a code owner January 13, 2026 17:20
@markschlosseratbentley

Copy link
Copy Markdown
Contributor

Approving, but I recommend waiting for Image Tests.

@eringram

Copy link
Copy Markdown
Member Author

@markschlosseratbentley Mind taking a look at my latest commit? I added some code comments and clarified the limitations of our support for the extension in the NextVersion entry.

Based on our discussion earlier, I concluded the extension can be present on anything that extends textureInfo like normalTextureInfo, occlusionTextureInfo, etc. as well as textures like metallicRoughnessTexture. However, this implementation only supports it for baseColorTexture fully, and emissiveTexture and normalMapTexture to a limited extent.

I think this is fine since it's the same scope that we support for glTF models in general (i.e. we never use metallicRoughnessTexture or occlusionTexture), and for iModels that use constant LOD (i.e. iModels also only support constant LOD for normal maps to a limited extent).

@eringram

Copy link
Copy Markdown
Member Author

Also, the image tests results showed no differences of note

@mergify

mergify Bot commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

This pull request is now in conflicts. Could you fix it @eringram? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

@mergify

mergify Bot commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

This pull request is now in conflicts. Could you fix it @eringram? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

@markschlosseratbentley

Copy link
Copy Markdown
Contributor

Looks good to me, @eringram.

@eringram eringram merged commit d0681c1 into master Jan 23, 2026
15 checks passed
@eringram eringram deleted the eringram/constant-lod-gltf branch January 23, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants