You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Our project leverages Export and Import of glTF files at runtime. To enhance our performance, we already implemented usage of Unity Texture Arrays and MipMaps. It means our texture coordinates (UVs) are of type Vector4 (x, y, textureArrayIndex, mipMapLevel). When we store a mesh, it saves Vector2 for UVs only and the textureArrayIndex+mipMapLevel information get removed.
Out-of-scope:
The feature request asks for Vector4 on UVs only. Texture Array support for Materials isn't needed as we retrieve the Arrays manually after Mesh restore from glTF.
Describe the solution you'd like
It would be great if glTFast can support UVs as Vector2, Vector3, and Vector4. It would be fine, if you add a parameter which tells the Exporter/Importer which version to use.
Example usage we could think of:
// ExportingvarexportSettings=new ExportSettings
{TextureCoordinateType=typeof(Vector4)// Defaults to typeof(Vector2) for backwards compatibility
...};varexport=new GameObjectExport(exportSettings);
export.AddScene(...);
...
export.SaveToFileAndDispose();// Importing// No parameter for UV=Vector4 needed, if this information is stored inside gltf file itself.// Otherwise we could leverage an ImportSettings property.varimport=new GltfImport();
Describe alternatives you've considered
If glTF isn't providing a native solution, we need to store additional metadata in a JSON (etc.) file. After the meshes are loaded, we need to fetch all vertices and merge the missing two vector data points for all UV elements.
Doable, but not preferred as:
We need to store additional metadata (additional file handling for mesh based data)
We need to loop through all the UVs (additional CPU cycles to iterate through the data again)
Unity doesn't allow updating UVs, but only to set them altogether. Which means we need to create a new UV array and store it in one chunk at the end of the loop (More RAM usage during execution)
Additional context
Unity's UV getter: for various Vector* implementations:
I investigated that a Vector4 texture coordinate is not covered by the glTF 2.0 specification.
I manually crafted such a file and the validation failed with the following error:
Invalid accessor format '{VEC4, FLOAT}' for this attribute semantic. Must be one of ('{VEC2, FLOAT}', '{VEC2, UNSIGNED_BYTE normalized}', '{VEC2, UNSIGNED_SHORT normalized}').glTF Validator(MESH_PRIMITIVE_ATTRIBUTES_ACCESSOR_INVALID_FORMAT)
That being said, that does not prevent anyone from implementing support for VEC4 UVs and optionally crafting a custom extension around it.
I don't think that would be too hard to implement, but given that this is a very narrow use-case I won't put a high priority on it.
However, I can offer guidance if you decide to beat me to it when it comes to implementation.
As a starting point, could you provide a mesh that has 4 dimensional UVs? Frankly I lack the knowledge/tools to do it quickly.
Is your feature request related to a problem? Please describe.
Our project leverages Export and Import of glTF files at runtime. To enhance our performance, we already implemented usage of Unity Texture Arrays and MipMaps. It means our texture coordinates (UVs) are of type Vector4 (x, y, textureArrayIndex, mipMapLevel). When we store a mesh, it saves Vector2 for UVs only and the textureArrayIndex+mipMapLevel information get removed.
Out-of-scope:
The feature request asks for Vector4 on UVs only. Texture Array support for Materials isn't needed as we retrieve the Arrays manually after Mesh restore from glTF.
Describe the solution you'd like
It would be great if glTFast can support UVs as Vector2, Vector3, and Vector4. It would be fine, if you add a parameter which tells the Exporter/Importer which version to use.
Example usage we could think of:
Describe alternatives you've considered
If glTF isn't providing a native solution, we need to store additional metadata in a JSON (etc.) file. After the meshes are loaded, we need to fetch all vertices and merge the missing two vector data points for all UV elements.
Doable, but not preferred as:
Additional context
Unity's UV getter: for various Vector* implementations:
Test images from our project:
1: Before saving glT file
2: After loading the glT file
The text was updated successfully, but these errors were encountered: