Bug Report: MSFT_texture_dds extension swaps image source indices incorrectly
Description
When creating a material with texture (via MaterialBuilder.WithChannelImage or ImageBuilder), the generated glTF file has incorrectly swapped image source indices between the standard texture source and the MSFT_texture_dds extension:
-
The images array contains two entries:
- Index 0: The correct original texture file (e.g., DDS format, which is the texture I actually want to use)
- Index 1: An auto-generated redundant PNG "satellite image" (I never created this image manually)
-
The textures entry shows:
{
"extensions": {
"MSFT_texture_dds": {
"source": 0 // Points to the correct original image (index 0)
}
},
"source": 1 // Incorrectly points to the auto-generated redundant image (index 1)
}
Expected Behavior
The standard source field should point to index 0 (my original texture)
The auto-generated redundant PNG image (index 1) should not exist at all (unless explicitly requested)
The MSFT_texture_dds extension should not be added automatically if I don't use DDS textures intentionally
Reproduction Steps
Create a simple material with MaterialBuilder.WithChannelImage (or ImageBuilder) to bind a texture file (PNG/DDS)
Export the model to glTF format via ModelRoot.SaveGLTF()
Check the generated glTF JSON:
images array has 2 entries (1 original + 1 auto-generated)
textures[0].source = 1 (wrong), textures[0].extensions.MSFT_texture_dds.source = 0 (correct)
Additional Notes
This issue occurs regardless of how I create the texture:
Using MaterialBuilder.WithChannelImage (direct file path)
Using ImageBuilder + WithPrimaryImage
Binding single/multiple texture channels
Exporting to glTF (satellite files) or GLB (embedded)
The redundant PNG image (index 1) is never requested by my code but is always auto-generated
The source index swap breaks texture loading in external tools (e.g., Blender, Three.js) because the standard source points to a non-existent/incorrect image
Environment
SharpGLTF version: [1.0.6]
.NET version: [NET 9.0]
OS: Windows 11
Bug Report: MSFT_texture_dds extension swaps image source indices incorrectly
Description
When creating a material with texture (via
MaterialBuilder.WithChannelImageorImageBuilder), the generated glTF file has incorrectly swapped image source indices between the standard texturesourceand theMSFT_texture_ddsextension:The
imagesarray contains two entries:The
texturesentry shows:{ "extensions": { "MSFT_texture_dds": { "source": 0 // Points to the correct original image (index 0) } }, "source": 1 // Incorrectly points to the auto-generated redundant image (index 1) }Expected Behavior
The standard source field should point to index 0 (my original texture)
The auto-generated redundant PNG image (index 1) should not exist at all (unless explicitly requested)
The MSFT_texture_dds extension should not be added automatically if I don't use DDS textures intentionally
Reproduction Steps
Create a simple material with MaterialBuilder.WithChannelImage (or ImageBuilder) to bind a texture file (PNG/DDS)
Export the model to glTF format via ModelRoot.SaveGLTF()
Check the generated glTF JSON:
images array has 2 entries (1 original + 1 auto-generated)
textures[0].source = 1 (wrong), textures[0].extensions.MSFT_texture_dds.source = 0 (correct)
Additional Notes
This issue occurs regardless of how I create the texture:
Using MaterialBuilder.WithChannelImage (direct file path)
Using ImageBuilder + WithPrimaryImage
Binding single/multiple texture channels
Exporting to glTF (satellite files) or GLB (embedded)
The redundant PNG image (index 1) is never requested by my code but is always auto-generated
The source index swap breaks texture loading in external tools (e.g., Blender, Three.js) because the standard source points to a non-existent/incorrect image
Environment
SharpGLTF version: [1.0.6]
.NET version: [NET 9.0]
OS: Windows 11