Skip to content

Commit faa0bde

Browse files
committed
com.atteneder.gltfast Release 6.16.1
1 parent fea7bce commit faa0bde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1971
-1512
lines changed

.gitignore

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Assets/AssetStoreTools*
1414
# Autogenerated VS/MD/Consulo solution and project files
1515
ExportedObj/
1616
.consulo/
17-
*.csproj
17+
Projects/**/*.csproj
1818
*.unityproj
19-
*.sln
19+
Projects/**/*.sln
2020
*.suo
2121
*.tmp
2222
*.user
@@ -39,3 +39,20 @@ sysinfo.txt
3939

4040
# Rider
4141
**/.idea
42+
43+
# Unity tooling
44+
/upm-ci~
45+
/test-results~
46+
/pvp-results
47+
48+
# glTFast test projects
49+
/Projects/*/ProjectSettings/*
50+
!Projects/*/ProjectSettings/ProjectVersion.txt
51+
/Projects/*/UserSettings
52+
/Projects/*/Assets/Resources*
53+
/Projects/*/Assets/StreamingAssets*
54+
/Projects/*/Packages/packages-lock.json
55+
/Projects/*/Logs
56+
57+
# CI Tols
58+
Tools/CI/bin

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,43 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [6.16.1] - 2026-02-19
8+
9+
### Added
10+
- (Test) *Empty Scene* test asset.
11+
- (Import) Support for 16-bit mesh indices reduces memory footprint for meshes with less than 65k vertices per sub-mesh.
12+
- 16-bit indices are not converted to 32-bit anymore.
13+
- 8-bit indices ar converted to 16-bit (instead of 32-bit).
14+
15+
### Changed
16+
- [GltfImport.Load](xref:GLTFast.GltfImportBase.Load*), [GltfImport.InstantiateSceneAsync](xref:GLTFast.GltfImportBase.InstantiateSceneAsync*) and their variants now throw an `OperationCanceledException` when cancelled before completion.
17+
- Replaced the generic [StandardMaterialExport](xref:GLTFast.Export.StandardMaterialExport) with specializations.
18+
- [LitMaterialExport](xref:GLTFast.Export.LitMaterialExport) for Universal Render Pipeline Lit shader material export.
19+
- [BuiltInStandardMaterialExport](xref:GLTFast.Export.BuiltInStandardMaterialExport) for Built-in Render Pipeline Standard shader material export.
20+
- (Performance) Improved performance of mesh indices conversion for draw modes line loop, triangle strips and triangle fan.
21+
22+
### Fixed
23+
- [GltfImport.InstantiateSceneAsync](xref:GLTFast.GltfImportBase.InstantiateSceneAsync*) properly handles an invalid scene index parameter.
24+
- [GltfImport](xref:GLTFast.GltfImportBase) waits for downloads to complete before attempting disposal during cancellation.
25+
- Projects depending on an outdated version of [meshoptimizer mesh compression for Unity] may suppress the corresponding compiler error by using the `GLTFAST_IGNORE_MESHOPT_OUTDATED_ERROR` scripting define symbol.
26+
- (Shader) Incorrect alpha blending/clipping due to invalid color space conversion on the base color map alpha and vertex color alpha values (affected shader graphs only; fixes [#800](https://github.com/atteneder/glTFast/issues/800)).
27+
- (Shader) Built-in render pipeline shaders metallic-roughness and specular-glossiness now factor in vertex color alpha values.
28+
- (Shader) All built-in render pipeline shaders apply vertex color alpha values linearly.
29+
- (Shader) Shader graph *glTF-pbrSpecularGlossiness* does not disregard the *Glossiness* parameter anymore.
30+
- (Import) Cases when specular-glossiness material setup would be incomplete at runtime.
31+
- (Import) Removed remains of incorrectly signed integer indices.
32+
- (Export) Smoothness value property is exported correctly across more combination of settings for Universal Render Pipeline Lit shader based materials (fixes [#795](https://github.com/atteneder/glTFast/issues/795) and [796](https://github.com/atteneder/glTFast/issues/796)).
33+
- (Export) When a Lit/Standard material has a smoothness texture, their smoothness value is baked into the resulting roughness channel (of the ORM map). This preserves the visual appearance, but is a lossy operation if the smoothness value is not `1.0` (fixes [#795](https://github.com/atteneder/glTFast/issues/795) and [796](https://github.com/atteneder/glTFast/issues/796)).
34+
- (Export) `MetaMaterialExportBuiltIn` is used for built-in material export (unless `GLTFAST_BUILTIN_SHADER_GRAPH` is set).
35+
- (Import) Solved exception when scenes with no nodes are loaded.
36+
- (Import) Triangle fan meshes with the center vertex not being the first vertex import correctly now.
37+
- (Test) Graphics tests are more stable/consistent due to dedicated scene.
38+
- (Shader) Incorrect normal unpacking when using default normal map on Android (fixes [#791](https://github.com/atteneder/glTFast/issues/791) and [802](https://github.com/atteneder/glTFast/issues/802)).
39+
- (Export) Texture scaling not preserved on URP/Lit export (fixes [#805](https://github.com/atteneder/glTFast/issues/805)).
40+
41+
### Deprecated
42+
- Generic built-in/Universal render pipeline [StandardMaterialExport](xref:GLTFast.Export.StandardMaterialExport).
43+
744
## [6.16.0] - 2026-01-20
845

946
### Added

Editor/Scripts/GltfImporter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ void ImportScene(
327327
{
328328
throw new InvalidOperationException("Instantiating scene failed");
329329
}
330-
var useFirstChild = true;
331-
var multipleNodes = scene.nodes.Length > 1;
330+
var useFirstChild = scene.nodes is { Length: > 0 };
331+
var singleNode = scene.nodes is { Length: 1 };
332332
var hasAnimation = false;
333333
#if UNITY_ANIMATION
334334
if (importSettings.AnimationMethod != AnimationMethod.None
@@ -341,7 +341,7 @@ void ImportScene(
341341
#endif
342342

343343
if (instantiationSettings.SceneObjectCreation == SceneObjectCreation.Never
344-
|| instantiationSettings.SceneObjectCreation == SceneObjectCreation.WhenMultipleRootNodes && !multipleNodes)
344+
|| instantiationSettings.SceneObjectCreation == SceneObjectCreation.WhenMultipleRootNodes && singleNode)
345345
{
346346
// No scene GameObject was created, so the first
347347
// child is the first (and in this case only) node.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#if DEBUG && (!UNITY_WEBGL || UNITY_EDITOR)
5+
#define LOG_CANCELLATION_SOURCE
6+
#endif
7+
8+
using System;
9+
using System.Runtime.CompilerServices;
10+
using System.Threading;
11+
using UnityEngine;
12+
13+
#if LOG_CANCELLATION_SOURCE
14+
using System.Diagnostics;
15+
using System.Reflection;
16+
#endif
17+
18+
namespace GLTFast
19+
{
20+
static class CancellationTokenExtension
21+
{
22+
#if DEBUG
23+
internal static Action s_OnCancellationCheck;
24+
#endif
25+
26+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
27+
internal static void ThrowIfCancellationRequestedWithTracking(this CancellationToken token)
28+
{
29+
#if DEBUG
30+
s_OnCancellationCheck?.Invoke();
31+
32+
if (token.IsCancellationRequested)
33+
{
34+
#if LOG_CANCELLATION_SOURCE
35+
var stackTrace = new StackTrace();
36+
// frame 0 is this cancellation method, frame 1 is the target caller
37+
if (stackTrace.FrameCount > 1 && stackTrace.GetFrame(1).GetMethod() is MethodInfo methodInfo)
38+
throw new OperationCanceledException($"{methodInfo.DeclaringType}.{methodInfo.Name}", token);
39+
#endif
40+
throw new OperationCanceledException(token);
41+
}
42+
#else // DEBUG
43+
token.ThrowIfCancellationRequested();
44+
#endif // DEBUG
45+
}
46+
}
47+
}

Runtime/Scripts/CancellationTokenExtension.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Scripts/DOTS/EntityInstantiator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ uint[] nodeIndices
7575
);
7676

7777
var dedicatedSceneEntity = m_Settings.SceneObjectCreation == SceneObjectCreation.Always
78-
|| m_Settings.SceneObjectCreation == SceneObjectCreation.WhenMultipleRootNodes && nodeIndices.Length > 1;
78+
|| (m_Settings.SceneObjectCreation == SceneObjectCreation.WhenMultipleRootNodes
79+
&& nodeIndices is { Length: > 1 });
7980

8081
if (dedicatedSceneEntity) {
8182
var sceneEntity = m_EntityManager.CreateEntity(m_Parent == Entity.Null ? m_SceneArchetype : m_NodeArchetype);

Runtime/Scripts/DataUri.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#endif
77

88
using System;
9+
using System.Threading;
910
using System.Threading.Tasks;
1011
using Unity.Collections;
1112
using UnityEngine;
@@ -32,6 +33,7 @@ public static async ValueTask<NativeArray<byte>> DecodeDataUriAsync(
3233
int startIndex,
3334
int byteLength,
3435
IDeferAgent deferAgent,
36+
CancellationToken cancellationToken,
3537
bool timeCritical = false
3638
)
3739
{
@@ -42,7 +44,14 @@ public static async ValueTask<NativeArray<byte>> DecodeDataUriAsync(
4244
#elif GLTFAST_THREADS
4345
if (!timeCritical || deferAgent.ShouldDefer(predictedTime))
4446
{
45-
return await Task.Run(() => DecodeDataUri(dataUri, startIndex, byteLength));
47+
try
48+
{
49+
return await Task.Run(() => DecodeDataUri(dataUri, startIndex, byteLength), cancellationToken);
50+
}
51+
catch (OperationCanceledException)
52+
{
53+
cancellationToken.ThrowIfCancellationRequestedWithTracking();
54+
}
4655
}
4756
#endif
4857
await deferAgent.BreakPoint(predictedTime);
@@ -66,14 +75,22 @@ public static async ValueTask<byte[]> DecodeDataUriToManagedArrayAsync(
6675
int startIndex,
6776
int byteLength,
6877
IDeferAgent deferAgent,
78+
CancellationToken cancellationToken,
6979
bool timeCritical = false
7080
)
7181
{
7282
var predictedTime = dataUri.Length / (float)k_Base64DecodeSpeed;
7383
#if GLTFAST_THREADS
7484
if (!timeCritical || deferAgent.ShouldDefer(predictedTime))
7585
{
76-
return await Task.Run(() => DecodeDataUriToManagedArray(dataUri, startIndex, byteLength));
86+
try
87+
{
88+
return await Task.Run(() => DecodeDataUriToManagedArray(dataUri, startIndex, byteLength), cancellationToken);
89+
}
90+
catch (OperationCanceledException)
91+
{
92+
cancellationToken.ThrowIfCancellationRequestedWithTracking();
93+
}
7794
}
7895
#endif
7996
await deferAgent.BreakPoint(predictedTime);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// SPDX-FileCopyrightText: 2026 Unity Technologies and the glTFast authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
using System;
5+
using GLTFast.Logging;
6+
using GLTFast.Schema;
7+
using UnityEngine;
8+
9+
namespace GLTFast.Export
10+
{
11+
/// <summary>
12+
/// Converts Built-In Standard shader based materials to glTF materials
13+
/// </summary>
14+
public sealed class BuiltInStandardMaterialExport : StandardMaterialExportBase
15+
{
16+
const string k_KeywordMetallicGlossMap = "_METALLICGLOSSMAP";
17+
18+
static readonly int k_GlossMapScaleProperty = Shader.PropertyToID("_GlossMapScale");
19+
20+
/// <summary>
21+
/// _Glossiness shader property identifier
22+
/// </summary>
23+
public static readonly int GlossinessProperty = Shader.PropertyToID("_Glossiness");
24+
25+
protected override bool HasMetallicGlossMap(UnityEngine.Material uMaterial)
26+
{
27+
return uMaterial.IsKeywordEnabled(k_KeywordMetallicGlossMap);
28+
}
29+
30+
protected override bool IsPbrMetallicRoughness(UnityEngine.Material material)
31+
{
32+
return material.HasProperty(MetallicProperty)
33+
&& (
34+
HasMetallicGlossMap(material)
35+
|| material.HasProperty(GlossinessProperty)
36+
);
37+
}
38+
39+
protected override int GetSmoothnessProperty(bool sourceAlbedoAlpha, bool hasMetallicGlossinessMap)
40+
{
41+
return sourceAlbedoAlpha || hasMetallicGlossinessMap ? k_GlossMapScaleProperty : GlossinessProperty;
42+
}
43+
}
44+
}

Runtime/Scripts/Export/BuiltInStandardMaterialExport.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Scripts/Export/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace GLTFast.Export
77
{
88
static class Constants
99
{
10-
public const string version = "6.16.0";
10+
public const string version = "6.16.1";
1111

1212
internal const string mimeTypePNG = "image/png";
1313
internal const string mimeTypeJPG = "image/jpeg";

0 commit comments

Comments
 (0)