Skip to content

Commit

Permalink
Merge tag 'release/6.2.0' into openupm
Browse files Browse the repository at this point in the history
Release 6.2.0
  • Loading branch information
atteneder committed Jan 29, 2024
2 parents decd203 + 28bb7fc commit cb68834
Show file tree
Hide file tree
Showing 18 changed files with 292 additions and 43 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [6.2.0] - 2024-01-29

### Added
- Deprecated soft-dependency packages are detected and a warning with upgrade instructions is shown in the console.

### Changed
- Support for Draco 3D Data Compression is now provided by [*Draco for Unity* (com.unity.cloud.draco)][DracoForUnity], which is a fork of and replaces [*DracoUnity* (com.atteneder.draco)][DracoUnity].

### Fixed
- Compiler error when Newtonsoft JSON package was not installed.
- All Draco vertex attributes are assigned by identifier instead of type. As a result, tangents are now decoded properly instead of recalculated.
- Compilation error when scripting define `GLTFAST_BUILTIN_SHADER_GRAPH` is set.
- `GltfImport.IsTextureYFlipped` returns correct result for non-KTX textures.

## [6.1.0] - 2024-01-17

### Added
Expand Down Expand Up @@ -1062,6 +1076,7 @@ This release contains multiple breaking changes. Please read the [upgrade guide]
[Entities1.0]: https://docs.unity3d.com/Packages/[email protected]
[KtxUnity]: https://github.com/atteneder/KtxUnity
[DanDovi]: https://github.com/DanDovi
[DracoForUnity]: https://docs.unity3d.com/Packages/com.unity.cloud.draco@latest
[DracoUnity]: https://github.com/atteneder/DracoUnity
[aurorahcx]: https://github.com/aurorahcx
[Battlehub0x]: https://github.com/Battlehub0x
Expand Down
4 changes: 2 additions & 2 deletions Documentation~/ExportRuntime.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public class TestExport : MonoBehaviour {
### Draco Compression

*Unity glTFast* supports applying [Google Draco™ 3D Data compression][Draco] to meshes. This requires the [DracoUnity][DracoUnity] package to be installed.
*Unity glTFast* supports applying [Google Draco™ 3D Data compression][Draco] to meshes. This requires the [Draco for Unity][DracoForUnity] package to be installed.

```csharp
// ExportSettings provides generic export settings
Expand All @@ -147,7 +147,7 @@ var exportSettings = new ExportSettings {

[asmdef]: https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html
[Draco]: https://google.github.io/draco/
[DracoUnity]: https://github.com/atteneder/DracoUnity
[DracoForUnity]: https://docs.unity3d.com/Packages/com.unity.cloud.draco@latest
[GoogleLLC]: https://about.google/
[khronos]: https://www.khronos.org
[unity]: https://unity.com
2 changes: 1 addition & 1 deletion Documentation~/UpgradeGuides.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Unity forks have been created for *KtxUnity* and *DracoUnity* as well. If you've
See their respective upgrade guides

- Upgrade to [*KTX for Unity*](https://docs.unity3d.com/Packages/[email protected]/manual/upgrade-guide.html)
- Upgrade to *Draco for Unity* (coming soon)
- Upgrade to [*Draco for Unity*](https://docs.unity3d.com/Packages/[email protected]/manual/upgrade-guide.html)

### Keep using the original glTFast

Expand Down
4 changes: 2 additions & 2 deletions Documentation~/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The glTF 2.0 specification is fully supported, with only a few minor remarks.
| Texture coordinates / UV sets | ✅ | `?`
| Three or more texture coordinates / UV sets | <sup>2</sup>☑️ | `?`
| Vertex colors | ✅ | `?`
| Draco&trade; mesh compression (via [DracoUnity]) | ✅ | ✅
| Draco&trade; mesh compression (via [DracoForUnity]) | ✅ | ✅
| Implicit (no) indices ||
| Per primitive material | ✅ | ✅
| Joints (up to 4 per vertex) ||
Expand Down Expand Up @@ -268,7 +268,7 @@ Possibly incomplete list of things that are known to not work with Entities yet:
[AnimationMecanim]: https://github.com/atteneder/glTFast/issues/167
[AnimationPlayables]: https://github.com/atteneder/glTFast/issues/166
[ClearCoat]: https://github.com/atteneder/glTFast/issues/68
[DracoUnity]: https://github.com/atteneder/DracoUnity
[DracoForUnity]: https://docs.unity3d.com/Packages/com.unity.cloud.draco@latest
[DOTS]: https://unity.com/dots
[Entities]: https://docs.unity3d.com/Packages/com.unity.entities@latest
[EntitiesGraphics]: https://docs.unity3d.com/Packages/com.unity.entities.graphics@latest
Expand Down
4 changes: 2 additions & 2 deletions Documentation~/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To install the *Unity glTFast* package, follow these steps:

There are some related package that improve *Unity glTFast* by extending its feature set.

- [Draco&trade; 3D Data Compression Unity Package][DracoUnity] (provides support for [KHR_draco_mesh_compression][ExtDraco])
- [Draco&trade; for Unity][DracoForUnity] (provides support for [KHR_draco_mesh_compression][ExtDraco])
- [KTX&trade; for Unity][KtxUnity] (provides support for [KHR_texture_basisu][ExtBasisU])
- [*meshoptimizer decompression for Unity*][Meshopt] (provides support for [EXT_meshopt_compression][ExtMeshopt])

Expand All @@ -29,7 +29,7 @@ There are some related package that improve *Unity glTFast* by extending its fea

*Draco&trade;* is a trademark of [*Google LLC*][GoogleLLC].

[DracoUnity]: https://github.com/atteneder/DracoUnity
[DracoForUnity]: https://docs.unity3d.com/Packages/com.unity.cloud.draco@latest
[ExtBasisU]: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu
[ExtDraco]: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
[ExtMeshopt]: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Vendor/EXT_meshopt_compression
Expand Down
158 changes: 158 additions & 0 deletions Editor/Scripts/PackageSetupCheck.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// SPDX-FileCopyrightText: 2023 Unity Technologies and the glTFast authors
// SPDX-License-Identifier: Apache-2.0

#if UNITY_2021_2_OR_NEWER
#define HYPERLINK
#define COMBINED
#endif

using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.PackageManager;
using UnityEditor.PackageManager.Requests;
using UnityEngine;

namespace GLTFast.Editor
{
[InitializeOnLoad]
static class PackageSetupCheck
{
static ListRequest s_ListRequest;

static PackageReplacement[] s_Packages = new PackageReplacement[]
{
new PackageReplacement()
{
name = "Draco for Unity",
identifier = "com.unity.cloud.draco",
legacyName = "Draco 3D Data Compression",
legacyIdentifier = "com.atteneder.draco",
feature = "KHR_draco_mesh_compression",
featureUri = "https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_draco_mesh_compression/README.md",
upgradeDocsUri = "https://docs.unity3d.com/Packages/[email protected]/manual/upgrade-guide.html#transition-to-draco-for-unity"
},
new PackageReplacement()
{
name = "KTX for Unity",
identifier = "com.unity.cloud.ktx",
legacyName = "KTX/Basis Universal Texture",
legacyIdentifier = "com.atteneder.ktx",
feature = "KHR_texture_basisu",
featureUri = "https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md",
upgradeDocsUri = "https://docs.unity3d.com/Packages/[email protected]/manual/upgrade-guide.html#transition-to-ktx-for-unity"
}
};

static PackageSetupCheck()
{
EditorApplication.update += WaitForPackageList;
s_ListRequest = Client.List(true);
#if HYPERLINK
EditorGUI.hyperLinkClicked += HyperLinkClicked;
#endif
}

static void WaitForPackageList()
{
if (s_ListRequest != null && s_ListRequest.IsCompleted)
{
if (s_ListRequest.Error == null)
{
foreach (var package in s_Packages)
{
CheckForLegacyPackage(s_ListRequest.Result, package);
}
}

s_ListRequest = null;
EditorApplication.update -= WaitForPackageList;
}
}

static void CheckForLegacyPackage(
PackageCollection packages,
PackageReplacement pkg
)
{
var legacyFound = false;

foreach (var packageInfo in packages)
{
if (packageInfo.name == pkg.legacyIdentifier)
{
legacyFound = true;
}
}
if (legacyFound)
{
pkg.LogUpgradeMessage();
}
}

#if HYPERLINK
static void HyperLinkClicked(EditorWindow window, HyperLinkClickedEventArgs args)
{
if(args.hyperLinkData.TryGetValue("command", out var command) && command=="replace")
{
if (args.hyperLinkData.TryGetValue("arg", out var pkg))
{
foreach (var package in s_Packages)
{
if (package.legacyIdentifier == pkg)
{
ReplacePackage(package);
}
}
}
}
}
#endif

#if COMBINED
static void ReplacePackage(PackageReplacement package)
{
if (EditorUtility.DisplayDialog(
"Package Upgrade",
$"Replace deprecated {package.legacyName} ({package.legacyIdentifier}) by {package.name} ({package.identifier})?",
"Replace",
"Cancel"
)
)
{
Client.AddAndRemove(
new[] { package.identifier },
new[] { package.legacyIdentifier }
);
}
}
#endif
}

struct PackageReplacement
{
public string name;
public string identifier;
public string legacyName;
public string legacyIdentifier;
public string feature;
public string featureUri;
public string upgradeDocsUri;

public void LogUpgradeMessage()
{
var message = $"Deprecated package <i>{legacyName}</i> (<i>{legacyIdentifier}</i>) detected!\n" +
$"<i>glTFast</i> now requires <i>{name}</i> (<i>{identifier}</i>) instead to provide support for " +
$"<a href=\"{featureUri}\">{feature}</a>.\n";
#if HYPERLINK
message +=
$"You can <a command=\"replace\" arg=\"{legacyIdentifier}\">automatically replace</a> the " +
$"deprecated package or do it manually following the <a href=\"{upgradeDocsUri}\">documentation</a>.";
#else
message += "To upgrade the package, follow the documentation at " +
$"<a href=\"{upgradeDocsUri}\">{upgradeDocsUri}</a>";
#endif
Debug.LogWarning(message);
}
}
}
11 changes: 11 additions & 0 deletions Editor/Scripts/PackageSetupCheck.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Runtime/Scripts/Export/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace GLTFast.Export
{
static class Constants
{
public const string version = "6.1.0";
public const string version = "6.2.0";

internal const string mimeTypePNG = "image/png";
internal const string mimeTypeJPG = "image/jpeg";
Expand Down
18 changes: 18 additions & 0 deletions Runtime/Scripts/Export/DracoExportSettings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// SPDX-FileCopyrightText: 2023 Unity Technologies and the glTFast authors
// SPDX-License-Identifier: Apache-2.0

#if DRACO_UNITY
using Draco.Encode;
#endif

namespace GLTFast.Export
{
/// <summary>
Expand Down Expand Up @@ -28,5 +32,19 @@ public class DracoExportSettings

/// <summary>Color quantization.</summary>
public int colorQuantization = 8;

#if DRACO_UNITY
public static implicit operator QuantizationSettings(DracoExportSettings s) => new QuantizationSettings(
s.positionQuantization,
s.normalQuantization,
s.texCoordQuantization,
s.colorQuantization
);

public static implicit operator SpeedSettings(DracoExportSettings s) => new SpeedSettings(
s.encodingSpeed,
s.decodingSpeed
);
#endif
}
}
12 changes: 4 additions & 8 deletions Runtime/Scripts/Export/GltfWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
using System.Threading.Tasks;

#if DRACO_UNITY
using Draco.Encoder;
using Draco.Encode;
#endif
using GLTFast.Schema;
using Unity.Collections;
Expand Down Expand Up @@ -926,7 +926,7 @@ async Task<bool> BakeMeshes() {
m_Logger.Warning(LogCode.UncompressedFallbackNotSupported);
}
#else
m_Logger?.Error(LogCode.PackageMissing, "DracoUnity", ExtensionName.DracoMeshCompression);
m_Logger?.Error(LogCode.PackageMissing, "Draco For Unity", ExtensionName.DracoMeshCompression);
return false;
#endif
}
Expand Down Expand Up @@ -1296,12 +1296,8 @@ async Task BakeMeshDraco(int meshId, UnityEngine.Mesh.MeshData meshData)
var results = await DracoEncoder.EncodeMesh(
unityMesh,
meshData,
m_Settings.DracoSettings.encodingSpeed,
m_Settings.DracoSettings.decodingSpeed,
m_Settings.DracoSettings.positionQuantization,
m_Settings.DracoSettings.normalQuantization,
m_Settings.DracoSettings.texCoordQuantization,
m_Settings.DracoSettings.colorQuantization
(QuantizationSettings) m_Settings.DracoSettings,
(SpeedSettings) m_Settings.DracoSettings
);

if (results == null) return;
Expand Down
4 changes: 2 additions & 2 deletions Runtime/Scripts/Export/glTFast.Export.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"Unity.Burst",
"Unity.RenderPipelines.Universal.Runtime",
"Unity.RenderPipelines.HighDefinition.Runtime",
"DracoEncoder"
"Draco.Encode"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand All @@ -33,7 +33,7 @@
"define": "UNITY_IMAGECONVERSION"
},
{
"name": "com.atteneder.draco",
"name": "com.unity.cloud.draco",
"expression": "5.0.0-pre.1",
"define": "DRACO_UNITY"
}
Expand Down
7 changes: 3 additions & 4 deletions Runtime/Scripts/GltfImport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
using UnityEngine.Experimental.Rendering;
using UnityEngine.Profiling;
using UnityEngine;

using Debug = UnityEngine.Debug;

[assembly: InternalsVisibleTo("glTFast.Editor")]
Expand Down Expand Up @@ -832,7 +831,7 @@ public Texture2D GetTexture(int index = 0)
public bool IsTextureYFlipped(int index = 0)
{
#if KTX
return m_NonFlippedYTextureIndices == null || !m_NonFlippedYTextureIndices.Contains(index);
return (m_NonFlippedYTextureIndices == null || !m_NonFlippedYTextureIndices.Contains(index)) && GetSourceTexture(index).IsKtx;
#else
return false;
#endif
Expand Down Expand Up @@ -1154,7 +1153,7 @@ bool CheckExtensionSupport(IEnumerable<string> extensions, bool required = true)
#if !DRACO_UNITY
if (ext == ExtensionName.DracoMeshCompression)
{
m_Logger?.Error(LogCode.PackageMissing, "DracoUnity", ext);
m_Logger?.Error(LogCode.PackageMissing, "Draco for Unity", ext);

}
#endif
Expand Down Expand Up @@ -3473,7 +3472,7 @@ void PreparePrimitiveDraco( RootBase gltf, MeshPrimitiveBase primitive, ref Prim
var bufferView = gltf.BufferViews[dracoExt.bufferView];
var buffer = GetBufferViewSlice(bufferView);

c.StartDecode(buffer, dracoExt.attributes.WEIGHTS_0, dracoExt.attributes.JOINTS_0);
c.StartDecode(buffer, dracoExt.attributes);
}
#endif

Expand Down
Loading

0 comments on commit cb68834

Please sign in to comment.