-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TinyGltfImporter: implement support for non-float attribute types.
This also makes the plugin support KHR_mesh_quantization, yay! There's an ugly interaction with Y-flip in texture coordiantes, hope this won't bite back too often.
- Loading branch information
Showing
16 changed files
with
1,512 additions
and
479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
454 changes: 322 additions & 132 deletions
454
src/MagnumPlugins/TinyGltfImporter/Test/TinyGltfImporterTest.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
94 changes: 94 additions & 0 deletions
94
src/MagnumPlugins/TinyGltfImporter/Test/material-texcoord-flip-unnormalized.gltf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ | ||
"asset": { | ||
"version": "2.0" | ||
}, | ||
"meshes": [ | ||
{ | ||
"name": "normalized signed integer", | ||
"primitives": [ | ||
{ | ||
"attributes": { | ||
"TEXCOORD_0": 0 | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "signed integer", | ||
"primitives": [ | ||
{ | ||
"attributes": { | ||
"TEXCOORD_0": 1 | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"accessors": [ | ||
{ | ||
"bufferView": 0, | ||
"componentType": 5120, | ||
"normalized": true, | ||
"count": 3, | ||
"type": "VEC2" | ||
}, | ||
{ | ||
"bufferView": 1, | ||
"componentType": 5122, | ||
"count": 3, | ||
"type": "VEC2" | ||
} | ||
], | ||
"bufferViews": [ | ||
{ | ||
"buffer": 0, | ||
"byteOffset": 44, | ||
"byteLength": 8 | ||
}, | ||
{ | ||
"buffer": 0, | ||
"byteOffset": 52, | ||
"byteLength": 12 | ||
} | ||
], | ||
"buffers": [ | ||
{ | ||
"note": "reusing the same as material-texcoord-flip.gltf", | ||
"byteLength": 64, | ||
"uri": "material-texcoord-flip.bin" | ||
} | ||
], | ||
"materials": [ | ||
{ | ||
"name": "transform from normalized signed integer", | ||
"pbrMetallicRoughness": { | ||
"baseColorTexture": { | ||
"index": 0, | ||
"extensions": { | ||
"KHR_texture_transform": { | ||
"offset": [0.5, 0.5], | ||
"scale": [-0.5, 0.5] | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "transform from signed integer", | ||
"pbrMetallicRoughness": { | ||
"baseColorTexture": { | ||
"index": 0, | ||
"extensions": { | ||
"KHR_texture_transform": { | ||
"offset": [0.0, 0.25], | ||
"scale": [0.005, 0.0025] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"textures": [ | ||
{} | ||
] | ||
} |
Binary file modified
BIN
+40 Bytes
(270%)
src/MagnumPlugins/TinyGltfImporter/Test/material-texcoord-flip.bin
Binary file not shown.
40 changes: 38 additions & 2 deletions
40
src/MagnumPlugins/TinyGltfImporter/Test/material-texcoord-flip.bin.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,44 @@ | ||
type = '<6f' | ||
input = [ | ||
type = '<' | ||
input = [] | ||
|
||
# Floats | ||
type += '6f' | ||
input += [ | ||
1.0, 0.5, | ||
0.5, 0.0, | ||
0.0, 1.0 | ||
] | ||
|
||
# Normalized unsigned bytes. On Y it's flipped. | ||
type += '6Bxx' | ||
input += [ | ||
254, 127, | ||
127, 254, | ||
0, 0 | ||
] | ||
|
||
# Normalized unsigned shorts. On Y it's flipped. | ||
type += '6H' | ||
input += [ | ||
65534, 32767, | ||
32767, 65534, | ||
0, 0 | ||
] | ||
|
||
# Normalized signed bytes. On X it's flipped. | ||
type += '6bxx' | ||
input += [ | ||
-127, 0, | ||
0, -127, | ||
127, 127, | ||
] | ||
|
||
# Unnormalized signed shorts. On Y it's off-center. | ||
type += '6h' | ||
input += [ | ||
200, 100, | ||
100, -100, | ||
0, 300 | ||
] | ||
|
||
# kate: hl python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.