From 3ef12503850b1e47afd338c8f99b1b21a0b9369b Mon Sep 17 00:00:00 2001
From: Aurora Huang
Date: Thu, 12 Oct 2023 09:22:09 -0400
Subject: [PATCH 01/14] Post Release 6.0.1 (#64)
---
CHANGELOG.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1e480002..5efe6bac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,8 @@ 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).
+## [Unreleased]
+
## [6.0.1] - 2023-10-11
### Fixed
From 55a11fadfc24ff139cb39a72e965b51d60f56bec Mon Sep 17 00:00:00 2001
From: Andreas Atteneder
Date: Thu, 12 Oct 2023 15:56:28 +0200
Subject: [PATCH 02/14] doc: Updated link to a version that actually contains
the right upgrade guide for *KTX for Unity* (#65)
---
Documentation~/UpgradeGuides.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation~/UpgradeGuides.md b/Documentation~/UpgradeGuides.md
index 9f924e8d..18bf83f2 100644
--- a/Documentation~/UpgradeGuides.md
+++ b/Documentation~/UpgradeGuides.md
@@ -30,7 +30,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/com.unity.cloud.ktx@3.0/manual/upgrade-guide.html)
+- Upgrade to [*KTX for Unity*](https://docs.unity3d.com/Packages/com.unity.cloud.ktx@3.2/manual/upgrade-guide.html)
- Upgrade to *Draco for Unity* (coming soon)
### Keep using the original glTFast
From 3d54b6b7ab92d21c15d850b578e6b4c7fd79d5d2 Mon Sep 17 00:00:00 2001
From: Andreas Atteneder
Date: Fri, 20 Oct 2023 15:02:09 +0200
Subject: [PATCH 03/14] Doc/installation (#68)
* doc: Removed system requirements and prerequisites from installation instructions
System requirements falsely imply that glTFast only works on those platforms. While not extensively tested on all platforms, it should work everywhere.
Minimum version definition in prerequisites is redundant to package manifest and prone to be outdated in the future.
Removed unused trademark note
* doc: Included installation instructions in table of content and upgrade guide
Partially applied template ToC layout
* doc: Correct 2 space indent (markdownlint)
* doc: Fixed listing installation items
* doc: Removed redundant installation instructions from `README.md` and merged it into `installation.md`.
* doc: Added registered trademark char to first appearance of Unity.
* doc: Added missing changelog entry about minimum required Unity version.
* doc: Fixed changelog entry
---
CHANGELOG.md | 6 ++--
Documentation~/TableOfContents.md | 19 ++++++------
Documentation~/UpgradeGuides.md | 2 +-
Documentation~/installation.md | 49 +++++++++++++++----------------
README.md | 32 ++------------------
5 files changed, 41 insertions(+), 67 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5efe6bac..676493a3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [6.0.0] - 2023-10-04
### Added
-- Custom Extension API (`GLTFast.Extensions` namespace)
+- Custom Add-On API (`GLTFast.Addons` namespace)
- Support for alternative JSON parsing via Newtonsoft JSON
- `Accessor.ElementByteSize`: Byte size of one element of that accessor
- `Accessor.ByteSize`: Overall byte size
@@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- (Export) Clearcoat material export support for HDRP Lit shader
### Changed
+- Bumped minimum Unity version to 2020.3.48f1
- Renamed `GltfAnimation` to `Animation` for consistent naming.
- Bumped Burst dependency version to 1.8.4
- Bumped Mathematics dependency version to 1.3.1
@@ -43,10 +44,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Runtime tests
- (Export) Setting for deterministic export (limits concurrency to ensure consistent output)
- (DOTS) Support for [Entities 1.0][Entities1.0]
+
### Changed
- Optimized `Accessor.GetAccessorAttributeType`
- Optimized `GltfEntityAsset.ClearScenes` via Burst
-- Bump minimum unity version from 2019.4.7f1 to 2019.4.40f1
+- Bump minimum Unity version from 2019.4.7f1 to 2019.4.40f1
### Fixed
- Compiler errors and warnings on Unity 2023.2 (and newer) due to using obsolete types.
diff --git a/Documentation~/TableOfContents.md b/Documentation~/TableOfContents.md
index fb4894e3..32420c33 100644
--- a/Documentation~/TableOfContents.md
+++ b/Documentation~/TableOfContents.md
@@ -1,14 +1,15 @@
-* [Overview](index.md)
+* [Unity glTFast](index.md)
+ * [Installation](installation.md)
+ * [Upgrade guides](UpgradeGuides.md)
* [Features](features.md)
* Runtime
- * [Import](ImportRuntime.md)
- * [Export](ExportRuntime.md)
+ * [Import](ImportRuntime.md)
+ * [Export](ExportRuntime.md)
* Editor
- * [Import](ImportEditor.md)
- * [Export](ExportEditor.md)
+ * [Import](ImportEditor.md)
+ * [Export](ExportEditor.md)
* [Project Setup](ProjectSetup.md)
* More Information
- * [Upgrade Guides](UpgradeGuides.md)
- * [Known Issues](KnownIssues.md)
- * [Physical Light Units in glTF](LightUnits.md)
- * [Implementation Details](ImplementationDetails.md)
+ * [Known Issues](KnownIssues.md)
+ * [Physical Light Units in glTF](LightUnits.md)
+ * [Implementation Details](ImplementationDetails.md)
diff --git a/Documentation~/UpgradeGuides.md b/Documentation~/UpgradeGuides.md
index 18bf83f2..3314528e 100644
--- a/Documentation~/UpgradeGuides.md
+++ b/Documentation~/UpgradeGuides.md
@@ -20,7 +20,7 @@ For now, both the Unity variant and the original version will receive updates.
The C# namespaces are identical between the variants, so all you need to do is:
- Removed original *glTFast* (with package identifier `com.atteneder.gltfast`).
-- Add *Unity glTFast* (`com.unity.cloud.gltfast`).
+- [Install *Unity glTFast*](installation.html) (`com.unity.cloud.gltfast`).
- Update assembly definition references (if your project had any).
- Update any dependencies in your packages manifest (if your package had any)
diff --git a/Documentation~/installation.md b/Documentation~/installation.md
index 7a2b55dc..b4f486fc 100644
--- a/Documentation~/installation.md
+++ b/Documentation~/installation.md
@@ -1,42 +1,41 @@
# Installation
-Before you install the package, make sure you meet the [system requirement](#system-requirement) and [prerequisites](#prerequisites).
-
## Install the *Unity glTFast* package using the Unity Package Manager
To install the *Unity glTFast* package, follow these steps:
-In your Unity project, go to Windows > Package Manager.
-On the status bar, select the Add (+) button.
-From the Add menu, select Add + package by name. Name and Version fields appear.
-In the Name field, enter `com.unity.cloud.gltfast`.
-Select Add.
-The Editor installs the latest available version of the package and any dependent packages.
-
-## System Requirement
+- In your Unity project, go to Windows > Package Manager.
+- On the status bar, select the Add (+) button.
+- From the Add menu, select Add + package by name. Name and Version fields appear.
+- In the Name field, enter `com.unity.cloud.gltfast`.
+- Select Add.
+- The Editor installs the latest available version of the package and any dependent packages.
-*Unity glTFast* supports the following platforms:
+## Optional Packages
-- WebGL
-- iOS (arm64 and armv7a)
-- Android (arm64 and armv7a)
-- Windows (64 bit)
-- Universal Windows Platform (x64, x86, ARM, ARM64)
-- MacOS Universal (Apple Silicon and Intel)
-- Linux (64 bit)
-- Lumin / Magic Leap
+There are some related package that improve *Unity glTFast* by extending its feature set.
-## Prerequisites
+- [Draco™ 3D Data Compression Unity Package][DracoUnity] (provides support for [KHR_draco_mesh_compression][ExtDraco])
+- [KTX™ for Unity][KtxUnity] (provides support for [KHR_texture_basisu][ExtBasisU])
+- [*meshoptimizer decompression for Unity*][Meshopt] (provides support for [EXT_meshopt_compression][ExtMeshopt])
-To use the package, you require the following:
+## Trademarks
-- A Unity version of 2020.1 or later. In the Unity Hub, go to **Installs** > **Official releases** to find the latest Long Term Support version.
+*Unity®* is a registered trademark of [Unity Technologies][unity].
-## Trademarks
+*Khronos®* is a registered trademark and [glTF™][gltf] is a trademark of [The Khronos Group Inc][khronos].
-*Unity* is a registered trademark of [Unity Technologies][unity].
+*KTX™* and the KTX logo are trademarks of the [The Khronos Group Inc][khronos].
-*Khronos®* is a registered trademark and *glTF™* is a trademark of [The Khronos Group Inc][khronos].
+*Draco™* is a trademark of [*Google LLC*][GoogleLLC].
+[DracoUnity]: https://github.com/atteneder/DracoUnity
+[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
+[gltf]: https://www.khronos.org/gltf
+[GoogleLLC]: https://about.google/
[khronos]: https://www.khronos.org
+[KtxUnity]: https://docs.unity3d.com/Packages/com.unity.cloud.ktx@latest/
+[Meshopt]: https://docs.unity3d.com/Packages/com.unity.meshopt.decompress@latest/
[unity]: https://unity.com
diff --git a/README.md b/README.md
index afd3347b..a7ea9ea5 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
-*Unity glTFast* enables use of [glTF™ (GL Transmission Format)][gltf] asset files in [Unity][unity].
+*Unity glTFast* enables use of [glTF™ (GL Transmission Format)][gltf] asset files in [Unity®][unity].
It focuses on speed, memory efficiency and a small build footprint while also providing:
@@ -36,27 +36,10 @@ Read more about the workflows in the [documentation][workflows].
## Installing
-To install the *Unity glTFast* package, follow these steps:
-
-In your Unity project, go to Windows > Package Manager.
-On the status bar, select the Add (+) button.
-From the Add menu, select Add + package by name. Name and Version fields appear.
-In the Name field, enter `com.unity.cloud.gltfast`.
-Select Add.
-The Editor installs the latest available version of the package and any dependent packages.
+[Installation instructions](./Documentation~/installation.md)
> **NOTE:** This package originally had the identifier `com.atteneder.gltfast`. Consult the [upgrade guide](./Documentation~/UpgradeGuides.md#unity-fork) to learn how to switch to the Unity version (`com.unity.cloud.gltfast`) or [install the original package](./Documentation~/Original.md).
-### Optional Packages
-
-There are some related package that improve *Unity glTFast* by extending its feature set.
-
-- [Draco™ 3D Data Compression Unity Package][DracoUnity] (provides support for [KHR_draco_mesh_compression][ExtDraco])
-- [KTX™ for Unity][KtxUnity] (provides support for [KHR_texture_basisu][ExtBasisU])
-- [*meshoptimizer decompression for Unity*][Meshopt] (provides support for [EXT_meshopt_compression][ExtMeshopt])
-
-*Unity glTFast* 5.x requires Unity 2020.1 or newer.
-
## Usage
You can load a glTF asset from an URL or a file path.
@@ -127,21 +110,10 @@ limitations under the License.
*Khronos®* is a registered trademark and [glTF™][gltf] is a trademark of [The Khronos Group Inc][khronos].
-*KTX™* and the KTX logo are trademarks of the [The Khronos Group Inc][khronos].
-
-*Draco™* is a trademark of [*Google LLC*][GoogleLLC].
-
-[DracoUnity]: https://github.com/atteneder/DracoUnity
-[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
[gltf-spec]: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html
[gltf]: https://www.khronos.org/gltf
[gltfasset_component]: ./Documentation~/Images/gltfasset_component.png "Inspector showing a GltfAsset component added to a GameObject"
-[GoogleLLC]: https://about.google/
[import-gif]: ./Documentation~/Images/import.gif "Video showing glTF files being copied into the Assets folder and imported"
[khronos]: https://www.khronos.org
-[KtxUnity]: https://docs.unity3d.com/Packages/com.unity.cloud.ktx@latest
-[Meshopt]: https://docs.unity3d.com/Packages/com.unity.meshopt.decompress@0.1/manual/index.html
[unity]: https://unity.com
[workflows]: ./Documentation~/index.md#workflows
From 1e85cf730c714fbe9badc1e370753f4fa4dcfe52 Mon Sep 17 00:00:00 2001
From: Andreas Atteneder
Date: Wed, 1 Nov 2023 11:58:35 +0100
Subject: [PATCH 04/14] Fix/docs contribution (#69)
* doc: Changelog entry
* doc: Updated contributing documentation.
---
CHANGELOG.md | 3 +++
CONTRIBUTING.md | 49 ++++++++++++++++++++++++++++++++++---------------
README.md | 2 +-
3 files changed, 38 insertions(+), 16 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 676493a3..c4cb42f1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Changed
+- Documentation improvements
+
## [6.0.1] - 2023-10-11
### Fixed
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 3a78fa01..e204da6b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -7,36 +7,55 @@ of guidelines to ensure that your extensions can be easily integrated.
## Communication
-First, please read through our [code of conduct](CODE_OF_CONDUCT.md), as we
+Please read through our [code of conduct][COC], as we
expect all our contributors to follow it.
-Second, before starting on a project that you intend to contribute in any form, we
-**strongly** recommend posting on our
-[Issues page](https://github.com/atteneder/glTFast/issues) and
-briefly outline the changes you plan to make. This will enable us to provide
-some context that may be helpful for you. This could range from advice and
-feedback on how to optimally perform your changes or reasons for not doing it.
+For inquiries of all sorts, feel free to raise an issue by going to the
+[issues page][issues] and click the *New issue* button.
-Lastly, if you're looking for input on what to contribute browse the GitHub
-issues, especially ones with the `help wanted` or `good first issue` label.
+If you're looking for ideas on ways to contribute browse the [issues][issues],
+especially ones with the `help wanted` or `good first issue` label.
-## Git Branches
+## Preparation
-The main branch corresponds to the most recent version of the project. Note
-that this branch may be unstable and may be newer that the latest release.
+Before starting to work on a contribution we recommend searching within the
+existing [issues][issues] and [pull requests][pulls] for similar topics to
+avoid redundant efforts and make sure you got all contextual information.
-When contributing to the project, please make sure that your Pull Request (PR)
-contains the following:
+Feel free to propose ideas upfront via an [issue][issues] that briefly outlines
+your intended changes. We'll then try to give you advice and feedback on how to
+optimally implement those changes or, if justifiable, reasons to abandon an
+idea. This pre-evaluation can raise the chances of getting a contribution
+accepted.
+
+## Version Control
+
+*glTFast* uses [Git][Git] and [GitHub][repo] for version control.
+
+## Submission via Pull Request
+
+Changes can be proposed via [pull requests (PR)][GithubDocPR] on the [pull requests][pulls] page.
+
+Please make sure that your PR contains the following:
- Detailed description of the changes performed
- Corresponding changes to documentation, changelog and unit tests
- Summary of the tests performed to validate your changes
- Issue numbers that the PR resolves (if any)
+PRs will be transferred to an internal, mirrored repository to undergo review and (automated) tests that use Unity's internal tools and infrastructure. If those tests and reviews are not successful, we'll help you resolve remaining issues and merge your work, once it passes all tests. The merge will happen on the mirrored repository and the original pull requests will get closed with a proper notification about expected release version and date.
+
## Contributor License Agreements
When you open a pull request, you will be asked to acknowledge our Contributor
License Agreement. You will have to confirm that your Contributions are your
original creation and that you have complete right and authority to make your
-Contributions. We allow both individual contributions and contributions made on
+contributions. We allow both individual contributions and contributions made on
behalf of companies.
+
+[COC]: (CODE_OF_CONDUCT.md)
+[Git]: https://git-scm.com/
+[repo]: https://github.com/Unity-Technologies/com.unity.cloud.gltfast
+[issues]: https://github.com/Unity-Technologies/com.unity.cloud.gltfast/issues
+[pulls]: https://github.com/Unity-Technologies/com.unity.cloud.gltfast/pulls
+[GithubDocPR]: https://docs.github.com/pull-requests
diff --git a/README.md b/README.md
index a7ea9ea5..861d68a1 100644
--- a/README.md
+++ b/README.md
@@ -86,7 +86,7 @@ Read the section *Materials and Shader Variants* in the [Documentation](./Docume
## Contribution
-Contributions in the form of ideas, comments, critique, bug reports, pull requests are highly appreciated. Feel free to get in contact if you consider using or improving *Unity glTFast*.
+See [CONTRIBUTING.md](CONTRIBUTING.md).
## License
From 835417c6d6258391a83c22060b3866cf6332aa5b Mon Sep 17 00:00:00 2001
From: Aurora Huang
Date: Thu, 9 Nov 2023 11:04:36 -0500
Subject: [PATCH 05/14] Documentation for glTFast add-on API (#73)
* Documentation for glTFast add-on API
* Add assembly definitions for samples
* Update CHANGELOG.md
---
CHANGELOG.md | 3 +
Documentation~/Images/gltf-extra-data.PNG | 3 +
Documentation~/TableOfContents.md | 2 +
Documentation~/UseCaseCustomExtras.md | 104 ++++++++++++++++++
Documentation~/features.md | 6 +
Samples.meta | 8 ++
Samples/Documentation.meta | 8 ++
Samples/Documentation/Manual.meta | 8 ++
.../Documentation/Manual/CustomGltfImport.cs | 102 +++++++++++++++++
.../Manual/CustomGltfImport.cs.meta | 11 ++
Samples/Documentation/Manual/ExtraData.cs | 13 +++
.../Documentation/Manual/ExtraData.cs.meta | 11 ++
.../Unity.Cloud.Gltfast.Documentation.asmdef | 17 +++
...ty.Cloud.Gltfast.Documentation.asmdef.meta | 7 ++
14 files changed, 303 insertions(+)
create mode 100644 Documentation~/Images/gltf-extra-data.PNG
create mode 100644 Documentation~/UseCaseCustomExtras.md
create mode 100644 Samples.meta
create mode 100644 Samples/Documentation.meta
create mode 100644 Samples/Documentation/Manual.meta
create mode 100644 Samples/Documentation/Manual/CustomGltfImport.cs
create mode 100644 Samples/Documentation/Manual/CustomGltfImport.cs.meta
create mode 100644 Samples/Documentation/Manual/ExtraData.cs
create mode 100644 Samples/Documentation/Manual/ExtraData.cs.meta
create mode 100644 Samples/Documentation/Unity.Cloud.Gltfast.Documentation.asmdef
create mode 100644 Samples/Documentation/Unity.Cloud.Gltfast.Documentation.asmdef.meta
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c4cb42f1..cd9640c7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Added
+- (Documentation) Explanation and user case for the add-on API
+
### Changed
- Documentation improvements
diff --git a/Documentation~/Images/gltf-extra-data.PNG b/Documentation~/Images/gltf-extra-data.PNG
new file mode 100644
index 00000000..bd60625d
--- /dev/null
+++ b/Documentation~/Images/gltf-extra-data.PNG
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:57f7aced9ce2532edcddcf1966b739313f604854463e658916d990b58d84bbe9
+size 24697
diff --git a/Documentation~/TableOfContents.md b/Documentation~/TableOfContents.md
index 32420c33..945ac149 100644
--- a/Documentation~/TableOfContents.md
+++ b/Documentation~/TableOfContents.md
@@ -9,6 +9,8 @@
* [Import](ImportEditor.md)
* [Export](ExportEditor.md)
* [Project Setup](ProjectSetup.md)
+* Use Cases
+ * [Use glTFast Add-on API to import custom data](UseCaseCustomExtras.md)
* More Information
* [Known Issues](KnownIssues.md)
* [Physical Light Units in glTF](LightUnits.md)
diff --git a/Documentation~/UseCaseCustomExtras.md b/Documentation~/UseCaseCustomExtras.md
new file mode 100644
index 00000000..68e7e563
--- /dev/null
+++ b/Documentation~/UseCaseCustomExtras.md
@@ -0,0 +1,104 @@
+# Use case: Use glTFast Add-on API
+
+This use case describes the step to use glTFast Add-on API to import custom data in the `extras` property of a glTF™ JSON object. This example uses Newtonsoft JSON parser to deserialize data.
+
+To accomplish this use case, do the following:
+
+1. Add custom data in a gltf asset
+2. Create a custom gltf import behavior
+3. Add assembly definitions
+4. Set up a new scene
+5. Import the gltf asset in runtime
+
+## Before you start
+
+Before you start, you must add the following package dependencies to your project.
+
+* In the `manifest.json` file, add the following dependencies:
+
+```json
+ {
+ "dependencies": {
+ // Add these lines:
+ // Replace "" with the version you wish to install
+ "com.unity.cloud.gltfast": "",
+ "com.unity.nuget.newtonsoft-json": ""
+ // Other dependencies...
+ }
+ }
+```
+
+## How do I...?
+
+### Add custom data in a gltf asset
+
+Add some custom data in the `extras` property of a glTF JSON object:
+
+```json
+ "nodes": [
+ {
+ // Example of mesh data in a glTF
+ "mesh": 0,
+ "name": "Cube",
+
+ // Add these lines:
+ "extras": {
+ "some-extra-key": "some-extra-value"
+ }
+ }
+ ]
+```
+
+### Create a custom gltf import behavior
+
+To create a custom gltf import behavior, follow these steps:
+
+1. Open your Unity® Project.
+2. Go to the **Assets** folder in the Project window.
+3. Select and hold **Create**.
+4. Select **C# Script**.
+5. Rename the new script as `CustomGltfImport`.
+6. Open the `CustomGltfImport` script and replace the content with the following:
+ [!code-cs [custom-gltf-import](../Samples/Documentation/Manual/CustomGltfImport.cs#CustomGltfImport)]
+7. Repeat step 2-4 to create another new script
+8. Rename the new script as `ExtraData`.
+9. Open the `ExtraData` script and replace the content with the following:
+ [!code-cs [extra-data](../Samples/Documentation/Manual/ExtraData.cs#ExtraData)]
+
+### Add assembly definitions
+
+In your [assembly definition](https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html) file (`.asmdef` file), add the following references:
+
+```json
+ "references": [
+ // Add these lines:
+ "glTFast",
+ "glTFast.Newtonsoft"
+ // Other references...
+ ]
+```
+
+### Set up a new scene
+
+To set up a new scene, follow these steps:
+
+1. Create a new scene.
+2. Create a GameObject called **GltfImport**.
+3. Select **Add Component** in the Inspector window and add the **Custom Gltf Import** component.
+4. In the **Uri** field, set the path to point to where the gltf asset is stored.
+
+### Import the gltf asset in runtime
+
+Select **Play**, the gltf asset should be loaded and displayed at runtime.
+
+You can verify that the custom data in the `extras` property of the glTF is imported correctly by inspecting the loaded gltf asset:
+![Screen capture that displays the extra data in the imported gltf asset](Images/gltf-extra-data.PNG)
+
+## Trademarks
+
+*Unity®* is a registered trademark of [Unity Technologies][Unity].
+
+*glTF™* is a trademark of [The Khronos Group Inc][Khronos].
+
+[Khronos]: https://www.khronos.org
+[Unity]: https://unity.com
diff --git a/Documentation~/features.md b/Documentation~/features.md
index b4607671..b6e27e05 100644
--- a/Documentation~/features.md
+++ b/Documentation~/features.md
@@ -138,6 +138,12 @@ Not investigated yet:
- FB_geometry_metadata (prefer KTX_xmp)
- MSFT_texture_dds (prefer KTX/basisu)
+### Custom extras and extensions
+
+Optional `extras` and `extensions` object properties are supported. glTFast uses Newtonsoft JSON parser to access these additional properties.
+
+See [glTFast Add-on API](UseCaseCustomExtras.md) for an example to import the `extras` property in a gltf asset.
+
## Materials Details
### Material Import
diff --git a/Samples.meta b/Samples.meta
new file mode 100644
index 00000000..0c6eff69
--- /dev/null
+++ b/Samples.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 80a9660688f788a4b90e36414fcb5fb6
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Samples/Documentation.meta b/Samples/Documentation.meta
new file mode 100644
index 00000000..bbe32df9
--- /dev/null
+++ b/Samples/Documentation.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: c31dca948fd8a9c45b6a13732c190c2e
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Samples/Documentation/Manual.meta b/Samples/Documentation/Manual.meta
new file mode 100644
index 00000000..66d89b5e
--- /dev/null
+++ b/Samples/Documentation/Manual.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 19e2269416001a74bb7886e4e56b9b05
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Samples/Documentation/Manual/CustomGltfImport.cs b/Samples/Documentation/Manual/CustomGltfImport.cs
new file mode 100644
index 00000000..b6586350
--- /dev/null
+++ b/Samples/Documentation/Manual/CustomGltfImport.cs
@@ -0,0 +1,102 @@
+namespace Samples.Documentation.Manual
+{
+
+#region CustomGltfImport
+using GLTFast;
+using GLTFast.Addons;
+using System;
+using System.Threading.Tasks;
+using UnityEngine;
+using GltfImport = GLTFast.Newtonsoft.GltfImport;
+
+public class CustomGltfImport : MonoBehaviour
+{
+ // Path to the gltf asset to be imported
+ public string Uri;
+
+ async Task Start()
+ {
+ try
+ {
+ ImportAddonRegistry.RegisterImportAddon(new MyAddon());
+ var gltfImport = new GltfImport();
+ await gltfImport.Load(Uri);
+ await gltfImport.InstantiateMainSceneAsync(transform);
+ }
+ catch (Exception e)
+ {
+ Debug.LogException(e);
+ }
+ }
+
+ public class MyAddon : ImportAddon { }
+ public class MyAddonInstance : ImportAddonInstance
+ {
+ GltfImport m_GltfImport;
+
+ public override void Dispose() { }
+
+ public override void Inject(GltfImportBase gltfImport)
+ {
+ var newtonsoftGltfImport = gltfImport as GltfImport;
+ if (newtonsoftGltfImport == null)
+ return;
+
+ m_GltfImport = newtonsoftGltfImport;
+ newtonsoftGltfImport.AddImportAddonInstance(this);
+ }
+
+ public override void Inject(IInstantiator instantiator)
+ {
+ var goInstantiator = instantiator as GameObjectInstantiator;
+ if (goInstantiator == null)
+ return;
+ var _ = new MyInstantiatorAddon(m_GltfImport, goInstantiator);
+ }
+
+ public override bool SupportsGltfExtension(string extensionName)
+ {
+ return false;
+ }
+ }
+}
+
+public class MyInstantiatorAddon
+{
+ GltfImport m_GltfImport;
+ GameObjectInstantiator m_Instantiator;
+
+ public MyInstantiatorAddon(GltfImport gltfImport, GameObjectInstantiator instantiator)
+ {
+ m_GltfImport = gltfImport;
+ m_Instantiator = instantiator;
+ m_Instantiator.NodeCreated += OnNodeCreated;
+ m_Instantiator.EndSceneCompleted += () =>
+ {
+ m_Instantiator.NodeCreated -= OnNodeCreated;
+ };
+ }
+
+ void OnNodeCreated(uint nodeIndex, GameObject gameObject)
+ {
+ // De-serialize glTF JSON
+ var gltf = m_GltfImport.GetSourceRoot();
+
+ var node = gltf.Nodes[(int)nodeIndex] as GLTFast.Newtonsoft.Schema.Node;
+ var extras = node.extras;
+
+ if (extras == null)
+ return;
+
+ // Access values in the extras property
+ if (extras.TryGetValue("some-extra-key", out string extraValue))
+ {
+ var component = gameObject.AddComponent();
+ component.someExtraKey = extraValue;
+ }
+ }
+}
+#endregion
+
+}
+
diff --git a/Samples/Documentation/Manual/CustomGltfImport.cs.meta b/Samples/Documentation/Manual/CustomGltfImport.cs.meta
new file mode 100644
index 00000000..ae8e8613
--- /dev/null
+++ b/Samples/Documentation/Manual/CustomGltfImport.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ed7eb2828185cf54896d0bc4e34c7d24
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Samples/Documentation/Manual/ExtraData.cs b/Samples/Documentation/Manual/ExtraData.cs
new file mode 100644
index 00000000..993efcd5
--- /dev/null
+++ b/Samples/Documentation/Manual/ExtraData.cs
@@ -0,0 +1,13 @@
+namespace Samples.Documentation.Manual
+{
+
+#region ExtraData
+using UnityEngine;
+
+public class ExtraData : MonoBehaviour
+{
+ public string someExtraKey;
+}
+
+#endregion
+}
\ No newline at end of file
diff --git a/Samples/Documentation/Manual/ExtraData.cs.meta b/Samples/Documentation/Manual/ExtraData.cs.meta
new file mode 100644
index 00000000..41909859
--- /dev/null
+++ b/Samples/Documentation/Manual/ExtraData.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c228dd24f481eca4d8b951a9b54398b1
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Samples/Documentation/Unity.Cloud.Gltfast.Documentation.asmdef b/Samples/Documentation/Unity.Cloud.Gltfast.Documentation.asmdef
new file mode 100644
index 00000000..1b779752
--- /dev/null
+++ b/Samples/Documentation/Unity.Cloud.Gltfast.Documentation.asmdef
@@ -0,0 +1,17 @@
+{
+ "name": "Unity.Cloud.Gltfast.Documentation",
+ "rootNamespace": "",
+ "references": [
+ "glTFast",
+ "glTFast.Newtonsoft"
+ ],
+ "includePlatforms": [],
+ "excludePlatforms": [],
+ "allowUnsafeCode": false,
+ "overrideReferences": false,
+ "precompiledReferences": [],
+ "autoReferenced": true,
+ "defineConstraints": [],
+ "versionDefines": [],
+ "noEngineReferences": false
+}
\ No newline at end of file
diff --git a/Samples/Documentation/Unity.Cloud.Gltfast.Documentation.asmdef.meta b/Samples/Documentation/Unity.Cloud.Gltfast.Documentation.asmdef.meta
new file mode 100644
index 00000000..0bb8b661
--- /dev/null
+++ b/Samples/Documentation/Unity.Cloud.Gltfast.Documentation.asmdef.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 8f5c1be42eb774f4e8372825ac2e4d50
+AssemblyDefinitionImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
From 53a8ccefc3575127d4c592667607c1f8add1810f Mon Sep 17 00:00:00 2001
From: Andreas Atteneder
Date: Mon, 13 Nov 2023 20:33:53 +0100
Subject: [PATCH 06/14] doc: addon-api fixes (#74)
* chore: Auto-formatted code
* doc: Consistent case on glTF.
* doc: typo
---
Documentation~/UseCaseCustomExtras.md | 24 +--
.../Documentation/Manual/CustomGltfImport.cs | 157 +++++++++---------
Samples/Documentation/Manual/ExtraData.cs | 16 +-
3 files changed, 98 insertions(+), 99 deletions(-)
diff --git a/Documentation~/UseCaseCustomExtras.md b/Documentation~/UseCaseCustomExtras.md
index 68e7e563..22caef0d 100644
--- a/Documentation~/UseCaseCustomExtras.md
+++ b/Documentation~/UseCaseCustomExtras.md
@@ -1,14 +1,14 @@
# Use case: Use glTFast Add-on API
-This use case describes the step to use glTFast Add-on API to import custom data in the `extras` property of a glTF™ JSON object. This example uses Newtonsoft JSON parser to deserialize data.
+This use case describes the steps to use glTFast Add-on API to import custom data from the `extras` property of a glTF™ JSON object. This example uses Newtonsoft JSON parser to deserialize data.
To accomplish this use case, do the following:
-1. Add custom data in a gltf asset
-2. Create a custom gltf import behavior
+1. Add custom data in a glTF asset
+2. Create a custom glTF import behavior
3. Add assembly definitions
4. Set up a new scene
-5. Import the gltf asset in runtime
+5. Import the glTF asset in runtime
## Before you start
@@ -30,7 +30,7 @@ Before you start, you must add the following package dependencies to your projec
## How do I...?
-### Add custom data in a gltf asset
+### Add custom data in a glTF asset
Add some custom data in the `extras` property of a glTF JSON object:
@@ -49,9 +49,9 @@ Add some custom data in the `extras` property of a glTF JSON object:
]
```
-### Create a custom gltf import behavior
+### Create a custom glTF import behavior
-To create a custom gltf import behavior, follow these steps:
+To create a custom glTF import behavior, follow these steps:
1. Open your Unity® Project.
2. Go to the **Assets** folder in the Project window.
@@ -85,14 +85,14 @@ To set up a new scene, follow these steps:
1. Create a new scene.
2. Create a GameObject called **GltfImport**.
3. Select **Add Component** in the Inspector window and add the **Custom Gltf Import** component.
-4. In the **Uri** field, set the path to point to where the gltf asset is stored.
+4. In the **Uri** field, set the path to point to where the glTF asset is stored.
-### Import the gltf asset in runtime
+### Import the glTF asset in runtime
-Select **Play**, the gltf asset should be loaded and displayed at runtime.
+Select **Play**, the glTF asset should be loaded and displayed at runtime.
-You can verify that the custom data in the `extras` property of the glTF is imported correctly by inspecting the loaded gltf asset:
-![Screen capture that displays the extra data in the imported gltf asset](Images/gltf-extra-data.PNG)
+You can verify that the custom data in the `extras` property of the glTF is imported correctly by inspecting the loaded glTF asset:
+![Screen capture that displays the extra data in the imported glTF asset](Images/gltf-extra-data.PNG)
## Trademarks
diff --git a/Samples/Documentation/Manual/CustomGltfImport.cs b/Samples/Documentation/Manual/CustomGltfImport.cs
index b6586350..ea617af1 100644
--- a/Samples/Documentation/Manual/CustomGltfImport.cs
+++ b/Samples/Documentation/Manual/CustomGltfImport.cs
@@ -1,102 +1,101 @@
namespace Samples.Documentation.Manual
{
-#region CustomGltfImport
-using GLTFast;
-using GLTFast.Addons;
-using System;
-using System.Threading.Tasks;
-using UnityEngine;
-using GltfImport = GLTFast.Newtonsoft.GltfImport;
-
-public class CustomGltfImport : MonoBehaviour
-{
- // Path to the gltf asset to be imported
- public string Uri;
+ #region CustomGltfImport
+ using GLTFast;
+ using GLTFast.Addons;
+ using System;
+ using System.Threading.Tasks;
+ using UnityEngine;
+ using GltfImport = GLTFast.Newtonsoft.GltfImport;
- async Task Start()
+ public class CustomGltfImport : MonoBehaviour
{
- try
+ // Path to the gltf asset to be imported
+ public string Uri;
+
+ async Task Start()
{
- ImportAddonRegistry.RegisterImportAddon(new MyAddon());
- var gltfImport = new GltfImport();
- await gltfImport.Load(Uri);
- await gltfImport.InstantiateMainSceneAsync(transform);
+ try
+ {
+ ImportAddonRegistry.RegisterImportAddon(new MyAddon());
+ var gltfImport = new GltfImport();
+ await gltfImport.Load(Uri);
+ await gltfImport.InstantiateMainSceneAsync(transform);
+ }
+ catch (Exception e)
+ {
+ Debug.LogException(e);
+ }
}
- catch (Exception e)
+
+ public class MyAddon : ImportAddon { }
+ public class MyAddonInstance : ImportAddonInstance
{
- Debug.LogException(e);
+ GltfImport m_GltfImport;
+
+ public override void Dispose() { }
+
+ public override void Inject(GltfImportBase gltfImport)
+ {
+ var newtonsoftGltfImport = gltfImport as GltfImport;
+ if (newtonsoftGltfImport == null)
+ return;
+
+ m_GltfImport = newtonsoftGltfImport;
+ newtonsoftGltfImport.AddImportAddonInstance(this);
+ }
+
+ public override void Inject(IInstantiator instantiator)
+ {
+ var goInstantiator = instantiator as GameObjectInstantiator;
+ if (goInstantiator == null)
+ return;
+ var _ = new MyInstantiatorAddon(m_GltfImport, goInstantiator);
+ }
+
+ public override bool SupportsGltfExtension(string extensionName)
+ {
+ return false;
+ }
}
}
-
- public class MyAddon : ImportAddon { }
- public class MyAddonInstance : ImportAddonInstance
+
+ public class MyInstantiatorAddon
{
GltfImport m_GltfImport;
-
- public override void Dispose() { }
-
- public override void Inject(GltfImportBase gltfImport)
- {
- var newtonsoftGltfImport = gltfImport as GltfImport;
- if (newtonsoftGltfImport == null)
- return;
-
- m_GltfImport = newtonsoftGltfImport;
- newtonsoftGltfImport.AddImportAddonInstance(this);
- }
-
- public override void Inject(IInstantiator instantiator)
- {
- var goInstantiator = instantiator as GameObjectInstantiator;
- if (goInstantiator == null)
- return;
- var _ = new MyInstantiatorAddon(m_GltfImport, goInstantiator);
- }
-
- public override bool SupportsGltfExtension(string extensionName)
+ GameObjectInstantiator m_Instantiator;
+
+ public MyInstantiatorAddon(GltfImport gltfImport, GameObjectInstantiator instantiator)
{
- return false;
+ m_GltfImport = gltfImport;
+ m_Instantiator = instantiator;
+ m_Instantiator.NodeCreated += OnNodeCreated;
+ m_Instantiator.EndSceneCompleted += () =>
+ {
+ m_Instantiator.NodeCreated -= OnNodeCreated;
+ };
}
- }
-}
-public class MyInstantiatorAddon
-{
- GltfImport m_GltfImport;
- GameObjectInstantiator m_Instantiator;
-
- public MyInstantiatorAddon(GltfImport gltfImport, GameObjectInstantiator instantiator)
- {
- m_GltfImport = gltfImport;
- m_Instantiator = instantiator;
- m_Instantiator.NodeCreated += OnNodeCreated;
- m_Instantiator.EndSceneCompleted += () =>
+ void OnNodeCreated(uint nodeIndex, GameObject gameObject)
{
- m_Instantiator.NodeCreated -= OnNodeCreated;
- };
- }
+ // De-serialize glTF JSON
+ var gltf = m_GltfImport.GetSourceRoot();
- void OnNodeCreated(uint nodeIndex, GameObject gameObject)
- {
- // De-serialize glTF JSON
- var gltf = m_GltfImport.GetSourceRoot();
+ var node = gltf.Nodes[(int)nodeIndex] as GLTFast.Newtonsoft.Schema.Node;
+ var extras = node.extras;
- var node = gltf.Nodes[(int)nodeIndex] as GLTFast.Newtonsoft.Schema.Node;
- var extras = node.extras;
-
- if (extras == null)
- return;
+ if (extras == null)
+ return;
- // Access values in the extras property
- if (extras.TryGetValue("some-extra-key", out string extraValue))
- {
- var component = gameObject.AddComponent();
- component.someExtraKey = extraValue;
+ // Access values in the extras property
+ if (extras.TryGetValue("some-extra-key", out string extraValue))
+ {
+ var component = gameObject.AddComponent();
+ component.someExtraKey = extraValue;
+ }
}
}
-}
-#endregion
+ #endregion
}
-
diff --git a/Samples/Documentation/Manual/ExtraData.cs b/Samples/Documentation/Manual/ExtraData.cs
index 993efcd5..43028ddd 100644
--- a/Samples/Documentation/Manual/ExtraData.cs
+++ b/Samples/Documentation/Manual/ExtraData.cs
@@ -1,13 +1,13 @@
namespace Samples.Documentation.Manual
{
-#region ExtraData
-using UnityEngine;
+ #region ExtraData
+ using UnityEngine;
-public class ExtraData : MonoBehaviour
-{
- public string someExtraKey;
-}
+ public class ExtraData : MonoBehaviour
+ {
+ public string someExtraKey;
+ }
-#endregion
-}
\ No newline at end of file
+ #endregion
+}
From aa47a027e696d26a98ccc4926de0395b6048e52d Mon Sep 17 00:00:00 2001
From: Andreas Atteneder
Date: Thu, 16 Nov 2023 13:35:11 +0100
Subject: [PATCH 07/14] fix: Made code compatible with 2020 LTS. (#75)
---
CHANGELOG.md | 1 +
Runtime/Scripts/Export/GltfWriter.cs | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cd9640c7..8a1b5d00 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Compilation error when Animation module is disabled and Newtonsoft JSON package installed.
+- Compilation on Unity 2020 LTS
## [6.0.0] - 2023-10-04
diff --git a/Runtime/Scripts/Export/GltfWriter.cs b/Runtime/Scripts/Export/GltfWriter.cs
index d85e3a35..77c741e7 100644
--- a/Runtime/Scripts/Export/GltfWriter.cs
+++ b/Runtime/Scripts/Export/GltfWriter.cs
@@ -1314,8 +1314,10 @@ async Task BakeMeshDraco(int meshId, UnityEngine.Mesh.MeshData meshData)
var attributes = new Attributes();
var dracoAttributes = new Attributes();
- foreach (var (vertexAttribute, attribute) in encodeResult.vertexAttributes)
+ foreach ( var vertexAttributeTuple in encodeResult.vertexAttributes)
{
+ var vertexAttribute = vertexAttributeTuple.Key;
+ var attribute = vertexAttributeTuple.Value;
var accessor = new Accessor {
componentType = GltfComponentType.Float,
count = (int)encodeResult.vertexCount
From 2415b300aad52700284a348270d979f8750353aa Mon Sep 17 00:00:00 2001
From: Andreas Atteneder
Date: Thu, 16 Nov 2023 13:35:23 +0100
Subject: [PATCH 08/14] chore: Auto-formatted all markdown, USS, UXML and
shader code (#76)
---
CHANGELOG.md | 5 +-
Documentation~/ExportRuntime.md | 6 +-
Documentation~/ImportRuntime.md | 14 +-
Documentation~/UpgradeGuides.md | 2 +-
Documentation~/UseCaseCustomExtras.md | 2 +-
Editor/UI/Dependency-style.uss | 16 +--
Editor/UI/Dependency.uxml | 14 +-
Editor/UI/GltfImporter-style.uss | 84 ++++++------
Editor/UI/GltfImporter.uxml | 58 ++++-----
Editor/UI/ReportItem-style.uss | 62 ++++-----
Editor/UI/ReportItem.uxml | 14 +-
LICENSE.md | 2 +-
.../Shader/Built-In/glTFIncludes/glTF.cginc | 2 +-
.../glTFIncludes/glTFUnityStandardCore.cginc | 14 +-
.../glTFUnityStandardCoreForwardSimple.cginc | 6 +-
.../glTFIncludes/glTFUnityStandardMeta.cginc | 6 +-
.../Built-In/glTFPbrMetallicRoughness.shader | 6 +-
.../Built-In/glTFPbrSpecularGlossiness.shader | 2 +-
Runtime/Shader/Built-In/glTFUnlit.shader | 2 +-
Runtime/Shader/Export/glTFExportColor.shader | 94 +++++++-------
.../Shader/Export/glTFExportMaskMap.shader | 96 +++++++-------
.../Shader/Export/glTFExportMetalGloss.shader | 122 +++++++++---------
Runtime/Shader/Export/glTFExportNormal.shader | 108 ++++++++--------
.../Shader/Export/glTFExportOcclusion.shader | 92 ++++++-------
.../Shader/Export/glTFExportSmoothness.shader | 92 ++++++-------
Runtime/Shader/Includes/Emission.cginc | 2 +-
26 files changed, 462 insertions(+), 461 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8a1b5d00..184a41c4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Documentation improvements
+- Auto-formatted all markdown, USS, UXML and shader code
## [6.0.1] - 2023-10-11
@@ -500,7 +501,7 @@ This release contains multiple breaking changes. Please read the [upgrade guide]
## [4.3.4] - 2021-10-26
### Added
-- Option to turn off Editor import by adding `GLTFAST_EDITOR_IMPORT_OFF` to the project's *Scripting Define Symbols* in the *Player Settings* (#256)
+- Option to turn off Editor import by adding `GLTFAST_EDITOR_IMPORT_OFF` to the project's *Scripting Define Symbols* in the *Player Settings* (#256)
### Fixed
- Import of glTFs with no meshes (#257)
@@ -686,7 +687,7 @@ This release contains multiple breaking changes. Please read the [upgrade guide]
- Support for unsigned byte joint indices
### Changed
-- Accelerated loading meshes by obtaining and setting bounds from accessors min/max values instead of recalculating them
+- Accelerated loading meshes by obtaining and setting bounds from accessors min/max values instead of recalculating them
- Improved log message when DracoUnity/KtxUnity packages are missing
- Restored/simplified `GLTFast.LoadGltfBinary`, allowing users to load glTF binary files from byte arrays directly (also added documentation; fixes #148)
diff --git a/Documentation~/ExportRuntime.md b/Documentation~/ExportRuntime.md
index 442bf5ec..f767f208 100644
--- a/Documentation~/ExportRuntime.md
+++ b/Documentation~/ExportRuntime.md
@@ -35,7 +35,7 @@ public class TestExport : MonoBehaviour {
// Example of gathering GameObjects to be exported (recursively)
var rootLevelNodes = GameObject.FindGameObjectsWithTag("ExportMe");
-
+
// GameObjectExport lets you create glTFs from GameObject hierarchies
var export = new GameObjectExport();
@@ -76,14 +76,14 @@ public class TestExport : MonoBehaviour {
// ExportSettings and GameObjectExportSettings allow you to configure the export
// Check their respective source for details
-
+
// ExportSettings provides generic export settings
var exportSettings = new ExportSettings {
Format = GltfFormat.Binary,
FileConflictResolution = FileConflictResolution.Overwrite,
// Export everything except cameras or animation
ComponentMask = ~(ComponentType.Camera | ComponentType.Animation),
- // Boost light intensities
+ // Boost light intensities
LightIntensityFactor = 100f,
};
diff --git a/Documentation~/ImportRuntime.md b/Documentation~/ImportRuntime.md
index abb76ed9..b922ff84 100644
--- a/Documentation~/ImportRuntime.md
+++ b/Documentation~/ImportRuntime.md
@@ -27,7 +27,7 @@ async void LoadGltfBinaryFromMemory() {
byte[] data = File.ReadAllBytes(filePath);
var gltf = new GltfImport();
bool success = await gltf.LoadGltfBinary(
- data,
+ data,
// The URI of the original data is important for resolving relative URIs within the glTF
new Uri(filePath)
);
@@ -92,7 +92,7 @@ async void Start() {
if (success) {
// Here you can customize the post-loading behavior
-
+
// Get the first material
var material = gltf.GetMaterial();
Debug.LogFormat("The first material is called {0}", material.name);
@@ -186,7 +186,7 @@ async void Start()
var instantiator = new GameObjectInstantiator(gltfImport,transform);
var success = await gltfImport.InstantiateMainSceneAsync(instantiator);
if (success) {
-
+
// Get the SceneInstance to access the instance's properties
var sceneInstance = instantiator.SceneInstance;
@@ -194,14 +194,14 @@ async void Start()
if (sceneInstance.Cameras is { Count: > 0 }) {
sceneInstance.Cameras[0].enabled = true;
}
-
+
// Decrease lights' ranges
if (sceneInstance.Lights != null) {
foreach (var glTFLight in sceneInstance.Lights) {
glTFLight.range *= 0.1f;
}
}
-
+
// Play the default (i.e. the first) animation clip
var legacyAnimation = instantiator.SceneInstance.LegacyAnimation;
if (legacyAnimation != null) {
@@ -219,7 +219,7 @@ When loading a glTF file, *Unity glTFast* logs messages of varying severity (err
- Feed the information into an analytics framework
- Display details to the users
-The provided component `GltfAsset` logs all of those messages to the console by default.
+The provided component `GltfAsset` logs all of those messages to the console by default.
You can customize logging by providing an implementation of [`ICodeLogger`][ICodeLogger] to methods like `GltfImport.Load` or `GltfImport.InstantiateMainScene`.
@@ -258,7 +258,7 @@ async Task CustomDeferAgentPerGltfImport() {
deferAgent = new UninterruptedDeferAgent();
var tasks = new List();
-
+
foreach( var url in manyUrls) {
var gltf = new GLTFast.GltfImport(null,deferAgent);
var task = gltf.Load(url).ContinueWith(
diff --git a/Documentation~/UpgradeGuides.md b/Documentation~/UpgradeGuides.md
index 3314528e..27a18ce9 100644
--- a/Documentation~/UpgradeGuides.md
+++ b/Documentation~/UpgradeGuides.md
@@ -153,7 +153,7 @@ async void Start() {
var instantiator = new GameObjectInstantiator(gltfImport,transform);
var success = gltfImport.InstantiateMainScene(instantiator);
if (success) {
-
+
// Get the SceneInstance to access the instance's properties
var sceneInstance = instantiator.SceneInstance;
diff --git a/Documentation~/UseCaseCustomExtras.md b/Documentation~/UseCaseCustomExtras.md
index 22caef0d..23c53507 100644
--- a/Documentation~/UseCaseCustomExtras.md
+++ b/Documentation~/UseCaseCustomExtras.md
@@ -37,7 +37,7 @@ Add some custom data in the `extras` property of a glTF JSON object:
```json
"nodes": [
{
- // Example of mesh data in a glTF
+ // Example of mesh data in a glTF
"mesh": 0,
"name": "Cube",
diff --git a/Editor/UI/Dependency-style.uss b/Editor/UI/Dependency-style.uss
index a092bf04..cd3bed23 100644
--- a/Editor/UI/Dependency-style.uss
+++ b/Editor/UI/Dependency-style.uss
@@ -1,8 +1,8 @@
-.dependency {
- flex-direction: row;
- align-items: center;
-}
-
-.fix-button {
- margin-left: auto;
-}
+.dependency {
+ flex-direction: row;
+ align-items: center;
+}
+
+.fix-button {
+ margin-left: auto;
+}
diff --git a/Editor/UI/Dependency.uxml b/Editor/UI/Dependency.uxml
index fe270601..ddac9241 100644
--- a/Editor/UI/Dependency.uxml
+++ b/Editor/UI/Dependency.uxml
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/Editor/UI/GltfImporter-style.uss b/Editor/UI/GltfImporter-style.uss
index 125e7acf..2d607c6d 100644
--- a/Editor/UI/GltfImporter-style.uss
+++ b/Editor/UI/GltfImporter-style.uss
@@ -1,42 +1,42 @@
-.dependencies {
-}
-
-.header {
- margin-top: 5px;
- align-items: center;
- flex-direction: row;
-}
-
-.report {
- flex-grow: 1;
-}
-
-.report-list {
- flex-grow: 2;
- margin-top: 5px;
- min-height: 60px;
- background-color: rgb(32, 32, 32);
-}
-
-.icon {
- width: 24px;
- height: 24px;
- margin: 2px 4px;
-}
-
-.error {
- background-image: resource('Icons/d_console.erroricon.png');
-}
-
-.deps-foldout {
- margin-left: 15px;
-}
-
-.h1 {
- margin: 1px 3px 3px 3px;
- -unity-font-style: bold;
-}
-
-.section {
- margin-bottom: 10px;
-}
+.dependencies {
+}
+
+.header {
+ margin-top: 5px;
+ align-items: center;
+ flex-direction: row;
+}
+
+.report {
+ flex-grow: 1;
+}
+
+.report-list {
+ flex-grow: 2;
+ margin-top: 5px;
+ min-height: 60px;
+ background-color: rgb(32, 32, 32);
+}
+
+.icon {
+ width: 24px;
+ height: 24px;
+ margin: 2px 4px;
+}
+
+.error {
+ background-image: resource('Icons/d_console.erroricon.png');
+}
+
+.deps-foldout {
+ margin-left: 15px;
+}
+
+.h1 {
+ margin: 1px 3px 3px 3px;
+ -unity-font-style: bold;
+}
+
+.section {
+ margin-bottom: 10px;
+}
diff --git a/Editor/UI/GltfImporter.uxml b/Editor/UI/GltfImporter.uxml
index b30c33e3..3d31bcd3 100644
--- a/Editor/UI/GltfImporter.uxml
+++ b/Editor/UI/GltfImporter.uxml
@@ -1,29 +1,29 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Editor/UI/ReportItem-style.uss b/Editor/UI/ReportItem-style.uss
index dbec873b..fdee14e2 100644
--- a/Editor/UI/ReportItem-style.uss
+++ b/Editor/UI/ReportItem-style.uss
@@ -1,31 +1,31 @@
-.report-item {
- align-items: flex-start;
- flex-direction: row;
- min-width: 100px;
-}
-
-.report-message {
- flex-shrink: 1;
- flex-grow: 1;
- white-space: normal;
- padding-top: 2px;
-}
-
-.icon {
- width: 16px;
- height: 16px;
- margin: 2px 4px;
- flex-shrink: 0;
-}
-
-.warning {
- background-image: resource('Icons/d_console.warnicon.png');
-}
-
-.info {
- background-image: resource('Icons/d_console.infoicon.png');
-}
-
-.error {
- background-image: resource('Icons/d_console.erroricon.png');
-}
+.report-item {
+ align-items: flex-start;
+ flex-direction: row;
+ min-width: 100px;
+}
+
+.report-message {
+ flex-shrink: 1;
+ flex-grow: 1;
+ white-space: normal;
+ padding-top: 2px;
+}
+
+.icon {
+ width: 16px;
+ height: 16px;
+ margin: 2px 4px;
+ flex-shrink: 0;
+}
+
+.warning {
+ background-image: resource('Icons/d_console.warnicon.png');
+}
+
+.info {
+ background-image: resource('Icons/d_console.infoicon.png');
+}
+
+.error {
+ background-image: resource('Icons/d_console.erroricon.png');
+}
diff --git a/Editor/UI/ReportItem.uxml b/Editor/UI/ReportItem.uxml
index 3bde13c8..4abbf7a3 100644
--- a/Editor/UI/ReportItem.uxml
+++ b/Editor/UI/ReportItem.uxml
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/LICENSE.md b/LICENSE.md
index 43590124..7675e1c7 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -4,7 +4,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy
of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
diff --git a/Runtime/Shader/Built-In/glTFIncludes/glTF.cginc b/Runtime/Shader/Built-In/glTFIncludes/glTF.cginc
index e26763e4..f39ec838 100644
--- a/Runtime/Shader/Built-In/glTFIncludes/glTF.cginc
+++ b/Runtime/Shader/Built-In/glTFIncludes/glTF.cginc
@@ -37,4 +37,4 @@ void fragDeferredFacing (
);
}
-#endif // GLTF_INCLUDED
\ No newline at end of file
+#endif // GLTF_INCLUDED
diff --git a/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardCore.cginc b/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardCore.cginc
index 00c0187a..5ed84258 100644
--- a/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardCore.cginc
+++ b/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardCore.cginc
@@ -216,7 +216,7 @@ inline FragmentCommonData SpecularSetup (
#else
half4 specGloss = SpecularGloss(i_tex);
#endif
-
+
half3 specColor = specGloss.rgb;
half smoothness = specGloss.a;
@@ -425,7 +425,7 @@ struct VertexOutputForwardBase
#ifdef _EMISSION
float2 texEmission : TEXCOORD10;
#endif
-
+
half4 color : COLOR;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
@@ -461,7 +461,7 @@ VertexOutputForwardBase vertForwardBase (VertexInput v)
#ifdef _METALLICGLOSSMAP
o.texORM.zw = TexCoordsSingle((metallicRoughnessTexture_texCoord==0)?v.uv0:v.uv1,metallicRoughnessTexture);
#elif defined(_SPECGLOSSMAP)
- o.texORM.zw = TexCoordsSingle((specularGlossinessTexture_texCoord==0)?v.uv0:v.uv1,specularGlossinessTexture);
+ o.texORM.zw = TexCoordsSingle((specularGlossinessTexture_texCoord==0)?v.uv0:v.uv1,specularGlossinessTexture);
#endif
#ifdef _EMISSION
o.texEmission = TexCoordsSingle((emissiveTexture_texCoord==0)?v.uv0:v.uv1,emissiveTexture);
@@ -518,7 +518,7 @@ half4 fragForwardBaseInternal (VertexOutputForwardBase i)
UnityLight mainLight = MainLight ();
UNITY_LIGHT_ATTENUATION(atten, i, s.posWorld);
- half occlusion =
+ half occlusion =
#ifdef _OCCLUSION
Occlusion(i.texORM.xy);
#else
@@ -566,7 +566,7 @@ struct VertexOutputForwardAdd
#ifdef _EMISSION
float2 texEmission : TEXCOORD10;
#endif
-
+
half4 color : COLOR;
UNITY_VERTEX_OUTPUT_STEREO
@@ -592,7 +592,7 @@ VertexOutputForwardAdd vertForwardAdd (VertexInput v)
#ifdef _METALLICGLOSSMAP
o.texORM.zw = TexCoordsSingle((metallicRoughnessTexture_texCoord==0)?v.uv0:v.uv1,metallicRoughnessTexture);
#elif defined(_SPECGLOSSMAP)
- o.texORM.zw = TexCoordsSingle((specularGlossinessTexture_texCoord==0)?v.uv0:v.uv1,specularGlossinessTexture);
+ o.texORM.zw = TexCoordsSingle((specularGlossinessTexture_texCoord==0)?v.uv0:v.uv1,specularGlossinessTexture);
#endif
#ifdef _EMISSION
o.texEmission = TexCoordsSingle((emissiveTexture_texCoord==0)?v.uv0:v.uv1,emissiveTexture);
@@ -713,7 +713,7 @@ VertexOutputDeferred vertDeferred (VertexInput v)
#endif
o.pos = UnityObjectToClipPos(v.vertex);
-
+
o.tex.xy = TexCoordsSingle((baseColorTexture_texCoord==0)?v.uv0:v.uv1,baseColorTexture);
#ifdef _NORMALMAP
o.tex.zw = TexCoordsSingle((normalTexture_texCoord==0)?v.uv0:v.uv1,normalTexture);
diff --git a/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardCoreForwardSimple.cginc b/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardCoreForwardSimple.cginc
index 096ded18..75673eb7 100644
--- a/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardCoreForwardSimple.cginc
+++ b/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardCoreForwardSimple.cginc
@@ -150,13 +150,13 @@ FragmentCommonData FragmentSetupSimple(VertexOutputBaseSimple i)
clip (alpha - alphaCutoff);
#endif
-
+
#if defined(_METALLICGLOSSMAP) || defined(_SPECGLOSSMAP)
FragmentCommonData s = UNITY_SETUP_BRDF_INPUT (i.tex,i.texORM.zw,i.color);
#else
FragmentCommonData s = UNITY_SETUP_BRDF_INPUT (i.tex,i.color);
#endif
-
+
// NOTE: shader relies on pre-multiply alpha-blend (_SrcBlend = One, _DstBlend = OneMinusSrcAlpha)
s.diffColor = PreMultiplyAlpha (s.diffColor, alpha, s.oneMinusReflectivity, /*out*/ s.alpha);
@@ -352,7 +352,7 @@ FragmentCommonData FragmentSetupSimpleAdd(VertexOutputForwardAddSimple i)
#if defined(_ALPHATEST_ON)
clip (alpha - alphaCutoff);
#endif
-
+
#if defined(_METALLICGLOSSMAP) || defined(_SPECGLOSSMAP)
FragmentCommonData s = UNITY_SETUP_BRDF_INPUT (i.tex,i.texORM.zw,i.color);
#else
diff --git a/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardMeta.cginc b/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardMeta.cginc
index f2384377..e7a51e44 100644
--- a/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardMeta.cginc
+++ b/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardMeta.cginc
@@ -43,7 +43,7 @@ v2f_meta vert_meta (VertexInput v)
#else
o.uv.zw = float2(0,0);
#endif
-
+
#ifdef EDITOR_VISUALIZATION
o.vizUV = 0;
o.lightCoord = 0;
@@ -73,14 +73,14 @@ float4 frag_meta (v2f_meta i) : SV_Target
{
// we're interested in diffuse & specular colors,
// and surface roughness to produce final albedo.
-
+
#ifdef _METALLICGLOSSMAP
FragmentCommonData data = UNITY_SETUP_BRDF_INPUT (i.uv,i.uv,i.color);
#else
FragmentCommonData data = UNITY_SETUP_BRDF_INPUT (i.uv,i.color);
#endif
-
+
UnityMetaInput o;
UNITY_INITIALIZE_OUTPUT(UnityMetaInput, o);
diff --git a/Runtime/Shader/Built-In/glTFPbrMetallicRoughness.shader b/Runtime/Shader/Built-In/glTFPbrMetallicRoughness.shader
index efb7b3c7..55051b20 100644
--- a/Runtime/Shader/Built-In/glTFPbrMetallicRoughness.shader
+++ b/Runtime/Shader/Built-In/glTFPbrMetallicRoughness.shader
@@ -11,7 +11,7 @@ Shader "glTF/PbrMetallicRoughness"
[MainTexture] baseColorTexture("Base Color Tex", 2D) = "white" {}
baseColorTexture_Rotation ("Base Color Tex Rotation", Vector) = (0,0,0,0)
[Enum(UV0,0,UV1,1)] baseColorTexture_texCoord ("Base Color Tex UV", Float) = 0
-
+
alphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
roughnessFactor("Roughness", Range(0.0, 1.0)) = 1
@@ -38,12 +38,12 @@ Shader "glTF/PbrMetallicRoughness"
occlusionTexture("Occlusion Tex", 2D) = "white" {}
occlusionTexture_Rotation ("Occlusion Tex Rotation", Vector) = (0,0,0,0)
[Enum(UV0,0,UV1,1)] occlusionTexture_texCoord ("Occlusion Tex UV", Float) = 0
-
+
[HDR] emissiveFactor("Emissive", Color) = (0,0,0)
emissiveTexture("Emission Tex", 2D) = "white" {}
emissiveTexture_Rotation ("Emission Tex Rotation", Vector) = (0,0,0,0)
[Enum(UV0,0,UV1,1)] emissiveTexture_texCoord ("Emission Tex UV", Float) = 0
-
+
// _DetailMask("Detail Mask", 2D) = "white" {}
// _DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}
diff --git a/Runtime/Shader/Built-In/glTFPbrSpecularGlossiness.shader b/Runtime/Shader/Built-In/glTFPbrSpecularGlossiness.shader
index 2307c735..35550663 100644
--- a/Runtime/Shader/Built-In/glTFPbrSpecularGlossiness.shader
+++ b/Runtime/Shader/Built-In/glTFPbrSpecularGlossiness.shader
@@ -42,7 +42,7 @@ Shader "glTF/PbrSpecularGlossiness"
emissiveTexture("Emissive Tex", 2D) = "white" {}
emissiveTexture_Rotation ("Emissive Tex Rotation", Vector) = (0,0,0,0)
[Enum(UV0,0,UV1,1)] emissiveTexture_texCoord ("Emissive Tex UV", Float) = 0
-
+
// _DetailMask("Detail Mask", 2D) = "white" {}
// _DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}
diff --git a/Runtime/Shader/Built-In/glTFUnlit.shader b/Runtime/Shader/Built-In/glTFUnlit.shader
index cc937eba..2c766baf 100644
--- a/Runtime/Shader/Built-In/glTFUnlit.shader
+++ b/Runtime/Shader/Built-In/glTFUnlit.shader
@@ -26,7 +26,7 @@ SubShader {
LOD 100
Pass {
-
+
Blend [_SrcBlend] [_DstBlend]
ZWrite [_ZWrite]
Cull [_CullMode]
diff --git a/Runtime/Shader/Export/glTFExportColor.shader b/Runtime/Shader/Export/glTFExportColor.shader
index 555bbdb2..19d4b8e0 100644
--- a/Runtime/Shader/Export/glTFExportColor.shader
+++ b/Runtime/Shader/Export/glTFExportColor.shader
@@ -1,54 +1,54 @@
-Shader "Hidden/glTFExportColor"
+Shader "Hidden/glTFExportColor"
{
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- }
- SubShader
- {
- // No culling or depth
- Cull Off ZWrite Off ZTest Always
+ Properties
+ {
+ _MainTex ("Texture", 2D) = "white" {}
+ }
+ SubShader
+ {
+ // No culling or depth
+ Cull Off ZWrite Off ZTest Always
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
-
- #include "UnityCG.cginc"
+ Pass
+ {
+ CGPROGRAM
+ #pragma vertex vert
+ #pragma fragment frag
- struct appdata
- {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- };
+ #include "UnityCG.cginc"
- struct v2f
- {
- float2 uv : TEXCOORD0;
- float4 vertex : SV_POSITION;
- };
+ struct appdata
+ {
+ float4 vertex : POSITION;
+ float2 uv : TEXCOORD0;
+ };
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.uv = v.uv;
- return o;
- }
-
- sampler2D _MainTex;
+ struct v2f
+ {
+ float2 uv : TEXCOORD0;
+ float4 vertex : SV_POSITION;
+ };
- float4 frag (v2f i) : SV_Target
- {
- float4 col = tex2D(_MainTex, i.uv);
- #ifdef UNITY_COLORSPACE_GAMMA
- #else
- col.xyz = LinearToGammaSpace(col.xyz);
- #endif
- return col;
- }
- ENDCG
- }
- }
+ v2f vert (appdata v)
+ {
+ v2f o;
+ o.vertex = UnityObjectToClipPos(v.vertex);
+ o.uv = v.uv;
+ return o;
+ }
+
+ sampler2D _MainTex;
+
+ float4 frag (v2f i) : SV_Target
+ {
+ float4 col = tex2D(_MainTex, i.uv);
+ #ifdef UNITY_COLORSPACE_GAMMA
+ #else
+ col.xyz = LinearToGammaSpace(col.xyz);
+ #endif
+ return col;
+ }
+ ENDCG
+ }
+ }
}
diff --git a/Runtime/Shader/Export/glTFExportMaskMap.shader b/Runtime/Shader/Export/glTFExportMaskMap.shader
index 9f930f12..27a2bf4c 100644
--- a/Runtime/Shader/Export/glTFExportMaskMap.shader
+++ b/Runtime/Shader/Export/glTFExportMaskMap.shader
@@ -1,55 +1,55 @@
-Shader "Hidden/glTFExportMaskMap"
+Shader "Hidden/glTFExportMaskMap"
{
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- }
- SubShader
- {
- // No culling or depth
- Cull Off ZWrite Off ZTest Always
+ Properties
+ {
+ _MainTex ("Texture", 2D) = "white" {}
+ }
+ SubShader
+ {
+ // No culling or depth
+ Cull Off ZWrite Off ZTest Always
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
-
- #include "UnityCG.cginc"
+ Pass
+ {
+ CGPROGRAM
+ #pragma vertex vert
+ #pragma fragment frag
- struct appdata
- {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- };
+ #include "UnityCG.cginc"
- struct v2f
- {
- float2 uv : TEXCOORD0;
- float4 vertex : SV_POSITION;
- };
+ struct appdata
+ {
+ float4 vertex : POSITION;
+ float2 uv : TEXCOORD0;
+ };
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.uv = v.uv;
- return o;
- }
-
- sampler2D _MainTex;
+ struct v2f
+ {
+ float2 uv : TEXCOORD0;
+ float4 vertex : SV_POSITION;
+ };
- float4 frag (v2f i) : SV_Target
- {
- float4 col = tex2D(_MainTex, i.uv);
- float4 result = float4(col.g, 1 - col.a, col.r, 1);
- #ifdef UNITY_COLORSPACE_GAMMA
- #else
- result.xyz = GammaToLinearSpace(result.xyz);
- #endif
- return result;
- }
- ENDCG
- }
- }
+ v2f vert (appdata v)
+ {
+ v2f o;
+ o.vertex = UnityObjectToClipPos(v.vertex);
+ o.uv = v.uv;
+ return o;
+ }
+
+ sampler2D _MainTex;
+
+ float4 frag (v2f i) : SV_Target
+ {
+ float4 col = tex2D(_MainTex, i.uv);
+ float4 result = float4(col.g, 1 - col.a, col.r, 1);
+ #ifdef UNITY_COLORSPACE_GAMMA
+ #else
+ result.xyz = GammaToLinearSpace(result.xyz);
+ #endif
+ return result;
+ }
+ ENDCG
+ }
+ }
}
diff --git a/Runtime/Shader/Export/glTFExportMetalGloss.shader b/Runtime/Shader/Export/glTFExportMetalGloss.shader
index ca8998bb..0a146bc8 100644
--- a/Runtime/Shader/Export/glTFExportMetalGloss.shader
+++ b/Runtime/Shader/Export/glTFExportMetalGloss.shader
@@ -1,68 +1,68 @@
-Shader "Hidden/glTFExportMetalGloss"
+Shader "Hidden/glTFExportMetalGloss"
{
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- }
- SubShader
- {
- // No culling or depth
- Cull Off ZWrite Off ZTest Always
+ Properties
+ {
+ _MainTex ("Texture", 2D) = "white" {}
+ }
+ SubShader
+ {
+ // No culling or depth
+ Cull Off ZWrite Off ZTest Always
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
-
- #include "UnityCG.cginc"
+ Pass
+ {
+ CGPROGRAM
+ #pragma vertex vert
+ #pragma fragment frag
- struct appdata
- {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- };
+ #include "UnityCG.cginc"
- struct v2f
- {
- float2 uv : TEXCOORD0;
- float4 vertex : SV_POSITION;
- };
+ struct appdata
+ {
+ float4 vertex : POSITION;
+ float2 uv : TEXCOORD0;
+ };
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.uv = v.uv;
- return o;
- }
-
- sampler2D _MainTex;
+ struct v2f
+ {
+ float2 uv : TEXCOORD0;
+ float4 vertex : SV_POSITION;
+ };
- float4 frag (v2f i) : SV_Target
- {
- float4 col = tex2D(_MainTex, i.uv);
- // From the GLTF 2.0 spec
- // The metallic-roughness texture. The metalness values are sampled from the B channel.
- // The roughness values are sampled from the G channel. These values are linear.
- // If other channels are present (R or A), they are ignored for metallic-roughness calculations.
- //
- // Unity, by default, puts metallic in R channel and glossiness in A channel.
- // Unity uses a metallic-gloss texture so we need to invert the value in the g channel.
- //
- // Conversion Summary
- // Unity R channel goes into B channel
- // Unity A channel goes into G channel, then inverted
- float4 result = float4(1, 1 - col.a, col.r, 1);
- #ifdef UNITY_COLORSPACE_GAMMA
- #else
- // hack for linear color space, need to figure out
- // right way to sample textures.
- result.xyz = GammaToLinearSpace(result.xyz);
- #endif
- return result;
- }
- ENDCG
- }
- }
+ v2f vert (appdata v)
+ {
+ v2f o;
+ o.vertex = UnityObjectToClipPos(v.vertex);
+ o.uv = v.uv;
+ return o;
+ }
+
+ sampler2D _MainTex;
+
+ float4 frag (v2f i) : SV_Target
+ {
+ float4 col = tex2D(_MainTex, i.uv);
+ // From the GLTF 2.0 spec
+ // The metallic-roughness texture. The metalness values are sampled from the B channel.
+ // The roughness values are sampled from the G channel. These values are linear.
+ // If other channels are present (R or A), they are ignored for metallic-roughness calculations.
+ //
+ // Unity, by default, puts metallic in R channel and glossiness in A channel.
+ // Unity uses a metallic-gloss texture so we need to invert the value in the g channel.
+ //
+ // Conversion Summary
+ // Unity R channel goes into B channel
+ // Unity A channel goes into G channel, then inverted
+ float4 result = float4(1, 1 - col.a, col.r, 1);
+ #ifdef UNITY_COLORSPACE_GAMMA
+ #else
+ // hack for linear color space, need to figure out
+ // right way to sample textures.
+ result.xyz = GammaToLinearSpace(result.xyz);
+ #endif
+ return result;
+ }
+ ENDCG
+ }
+ }
}
diff --git a/Runtime/Shader/Export/glTFExportNormal.shader b/Runtime/Shader/Export/glTFExportNormal.shader
index ceea10e8..b4ae2951 100644
--- a/Runtime/Shader/Export/glTFExportNormal.shader
+++ b/Runtime/Shader/Export/glTFExportNormal.shader
@@ -1,56 +1,56 @@
-Shader "Hidden/glTFExportNormal"
+Shader "Hidden/glTFExportNormal"
{
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- }
- SubShader
- {
- // No culling or depth
- Cull Off ZWrite Off ZTest Always
-
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
-
- #include "UnityCG.cginc"
-
- struct appdata
- {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- };
-
- struct v2f
- {
- float2 uv : TEXCOORD0;
- float4 vertex : SV_POSITION;
- };
-
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.uv = v.uv;
- return o;
- }
-
- sampler2D _MainTex;
-
- float4 frag (v2f i) : SV_Target
- {
- float4 col = tex2D(_MainTex, i.uv);
- // If a texture is marked as a normal map
- // the values are stored in the A and G channel.
- float3 unpacked = UnpackNormal(col);
- // unpacked.xyz = LinearToGammaSpace(unpacked.xyz);
- float4 result = float4(unpacked * 0.5f + 0.5f, 1);
- return result;
- }
-
- ENDCG
- }
- }
+ Properties
+ {
+ _MainTex ("Texture", 2D) = "white" {}
+ }
+ SubShader
+ {
+ // No culling or depth
+ Cull Off ZWrite Off ZTest Always
+
+ Pass
+ {
+ CGPROGRAM
+ #pragma vertex vert
+ #pragma fragment frag
+
+ #include "UnityCG.cginc"
+
+ struct appdata
+ {
+ float4 vertex : POSITION;
+ float2 uv : TEXCOORD0;
+ };
+
+ struct v2f
+ {
+ float2 uv : TEXCOORD0;
+ float4 vertex : SV_POSITION;
+ };
+
+ v2f vert (appdata v)
+ {
+ v2f o;
+ o.vertex = UnityObjectToClipPos(v.vertex);
+ o.uv = v.uv;
+ return o;
+ }
+
+ sampler2D _MainTex;
+
+ float4 frag (v2f i) : SV_Target
+ {
+ float4 col = tex2D(_MainTex, i.uv);
+ // If a texture is marked as a normal map
+ // the values are stored in the A and G channel.
+ float3 unpacked = UnpackNormal(col);
+ // unpacked.xyz = LinearToGammaSpace(unpacked.xyz);
+ float4 result = float4(unpacked * 0.5f + 0.5f, 1);
+ return result;
+ }
+
+ ENDCG
+ }
+ }
}
diff --git a/Runtime/Shader/Export/glTFExportOcclusion.shader b/Runtime/Shader/Export/glTFExportOcclusion.shader
index c0663d0f..d7524ba7 100644
--- a/Runtime/Shader/Export/glTFExportOcclusion.shader
+++ b/Runtime/Shader/Export/glTFExportOcclusion.shader
@@ -1,52 +1,52 @@
-Shader "Hidden/glTFExportOcclusion"
+Shader "Hidden/glTFExportOcclusion"
{
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- }
- SubShader
- {
- // No culling or depth
- Cull Off ZWrite Off ZTest Always
- ColorMask R
-
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
-
- #include "UnityCG.cginc"
+ Properties
+ {
+ _MainTex ("Texture", 2D) = "white" {}
+ }
+ SubShader
+ {
+ // No culling or depth
+ Cull Off ZWrite Off ZTest Always
+ ColorMask R
- struct appdata
- {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- };
+ Pass
+ {
+ CGPROGRAM
+ #pragma vertex vert
+ #pragma fragment frag
- struct v2f
- {
- float2 uv : TEXCOORD0;
- float4 vertex : SV_POSITION;
- };
+ #include "UnityCG.cginc"
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.uv = v.uv;
- return o;
- }
-
- sampler2D _MainTex;
+ struct appdata
+ {
+ float4 vertex : POSITION;
+ float2 uv : TEXCOORD0;
+ };
- float4 frag (v2f i) : SV_Target
- {
- float4 col = tex2D(_MainTex, i.uv);
- float4 result = float4(col.g,0,0,0);
- return result;
- }
- ENDCG
- }
- }
+ struct v2f
+ {
+ float2 uv : TEXCOORD0;
+ float4 vertex : SV_POSITION;
+ };
+
+ v2f vert (appdata v)
+ {
+ v2f o;
+ o.vertex = UnityObjectToClipPos(v.vertex);
+ o.uv = v.uv;
+ return o;
+ }
+
+ sampler2D _MainTex;
+
+ float4 frag (v2f i) : SV_Target
+ {
+ float4 col = tex2D(_MainTex, i.uv);
+ float4 result = float4(col.g,0,0,0);
+ return result;
+ }
+ ENDCG
+ }
+ }
}
diff --git a/Runtime/Shader/Export/glTFExportSmoothness.shader b/Runtime/Shader/Export/glTFExportSmoothness.shader
index 8e936252..ae76f943 100644
--- a/Runtime/Shader/Export/glTFExportSmoothness.shader
+++ b/Runtime/Shader/Export/glTFExportSmoothness.shader
@@ -1,52 +1,52 @@
-Shader "Hidden/glTFExportSmoothness"
+Shader "Hidden/glTFExportSmoothness"
{
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- }
- SubShader
- {
- // No culling or depth
- Cull Off ZWrite Off ZTest Always
- ColorMask G
-
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
-
- #include "UnityCG.cginc"
+ Properties
+ {
+ _MainTex ("Texture", 2D) = "white" {}
+ }
+ SubShader
+ {
+ // No culling or depth
+ Cull Off ZWrite Off ZTest Always
+ ColorMask G
- struct appdata
- {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- };
+ Pass
+ {
+ CGPROGRAM
+ #pragma vertex vert
+ #pragma fragment frag
- struct v2f
- {
- float2 uv : TEXCOORD0;
- float4 vertex : SV_POSITION;
- };
+ #include "UnityCG.cginc"
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.uv = v.uv;
- return o;
- }
-
- sampler2D _MainTex;
+ struct appdata
+ {
+ float4 vertex : POSITION;
+ float2 uv : TEXCOORD0;
+ };
- float4 frag (v2f i) : SV_Target
- {
- float4 col = tex2D(_MainTex, i.uv);
- float4 result = float4(1,1-col.a,1,1);
- return result;
- }
- ENDCG
- }
- }
+ struct v2f
+ {
+ float2 uv : TEXCOORD0;
+ float4 vertex : SV_POSITION;
+ };
+
+ v2f vert (appdata v)
+ {
+ v2f o;
+ o.vertex = UnityObjectToClipPos(v.vertex);
+ o.uv = v.uv;
+ return o;
+ }
+
+ sampler2D _MainTex;
+
+ float4 frag (v2f i) : SV_Target
+ {
+ float4 col = tex2D(_MainTex, i.uv);
+ float4 result = float4(1,1-col.a,1,1);
+ return result;
+ }
+ ENDCG
+ }
+ }
}
diff --git a/Runtime/Shader/Includes/Emission.cginc b/Runtime/Shader/Includes/Emission.cginc
index a0a2ac9c..8fbf5b3d 100644
--- a/Runtime/Shader/Includes/Emission.cginc
+++ b/Runtime/Shader/Includes/Emission.cginc
@@ -20,4 +20,4 @@ void glTFast_HDRP_GetEmissionHDRColor_float(float3 Color, float ExposureWeight,
Output = hdrColor;
}
-#endif
\ No newline at end of file
+#endif
From 9b7910316b1655b51c661749e0cab8d42d35e885 Mon Sep 17 00:00:00 2001
From: Andreas Atteneder
Date: Thu, 16 Nov 2023 15:11:23 +0100
Subject: [PATCH 09/14] chore: Support for Draco 3D Data Compression is now
provided by *Draco for Unity* (com.unity.cloud.draco), which is a fork of and
replaces *DracoUnity* (com.atteneder.draco). (#77)
* doc: Updated documentation regarding switching to Draco for Unity.
note: The links are projected and not life yet.
---
CHANGELOG.md | 2 ++
Documentation~/ExportRuntime.md | 4 ++--
Documentation~/UpgradeGuides.md | 2 +-
Documentation~/features.md | 4 ++--
Documentation~/installation.md | 4 ++--
Runtime/Scripts/Export/GltfWriter.cs | 2 +-
Runtime/Scripts/Export/glTFast.Export.asmdef | 4 ++--
Runtime/Scripts/glTFast.asmdef | 6 +++---
8 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 184a41c4..ef5ae866 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- (Documentation) Explanation and user case for the add-on API
### 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].
- Documentation improvements
- Auto-formatted all markdown, USS, UXML and shader code
@@ -1057,6 +1058,7 @@ This release contains multiple breaking changes. Please read the [upgrade guide]
[Entities1.0]: https://docs.unity3d.com/Packages/com.unity.entities@1.0
[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
diff --git a/Documentation~/ExportRuntime.md b/Documentation~/ExportRuntime.md
index f767f208..057b582e 100644
--- a/Documentation~/ExportRuntime.md
+++ b/Documentation~/ExportRuntime.md
@@ -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
@@ -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
diff --git a/Documentation~/UpgradeGuides.md b/Documentation~/UpgradeGuides.md
index 27a18ce9..96b98c0e 100644
--- a/Documentation~/UpgradeGuides.md
+++ b/Documentation~/UpgradeGuides.md
@@ -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/com.unity.cloud.ktx@3.2/manual/upgrade-guide.html)
-- Upgrade to *Draco for Unity* (coming soon)
+- Upgrade to [*Draco for Unity*](https://docs.unity3d.com/Packages/com.unity.cloud.draco@5.0/manual/upgrade-guide.html)
### Keep using the original glTFast
diff --git a/Documentation~/features.md b/Documentation~/features.md
index b6e27e05..250d2e07 100644
--- a/Documentation~/features.md
+++ b/Documentation~/features.md
@@ -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 | 2☑️ | `?`
| Vertex colors | ✅ | `?`
-| Draco™ mesh compression (via [DracoUnity]) | ✅ | ✅
+| Draco™ mesh compression (via [DracoForUnity]) | ✅ | ✅
| Implicit (no) indices | ✅ |
| Per primitive material | ✅ | ✅
| Joints (up to 4 per vertex) | ✅ |
@@ -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
diff --git a/Documentation~/installation.md b/Documentation~/installation.md
index b4f486fc..7a5528ec 100644
--- a/Documentation~/installation.md
+++ b/Documentation~/installation.md
@@ -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™ 3D Data Compression Unity Package][DracoUnity] (provides support for [KHR_draco_mesh_compression][ExtDraco])
+- [Draco™ for Unity][DracoForUnity] (provides support for [KHR_draco_mesh_compression][ExtDraco])
- [KTX™ for Unity][KtxUnity] (provides support for [KHR_texture_basisu][ExtBasisU])
- [*meshoptimizer decompression for Unity*][Meshopt] (provides support for [EXT_meshopt_compression][ExtMeshopt])
@@ -29,7 +29,7 @@ There are some related package that improve *Unity glTFast* by extending its fea
*Draco™* 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
diff --git a/Runtime/Scripts/Export/GltfWriter.cs b/Runtime/Scripts/Export/GltfWriter.cs
index 77c741e7..be67ec91 100644
--- a/Runtime/Scripts/Export/GltfWriter.cs
+++ b/Runtime/Scripts/Export/GltfWriter.cs
@@ -14,7 +14,7 @@
using System.Threading.Tasks;
#if DRACO_UNITY
-using Draco.Encoder;
+using Draco.Encode;
#endif
using GLTFast.Schema;
using Unity.Collections;
diff --git a/Runtime/Scripts/Export/glTFast.Export.asmdef b/Runtime/Scripts/Export/glTFast.Export.asmdef
index f779a6c7..71eb66bd 100644
--- a/Runtime/Scripts/Export/glTFast.Export.asmdef
+++ b/Runtime/Scripts/Export/glTFast.Export.asmdef
@@ -7,7 +7,7 @@
"Unity.Burst",
"Unity.RenderPipelines.Universal.Runtime",
"Unity.RenderPipelines.HighDefinition.Runtime",
- "DracoEncoder"
+ "Draco.Encode"
],
"includePlatforms": [],
"excludePlatforms": [],
@@ -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"
}
diff --git a/Runtime/Scripts/glTFast.asmdef b/Runtime/Scripts/glTFast.asmdef
index 565dddda..ef0b734f 100644
--- a/Runtime/Scripts/glTFast.asmdef
+++ b/Runtime/Scripts/glTFast.asmdef
@@ -21,8 +21,8 @@
"defineConstraints": [],
"versionDefines": [
{
- "name": "com.atteneder.draco",
- "expression": "3.1.0",
+ "name": "com.unity.cloud.draco",
+ "expression": "5.0.0-pre.1",
"define": "DRACO_UNITY"
},
{
@@ -102,4 +102,4 @@
}
],
"noEngineReferences": false
-}
+}
\ No newline at end of file
From 057930348bd1fec56d87631211567a8428751cbf Mon Sep 17 00:00:00 2001
From: Andreas Atteneder
Date: Wed, 6 Dec 2023 15:31:45 +0100
Subject: [PATCH 10/14] Revert "chore: Support for Draco 3D Data Compression is
now provided by *Draco for Unity* (com.unity.cloud.draco), which is a fork of
and replaces *DracoUnity* (com.atteneder.draco). (#77)" (#78)
This reverts commit 9b7910316b1655b51c661749e0cab8d42d35e885.
---
CHANGELOG.md | 2 --
Documentation~/ExportRuntime.md | 4 ++--
Documentation~/UpgradeGuides.md | 2 +-
Documentation~/features.md | 4 ++--
Documentation~/installation.md | 4 ++--
Runtime/Scripts/Export/GltfWriter.cs | 2 +-
Runtime/Scripts/Export/glTFast.Export.asmdef | 4 ++--
Runtime/Scripts/glTFast.asmdef | 6 +++---
8 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ef5ae866..184a41c4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,7 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- (Documentation) Explanation and user case for the add-on API
### 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].
- Documentation improvements
- Auto-formatted all markdown, USS, UXML and shader code
@@ -1058,7 +1057,6 @@ This release contains multiple breaking changes. Please read the [upgrade guide]
[Entities1.0]: https://docs.unity3d.com/Packages/com.unity.entities@1.0
[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
diff --git a/Documentation~/ExportRuntime.md b/Documentation~/ExportRuntime.md
index 057b582e..f767f208 100644
--- a/Documentation~/ExportRuntime.md
+++ b/Documentation~/ExportRuntime.md
@@ -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 [Draco for Unity][DracoForUnity] package to be installed.
+*Unity glTFast* supports applying [Google Draco™ 3D Data compression][Draco] to meshes. This requires the [DracoUnity][DracoUnity] package to be installed.
```csharp
// ExportSettings provides generic export settings
@@ -147,7 +147,7 @@ var exportSettings = new ExportSettings {
[asmdef]: https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html
[Draco]: https://google.github.io/draco/
-[DracoForUnity]: https://docs.unity3d.com/Packages/com.unity.cloud.draco@latest
+[DracoUnity]: https://github.com/atteneder/DracoUnity
[GoogleLLC]: https://about.google/
[khronos]: https://www.khronos.org
[unity]: https://unity.com
diff --git a/Documentation~/UpgradeGuides.md b/Documentation~/UpgradeGuides.md
index 96b98c0e..27a18ce9 100644
--- a/Documentation~/UpgradeGuides.md
+++ b/Documentation~/UpgradeGuides.md
@@ -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/com.unity.cloud.ktx@3.2/manual/upgrade-guide.html)
-- Upgrade to [*Draco for Unity*](https://docs.unity3d.com/Packages/com.unity.cloud.draco@5.0/manual/upgrade-guide.html)
+- Upgrade to *Draco for Unity* (coming soon)
### Keep using the original glTFast
diff --git a/Documentation~/features.md b/Documentation~/features.md
index 250d2e07..b6e27e05 100644
--- a/Documentation~/features.md
+++ b/Documentation~/features.md
@@ -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 | 2☑️ | `?`
| Vertex colors | ✅ | `?`
-| Draco™ mesh compression (via [DracoForUnity]) | ✅ | ✅
+| Draco™ mesh compression (via [DracoUnity]) | ✅ | ✅
| Implicit (no) indices | ✅ |
| Per primitive material | ✅ | ✅
| Joints (up to 4 per vertex) | ✅ |
@@ -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
-[DracoForUnity]: https://docs.unity3d.com/Packages/com.unity.cloud.draco@latest
+[DracoUnity]: https://github.com/atteneder/DracoUnity
[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
diff --git a/Documentation~/installation.md b/Documentation~/installation.md
index 7a5528ec..b4f486fc 100644
--- a/Documentation~/installation.md
+++ b/Documentation~/installation.md
@@ -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™ for Unity][DracoForUnity] (provides support for [KHR_draco_mesh_compression][ExtDraco])
+- [Draco™ 3D Data Compression Unity Package][DracoUnity] (provides support for [KHR_draco_mesh_compression][ExtDraco])
- [KTX™ for Unity][KtxUnity] (provides support for [KHR_texture_basisu][ExtBasisU])
- [*meshoptimizer decompression for Unity*][Meshopt] (provides support for [EXT_meshopt_compression][ExtMeshopt])
@@ -29,7 +29,7 @@ There are some related package that improve *Unity glTFast* by extending its fea
*Draco™* is a trademark of [*Google LLC*][GoogleLLC].
-[DracoForUnity]: https://docs.unity3d.com/Packages/com.unity.cloud.draco@latest
+[DracoUnity]: https://github.com/atteneder/DracoUnity
[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
diff --git a/Runtime/Scripts/Export/GltfWriter.cs b/Runtime/Scripts/Export/GltfWriter.cs
index be67ec91..77c741e7 100644
--- a/Runtime/Scripts/Export/GltfWriter.cs
+++ b/Runtime/Scripts/Export/GltfWriter.cs
@@ -14,7 +14,7 @@
using System.Threading.Tasks;
#if DRACO_UNITY
-using Draco.Encode;
+using Draco.Encoder;
#endif
using GLTFast.Schema;
using Unity.Collections;
diff --git a/Runtime/Scripts/Export/glTFast.Export.asmdef b/Runtime/Scripts/Export/glTFast.Export.asmdef
index 71eb66bd..f779a6c7 100644
--- a/Runtime/Scripts/Export/glTFast.Export.asmdef
+++ b/Runtime/Scripts/Export/glTFast.Export.asmdef
@@ -7,7 +7,7 @@
"Unity.Burst",
"Unity.RenderPipelines.Universal.Runtime",
"Unity.RenderPipelines.HighDefinition.Runtime",
- "Draco.Encode"
+ "DracoEncoder"
],
"includePlatforms": [],
"excludePlatforms": [],
@@ -33,7 +33,7 @@
"define": "UNITY_IMAGECONVERSION"
},
{
- "name": "com.unity.cloud.draco",
+ "name": "com.atteneder.draco",
"expression": "5.0.0-pre.1",
"define": "DRACO_UNITY"
}
diff --git a/Runtime/Scripts/glTFast.asmdef b/Runtime/Scripts/glTFast.asmdef
index ef0b734f..565dddda 100644
--- a/Runtime/Scripts/glTFast.asmdef
+++ b/Runtime/Scripts/glTFast.asmdef
@@ -21,8 +21,8 @@
"defineConstraints": [],
"versionDefines": [
{
- "name": "com.unity.cloud.draco",
- "expression": "5.0.0-pre.1",
+ "name": "com.atteneder.draco",
+ "expression": "3.1.0",
"define": "DRACO_UNITY"
},
{
@@ -102,4 +102,4 @@
}
],
"noEngineReferences": false
-}
\ No newline at end of file
+}
From b12c66c3dab44ac4e7902291cf8a01bf7de9835b Mon Sep 17 00:00:00 2001
From: Andreas Atteneder
Date: Wed, 6 Dec 2023 15:35:00 +0100
Subject: [PATCH 11/14] fix: Updated references to *KTX for Unity* (#80)
---
CHANGELOG.md | 3 +++
Runtime/Scripts/GltfImport.cs | 8 ++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 184a41c4..5b0a8e94 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Documentation improvements
- Auto-formatted all markdown, USS, UXML and shader code
+### Fixed
+- Updated references to *KTX for Unity*
+
## [6.0.1] - 2023-10-11
### Fixed
diff --git a/Runtime/Scripts/GltfImport.cs b/Runtime/Scripts/GltfImport.cs
index f01fd75e..2a23cafd 100644
--- a/Runtime/Scripts/GltfImport.cs
+++ b/Runtime/Scripts/GltfImport.cs
@@ -8,7 +8,7 @@
#if KTX_UNITY_2_2_OR_NEWER || (!UNITY_2021_2_OR_NEWER && KTX_UNITY_1_3_OR_NEWER)
#define KTX
#elif KTX_UNITY
-#warning You have to update KtxUnity to enable support for KTX textures in glTFast
+#warning You have to update *KTX for Unity* to enable support for KTX textures in glTFast
#endif
// #define MEASURE_TIMINGS
@@ -1148,7 +1148,7 @@ bool CheckExtensionSupport(IEnumerable extensions, bool required = true)
#if !KTX_UNITY
if (ext == ExtensionName.TextureBasisUniversal)
{
- m_Logger?.Error(LogCode.PackageMissing, "KtxUnity", ext);
+ m_Logger?.Error(LogCode.PackageMissing, "KTX for Unity", ext);
}
else
#endif
@@ -1554,7 +1554,7 @@ void LoadImage(int imageIndex, Uri url, bool nonReadable, bool isKtx)
}
m_KtxDownloadTasks.Add(imageIndex, downloadTask);
#else
- m_Logger?.Error(LogCode.PackageMissing, "KtxUnity", ExtensionName.TextureBasisUniversal);
+ m_Logger?.Error(LogCode.PackageMissing, "KTX for Unity", ExtensionName.TextureBasisUniversal);
Profiler.EndSample();
return;
#endif // KTX_UNITY
@@ -2707,7 +2707,7 @@ ICollection contexts
Profiler.EndSample();
await m_DeferAgent.BreakPoint();
#else
- m_Logger?.Error(LogCode.PackageMissing, "KtxUnity", ExtensionName.TextureBasisUniversal);
+ m_Logger?.Error(LogCode.PackageMissing, "KTX for Unity", ExtensionName.TextureBasisUniversal);
#endif // KTX_UNITY
}
else
From 706cd1526ef1c3d75b083045af0310a8349ef244 Mon Sep 17 00:00:00 2001
From: Andreas Atteneder
Date: Wed, 6 Dec 2023 16:29:51 +0100
Subject: [PATCH 12/14] fix(ci): Replaced deprecated CI images. (#79)
---
.yamato/project.metafile | 4 ++--
.yamato/upm-ci.yml | 6 +++---
CHANGELOG.md | 1 +
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/.yamato/project.metafile b/.yamato/project.metafile
index 7e9f82ab..efd8ffdc 100644
--- a/.yamato/project.metafile
+++ b/.yamato/project.metafile
@@ -18,8 +18,8 @@ upm_test_platforms:
- name: win
type: Unity::VM
flavor: b1.large
- image: package-ci/win10:stable
+ image: package-ci/win10:v4
- name: mac
type: Unity::VM::osx
- image: package-ci/mac:stable
+ image: package-ci/macos-13:v4
flavor: m1.mac
\ No newline at end of file
diff --git a/.yamato/upm-ci.yml b/.yamato/upm-ci.yml
index cd69fcaa..86bc8cf0 100644
--- a/.yamato/upm-ci.yml
+++ b/.yamato/upm-ci.yml
@@ -6,7 +6,7 @@ upm_ci_pack:
name: "Pack"
agent:
type: Unity::VM
- image: package-ci/ubuntu:stable
+ image: package-ci/ubuntu-22.04:v4
flavor: b1.small
commands:
- npm install upm-ci-utils@stable -g --registry {{upm_ci_registry}}
@@ -43,7 +43,7 @@ upm_ci_publish_dry_run:
name: "Dry Run Publish to Internal Registry"
agent:
type: Unity::VM
- image: package-ci/win10:stable
+ image: package-ci/win10:v4
flavor: b1.small
commands:
- npm install upm-ci-utils@stable -g --registry {{ upm_ci_registry }}
@@ -67,7 +67,7 @@ upm_ci_publish:
name: "Publish to Internal Registry"
agent:
type: Unity::VM
- image: package-ci/win10:stable
+ image: package-ci/win10:v4
flavor: b1.small
commands:
- npm install upm-ci-utils@stable -g --registry {{ upm_ci_registry }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5b0a8e94..4c32a840 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Documentation improvements
- Auto-formatted all markdown, USS, UXML and shader code
+- CI maintenance
### Fixed
- Updated references to *KTX for Unity*
From d6b603034f171d212672c075821e082f3cd28614 Mon Sep 17 00:00:00 2001
From: Nick Constantinidis
Date: Wed, 17 Jan 2024 13:30:01 -0500
Subject: [PATCH 13/14] Support for KTX flipped Y texture orientations (#81)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* support for KTX flipped Y texture orientations
* only store indices with flipped y rather than all texture orientations
* store non-flipped texture indices instead of flipped to avoid allocating with KTX default
* check for flipped Y instead of just KTX format
* clean up potential unreachable code
* update changelog
---
CHANGELOG.md | 1 +
Runtime/Scripts/GltfImport.cs | 23 +++++++++++++++++++
Runtime/Scripts/IGltfReadable.cs | 8 +++++++
Runtime/Scripts/Material/MaterialGenerator.cs | 4 ++--
4 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4c32a840..2aa8fedf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- (Documentation) Explanation and user case for the add-on API
+- `GltfImport.IsTextureYFlipped` to support non-default texture orientations
### Changed
- Documentation improvements
diff --git a/Runtime/Scripts/GltfImport.cs b/Runtime/Scripts/GltfImport.cs
index 2a23cafd..85117473 100644
--- a/Runtime/Scripts/GltfImport.cs
+++ b/Runtime/Scripts/GltfImport.cs
@@ -233,6 +233,9 @@ public abstract class GltfImportBase : IGltfReadable, IGltfBuffers, IDisposable
///
Texture2D[] m_Textures;
+#if KTX
+ HashSet m_NonFlippedYTextureIndices;
+#endif
ImageFormat[] m_ImageFormats;
bool[] m_ImageReadable;
bool[] m_ImageGamma;
@@ -825,6 +828,16 @@ public Texture2D GetTexture(int index = 0)
return null;
}
+ ///
+ public bool IsTextureYFlipped(int index = 0)
+ {
+#if KTX
+ return m_NonFlippedYTextureIndices == null || !m_NonFlippedYTextureIndices.Contains(index);
+#else
+ return false;
+#endif
+ }
+
#if UNITY_ANIMATION
///
/// Returns all imported animation clips
@@ -1469,6 +1482,11 @@ async Task ProcessKtxDownload(int imageIndex, Task downloadTask
var result = await ktxContext.LoadTexture2D(forceSampleLinear);
if (result.errorCode == ErrorCode.Success) {
m_Images[imageIndex] = result.texture;
+ if (!result.orientation.IsYFlipped())
+ {
+ m_NonFlippedYTextureIndices ??= new HashSet();
+ m_NonFlippedYTextureIndices.Add(imageIndex);
+ }
return true;
}
} else {
@@ -3961,6 +3979,11 @@ async Task ProcessKtxLoadContexts() {
if (kTask.Result.result.errorCode == ErrorCode.Success) {
var ktx = m_KtxLoadContextsBuffer[i];
m_Images[ktx.imageIndex] = kTask.Result.result.texture;
+ if (!kTask.Result.result.orientation.IsYFlipped())
+ {
+ m_NonFlippedYTextureIndices ??= new HashSet();
+ m_NonFlippedYTextureIndices.Add(ktx.imageIndex);
+ }
await m_DeferAgent.BreakPoint();
}
ktxTasks.Remove(kTask);
diff --git a/Runtime/Scripts/IGltfReadable.cs b/Runtime/Scripts/IGltfReadable.cs
index ba2309cc..5900be15 100644
--- a/Runtime/Scripts/IGltfReadable.cs
+++ b/Runtime/Scripts/IGltfReadable.cs
@@ -71,6 +71,14 @@ public interface IGltfReadable
/// glTF texture index
/// Loaded Unity texture
Texture2D GetTexture(int index = 0);
+
+ ///
+ /// Evaluates if the texture's vertical orientation conforms to Unity's default.
+ /// If it's not aligned (=true; =flipped), the texture has to be applied mirrored vertically.
+ ///
+ /// glTF texture index
+ /// True if the vertical orientation is flipped, false otherwise
+ bool IsTextureYFlipped(int index = 0);
///
/// Get source (de-serialized glTF) camera
diff --git a/Runtime/Scripts/Material/MaterialGenerator.cs b/Runtime/Scripts/Material/MaterialGenerator.cs
index 5b7325b0..e70236e4 100644
--- a/Runtime/Scripts/Material/MaterialGenerator.cs
+++ b/Runtime/Scripts/Material/MaterialGenerator.cs
@@ -301,7 +301,7 @@ protected bool TrySetTexture(
// this condition
if (scaleTransformPropertyId >= 0 && rotationPropertyId >= 0 && uvChannelPropertyId >= 0)
{
- var isKtx = srcTexture.IsKtx;
+ var flipY = gltf.IsTextureYFlipped(textureIndex);
TrySetTextureTransform(
textureInfo,
material,
@@ -309,7 +309,7 @@ protected bool TrySetTexture(
scaleTransformPropertyId,
rotationPropertyId,
uvChannelPropertyId,
- isKtx
+ flipY
);
}
return true;
From be8b2b4650fa546f20636da498f41059ee52f427 Mon Sep 17 00:00:00 2001
From: Nick Constantinidis
Date: Thu, 18 Jan 2024 10:58:22 -0500
Subject: [PATCH 14/14] Release 6.1.0 (#83)
---
CHANGELOG.md | 2 +-
Runtime/Scripts/Export/Constants.cs | 2 +-
package.json | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2aa8fedf..b49fe5db 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,7 @@ 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).
-## [Unreleased]
+## [6.1.0] - 2024-01-17
### Added
- (Documentation) Explanation and user case for the add-on API
diff --git a/Runtime/Scripts/Export/Constants.cs b/Runtime/Scripts/Export/Constants.cs
index 7393b836..dea1f81c 100644
--- a/Runtime/Scripts/Export/Constants.cs
+++ b/Runtime/Scripts/Export/Constants.cs
@@ -7,7 +7,7 @@ namespace GLTFast.Export
{
static class Constants
{
- public const string version = "6.0.1";
+ public const string version = "6.1.0";
internal const string mimeTypePNG = "image/png";
internal const string mimeTypeJPG = "image/jpeg";
diff --git a/package.json b/package.json
index c37d6cda..24048a81 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "com.unity.cloud.gltfast",
- "version": "6.0.1",
+ "version": "6.1.0",
"displayName": "Unity glTFast",
"description": "Use glTFast to import and export glTF 3D files efficiently at runtime or in the Editor",
"unity": "2020.3",