Skip to content

Support KHR_mesh_quantization in bevy_gltf - #25954

Merged
alice-i-cecile merged 3 commits into
bevyengine:mainfrom
stuartparmenter:gltf-mesh-quantization
Oct 15, 2026
Merged

alice-i-cecile merged 3 commits into
bevyengine:mainfrom
stuartparmenter:gltf-mesh-quantization

Conversation

@stuartparmenter

@stuartparmenter stuartparmenter commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Objective

Bevy can't load glTF files that use KHR_mesh_quantization.

Solution

Add support for quantized positions, normals, tangents, texture coordinates and morph targets by dequantizing them to floats while loading. Integer formats the extension doesn't allow still warn and are skipped, as before.

Testing

Tested w/ Zorah scene and my game


This was AI assisted w/ Fable 5.1 and Opus 5.5 as part of my work to on my game specifically around high poly foliage. I used the LLMs to look for the cleanest way to add support and to do it. Validated with my gltfpack'd meshes. I've reviewed reviewed it, tested it, cleaned it up, and posted this PR.

@stuartparmenter stuartparmenter added C-Feature A new feature, making something new possible S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-glTF Related to the glTF 3D scene/model format labels Sep 28, 2026
@greeble-dev

Copy link
Copy Markdown
Contributor

Can you confirm there's no need for an AI disclosure? I'm asking just in case it was overlooked - most of your other PRs have one.

@stuartparmenter

Copy link
Copy Markdown
Contributor Author

Can you confirm there's no need for an AI disclosure? I'm asking just in case it was overlooked - most of your other PRs have one.

Sorry, re-added, not sure where it went, I blame GitHub

@greeble-dev
greeble-dev removed their request for review September 29, 2026 13:07
stuartparmenter added a commit to stuartparmenter/bevy that referenced this pull request Oct 3, 2026
Squashed from bevyengine#25954 (stuartparmenter:gltf-mesh-quantization).

Dequantizes quantized positions, normals, tangents, texture coordinates
and morph targets to floats while loading. Integer formats the extension
doesn't allow still warn and are skipped, as before. Validation lets a
required `KHR_mesh_quantization` through alongside the meshopt extensions.

@jbuehler23 jbuehler23 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.

I'm not an expert on GLTF loading, but this looks to be an improvement and can be used for exporting scenes as GLTF in jackdaw i would think!

@stuartparmenter
stuartparmenter requested a review from JMS55 October 4, 2026 22:05
stuartparmenter added a commit to stuartparmenter/bevy that referenced this pull request Oct 4, 2026
Squashed from bevyengine#26030 (stuartparmenter:gltf-gpu-quantization),
which includes bevyengine#25954.

Loads `KHR_mesh_quantization` files and, with
`GltfPlugin::preserve_quantization` (on by default, overridable per load in
`GltfLoaderSettings`), encodes quantized positions, normals, tangents and
texture coordinates directly into the `MeshAttributeCompressionFlags`
formats the mesh shaders already decode. `Mesh::decoded_positions`,
`decoded_normals` and `decoded_uvs` keep CPU readers working on compressed
meshes. Solari builds BLASes from compressed positions when the GPU supports
`EXTENDED_ACCELERATION_STRUCTURE_VERTEX_FORMATS`.
stuartparmenter added a commit to stuartparmenter/bevy that referenced this pull request Oct 5, 2026
Squashed from bevyengine#26030 (stuartparmenter:gltf-gpu-quantization),
which includes bevyengine#25954.

Loads `KHR_mesh_quantization` files and, with
`GltfPlugin::preserve_quantization` (on by default, overridable per load in
`GltfLoaderSettings`), encodes quantized positions, normals, tangents and
texture coordinates directly into the `MeshAttributeCompressionFlags`
formats the mesh shaders already decode. `Mesh::decoded_positions`,
`decoded_normals` and `decoded_uvs` keep CPU readers working on compressed
meshes. Solari builds BLASes from compressed positions when the GPU supports
`EXTENDED_ACCELERATION_STRUCTURE_VERTEX_FORMATS`.
stuartparmenter added a commit to stuartparmenter/bevy that referenced this pull request Oct 5, 2026
Squashed from bevyengine#26030 (stuartparmenter:gltf-gpu-quantization),
which includes bevyengine#25954.

Loads `KHR_mesh_quantization` files and, with
`GltfPlugin::preserve_quantization` (on by default, overridable per load in
`GltfLoaderSettings`), encodes quantized positions, normals, tangents and
texture coordinates directly into the `MeshAttributeCompressionFlags`
formats the mesh shaders already decode. `Mesh::decoded_positions`,
`decoded_normals` and `decoded_uvs` keep CPU readers working on compressed
meshes. Solari builds BLASes from compressed positions when the GPU supports
`EXTENDED_ACCELERATION_STRUCTURE_VERTEX_FORMATS`.
@hukasu hukasu added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 15, 2026
@alice-i-cecile
alice-i-cecile added this pull request to the merge queue Oct 15, 2026
Merged via the queue into bevyengine:main with commit 455bdb2 Oct 15, 2026
41 checks passed
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-bevyengine__bevy that referenced this pull request Oct 15, 2026
…vy_gltf (bevyengine#25953)

# Objective

Bevy can't load glTF files that use `EXT_meshopt_compression` or the
newer `KHR_meshopt_compression`.

## Solution

Add a `gltf_meshopt` feature (`meshopt` on bevy_gltf). It uses the
`meshopt` crate that bevy_pbr already depends on for meshlets. After the
buffers load, each compressed buffer view is decoded into its fallback
buffer, so the rest of the loader reads it like uncompressed data.
`bevy_gltf::extensions::khr_meshopt_compression::decode_buffer_views`
exposes the same pass for code that reads glTF with the `gltf` crate
directly.

The `gltf` crate's validation rejects the extension as an unsupported
required extension, so the loader runs the same validation with that one
error removed. Without the feature, loading a file that requires the
extension logs a warning that names the feature.

`KHR_mesh_quantization` support is in a separate PR bevyengine#25954.

## Testing

Tested w/ Zorah scene and my game

---

This was AI assisted w/ Fable 5.1 and Opus 5.5 as part of my work to get
the Zorah scene working. I used it to look for the cleanest way to add
support and to do it. Then reviewed it, validated it worked in multiple
applications, cleaned it up, and posted PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-glTF Related to the glTF 3D scene/model format C-Feature A new feature, making something new possible S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants