From ad61509167232eb54d3915d5be7cc30e1d1e8204 Mon Sep 17 00:00:00 2001 From: Andreas Atteneder Date: Thu, 30 May 2024 01:21:54 +0200 Subject: [PATCH 01/10] Post Release 6.6.0 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f089c6b2..09eacb7f 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.6.0] - 2024-05-29 ### Added From a20e7dd8cfd2cc437d58f2faa5a48d25f664a977 Mon Sep 17 00:00:00 2001 From: Andreas Atteneder Date: Thu, 30 May 2024 19:32:17 +0200 Subject: [PATCH 02/10] feat(ci): Speed up HDRP tests by utilizing GPUs. (#156) * refactor(ci): Unified naming --- .yamato/package.metafile | 3 +++ .yamato/project-test.yml | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.yamato/package.metafile b/.yamato/package.metafile index acbe0683..310038f6 100644 --- a/.yamato/package.metafile +++ b/.yamato/package.metafile @@ -60,6 +60,7 @@ test_setups: render_pipeline: HDRP-Deferred utr_timeout: 3600 agent_xlarge_required: !!bool true + gpu_required: !!bool true editor_versions: [2022,6000] platforms: [win] pr_test_subset: @@ -138,6 +139,7 @@ agents: win: os: win type: Unity::VM + gpu_type: Unity::VM::GPU image: package-ci/win10:v4 flavor: b1.large flavor_xlarge: b1.xlarge @@ -150,6 +152,7 @@ agents: ubuntu: os: linux type: Unity::VM + gpu_type: Unity::VM::GPU image: package-ci/ubuntu-22.04:v4 flavor: b1.large flavor_xlarge: b1.xlarge diff --git a/.yamato/project-test.yml b/.yamato/project-test.yml index 3337f4a0..d7baf6bc 100644 --- a/.yamato/project-test.yml +++ b/.yamato/project-test.yml @@ -59,7 +59,7 @@ test_{{ test_setup.project_setup }}_{{ platform_id }}_{{ editor }}: name : Test {{ test_setup.project_setup }} with {{ editor }} on {{ platform_id }} agent: - type: {{ agent.type }} + type: {% if test_setup.gpu_required %}{{ agent.gpu_type}}{% else %}{{ agent.type}}{% endif %} image: {{ agent.image }} flavor: {% if test_setup.agent_xlarge_required %}{{ agent.flavor_xlarge}}{% else %}{{ agent.flavor}}{% endif %} source: @@ -202,7 +202,7 @@ build_and_run_{{ test_setup.project_setup }}_{{ platform_id }}_{{ editor }}: name : Build and run {{ test_setup.project_setup }} with {{ editor }} on {{ platform_id }} agent: {% assign agent = agents[platform.build_and_run] -%} - type: {{ agent.type }} + type: {% if test_setup.gpu_required %}{{ agent.gpu_type}}{% else %}{{ agent.type}}{% endif %} image: {{ agent.image }} flavor: {% if test_setup.agent_xlarge_required %}{{ agent.flavor_xlarge}}{% else %}{{ agent.flavor}}{% endif %} source: @@ -340,7 +340,7 @@ build_{{ test_setup.project_setup }}_{{ platform_id }}_{{ editor }}: name : Build {{ test_setup.project_setup }} with {{ editor }} on {{ platform_id }} agent: {% assign agent = agents[platform.build] -%} - type: {{ agent.type }} + type: {% if test_setup.gpu_required %}{{ agent.gpu_type}}{% else %}{{ agent.type}}{% endif %} image: {{ agent.image }} flavor: {% if test_setup.agent_xlarge_required %}{{ agent.flavor_xlarge}}{% else %}{{ agent.flavor}}{% endif %} source: @@ -483,7 +483,7 @@ run_{{ test_setup.project_setup }}_{{ platform_id }}_{{ editor }}: name : Run {{ test_setup.project_setup }} with {{ editor }} on {{ platform_id }} agent: {% assign agent = agents[platform.run] -%} - type: {{ agent.type }} + type: {% if test_setup.gpu_required %}{{ agent.gpu_type}}{% else %}{{ agent.type}}{% endif %} image: {{ agent.image }} flavor: {% if test_setup.agent_xlarge_required %}{{ agent.flavor_xlarge}}{% else %}{{ agent.flavor}}{% endif %} source: From f7a86d1e95308720373940d1da3ff2bdbd8cdebe Mon Sep 17 00:00:00 2001 From: Andreas Atteneder Date: Thu, 20 Jun 2024 17:06:12 +0200 Subject: [PATCH 03/10] feat(import): Materials variants extension (KHR_materials_variants) (#158) --- CHANGELOG.md | 6 + Documentation~/features.md | 5 +- Editor/Scripts/GltfImporter.cs | 134 ++++++++++----- .../MaterialsVariantsComponentInspector.cs | 97 +++++++++++ ...aterialsVariantsComponentInspector.cs.meta | 13 ++ .../MaterialsVariantsComponentInspector.uxml | 3 + ...erialsVariantsComponentInspector.uxml.meta | 10 ++ Runtime/Scripts/GameObjectInstantiator.cs | 35 ++++ Runtime/Scripts/GameObjectSceneInstance.cs | 10 ++ Runtime/Scripts/GltfImport.cs | 69 ++++++++ Runtime/Scripts/IGltfReadable.cs | 10 +- Runtime/Scripts/IMaterialProvider.cs | 40 +++++ Runtime/Scripts/IMaterialProvider.cs.meta | 3 + Runtime/Scripts/IMaterialsVariantsProvider.cs | 20 +++ .../IMaterialsVariantsProvider.cs.meta | 3 + Runtime/Scripts/MaterialsVariants.meta | 8 + .../IMaterialsVariantsSlot.cs | 22 +++ .../IMaterialsVariantsSlot.cs.meta | 3 + .../IMaterialsVariantsSlotInstance.cs | 21 +++ .../IMaterialsVariantsSlotInstance.cs.meta | 3 + .../MaterialsVariantsComponent.cs | 20 +++ .../MaterialsVariantsComponent.cs.meta | 11 ++ .../MaterialsVariantsControl.cs | 57 +++++++ .../MaterialsVariantsControl.cs.meta | 3 + .../MaterialsVariantsSlotInstances.cs | 69 ++++++++ .../MaterialsVariantsSlotInstances.cs.meta | 3 + .../MultiMaterialsVariantsSlotInstances.cs | 84 ++++++++++ ...ultiMaterialsVariantsSlotInstances.cs.meta | 3 + .../Schema/MaterialsVariantsExtension.cs | 26 +++ Runtime/Scripts/Schema/MeshPrimitive.cs | 13 +- Runtime/Scripts/Schema/Root.cs | 23 +++ .../Documentation/Manual/MultipleInstances.cs | 60 +++++++ .../Manual/MultipleInstances.cs.meta | 11 ++ .../Scripts/Import/MaterialProviderMock.cs | 61 +++++++ .../Import/MaterialProviderMock.cs.meta | 3 + .../Scripts/Import/MaterialsVariantsTests.cs | 157 ++++++++++++++++++ .../Import/MaterialsVariantsTests.cs.meta | 11 ++ 37 files changed, 1088 insertions(+), 42 deletions(-) create mode 100644 Editor/Scripts/MaterialsVariantsComponentInspector.cs create mode 100644 Editor/Scripts/MaterialsVariantsComponentInspector.cs.meta create mode 100644 Editor/UI/MaterialsVariantsComponentInspector.uxml create mode 100644 Editor/UI/MaterialsVariantsComponentInspector.uxml.meta create mode 100644 Runtime/Scripts/IMaterialProvider.cs create mode 100644 Runtime/Scripts/IMaterialProvider.cs.meta create mode 100644 Runtime/Scripts/IMaterialsVariantsProvider.cs create mode 100644 Runtime/Scripts/IMaterialsVariantsProvider.cs.meta create mode 100644 Runtime/Scripts/MaterialsVariants.meta create mode 100644 Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlot.cs create mode 100644 Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlot.cs.meta create mode 100644 Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlotInstance.cs create mode 100644 Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlotInstance.cs.meta create mode 100644 Runtime/Scripts/MaterialsVariants/MaterialsVariantsComponent.cs create mode 100644 Runtime/Scripts/MaterialsVariants/MaterialsVariantsComponent.cs.meta create mode 100644 Runtime/Scripts/MaterialsVariants/MaterialsVariantsControl.cs create mode 100644 Runtime/Scripts/MaterialsVariants/MaterialsVariantsControl.cs.meta create mode 100644 Runtime/Scripts/MaterialsVariants/MaterialsVariantsSlotInstances.cs create mode 100644 Runtime/Scripts/MaterialsVariants/MaterialsVariantsSlotInstances.cs.meta create mode 100644 Runtime/Scripts/MaterialsVariants/MultiMaterialsVariantsSlotInstances.cs create mode 100644 Runtime/Scripts/MaterialsVariants/MultiMaterialsVariantsSlotInstances.cs.meta create mode 100644 Samples/Documentation/Manual/MultipleInstances.cs create mode 100644 Samples/Documentation/Manual/MultipleInstances.cs.meta create mode 100644 Tests/Runtime/Scripts/Import/MaterialProviderMock.cs create mode 100644 Tests/Runtime/Scripts/Import/MaterialProviderMock.cs.meta create mode 100644 Tests/Runtime/Scripts/Import/MaterialsVariantsTests.cs create mode 100644 Tests/Runtime/Scripts/Import/MaterialsVariantsTests.cs.meta diff --git a/CHANGELOG.md b/CHANGELOG.md index 09eacb7f..807a392a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - +### Added +- (Import) Support for [materials variants extension](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_variants). + +### Changed +- (Import) Prefabs imported from glTF assets (at design-time) don't have the glTF logo icon assigned to them anymore. This makes it more consistent with other file types (like FBX; fixes [#557](https://github.com/atteneder/glTFast/issues/557)). + ## [6.6.0] - 2024-05-29 ### Added diff --git a/Documentation~/features.md b/Documentation~/features.md index 9ad98473..6be4ac54 100644 --- a/Documentation~/features.md +++ b/Documentation~/features.md @@ -106,7 +106,7 @@ The glTF 2.0 specification is fully supported, with only a few minor remarks. | KHR_materials_clearcoat | ✅ | ✅ | KHR_materials_sheen | [ℹ️][Sheen] | | KHR_materials_transmission | [ℹ️][Transmission] | -| KHR_materials_variants | [ℹ️][Variants] | +| KHR_materials_variants | ✅ | | KHR_materials_ior | [ℹ️][IOR] | | KHR_materials_specular | [ℹ️][Specular] | | KHR_materials_volume | [ℹ️][Volume] | @@ -164,7 +164,7 @@ See [glTFast Add-on API](UseCaseCustomExtras.md) for an example to import the `e | Clear coat | ☑️³ | ✅ | [⛔️][ClearCoat] | | Sheen | [ℹ️][Sheen] | [ℹ️][Sheen] | [⛔️][Sheen] | | Transmission | [☑️][Transmission]⁴ | [☑️][Transmission]⁵ | [☑️][Transmission]⁵ | -| Variants | [ℹ️][Variants] | [ℹ️][Variants] | [ℹ️][Variants] | +| Variants | ✅ | ✅ | ✅ | | IOR | [ℹ️][IOR] | [ℹ️][IOR] | [⛔️][IOR] | | Specular | [ℹ️][Specular] | [ℹ️][Specular] | [⛔️][Specular] | | Volume | [ℹ️][Volume] | [ℹ️][Volume] | [⛔️][Volume] | @@ -328,5 +328,4 @@ Possibly incomplete list of things that are known to not work with Entities yet: [Unity]: https://unity.com [URP]: https://unity.com/srp/universal-render-pipeline [UVsets]: https://github.com/atteneder/glTFast/issues/206 -[Variants]: https://github.com/atteneder/glTFast/issues/112 [Volume]: https://github.com/atteneder/glTFast/issues/209 diff --git a/Editor/Scripts/GltfImporter.cs b/Editor/Scripts/GltfImporter.cs index 2c6248a7..4d641e82 100644 --- a/Editor/Scripts/GltfImporter.cs +++ b/Editor/Scripts/GltfImporter.cs @@ -137,48 +137,29 @@ public override void OnImportAsset(AssetImportContext ctx) instantiationLogger = new CollectingLogger(); for (var sceneIndex = 0; sceneIndex < m_Gltf.SceneCount; sceneIndex++) { - var scene = m_Gltf.GetSourceScene(sceneIndex); - var sceneName = m_Gltf.GetSceneName(sceneIndex); - var go = new GameObject(sceneName); - var instantiator = new GameObjectInstantiator(m_Gltf, go.transform, instantiationLogger, instantiationSettings); - var index = sceneIndex; - success = AsyncHelpers.RunSync(() => m_Gltf.InstantiateSceneAsync(instantiator, index)); - if (!success) break; - var useFirstChild = true; - var multipleNodes = scene.nodes.Length > 1; - var hasAnimation = false; -#if UNITY_ANIMATION - if (importSettings.AnimationMethod != AnimationMethod.None - && (instantiationSettings.Mask & ComponentType.Animation) != 0) { - var animationClips = m_Gltf.GetAnimationClips(); - if (animationClips != null && animationClips.Length > 0) { - hasAnimation = true; - } + try + { + ImportScene(ctx, sceneIndex, instantiationLogger); } -#endif - - if (instantiationSettings.SceneObjectCreation == SceneObjectCreation.Never - || instantiationSettings.SceneObjectCreation == SceneObjectCreation.WhenMultipleRootNodes && !multipleNodes) + catch (InvalidOperationException) { - // No scene GameObject was created, so the first - // child is the first (and in this case only) node. - - // If there's animation, its clips' paths are relative - // to the root GameObject (which will also carry the - // `Animation` component. If not, we can import the the - // first and only node as root directly. - - useFirstChild = !hasAnimation; + instantiationLogger.Error($"Failed creating scene {sceneIndex} instance."); } - var sceneTransform = useFirstChild - ? go.transform.GetChild(0) - : go.transform; - var sceneGo = sceneTransform.gameObject; - AddObjectToAsset(ctx, $"scenes/{sceneName}", sceneGo, gltfIcon); - if (sceneIndex == m_Gltf.DefaultSceneIndex) + if (m_Gltf.MaterialsVariantsCount > 0) { - ctx.SetMainObject(sceneGo); + for (var variantIndex = 0; variantIndex < m_Gltf.MaterialsVariantsCount; variantIndex++) + { + try + { + ImportScene(ctx, sceneIndex, instantiationLogger, variantIndex); + } + catch (InvalidOperationException) + { + instantiationLogger.Error($"Failed creating scene {sceneIndex} materials variant " + + $"{variantIndex} instance."); + } + } } } @@ -313,6 +294,85 @@ public override void OnImportAsset(AssetImportContext ctx) reportItems = reportItemList.ToArray(); } + void ImportScene( + AssetImportContext ctx, + int sceneIndex, + CollectingLogger instantiationLogger, + int? materialsVariantIndex = null + ) + { + var scene = m_Gltf.GetSourceScene(sceneIndex); + var sceneName = m_Gltf.GetSceneName(sceneIndex); + string sceneObjectName = null; + string variantNameSuffix = null; + if (materialsVariantIndex.HasValue) + { + variantNameSuffix = m_Gltf.GetMaterialsVariantName(materialsVariantIndex.Value); + if (string.IsNullOrEmpty(variantNameSuffix)) + { + variantNameSuffix = $"variant_{materialsVariantIndex.Value}"; + } + sceneObjectName = $"{sceneName}_{variantNameSuffix}"; + } + else + { + sceneObjectName = sceneName; + } + + var go = new GameObject(sceneObjectName); + var instantiator = new GameObjectInstantiator(m_Gltf, go.transform, instantiationLogger, instantiationSettings); + var index = sceneIndex; + var success = AsyncHelpers.RunSync(() => m_Gltf.InstantiateSceneAsync(instantiator, index)); + if (!success) + { + throw new InvalidOperationException("Instantiating scene failed"); + } + var useFirstChild = true; + var multipleNodes = scene.nodes.Length > 1; + var hasAnimation = false; +#if UNITY_ANIMATION + if (importSettings.AnimationMethod != AnimationMethod.None + && (instantiationSettings.Mask & ComponentType.Animation) != 0) { + var animationClips = m_Gltf.GetAnimationClips(); + if (animationClips != null && animationClips.Length > 0) { + hasAnimation = true; + } + } +#endif + + if (instantiationSettings.SceneObjectCreation == SceneObjectCreation.Never + || instantiationSettings.SceneObjectCreation == SceneObjectCreation.WhenMultipleRootNodes && !multipleNodes) + { + // No scene GameObject was created, so the first + // child is the first (and in this case only) node. + + // If there's animation, its clips' paths are relative + // to the root GameObject (which will also carry the + // `Animation` component. If not, we can import the the + // first and only node as root directly. + + useFirstChild = !hasAnimation; + } + + var sceneTransform = useFirstChild + ? go.transform.GetChild(0) + : go.transform; + var sceneGo = sceneTransform.gameObject; + + if (materialsVariantIndex.HasValue) + { + sceneGo.name = $"{sceneGo.name}_{variantNameSuffix}"; + + var variantsControl = instantiator.SceneInstance.MaterialsVariantsControl; + AsyncHelpers.RunSync(() => variantsControl.ApplyMaterialsVariantAsync(materialsVariantIndex.Value)); + } + AddObjectToAsset(ctx, $"scenes/{sceneObjectName}", sceneGo); + if (sceneIndex == m_Gltf.DefaultSceneIndex && !materialsVariantIndex.HasValue) + { + ctx.SetMainObject(sceneGo); + } + } + void AddObjectToAsset(AssetImportContext ctx, string originalName, Object obj, Texture2D thumbnail = null) { if (m_ImportedObjects.Contains(obj)) diff --git a/Editor/Scripts/MaterialsVariantsComponentInspector.cs b/Editor/Scripts/MaterialsVariantsComponentInspector.cs new file mode 100644 index 00000000..257251e9 --- /dev/null +++ b/Editor/Scripts/MaterialsVariantsComponentInspector.cs @@ -0,0 +1,97 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; +using UnityEngine.UIElements; + +namespace GLTFast.Editor +{ + [CustomEditor(typeof(MaterialsVariantsComponent))] + class MaterialsVariantsComponentInspector : UnityEditor.Editor + { + [SerializeField] VisualTreeAsset m_MainMarkup; + + List m_VariantNames; +#if UNITY_2021_2_OR_NEWER + DropdownField m_Dropdown; +#endif + + public override VisualElement CreateInspectorGUI() + { + if (m_VariantNames == null) + { + var control = (target as MaterialsVariantsComponent)?.Control; + if (control != null) + { + var count = control.MaterialsVariantsCount; + m_VariantNames = new List(count + 1) + { + "" + }; + for (var variantIndex = 0; variantIndex < count; variantIndex++) + { + m_VariantNames.Add(control.GetMaterialsVariantName(variantIndex)); + } + } + } + var myInspector = new VisualElement(); +#if UNITY_2021_2_OR_NEWER + m_MainMarkup.CloneTree(myInspector); + m_Dropdown = myInspector.Query().First(); + + if (m_VariantNames == null) + { + myInspector.SetEnabled(false); + } + else + { + m_Dropdown.choices = m_VariantNames; + m_Dropdown.index = 0; + m_Dropdown.RegisterValueChangedCallback(OnMaterialsVariantChanged); + myInspector.Add(m_Dropdown); + } +#else + if (m_VariantNames == null) + { + myInspector.SetEnabled(false); + } + else + { + for (var i = 0; i < m_VariantNames.Count; i++) + { + var button = new Button + { + text = m_VariantNames[i] + }; + + button.RegisterCallback(OnVariantButtonClicked, i - 1); // asset is the root visual element that will be closed + myInspector.Add(button); + } + } +#endif + return myInspector; + } + +#if UNITY_2021_2_OR_NEWER + void OnMaterialsVariantChanged(ChangeEvent evt) + { + var control = (target as MaterialsVariantsComponent)?.Control; + if (control != null) + { + _ = control.ApplyMaterialsVariantAsync(m_Dropdown.index - 1); + } + } +#else + void OnVariantButtonClicked(ClickEvent evt, int variantIndex) + { + var control = (target as MaterialsVariantsComponent)?.Control; + if (control != null) + { + _ = control.ApplyMaterialsVariantAsync(variantIndex); + } + } +#endif + } +} diff --git a/Editor/Scripts/MaterialsVariantsComponentInspector.cs.meta b/Editor/Scripts/MaterialsVariantsComponentInspector.cs.meta new file mode 100644 index 00000000..cee58b90 --- /dev/null +++ b/Editor/Scripts/MaterialsVariantsComponentInspector.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1533d582ae2ef4144a8c96f65c0b080e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: + - m_MainMarkup: {fileID: 9197481963319205126, guid: d61d79f8a5b6648529e9ae112313759d, + type: 3} + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/UI/MaterialsVariantsComponentInspector.uxml b/Editor/UI/MaterialsVariantsComponentInspector.uxml new file mode 100644 index 00000000..28a14bce --- /dev/null +++ b/Editor/UI/MaterialsVariantsComponentInspector.uxml @@ -0,0 +1,3 @@ + + + diff --git a/Editor/UI/MaterialsVariantsComponentInspector.uxml.meta b/Editor/UI/MaterialsVariantsComponentInspector.uxml.meta new file mode 100644 index 00000000..ad70a558 --- /dev/null +++ b/Editor/UI/MaterialsVariantsComponentInspector.uxml.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d61d79f8a5b6648529e9ae112313759d +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} diff --git a/Runtime/Scripts/GameObjectInstantiator.cs b/Runtime/Scripts/GameObjectInstantiator.cs index f54f9296..4fca662f 100644 --- a/Runtime/Scripts/GameObjectInstantiator.cs +++ b/Runtime/Scripts/GameObjectInstantiator.cs @@ -57,6 +57,8 @@ public class GameObjectInstantiator : IInstantiator /// protected Dictionary m_Nodes; + List m_InstanceSlots; + /// /// Transform representing the scene. /// Root nodes will get parented to it. @@ -289,6 +291,14 @@ public virtual void AddPrimitive( renderer.sharedMaterials = materials; + var slots = m_Gltf.GetMaterialsVariantsSlots(meshResult.meshIndex, primitiveNumeration); + if (slots != null && slots.Length > 0) + { + m_InstanceSlots ??= new List(); + var instanceSlot = new MaterialsVariantsSlotInstances(renderer, slots); + m_InstanceSlots.Add(instanceSlot); + } + MeshAdded?.Invoke( meshGo, nodeIndex, @@ -326,6 +336,12 @@ public virtual void AddPrimitiveInstanced( materials[index] = material; } + var slots = m_Gltf.GetMaterialsVariantsSlots(meshResult.meshIndex, primitiveNumeration); + var hasMaterialsVariants = slots != null && slots.Length > 0; + var renderers = hasMaterialsVariants + ? new Renderer[instanceCount] + : null; + for (var i = 0; i < instanceCount; i++) { var meshGo = new GameObject($"{meshName}_i{i}"); @@ -340,6 +356,18 @@ public virtual void AddPrimitiveInstanced( mf.mesh = meshResult.mesh; Renderer renderer = meshGo.AddComponent(); renderer.sharedMaterials = materials; + + if (hasMaterialsVariants) + { + renderers[i] = renderer; + } + } + + if (hasMaterialsVariants) + { + m_InstanceSlots ??= new List(); + var instanceSlot = new MultiMaterialsVariantsSlotInstances(renderers, slots); + m_InstanceSlots.Add(instanceSlot); } } @@ -522,6 +550,13 @@ uint lightIndex public virtual void EndScene(uint[] rootNodeIndices) { Profiler.BeginSample("EndScene"); + + if (m_InstanceSlots != null) + { + var materialsVariantsControl = new MaterialsVariantsControl(m_Gltf, m_InstanceSlots); + SceneInstance.SetMaterialsVariantsControl(materialsVariantsControl); + } + if (rootNodeIndices != null) { foreach (var nodeIndex in rootNodeIndices) diff --git a/Runtime/Scripts/GameObjectSceneInstance.cs b/Runtime/Scripts/GameObjectSceneInstance.cs index 0cfc4b38..7c397761 100644 --- a/Runtime/Scripts/GameObjectSceneInstance.cs +++ b/Runtime/Scripts/GameObjectSceneInstance.cs @@ -22,6 +22,11 @@ public class GameObjectSceneInstance /// public IReadOnlyList Lights => m_Lights; + /// + /// Enables controlling and applying materials variants. + /// + public MaterialsVariantsControl MaterialsVariantsControl { get; private set; } + #if UNITY_ANIMATION /// /// component. Is null if scene has no @@ -56,6 +61,11 @@ internal void AddLight(Light light) m_Lights.Add(light); } + internal void SetMaterialsVariantsControl(MaterialsVariantsControl control) + { + MaterialsVariantsControl = control; + } + #if UNITY_ANIMATION internal void SetLegacyAnimation(Animation animation) { LegacyAnimation = animation; diff --git a/Runtime/Scripts/GltfImport.cs b/Runtime/Scripts/GltfImport.cs index af2803fc..ef9ef666 100644 --- a/Runtime/Scripts/GltfImport.cs +++ b/Runtime/Scripts/GltfImport.cs @@ -157,6 +157,7 @@ public abstract class GltfImportBase : IGltfReadable, IGltfBuffers, IDisposable #endif ExtensionName.MaterialsPbrSpecularGlossiness, ExtensionName.MaterialsUnlit, + ExtensionName.MaterialsVariants, ExtensionName.TextureTransform, ExtensionName.MeshQuantization, ExtensionName.MaterialsTransmission, @@ -778,6 +779,18 @@ public UnityEngine.Material GetMaterial(int index = 0) return null; } + /// + public async Task GetMaterialAsync(int index) + { + return await GetMaterialAsync(index, new CancellationToken()); + } + + /// + public Task GetMaterialAsync(int index, CancellationToken cancellationToken) + { + return Task.FromResult(GetMaterial(index)); + } + /// public UnityEngine.Material GetDefaultMaterial() { @@ -796,6 +809,18 @@ public UnityEngine.Material GetDefaultMaterial() #endif } + /// + public async Task GetDefaultMaterialAsync() + { + return await GetDefaultMaterialAsync(new CancellationToken()); + } + + /// + public Task GetDefaultMaterialAsync(CancellationToken cancellationToken) + { + return Task.FromResult(GetDefaultMaterial()); + } + /// /// Returns a texture by its glTF image index /// @@ -900,6 +925,41 @@ public MaterialBase GetSourceMaterial(int index = 0) return null; } + /// + public MeshPrimitiveBase GetSourceMeshPrimitive(int meshIndex, int primitiveIndex) + { + if (Root?.Meshes != null && meshIndex >= 0 && meshIndex < Root.Meshes.Count) + { + var mesh = Root.Meshes[meshIndex]; + if (mesh?.Primitives != null && primitiveIndex >= 0 && primitiveIndex < mesh.Primitives.Count) + { + return mesh.Primitives[primitiveIndex]; + } + } + return null; + } + + /// + public IMaterialsVariantsSlot[] GetMaterialsVariantsSlots(int meshIndex, int meshResultOffset) + { + var meshResultIndex = m_MeshPrimitiveIndex[meshIndex] + meshResultOffset; + Assert.IsTrue(meshResultIndex < m_MeshPrimitiveIndex[meshIndex + 1]); + + List materialSlots = null; + var meshResult = m_Primitives[meshResultIndex]; + foreach (var primitiveIndex in meshResult.primitiveIndices) + { + var primitive = GetSourceMeshPrimitive(meshIndex, primitiveIndex); + if (primitive.Extensions?.KHR_materials_variants?.mappings != null) + { + materialSlots ??= new List(); + materialSlots.Add(primitive); + } + } + + return materialSlots?.ToArray(); + } + /// public NodeBase GetSourceNode(int index = 0) { @@ -960,6 +1020,15 @@ public NativeSlice GetAccessor(int accessorIndex) return GetBufferView(accessor.bufferView, accessor.byteOffset, accessor.ByteSize); } + /// + public int MaterialsVariantsCount => Root.MaterialsVariantsCount; + + /// + public string GetMaterialsVariantName(int index) + { + return Root.GetMaterialsVariantName(index); + } + async Task LoadFromUri(Uri url, CancellationToken cancellationToken) { diff --git a/Runtime/Scripts/IGltfReadable.cs b/Runtime/Scripts/IGltfReadable.cs index 37ecf0fa..14854343 100644 --- a/Runtime/Scripts/IGltfReadable.cs +++ b/Runtime/Scripts/IGltfReadable.cs @@ -26,7 +26,7 @@ public interface IGltfReadable : IGltfReadable /// /// Provides read-only access to a glTF (schema and imported Unity resources) /// - public interface IGltfReadable + public interface IGltfReadable : IMaterialProvider { /// @@ -94,6 +94,14 @@ public interface IGltfReadable /// De-serialized glTF material MaterialBase GetSourceMaterial(int index = 0); + /// + /// Get source (de-serialized glTF) mesh primitive + /// + /// glTF mesh index. + /// glTF primitive index within mesh. + /// De-serialized glTF mesh primitive + MeshPrimitiveBase GetSourceMeshPrimitive(int meshIndex, int primitiveIndex); + /// /// Get source (de-serialized glTF) node /// diff --git a/Runtime/Scripts/IMaterialProvider.cs b/Runtime/Scripts/IMaterialProvider.cs new file mode 100644 index 00000000..85ddc07a --- /dev/null +++ b/Runtime/Scripts/IMaterialProvider.cs @@ -0,0 +1,40 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System; +using System.Threading; +using System.Threading.Tasks; +using Material = UnityEngine.Material; + +namespace GLTFast +{ + /// + /// Provides access to glTF materials. + /// + public interface IMaterialProvider : IMaterialsVariantsProvider + { + /// + Task GetMaterialAsync(int index); + + /// + /// Token to submit cancellation requests. The default value is None. + Task GetMaterialAsync(int index, CancellationToken cancellationToken); + + /// + Task GetDefaultMaterialAsync(); + + /// + /// Token to submit cancellation requests. The default value is None. + Task GetDefaultMaterialAsync(CancellationToken cancellationToken); + + /// + /// Returns the material slots that correspond to the given MeshResult's sub-meshes. + /// + /// glTF mesh index. + /// Mesh result offset. + /// Corresponding materials variants slots. + /// + /// + IMaterialsVariantsSlot[] GetMaterialsVariantsSlots(int meshIndex, int meshResultOffset); + } +} diff --git a/Runtime/Scripts/IMaterialProvider.cs.meta b/Runtime/Scripts/IMaterialProvider.cs.meta new file mode 100644 index 00000000..f9cd3b68 --- /dev/null +++ b/Runtime/Scripts/IMaterialProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0d8696b9fb074a23a6d76da293a8d98d +timeCreated: 1718234937 \ No newline at end of file diff --git a/Runtime/Scripts/IMaterialsVariantsProvider.cs b/Runtime/Scripts/IMaterialsVariantsProvider.cs new file mode 100644 index 00000000..cc4bae31 --- /dev/null +++ b/Runtime/Scripts/IMaterialsVariantsProvider.cs @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System; +using GLTFast.Schema; + +namespace GLTFast +{ + /// + /// Provides access to glTF materials variants. + /// + public interface IMaterialsVariantsProvider + { + /// + int MaterialsVariantsCount { get; } + + /// + string GetMaterialsVariantName(int index); + } +} diff --git a/Runtime/Scripts/IMaterialsVariantsProvider.cs.meta b/Runtime/Scripts/IMaterialsVariantsProvider.cs.meta new file mode 100644 index 00000000..44a82230 --- /dev/null +++ b/Runtime/Scripts/IMaterialsVariantsProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9e554426dbbd4f148438960e7e80db45 +timeCreated: 1718275889 \ No newline at end of file diff --git a/Runtime/Scripts/MaterialsVariants.meta b/Runtime/Scripts/MaterialsVariants.meta new file mode 100644 index 00000000..df55286e --- /dev/null +++ b/Runtime/Scripts/MaterialsVariants.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a6f04553a2954d04ba95dce85a65d297 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlot.cs b/Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlot.cs new file mode 100644 index 00000000..8ea99d6b --- /dev/null +++ b/Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlot.cs @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System; + +namespace GLTFast +{ + /// + /// Represents a material slot. + /// + public interface IMaterialsVariantsSlot + { + /// + /// Provides the glTF material index, given a materials variant index. + /// If variantIndex is invalid (e.g. negative) or the slot does not have a material override for the given + /// variantIndex, it returns the default material index. + /// + /// Materials variant index. + /// Corresponding glTF material index. + int GetMaterialIndex(int variantIndex); + } +} diff --git a/Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlot.cs.meta b/Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlot.cs.meta new file mode 100644 index 00000000..f039c938 --- /dev/null +++ b/Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlot.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 266607c6e4de4c93a609c84e110a8ed1 +timeCreated: 1718028949 \ No newline at end of file diff --git a/Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlotInstance.cs b/Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlotInstance.cs new file mode 100644 index 00000000..c469a9b3 --- /dev/null +++ b/Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlotInstance.cs @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using UnityEngine; + +namespace GLTFast +{ + interface IMaterialsVariantsSlotInstance + { + Task ApplyMaterialsVariantAsync( + int variantIndex, + IMaterialProvider materialProvider, + List materials, + CancellationToken cancellationToken + ); + } +} diff --git a/Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlotInstance.cs.meta b/Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlotInstance.cs.meta new file mode 100644 index 00000000..c0580b0f --- /dev/null +++ b/Runtime/Scripts/MaterialsVariants/IMaterialsVariantsSlotInstance.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 119d662d0bf54ab2a3c2579b111ae03e +timeCreated: 1718098022 \ No newline at end of file diff --git a/Runtime/Scripts/MaterialsVariants/MaterialsVariantsComponent.cs b/Runtime/Scripts/MaterialsVariants/MaterialsVariantsComponent.cs new file mode 100644 index 00000000..3daf11db --- /dev/null +++ b/Runtime/Scripts/MaterialsVariants/MaterialsVariantsComponent.cs @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System; +using UnityEngine; + +namespace GLTFast +{ + /// + /// Wraps a and provides access to it. + /// + public class MaterialsVariantsComponent : MonoBehaviour + { + /// + /// Materials variants control instance. + /// + [field: SerializeField] + public MaterialsVariantsControl Control { get; set; } + } +} diff --git a/Runtime/Scripts/MaterialsVariants/MaterialsVariantsComponent.cs.meta b/Runtime/Scripts/MaterialsVariants/MaterialsVariantsComponent.cs.meta new file mode 100644 index 00000000..275f7850 --- /dev/null +++ b/Runtime/Scripts/MaterialsVariants/MaterialsVariantsComponent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7fc354af441a35b4eab3dd86d3f8d513 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 3b6a1cb26d29941f2a3cc902680e2e03, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Scripts/MaterialsVariants/MaterialsVariantsControl.cs b/Runtime/Scripts/MaterialsVariants/MaterialsVariantsControl.cs new file mode 100644 index 00000000..49c0f856 --- /dev/null +++ b/Runtime/Scripts/MaterialsVariants/MaterialsVariantsControl.cs @@ -0,0 +1,57 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using UnityEngine; + +namespace GLTFast +{ + /// + /// Allows switching the materials variant of a glTF scene instance. + /// + /// KHR_materials_variants extension + public class MaterialsVariantsControl : IMaterialsVariantsProvider + { + IMaterialProvider m_MaterialProvider; + IReadOnlyCollection m_Slots; + + int m_CurrentVariantIndex; + + internal MaterialsVariantsControl(IMaterialProvider materialProvider, IReadOnlyCollection slots) + { + m_MaterialProvider = materialProvider; + m_Slots = slots; + } + + /// + /// Applies a materials variant. + /// + /// glTF materials variant index. + /// Token to submit cancellation requests. The default value is None. + /// A task that represents the completion of the method. + public async Task ApplyMaterialsVariantAsync(int variantIndex, CancellationToken cancellationToken = default) + { + var materials = new List(); + var tasks = new List(); + foreach (var instanceSlot in m_Slots) + { + tasks.Add(instanceSlot.ApplyMaterialsVariantAsync(variantIndex, m_MaterialProvider, materials, cancellationToken)); + } + + await Task.WhenAll(tasks); + m_CurrentVariantIndex = variantIndex; + } + + /// + public int MaterialsVariantsCount => m_MaterialProvider.MaterialsVariantsCount; + + /// + public string GetMaterialsVariantName(int index) + { + return m_MaterialProvider.GetMaterialsVariantName(index); + } + } +} diff --git a/Runtime/Scripts/MaterialsVariants/MaterialsVariantsControl.cs.meta b/Runtime/Scripts/MaterialsVariants/MaterialsVariantsControl.cs.meta new file mode 100644 index 00000000..beb7bcb9 --- /dev/null +++ b/Runtime/Scripts/MaterialsVariants/MaterialsVariantsControl.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 15f39b36569a4f9999bd276e9734d6da +timeCreated: 1718028990 \ No newline at end of file diff --git a/Runtime/Scripts/MaterialsVariants/MaterialsVariantsSlotInstances.cs b/Runtime/Scripts/MaterialsVariants/MaterialsVariantsSlotInstances.cs new file mode 100644 index 00000000..9f37da61 --- /dev/null +++ b/Runtime/Scripts/MaterialsVariants/MaterialsVariantsSlotInstances.cs @@ -0,0 +1,69 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using UnityEngine; + +namespace GLTFast +{ + readonly struct MaterialsVariantsSlotInstances : IMaterialsVariantsSlotInstance + { + readonly Renderer m_Renderer; + + readonly IMaterialsVariantsSlot[] m_Slots; + + public MaterialsVariantsSlotInstances(Renderer renderer, IMaterialsVariantsSlot[] slots) + { + m_Renderer = renderer; + m_Slots = slots; + } + + public async Task ApplyMaterialsVariantAsync( + int variantIndex, + IMaterialProvider materialProvider, + List materials, + CancellationToken cancellationToken + ) + { + m_Renderer.GetSharedMaterials(materials); + Dictionary, int> getMaterialTasks = null; + Task getDefaultMaterialTask = null; + for (var subMesh = 0; subMesh < m_Slots.Length; subMesh++) + { + var slot = m_Slots[subMesh]; + var materialId = slot.GetMaterialIndex(variantIndex); + materials[subMesh] = null; + Task task; + if (materialId < 0) + { + getDefaultMaterialTask ??= materialProvider.GetDefaultMaterialAsync(cancellationToken); + task = getDefaultMaterialTask; + } + else + { + task = materialProvider.GetMaterialAsync(materialId, cancellationToken); + } + getMaterialTasks ??= new Dictionary, int>(); + getMaterialTasks[task] = subMesh; + } + + if (getMaterialTasks != null) + { + while (getMaterialTasks.Count > 0) + { + var task = await Task.WhenAny(getMaterialTasks.Keys); + materials[getMaterialTasks[task]] = task.Result; + getMaterialTasks.Remove(task); + } + } +#if UNITY_2022_2_OR_NEWER + m_Renderer.SetSharedMaterials(materials); +#else + m_Renderer.sharedMaterials = materials.ToArray(); +#endif + } + } +} diff --git a/Runtime/Scripts/MaterialsVariants/MaterialsVariantsSlotInstances.cs.meta b/Runtime/Scripts/MaterialsVariants/MaterialsVariantsSlotInstances.cs.meta new file mode 100644 index 00000000..26e01c6a --- /dev/null +++ b/Runtime/Scripts/MaterialsVariants/MaterialsVariantsSlotInstances.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f06acd2926d54cfe8dd39f82cc6d403a +timeCreated: 1718028977 \ No newline at end of file diff --git a/Runtime/Scripts/MaterialsVariants/MultiMaterialsVariantsSlotInstances.cs b/Runtime/Scripts/MaterialsVariants/MultiMaterialsVariantsSlotInstances.cs new file mode 100644 index 00000000..cf195f45 --- /dev/null +++ b/Runtime/Scripts/MaterialsVariants/MultiMaterialsVariantsSlotInstances.cs @@ -0,0 +1,84 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using UnityEngine; + +namespace GLTFast +{ + readonly struct MultiMaterialsVariantsSlotInstances : IMaterialsVariantsSlotInstance + { + readonly IEnumerable m_Renderers; + + readonly IReadOnlyList m_Slots; + + public MultiMaterialsVariantsSlotInstances(IEnumerable renderers, IReadOnlyList slots) + { + m_Renderers = renderers; + m_Slots = slots; + } + + public async Task ApplyMaterialsVariantAsync( + int variantIndex, + IMaterialProvider materialProvider, + List materials, + CancellationToken cancellationToken + ) + { + var firstIteration = true; +#if !UNITY_2022_2_OR_NEWER + Material[] materialsArray = null; +#endif + foreach (var renderer in m_Renderers) + { + if (firstIteration) + { + renderer.GetSharedMaterials(materials); + Dictionary, int> getMaterialTasks = null; + Task getDefaultMaterialTask = null; + for (var subMesh = 0; subMesh < m_Slots.Count; subMesh++) + { + var slot = m_Slots[subMesh]; + var materialId = slot.GetMaterialIndex(variantIndex); + Task task; + materials[subMesh] = null; + if (materialId < 0) + { + getDefaultMaterialTask ??= materialProvider.GetDefaultMaterialAsync(cancellationToken); + task = getDefaultMaterialTask; + } + else + { + task = materialProvider.GetMaterialAsync(materialId, cancellationToken); + } + getMaterialTasks ??= new Dictionary, int>(); + getMaterialTasks[task] = subMesh; + } + + if (getMaterialTasks != null) + { + while (getMaterialTasks.Count > 0) + { + var task = await Task.WhenAny(getMaterialTasks.Keys); + materials[getMaterialTasks[task]] = task.Result; + getMaterialTasks.Remove(task); + } + } + +#if !UNITY_2022_2_OR_NEWER + materialsArray = materials.ToArray(); +#endif + firstIteration = false; + } +#if UNITY_2022_2_OR_NEWER + renderer.SetSharedMaterials(materials); +#else + renderer.sharedMaterials = materialsArray; +#endif + } + } + } +} diff --git a/Runtime/Scripts/MaterialsVariants/MultiMaterialsVariantsSlotInstances.cs.meta b/Runtime/Scripts/MaterialsVariants/MultiMaterialsVariantsSlotInstances.cs.meta new file mode 100644 index 00000000..564400be --- /dev/null +++ b/Runtime/Scripts/MaterialsVariants/MultiMaterialsVariantsSlotInstances.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c6aa6418ed574092ab2e55c01bb51b08 +timeCreated: 1718098054 \ No newline at end of file diff --git a/Runtime/Scripts/Schema/MaterialsVariantsExtension.cs b/Runtime/Scripts/Schema/MaterialsVariantsExtension.cs index 817b267a..4c6279d6 100644 --- a/Runtime/Scripts/Schema/MaterialsVariantsExtension.cs +++ b/Runtime/Scripts/Schema/MaterialsVariantsExtension.cs @@ -62,6 +62,32 @@ public class MaterialsVariantsMeshPrimitiveExtension /// public List mappings; + /// + /// Retrieves the index of the material that corresponds to a material variant. + /// If there's no match for this variant index, it returns false. In this case the default material has to be + /// applied. + /// + /// glTF materials variant index. + /// glTF material index. + /// True if there's a matching mapping with the provided variant index. False otherwise. + public bool TryGetMaterialIndex(int variantIndex, out int materialIndex) + { + foreach (var mapping in mappings) + { + foreach (var i in mapping.variants) + { + if (variantIndex == i) + { + materialIndex = mapping.material; + return true; + } + } + } + + materialIndex = -1; + return false; + } + internal void GltfSerialize(JsonWriter writer) { writer.AddObject(); diff --git a/Runtime/Scripts/Schema/MeshPrimitive.cs b/Runtime/Scripts/Schema/MeshPrimitive.cs index 1b91b3da..648a5b9a 100644 --- a/Runtime/Scripts/Schema/MeshPrimitive.cs +++ b/Runtime/Scripts/Schema/MeshPrimitive.cs @@ -55,7 +55,7 @@ internal override void UnsetExtensions() /// Geometry to be rendered with the given material. /// [Serializable] - public abstract class MeshPrimitiveBase : ICloneable + public abstract class MeshPrimitiveBase : ICloneable, IMaterialsVariantsSlot { /// @@ -98,6 +98,17 @@ public abstract class MeshPrimitiveBase : ICloneable /// public abstract MeshPrimitiveExtensions Extensions { get; } + /// + public int GetMaterialIndex(int variantIndex) + { + var mapping = Extensions?.KHR_materials_variants; + if (mapping != null && mapping.TryGetMaterialIndex(variantIndex, out var materialIndex)) + { + return materialIndex; + } + return material; + } + /// ` /// Sets to null. /// diff --git a/Runtime/Scripts/Schema/Root.cs b/Runtime/Scripts/Schema/Root.cs index c774a3c5..95be6585 100644 --- a/Runtime/Scripts/Schema/Root.cs +++ b/Runtime/Scripts/Schema/Root.cs @@ -628,5 +628,28 @@ public virtual void JsonUtilityCleanup() UnsetExtensions(); } } + + /// + /// Number of materials variants. + /// + /// + public int MaterialsVariantsCount => Extensions?.KHR_materials_variants?.variants?.Count ?? 0; + + /// + /// Gets the name of a specific materials variant. + /// + /// Materials variant index. + /// Name of a materials variant. + /// + public string GetMaterialsVariantName(int index) + { + var variants = Extensions?.KHR_materials_variants?.variants; + if (variants != null && index >= 0 && index < variants.Count) + { + return variants[index].name; + } + + return null; + } } } diff --git a/Samples/Documentation/Manual/MultipleInstances.cs b/Samples/Documentation/Manual/MultipleInstances.cs new file mode 100644 index 00000000..ef40e8d8 --- /dev/null +++ b/Samples/Documentation/Manual/MultipleInstances.cs @@ -0,0 +1,60 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using GLTFast; + +#if NEWTONSOFT_JSON +namespace Samples.Documentation.Manual +{ +#region MultipleInstances + using System; + using UnityEngine; + using GltfImport = GLTFast.Newtonsoft.GltfImport; + + public class MultipleInstances : MonoBehaviour + { + // Path to the gltf asset to be imported + public string Uri; + + [Range(1,10)] + public int quantity = 3; + + async void Start() + { + try + { + var gltfImport = new GltfImport(); + await gltfImport.Load(Uri); + + for (var i = 0; i < quantity; i++) + { + var go = new GameObject($"glTF-{i}") + { + transform = + { + localPosition = new Vector3(0, 0, i * .13f) + } + }; + var instantiator = new GameObjectInstantiator(gltfImport, go.transform); + await gltfImport.InstantiateMainSceneAsync(instantiator); + var scene = instantiator.SceneInstance; + var materialsVariantsControl = scene.MaterialsVariantsControl; + + if (materialsVariantsControl != null) + { + var materialsVariantsComponent = go.AddComponent(); + materialsVariantsComponent.Control = materialsVariantsControl; + + await materialsVariantsControl.ApplyMaterialsVariantAsync(i%gltfImport.MaterialsVariantsCount); + } + } + } + catch (Exception e) + { + Debug.LogException(e); + } + } + } +#endregion +} +#endif diff --git a/Samples/Documentation/Manual/MultipleInstances.cs.meta b/Samples/Documentation/Manual/MultipleInstances.cs.meta new file mode 100644 index 00000000..21631022 --- /dev/null +++ b/Samples/Documentation/Manual/MultipleInstances.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5eb4588209c214a4e8be0ac7a9f33729 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Runtime/Scripts/Import/MaterialProviderMock.cs b/Tests/Runtime/Scripts/Import/MaterialProviderMock.cs new file mode 100644 index 00000000..124bed9a --- /dev/null +++ b/Tests/Runtime/Scripts/Import/MaterialProviderMock.cs @@ -0,0 +1,61 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System; +using System.Threading; +using System.Threading.Tasks; +using UnityEngine; + +namespace GLTFast.Tests +{ + class MaterialProviderMock : IMaterialProvider + { + public Material GetMaterial(int index = 0) + { + return new Material(Shader.Find("Standard")) + { + name = index.ToString() + }; + } + + public Task GetMaterialAsync(int index) + { + return Task.FromResult(GetMaterial(index)); + } + + public Task GetMaterialAsync(int index, CancellationToken cancellationToken) + { + return Task.FromResult(GetMaterial(index)); + } + + public Task GetDefaultMaterialAsync() + { + return Task.FromResult(GetDefaultMaterial()); + } + + public Task GetDefaultMaterialAsync(CancellationToken cancellationToken) + { + return Task.FromResult(GetDefaultMaterial()); + } + + public Material GetDefaultMaterial() + { + return new Material(Shader.Find("Standard")) + { + name = "Default" + }; + } + + public int MaterialsVariantsCount => 6; + + public string GetMaterialsVariantName(int index) + { + return $"Variant {index}"; + } + + public IMaterialsVariantsSlot[] GetMaterialsVariantsSlots(int meshIndex, int meshResultOffset) + { + throw new System.NotImplementedException(); + } + } +} diff --git a/Tests/Runtime/Scripts/Import/MaterialProviderMock.cs.meta b/Tests/Runtime/Scripts/Import/MaterialProviderMock.cs.meta new file mode 100644 index 00000000..a6836245 --- /dev/null +++ b/Tests/Runtime/Scripts/Import/MaterialProviderMock.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 602fb593804b4075a18988c3c9cedff7 +timeCreated: 1718274207 \ No newline at end of file diff --git a/Tests/Runtime/Scripts/Import/MaterialsVariantsTests.cs b/Tests/Runtime/Scripts/Import/MaterialsVariantsTests.cs new file mode 100644 index 00000000..598704e0 --- /dev/null +++ b/Tests/Runtime/Scripts/Import/MaterialsVariantsTests.cs @@ -0,0 +1,157 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System.Collections; +using System.Collections.Generic; +using GLTFast.Schema; +using NUnit.Framework; +using UnityEngine; +using UnityEngine.TestTools; +using Material = UnityEngine.Material; + +namespace GLTFast.Tests +{ + class MaterialsVariantsTests + { + const int k_SubMeshCount = 3; + + [UnityTest] + public IEnumerator MaterialsVariantsControlTest() + { + var provider = new MaterialProviderMock(); + var renderer = CreateRenderer(); + var renderers = new MeshRenderer[] + { + CreateRenderer(), + CreateRenderer(), + }; + var slots = new IMaterialsVariantsSlot[k_SubMeshCount]; + for (var subMesh = 0; subMesh < k_SubMeshCount; subMesh++) + { + slots[subMesh] = CreatePrimitive(subMesh, provider.MaterialsVariantsCount); + } + var slotInstance = new MaterialsVariantsSlotInstances(renderer, slots); + var multiSlotInstance = new MultiMaterialsVariantsSlotInstances(renderers, slots); + var slotInstances = new List { slotInstance, multiSlotInstance }; + var ctrl = new MaterialsVariantsControl(provider, slotInstances); + var go = new GameObject(); + var comp = go.AddComponent(); + comp.Control = ctrl; + + for (var variant = 0; variant < provider.MaterialsVariantsCount; variant++) + { + yield return AsyncWrapper.WaitForTask( + ctrl.ApplyMaterialsVariantAsync(variant) + ); + + AssertMaterials(renderer, variant); + foreach (var r in renderers) + { + AssertMaterials(r, variant); + } + } + + // Reset to default materials + yield return AsyncWrapper.WaitForTask( + comp.Control.ApplyMaterialsVariantAsync(-1) + ); + + AssertDefaultMaterials(renderer); + foreach (var r in renderers) + { + AssertDefaultMaterials(r); + } + } + + static void AssertDefaultMaterials(MeshRenderer renderer) + { + var materials = renderer.sharedMaterials; + Assert.AreEqual("Default", materials[0].name); + for (var subMesh = 1; subMesh < 3; subMesh++) + { + Assert.AreEqual(materials[subMesh].name, subMesh.ToString()); + } + } + + static void AssertMaterials(MeshRenderer renderer, int variant) + { + var materials = renderer.sharedMaterials; + for (var subMesh = 0; subMesh < 3; subMesh++) + { + string actual; + if ((variant + 1) % 3 == 0) + { + actual = subMesh == 0 ? "Default" : subMesh.ToString(); + } + else + { + actual = ((variant + 3) / 3 * 100 + subMesh).ToString(); + } + + if (actual != materials[subMesh].name) + { + + Assert.AreEqual(actual, materials[subMesh].name); + } + } + } + + static MeshRenderer CreateRenderer() + { + var go = new GameObject(); + var renderer = go.AddComponent(); + renderer.sharedMaterials = new Material[k_SubMeshCount]; + return renderer; + } + + static MeshPrimitive CreatePrimitive(int seed, int variantsCount) + { + var result = new MeshPrimitive + { + material = seed == 0 ? -1 : seed, + extensions = new MeshPrimitiveExtensions + { + KHR_materials_variants = new MaterialsVariantsMeshPrimitiveExtension + { + mappings = new List() + } + } + }; + + for (var variant = 0; variant < variantsCount + 2; variant += 3) + { + result.extensions.KHR_materials_variants.mappings.Add( + new MaterialVariantsMapping { material = seed + (variant + 3) / 3 * 100, variants = new[] { variant, variant + 1 } } + ); + } + + return result; + } + + [Test] + public void MaterialsVariantsRootExtensionTest() + { + var root = new Root + { + extensions = new RootExtensions + { + KHR_materials_variants = new MaterialsVariantsRootExtension + { + variants = new List + { + new MaterialsVariant { name = "One" }, + new MaterialsVariant { name = "Two" }, + new MaterialsVariant { name = "Spanish Inquisition" }, + } + } + } + }; + + Assert.AreEqual("One", root.GetMaterialsVariantName(0)); + Assert.AreEqual("Two", root.GetMaterialsVariantName(1)); + Assert.AreEqual("Spanish Inquisition", root.GetMaterialsVariantName(2)); + Assert.IsNull(root.GetMaterialsVariantName(3)); + Assert.IsNull(root.GetMaterialsVariantName(-1)); + } + } +} diff --git a/Tests/Runtime/Scripts/Import/MaterialsVariantsTests.cs.meta b/Tests/Runtime/Scripts/Import/MaterialsVariantsTests.cs.meta new file mode 100644 index 00000000..1cfcca27 --- /dev/null +++ b/Tests/Runtime/Scripts/Import/MaterialsVariantsTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 685708dbbe21e45db850b7d90c8bd1f6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From a07fdf9a6ff4ea55c69e216646433260d20aff0b Mon Sep 17 00:00:00 2001 From: Andreas Atteneder Date: Thu, 20 Jun 2024 23:18:16 +0200 Subject: [PATCH 04/10] feat: Serialization support for material extensions IOR, Sheen and Specular. (#159) * feat: Added missing extension `MeshoptCompression`. * doc: Reduced redundancies in XML docs. * fix: Corrected XML doc inheritances. --- CHANGELOG.md | 1 + Runtime/Scripts/Extensions.cs | 78 ++++++------ .../Schema/FakeSchema/MaterialExtension.cs | 2 + Runtime/Scripts/Schema/MaterialExtensions.cs | 24 +++- Runtime/Scripts/Schema/MaterialIor.cs | 39 ++++++ Runtime/Scripts/Schema/MaterialIor.cs.meta | 11 ++ Runtime/Scripts/Schema/MaterialSheen.cs | 43 ++++++- Runtime/Scripts/Schema/MaterialSpecular.cs | 82 ++++++++++++ .../Scripts/Schema/MaterialSpecular.cs.meta | 11 ++ Runtime/Scripts/Schema/Root.cs | 10 ++ .../Scripts/JsonParsing/JsonParsingTests.cs | 59 ++++++++- .../Scripts/JsonParsing/JsonWriterTests.cs | 120 ++++++++++++++++++ 12 files changed, 429 insertions(+), 51 deletions(-) create mode 100644 Runtime/Scripts/Schema/MaterialIor.cs create mode 100644 Runtime/Scripts/Schema/MaterialIor.cs.meta create mode 100644 Runtime/Scripts/Schema/MaterialSpecular.cs create mode 100644 Runtime/Scripts/Schema/MaterialSpecular.cs.meta diff --git a/CHANGELOG.md b/CHANGELOG.md index 807a392a..b22720f5 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 - (Import) Support for [materials variants extension](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_variants). +- Serialization support for material extensions IOR, Sheen and Specular. ### Changed - (Import) Prefabs imported from glTF assets (at design-time) don't have the glTF logo icon assigned to them anymore. This makes it more consistent with other file types (like FBX; fixes [#557](https://github.com/atteneder/glTFast/issues/557)). diff --git a/Runtime/Scripts/Extensions.cs b/Runtime/Scripts/Extensions.cs index 4ea9aa80..66dee807 100644 --- a/Runtime/Scripts/Extensions.cs +++ b/Runtime/Scripts/Extensions.cs @@ -53,6 +53,22 @@ public enum Extension /// KHR_materials_variants glTF extension /// MaterialsVariants, + /// + /// EXT_meshopt_compression glTF extension + /// + MeshoptCompression, + /// + /// KHR_materials_ior glTF extension + /// + MaterialsIor, + /// + /// KHR_materials_sheen glTF extension + /// + MaterialsSheen, + /// + /// KHR_materials_specular glTF extension + /// + MaterialsSpecular, } /// @@ -60,53 +76,35 @@ public enum Extension /// public static class ExtensionName { - /// - /// KHR_draco_mesh_compression glTF extension - /// + /// public const string DracoMeshCompression = "KHR_draco_mesh_compression"; - /// - /// KHR_materials_pbrSpecularGlossiness glTF extension - /// + /// public const string MaterialsPbrSpecularGlossiness = "KHR_materials_pbrSpecularGlossiness"; - /// - /// KHR_materials_transmission glTF extension - /// + /// public const string MaterialsTransmission = "KHR_materials_transmission"; - /// - /// KHR_materials_unlit glTF extension - /// + /// public const string MaterialsUnlit = "KHR_materials_unlit"; - /// - /// EXT_mesh_gpu_instancing glTF extension - /// + /// public const string MeshGPUInstancing = "EXT_mesh_gpu_instancing"; - /// - /// EXT_meshopt_compression glTF extension - /// + /// public const string MeshoptCompression = "EXT_meshopt_compression"; - /// - /// KHR_mesh_quantization glTF extension - /// + /// public const string MeshQuantization = "KHR_mesh_quantization"; - /// - /// KHR_texture_basisu glTF extension - /// + /// public const string TextureBasisUniversal = "KHR_texture_basisu"; - /// - /// KHR_texture_transform glTF extension - /// + /// public const string TextureTransform = "KHR_texture_transform"; - /// - /// KHR_lights_punctual glTF extension - /// + /// public const string LightsPunctual = "KHR_lights_punctual"; - /// - /// KHR_materials_clearcoat glTF extension - /// + /// public const string MaterialsClearcoat = "KHR_materials_clearcoat"; - /// - /// KHR_materials_variants glTF extension - /// + /// + public const string MaterialsIor = "KHR_materials_ior"; + /// + public const string MaterialsSheen = "KHR_materials_sheen"; + /// + public const string MaterialsSpecular = "KHR_materials_specular"; + /// public const string MaterialsVariants = "KHR_materials_variants"; /// @@ -140,6 +138,14 @@ public static string GetName(this Extension extension) return MaterialsClearcoat; case Extension.MaterialsVariants: return MaterialsVariants; + case Extension.MeshoptCompression: + return MeshoptCompression; + case Extension.MaterialsIor: + return MaterialsIor; + case Extension.MaterialsSpecular: + return MaterialsSpecular; + case Extension.MaterialsSheen: + return MaterialsSheen; default: return null; } diff --git a/Runtime/Scripts/Schema/FakeSchema/MaterialExtension.cs b/Runtime/Scripts/Schema/FakeSchema/MaterialExtension.cs index 35d8f703..52f852f8 100644 --- a/Runtime/Scripts/Schema/FakeSchema/MaterialExtension.cs +++ b/Runtime/Scripts/Schema/FakeSchema/MaterialExtension.cs @@ -13,6 +13,8 @@ class MaterialExtension public string KHR_materials_transmission; public string KHR_materials_clearcoat; public string KHR_materials_sheen; + public string KHR_materials_ior; + public string KHR_materials_specular; // ReSharper restore InconsistentNaming } } diff --git a/Runtime/Scripts/Schema/MaterialExtensions.cs b/Runtime/Scripts/Schema/MaterialExtensions.cs index f1a2266b..6a32d18a 100644 --- a/Runtime/Scripts/Schema/MaterialExtensions.cs +++ b/Runtime/Scripts/Schema/MaterialExtensions.cs @@ -18,18 +18,24 @@ public class MaterialExtensions /// public PbrSpecularGlossiness KHR_materials_pbrSpecularGlossiness; - /// + /// public MaterialUnlit KHR_materials_unlit; - /// + /// public Transmission KHR_materials_transmission; - /// + /// public ClearCoat KHR_materials_clearcoat; - /// + /// public Sheen KHR_materials_sheen; + /// + public MaterialSpecular KHR_materials_specular; + + /// + public MaterialIor KHR_materials_ior; + // ReSharper restore InconsistentNaming internal void GltfSerialize(JsonWriter writer) @@ -60,6 +66,16 @@ internal void GltfSerialize(JsonWriter writer) writer.AddProperty("KHR_materials_sheen"); KHR_materials_sheen.GltfSerialize(writer); } + if (KHR_materials_specular != null) + { + writer.AddProperty("KHR_materials_specular"); + KHR_materials_specular.GltfSerialize(writer); + } + if (KHR_materials_ior != null) + { + writer.AddProperty("KHR_materials_ior"); + KHR_materials_ior.GltfSerialize(writer); + } writer.Close(); } } diff --git a/Runtime/Scripts/Schema/MaterialIor.cs b/Runtime/Scripts/Schema/MaterialIor.cs new file mode 100644 index 00000000..8a5178af --- /dev/null +++ b/Runtime/Scripts/Schema/MaterialIor.cs @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System; +using Unity.Mathematics; + +namespace GLTFast.Schema +{ + /// + /// The dielectric BRDF of the metallic-roughness material in glTF uses a fixed value of 1.5 for the index of + /// refraction. This is a good fit for many plastics and glass, but not for other materials like water or asphalt, + /// sapphire or diamond. This extension allows users to set the index of refraction to a certain value. + /// + /// + [Serializable] + public class MaterialIor + { + /// + /// Default index of refraction. A good compromise for most opaque, dielectric materials. + /// + /// + public const float defaultIndexOfRefraction = 1.5f; + + /// + /// The index of refraction. + /// + public float ior = defaultIndexOfRefraction; + + internal void GltfSerialize(JsonWriter writer) + { + writer.AddObject(); + if (math.abs(ior - defaultIndexOfRefraction) > Constants.epsilon) + { + writer.AddProperty("ior", ior); + } + writer.Close(); + } + } +} diff --git a/Runtime/Scripts/Schema/MaterialIor.cs.meta b/Runtime/Scripts/Schema/MaterialIor.cs.meta new file mode 100644 index 00000000..bb6297b5 --- /dev/null +++ b/Runtime/Scripts/Schema/MaterialIor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 22b112ac537d34054a2057faa49ac80f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Scripts/Schema/MaterialSheen.cs b/Runtime/Scripts/Schema/MaterialSheen.cs index 184aca01..5b5f5c45 100644 --- a/Runtime/Scripts/Schema/MaterialSheen.cs +++ b/Runtime/Scripts/Schema/MaterialSheen.cs @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: 2023 Unity Technologies and the glTFast authors // SPDX-License-Identifier: Apache-2.0 +using Unity.Mathematics; using UnityEngine; namespace GLTFast.Schema @@ -25,12 +26,19 @@ public class Sheen /// /// The sheen color in linear space. /// - public Color SheenColor => - new Color( - sheenColorFactor[0], - sheenColorFactor[1], - sheenColorFactor[2] - ); + public Color SheenColor + { + get => + new Color( + sheenColorFactor[0], + sheenColorFactor[1], + sheenColorFactor[2] + ); + set + { + sheenColorFactor = new[] { value.r, value.g, value.b }; + } + } /// /// The sheen color texture. @@ -50,8 +58,29 @@ public class Sheen internal void GltfSerialize(JsonWriter writer) { writer.AddObject(); + if (sheenColorFactor != null && sheenColorFactor.Length > 2 && ( + math.abs(sheenColorFactor[0] - 1f) > Constants.epsilon || + math.abs(sheenColorFactor[1] - 1f) > Constants.epsilon || + math.abs(sheenColorFactor[2] - 1f) > Constants.epsilon + )) + { + writer.AddArrayProperty("sheenColorFactor", sheenColorFactor); + } + if (sheenColorTexture != null) + { + writer.AddProperty("sheenColorTexture"); + sheenColorTexture.GltfSerialize(writer); + } + if (sheenRoughnessFactor > 0) + { + writer.AddProperty("sheenRoughnessFactor", sheenRoughnessFactor); + } + if (sheenRoughnessTexture != null) + { + writer.AddProperty("sheenRoughnessTexture"); + sheenRoughnessTexture.GltfSerialize(writer); + } writer.Close(); - throw new System.NotImplementedException($"GltfSerialize missing on {GetType()}"); } } } diff --git a/Runtime/Scripts/Schema/MaterialSpecular.cs b/Runtime/Scripts/Schema/MaterialSpecular.cs new file mode 100644 index 00000000..18f1c241 --- /dev/null +++ b/Runtime/Scripts/Schema/MaterialSpecular.cs @@ -0,0 +1,82 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System; +using Unity.Mathematics; +using UnityEngine; + +namespace GLTFast.Schema +{ + /// + /// This extension allows configuring the specular reflection. + /// + /// + [Serializable] + public class MaterialSpecular + { + /// + /// The strength of the specular reflection. + /// + public float specularFactor = 1f; + + /// + /// A texture that defines the strength of the specular reflection, stored in the alpha (A) channel. + /// This will be multiplied by specularFactor. + /// + public TextureInfo specularTexture; + + /// + /// The F0 color of the specular reflection (linear RGB). + /// + public float[] specularColorFactor = { 1, 1, 1 }; + + /// + public Color SpecularColor + { + get => + new Color( + specularColorFactor[0], + specularColorFactor[1], + specularColorFactor[2] + ); + set + { + specularColorFactor = new[] { value.r, value.g, value.b }; + } + } + + /// + /// A texture that defines the F0 color of the specular reflection, stored in the RGB channels and encoded in + /// sRGB. This texture will be multiplied by specularColorFactor. + /// + public TextureInfo specularColorTexture; + + internal void GltfSerialize(JsonWriter writer) + { + writer.AddObject(); + if (math.abs(specularFactor - 1f) > Constants.epsilon) + { + writer.AddProperty("specularFactor", specularFactor); + } + if (specularTexture != null) + { + writer.AddProperty("specularTexture"); + specularTexture.GltfSerialize(writer); + } + if (specularColorFactor != null && specularColorFactor.Length > 2 && ( + math.abs(specularColorFactor[0] - 1f) > Constants.epsilon || + math.abs(specularColorFactor[1] - 1f) > Constants.epsilon || + math.abs(specularColorFactor[2] - 1f) > Constants.epsilon + )) + { + writer.AddArrayProperty("specularColorFactor", specularColorFactor); + } + if (specularColorTexture != null) + { + writer.AddProperty("specularColorTexture"); + specularColorTexture.GltfSerialize(writer); + } + writer.Close(); + } + } +} diff --git a/Runtime/Scripts/Schema/MaterialSpecular.cs.meta b/Runtime/Scripts/Schema/MaterialSpecular.cs.meta new file mode 100644 index 00000000..8dc5a841 --- /dev/null +++ b/Runtime/Scripts/Schema/MaterialSpecular.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 703b3e092576b4966bde5beebac9521b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Scripts/Schema/Root.cs b/Runtime/Scripts/Schema/Root.cs index 95be6585..a9e30a72 100644 --- a/Runtime/Scripts/Schema/Root.cs +++ b/Runtime/Scripts/Schema/Root.cs @@ -567,6 +567,16 @@ internal void JsonUtilityCleanupAgainstSecondParse(FakeSchema.Root fakeRoot) { mat.Extensions.KHR_materials_sheen = null; } + + if (fake.KHR_materials_ior == null) + { + mat.Extensions.KHR_materials_ior = null; + } + + if (fake.KHR_materials_specular == null) + { + mat.Extensions.KHR_materials_specular = null; + } } } diff --git a/Tests/Runtime/Scripts/JsonParsing/JsonParsingTests.cs b/Tests/Runtime/Scripts/JsonParsing/JsonParsingTests.cs index ca9f5b7e..a506de45 100644 --- a/Tests/Runtime/Scripts/JsonParsing/JsonParsingTests.cs +++ b/Tests/Runtime/Scripts/JsonParsing/JsonParsingTests.cs @@ -60,6 +60,18 @@ public void MaterialExtensions() ""KHR_materials_sheen"": {} } }, + { + ""name"" : ""ior"", + ""extensions"": { + ""KHR_materials_ior"": {} + } + }, + { + ""name"" : ""specular"", + ""extensions"": { + ""KHR_materials_specular"": {} + } + }, { ""name"" : ""all"", ""extensions"": { @@ -67,7 +79,9 @@ public void MaterialExtensions() ""KHR_materials_pbrSpecularGlossiness"": {}, ""KHR_materials_transmission"": {}, ""KHR_materials_clearcoat"": {}, - ""KHR_materials_sheen"": {} + ""KHR_materials_sheen"": {}, + ""KHR_materials_ior"": {}, + ""KHR_materials_specular"": {} } } ] @@ -77,7 +91,7 @@ public void MaterialExtensions() Assert.NotNull(gltf); Assert.NotNull(gltf.Materials, "No materials"); - Assert.AreEqual(8, gltf.Materials.Count, "Invalid material quantity"); + Assert.AreEqual(10, gltf.Materials.Count, "Invalid material quantity"); var none = gltf.Materials[0]; Assert.NotNull(none); @@ -93,6 +107,8 @@ public void MaterialExtensions() Assert.IsNull(empty.Extensions.KHR_materials_clearcoat); Assert.IsNull(empty.Extensions.KHR_materials_sheen); Assert.IsNull(empty.Extensions.KHR_materials_transmission); + Assert.IsNull(empty.Extensions.KHR_materials_ior); + Assert.IsNull(empty.Extensions.KHR_materials_specular); var unlit = gltf.Materials[2]; Assert.NotNull(unlit); @@ -103,6 +119,8 @@ public void MaterialExtensions() Assert.IsNull(unlit.Extensions.KHR_materials_clearcoat); Assert.IsNull(unlit.Extensions.KHR_materials_sheen); Assert.IsNull(unlit.Extensions.KHR_materials_transmission); + Assert.IsNull(unlit.Extensions.KHR_materials_ior); + Assert.IsNull(unlit.Extensions.KHR_materials_specular); var specGloss = gltf.Materials[3]; Assert.NotNull(specGloss); @@ -113,6 +131,8 @@ public void MaterialExtensions() Assert.IsNull(specGloss.Extensions.KHR_materials_clearcoat); Assert.IsNull(specGloss.Extensions.KHR_materials_sheen); Assert.IsNull(specGloss.Extensions.KHR_materials_transmission); + Assert.IsNull(specGloss.Extensions.KHR_materials_ior); + Assert.IsNull(specGloss.Extensions.KHR_materials_specular); var transmission = gltf.Materials[4]; Assert.NotNull(transmission); @@ -123,6 +143,8 @@ public void MaterialExtensions() Assert.IsNull(transmission.Extensions.KHR_materials_clearcoat); Assert.IsNull(transmission.Extensions.KHR_materials_sheen); Assert.NotNull(transmission.Extensions.KHR_materials_transmission); + Assert.IsNull(transmission.Extensions.KHR_materials_ior); + Assert.IsNull(transmission.Extensions.KHR_materials_specular); var clearcoat = gltf.Materials[5]; Assert.NotNull(clearcoat); @@ -133,6 +155,8 @@ public void MaterialExtensions() Assert.NotNull(clearcoat.Extensions.KHR_materials_clearcoat); Assert.IsNull(clearcoat.Extensions.KHR_materials_sheen); Assert.IsNull(clearcoat.Extensions.KHR_materials_transmission); + Assert.IsNull(clearcoat.Extensions.KHR_materials_ior); + Assert.IsNull(clearcoat.Extensions.KHR_materials_specular); var sheen = gltf.Materials[6]; Assert.NotNull(sheen); @@ -143,8 +167,35 @@ public void MaterialExtensions() Assert.IsNull(sheen.Extensions.KHR_materials_clearcoat); Assert.NotNull(sheen.Extensions.KHR_materials_sheen); Assert.IsNull(sheen.Extensions.KHR_materials_transmission); - - var all = gltf.Materials[7]; + Assert.IsNull(sheen.Extensions.KHR_materials_ior); + Assert.IsNull(sheen.Extensions.KHR_materials_specular); + + + var ior = gltf.Materials[7]; + Assert.NotNull(ior); + Assert.AreEqual("ior", ior.name); + Assert.NotNull(ior.Extensions); + Assert.IsNull(ior.Extensions.KHR_materials_unlit); + Assert.IsNull(ior.Extensions.KHR_materials_pbrSpecularGlossiness); + Assert.IsNull(ior.Extensions.KHR_materials_clearcoat); + Assert.IsNull(ior.Extensions.KHR_materials_sheen); + Assert.IsNull(ior.Extensions.KHR_materials_transmission); + Assert.NotNull(ior.Extensions.KHR_materials_ior); + Assert.IsNull(ior.Extensions.KHR_materials_specular); + + var specular = gltf.Materials[8]; + Assert.NotNull(specular); + Assert.AreEqual("specular", specular.name); + Assert.NotNull(specular.Extensions); + Assert.IsNull(specular.Extensions.KHR_materials_unlit); + Assert.IsNull(specular.Extensions.KHR_materials_pbrSpecularGlossiness); + Assert.IsNull(specular.Extensions.KHR_materials_clearcoat); + Assert.IsNull(specular.Extensions.KHR_materials_sheen); + Assert.IsNull(specular.Extensions.KHR_materials_transmission); + Assert.IsNull(specular.Extensions.KHR_materials_ior); + Assert.NotNull(specular.Extensions.KHR_materials_specular); + + var all = gltf.Materials[9]; Assert.NotNull(all); Assert.AreEqual("all", all.name); Assert.NotNull(all.Extensions); diff --git a/Tests/Runtime/Scripts/JsonParsing/JsonWriterTests.cs b/Tests/Runtime/Scripts/JsonParsing/JsonWriterTests.cs index 3cb34a89..24fdd1f0 100644 --- a/Tests/Runtime/Scripts/JsonParsing/JsonWriterTests.cs +++ b/Tests/Runtime/Scripts/JsonParsing/JsonWriterTests.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json.Linq; using NUnit.Framework; using UnityEngine; +using UnityEngine.TestTools.Utils; namespace GLTFast.Tests.JsonParsing { @@ -150,6 +151,125 @@ public void EscapedArrayValue() ); } + [Test] + public void ExtMaterialSheen() + { + var sheenColor = new Color(.2f, .5f, .7f); + var ext = new Sheen + { + SheenColor = sheenColor, + sheenRoughnessFactor = .42f, + sheenColorTexture = new TextureInfo + { + index = 42, + texCoord = 1, + }, + sheenRoughnessTexture = new TextureInfo + { + index = 43, + texCoord = 2, + } + }; + + Assert.That(ext.SheenColor, Is.EqualTo(sheenColor).Using(ColorEqualityComparer.Instance)); + + var json = CreateJsonTest(writer => + { + writer.AddProperty("ext"); + ext.GltfSerialize(writer); + }); + + Assert.AreEqual( + @"{""ext"":{""sheenColorFactor"":[0.2,0.5,0.7],""sheenColorTexture"":{""index"":42,""texCoord"":1},""sheenRoughnessFactor"":0.42,""sheenRoughnessTexture"":{""index"":43,""texCoord"":2}}}", + json + ); + } + + [Test] + public void ExtMaterialSpecular() + { + var specularColor = new Color(.2f, .5f, .7f); + var ext = new MaterialSpecular() + { + specularFactor = .42f, + specularTexture = new TextureInfo + { + index = 42, + texCoord = 1, + }, + SpecularColor = specularColor, + specularColorTexture = new TextureInfo + { + index = 43, + texCoord = 2, + } + }; + + Assert.That(ext.SpecularColor, Is.EqualTo(specularColor).Using(ColorEqualityComparer.Instance)); + + var json = CreateJsonTest(writer => + { + writer.AddProperty("ext"); + ext.GltfSerialize(writer); + }); + + Assert.AreEqual( + @"{""ext"":{""specularFactor"":0.42,""specularTexture"":{""index"":42,""texCoord"":1},""specularColorFactor"":[0.2,0.5,0.7],""specularColorTexture"":{""index"":43,""texCoord"":2}}}", + json + ); + } + + [Test] + public void ExtMaterialIor() + { + var ext = new MaterialIor() + { + ior = 1.42f + }; + + var json = CreateJsonTest(writer => + { + writer.AddProperty("ext"); + ext.GltfSerialize(writer); + }); + + Assert.AreEqual( + @"{""ext"":{""ior"":1.42}}", + json + ); + } + + [Test] + public void ExtMaterialExtensions() + { + var ext = new MaterialExtensions + { + KHR_materials_sheen = new Sheen + { + sheenRoughnessFactor = .42f + }, + KHR_materials_specular = new MaterialSpecular + { + specularFactor = .43f + }, + KHR_materials_ior = new MaterialIor + { + ior = 1.42f + }, + }; + + var json = CreateJsonTest(writer => + { + writer.AddProperty("ext"); + ext.GltfSerialize(writer); + }); + + Assert.AreEqual( + @"{""ext"":{""KHR_materials_sheen"":{""sheenRoughnessFactor"":0.42},""KHR_materials_specular"":{""specularFactor"":0.43},""KHR_materials_ior"":{""ior"":1.42}}}", + json + ); + } + static string CreateJsonTest(Action func) { var stream = new MemoryStream(); From 7735dad936c127abed064288f927ea24c1691ce2 Mon Sep 17 00:00:00 2001 From: Andreas Atteneder Date: Mon, 24 Jun 2024 17:10:11 +0200 Subject: [PATCH 05/10] fix(export): Base colors are now in correct, linear color space. (#162) * fix(export): Base colors are now in correct, linear color space. * fix: Updated tests and reference values. * fix(test): Increased error tolerance on color property values. Those usually undergo a gamma to linear conversion introducing some error. --- CHANGELOG.md | 3 +++ Runtime/Scripts/Export/GltfMaterialExporter.cs | 8 +------- .../Scripts/Export/GltfUnlitMaterialExporter.cs | 8 +------- .../Export/HighDefinitionMaterialExport.cs | 4 ++-- Runtime/Scripts/Export/MaterialExportBase.cs | 2 +- Runtime/Scripts/Export/StandardMaterialExport.cs | 10 +++++----- Tests/Resources/ExportTargets/Dielectric.gltf.txt | 2 +- .../Resources/ExportTargets/DoubleSided.gltf.txt | 2 +- .../ExportTargets/HDRP/Dielectric.gltf.txt | 2 +- .../ExportTargets/HDRP/DoubleSided.gltf.txt | 2 +- .../MetallicSmoothnessOcclusionTexture.gltf.txt | 2 +- .../HDRP/MetallicSmoothnessTexture.gltf.txt | 2 +- .../ExportTargets/HDRP/MetallicTexture.gltf.txt | 2 +- .../ExportTargets/HDRP/OcclusionTexture.gltf.txt | 2 +- .../HDRP/OcclusionTextureStrength.gltf.txt | 2 +- .../ExportTargets/HDRP/SmoothnessTexture.gltf.txt | 2 +- .../Resources/ExportTargets/HDRP/Submesh.gltf.txt | 2 +- Tests/Resources/ExportTargets/HDRP/Unlit.gltf.txt | 2 +- .../MetallicSmoothnessOcclusionTexture.gltf.txt | 2 +- .../MetallicSmoothnessTexture.gltf.txt | 2 +- .../ExportTargets/MetallicTexture.gltf.txt | 2 +- .../ExportTargets/OcclusionTexture.gltf.txt | 2 +- .../OcclusionTextureStrength.gltf.txt | 2 +- .../ExportTargets/SmoothnessTexture.gltf.txt | 2 +- Tests/Resources/ExportTargets/Submesh.gltf.txt | 2 +- .../ExportTargets/URP/Dielectric.gltf.txt | 2 +- .../ExportTargets/URP/DoubleSided.gltf.txt | 2 +- .../MetallicSmoothnessOcclusionTexture.gltf.txt | 2 +- .../URP/MetallicSmoothnessTexture.gltf.txt | 2 +- .../ExportTargets/URP/MetallicTexture.gltf.txt | 2 +- .../ExportTargets/URP/OcclusionTexture.gltf.txt | 2 +- .../URP/OcclusionTextureStrength.gltf.txt | 2 +- .../ExportTargets/URP/SmoothnessTexture.gltf.txt | 2 +- .../Resources/ExportTargets/URP/Submesh.gltf.txt | 2 +- Tests/Resources/ExportTargets/URP/Unlit.gltf.txt | 2 +- Tests/Resources/ExportTargets/Unlit.gltf.txt | 2 +- Tests/Runtime/Scripts/Export/ExportTests.cs | 15 +++++++++++++-- .../Runtime/Scripts/Export/MaterialExportTests.cs | 6 +++--- 38 files changed, 59 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b22720f5..d71852c0 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 ### Changed - (Import) Prefabs imported from glTF assets (at design-time) don't have the glTF logo icon assigned to them anymore. This makes it more consistent with other file types (like FBX; fixes [#557](https://github.com/atteneder/glTFast/issues/557)). +### Fixed +- (Export) Base colors are now in correct, linear color space. + ## [6.6.0] - 2024-05-29 ### Added diff --git a/Runtime/Scripts/Export/GltfMaterialExporter.cs b/Runtime/Scripts/Export/GltfMaterialExporter.cs index f67ee2e4..19b6ccb9 100644 --- a/Runtime/Scripts/Export/GltfMaterialExporter.cs +++ b/Runtime/Scripts/Export/GltfMaterialExporter.cs @@ -105,13 +105,7 @@ out var textureTransform if (TryGetValue(unityMaterial, MaterialProperty.BaseColor, out Color baseColor)) { - material.pbrMetallicRoughness.baseColorFactor = new[] - { - baseColor.r, - baseColor.g, - baseColor.b, - baseColor.a - }; + material.pbrMetallicRoughness.BaseColor = baseColor.linear; } material = HandleMetallicRoughness(gltf, material, unityMaterial); diff --git a/Runtime/Scripts/Export/GltfUnlitMaterialExporter.cs b/Runtime/Scripts/Export/GltfUnlitMaterialExporter.cs index 3b3f818e..22ff4b03 100644 --- a/Runtime/Scripts/Export/GltfUnlitMaterialExporter.cs +++ b/Runtime/Scripts/Export/GltfUnlitMaterialExporter.cs @@ -81,13 +81,7 @@ out var textureTransform if (GltfMaterialExporter.TryGetValue(unityMaterial, MaterialProperty.BaseColor, out Color baseColor)) { - material.pbrMetallicRoughness.baseColorFactor = new[] - { - baseColor.r, - baseColor.g, - baseColor.b, - baseColor.a - }; + material.pbrMetallicRoughness.BaseColor = baseColor.linear; } return material; diff --git a/Runtime/Scripts/Export/HighDefinitionMaterialExport.cs b/Runtime/Scripts/Export/HighDefinitionMaterialExport.cs index bc992266..7e64d021 100644 --- a/Runtime/Scripts/Export/HighDefinitionMaterialExport.cs +++ b/Runtime/Scripts/Export/HighDefinitionMaterialExport.cs @@ -258,10 +258,10 @@ ICodeLogger logger if (uMaterial.HasProperty(BaseColorProperty)) { - pbr.BaseColor = uMaterial.GetColor(BaseColorProperty); + pbr.BaseColor = uMaterial.GetColor(BaseColorProperty).linear; } else if (uMaterial.HasProperty(ColorProperty)) { - pbr.BaseColor = uMaterial.GetColor(ColorProperty); + pbr.BaseColor = uMaterial.GetColor(ColorProperty).linear; } if(ormImageExport == null && uMaterial.HasProperty(SmoothnessProperty)) { diff --git a/Runtime/Scripts/Export/MaterialExportBase.cs b/Runtime/Scripts/Export/MaterialExportBase.cs index 7139b079..dfb03c7b 100644 --- a/Runtime/Scripts/Export/MaterialExportBase.cs +++ b/Runtime/Scripts/Export/MaterialExportBase.cs @@ -135,7 +135,7 @@ ICodeLogger logger if (GetUnlitColor(uMaterial, out var baseColor)) { - pbr.BaseColor = baseColor; + pbr.BaseColor = baseColor.linear; } if (uMaterial.HasProperty(mainTexProperty)) diff --git a/Runtime/Scripts/Export/StandardMaterialExport.cs b/Runtime/Scripts/Export/StandardMaterialExport.cs index aa4a5367..76c793d7 100644 --- a/Runtime/Scripts/Export/StandardMaterialExport.cs +++ b/Runtime/Scripts/Export/StandardMaterialExport.cs @@ -177,7 +177,7 @@ public override bool ConvertMaterial(UnityEngine.Material uMaterial, out Materia metallicFactor = 0, roughnessFactor = 1.0f, BaseColor = uMaterial.HasProperty(BaseColorProperty) - ? uMaterial.GetColor(BaseColorProperty) + ? uMaterial.GetColor(BaseColorProperty).linear : Color.white }; if (mainTex != null) @@ -191,7 +191,7 @@ public override bool ConvertMaterial(UnityEngine.Material uMaterial, out Materia if (uMaterial.HasProperty(k_TintColor)) { //particles use _TintColor instead of _Color - material.pbrMetallicRoughness.BaseColor = uMaterial.GetColor(k_TintColor); + material.pbrMetallicRoughness.BaseColor = uMaterial.GetColor(k_TintColor).linear; } } @@ -288,12 +288,12 @@ ICodeLogger logger if (uMaterial.HasProperty(BaseColorProperty)) { - pbr.BaseColor = uMaterial.GetColor(BaseColorProperty); + pbr.BaseColor = uMaterial.GetColor(BaseColorProperty).linear; } else if (uMaterial.HasProperty(ColorProperty)) { - pbr.BaseColor = uMaterial.GetColor(ColorProperty); + pbr.BaseColor = uMaterial.GetColor(ColorProperty).linear; } if (uMaterial.HasProperty(k_TintColor)) @@ -306,7 +306,7 @@ ICodeLogger logger white = (c.r + c.g + c.b) / 3.0f; //multiply alpha by overall whiteness of TintColor } - pbr.BaseColor = uMaterial.GetColor(k_TintColor) * white; + pbr.BaseColor = (uMaterial.GetColor(k_TintColor) * white).linear; } if (uMaterial.HasProperty(mainTexProperty)) diff --git a/Tests/Resources/ExportTargets/Dielectric.gltf.txt b/Tests/Resources/ExportTargets/Dielectric.gltf.txt index bd2128d8..6c15d41a 100644 --- a/Tests/Resources/ExportTargets/Dielectric.gltf.txt +++ b/Tests/Resources/ExportTargets/Dielectric.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2020.3.41f1 glTFast 4.8.5"},"nodes":[{"name":"Sphere","mesh":0},{"name":"sphere 1","children":[0]},{"name":"Sphere","mesh":1},{"name":"sphere 2","children":[2],"translation":[0,0,1]},{"name":"Sphere","mesh":2},{"name":"sphere 3","children":[4],"translation":[0,0,2]},{"name":"Sphere","mesh":3},{"name":"sphere 4","children":[6],"translation":[0,0,3]},{"name":"Sphere","mesh":4},{"name":"sphere 5","children":[8],"translation":[0,0,4]},{"name":"Dielectric","children":[1,3,5,7,9],"translation":[-8,0,0]}],"buffers":[{"uri":"Dielectric.bin","byteLength":24576}],"bufferViews":[{"buffer":0,"byteLength":9216},{"buffer":0,"byteLength":11520,"byteOffset":9216,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20736,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":1,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":2304,"type":"SCALAR"}],"materials":[{"name":"Dielectric 1","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.4198113,1,1],"metallicFactor":0,"roughnessFactor":0}},{"name":"Dielectric 2","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.4198113,1,1],"metallicFactor":0,"roughnessFactor":0.25}},{"name":"Dielectric 3","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.4198113,1,1],"metallicFactor":0,"roughnessFactor":0.5}},{"name":"Dielectric 4","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.4198113,1,1],"metallicFactor":0,"roughnessFactor":0.75}},{"name":"Dielectric 5","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.4198113,1,1],"metallicFactor":0}}],"meshes":[{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":1}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":2}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":3}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":4}]}],"scene":0,"scenes":[{"name":"Dielectric","nodes":[10]}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Sphere","mesh":0},{"name":"sphere 1","children":[0]},{"name":"Sphere","mesh":1},{"name":"sphere 2","children":[2],"translation":[0,0,1]},{"name":"Sphere","mesh":2},{"name":"sphere 3","children":[4],"translation":[0,0,2]},{"name":"Sphere","mesh":3},{"name":"sphere 4","children":[6],"translation":[0,0,3]},{"name":"Sphere","mesh":4},{"name":"sphere 5","children":[8],"translation":[0,0,4]},{"name":"Dielectric","children":[1,3,5,7,9],"translation":[-8,0,0]}],"buffers":[{"uri":"Dielectric.bin","byteLength":24576}],"bufferViews":[{"buffer":0,"byteLength":9216},{"buffer":0,"byteLength":11520,"byteOffset":9216,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20736,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":1,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":2304,"type":"SCALAR"}],"materials":[{"name":"Dielectric 1","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.14717856,1,1],"metallicFactor":0,"roughnessFactor":0}},{"name":"Dielectric 2","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.14717856,1,1],"metallicFactor":0,"roughnessFactor":0.25}},{"name":"Dielectric 3","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.14717856,1,1],"metallicFactor":0,"roughnessFactor":0.5}},{"name":"Dielectric 4","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.14717856,1,1],"metallicFactor":0,"roughnessFactor":0.75}},{"name":"Dielectric 5","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.14717856,1,1],"metallicFactor":0}}],"meshes":[{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":1}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":2}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":3}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":4}]}],"scene":0,"scenes":[{"name":"Dielectric","nodes":[10]}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/DoubleSided.gltf.txt b/Tests/Resources/ExportTargets/DoubleSided.gltf.txt index d0551dc0..0919cc18 100644 --- a/Tests/Resources/ExportTargets/DoubleSided.gltf.txt +++ b/Tests/Resources/ExportTargets/DoubleSided.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.12f1 glTFast 4.8.5"},"nodes":[{"name":"DoubleSided","mesh":0,"translation":[-18,0,0],"rotation":[-0.5,-0.5,-0.5,0.5]}],"buffers":[{"uri":"DoubleSided.bin","byteLength":152}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"}],"materials":[{"name":"DoubleSided","pbrMetallicRoughness":{"baseColorFactor":[0,0.0871942043,1,1],"metallicFactor":0,"roughnessFactor":0.7},"doubleSided":true}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]}],"scene":0,"scenes":[{"name":"DoubleSided","nodes":[0]}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"DoubleSided","mesh":0,"translation":[-18,0,0],"rotation":[-0.5,-0.5,-0.5,0.5]}],"buffers":[{"uri":"DoubleSided.bin","byteLength":152}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"}],"materials":[{"name":"DoubleSided","pbrMetallicRoughness":{"baseColorFactor":[0,0.008149115,1,1],"metallicFactor":0,"roughnessFactor":0.7},"doubleSided":true}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]}],"scene":0,"scenes":[{"name":"DoubleSided","nodes":[0]}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/HDRP/Dielectric.gltf.txt b/Tests/Resources/ExportTargets/HDRP/Dielectric.gltf.txt index fc5ff6d9..5ba7e5ec 100644 --- a/Tests/Resources/ExportTargets/HDRP/Dielectric.gltf.txt +++ b/Tests/Resources/ExportTargets/HDRP/Dielectric.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.13f1 glTFast 4.8.5"},"nodes":[{"name":"Sphere","mesh":0},{"name":"sphere 1","children":[0]},{"name":"Sphere","mesh":1},{"name":"sphere 2","children":[2],"translation":[0,0,1]},{"name":"Sphere","mesh":2},{"name":"sphere 3","children":[4],"translation":[0,0,2]},{"name":"Sphere","mesh":3},{"name":"sphere 4","children":[6],"translation":[0,0,3]},{"name":"Sphere","mesh":4},{"name":"sphere 5","children":[8],"translation":[0,0,4]},{"name":"Dielectric","children":[1,3,5,7,9],"translation":[-8,0,0]}],"buffers":[{"uri":"Dielectric.bin","byteLength":24576}],"bufferViews":[{"buffer":0,"byteLength":9216},{"buffer":0,"byteLength":11520,"byteOffset":9216,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20736,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":1,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":2304,"type":"SCALAR"}],"materials":[{"name":"Dielectric 1","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.419811249,1,1],"metallicFactor":0,"roughnessFactor":0}},{"name":"Dielectric 2","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.419811249,1,1],"metallicFactor":0,"roughnessFactor":0.25}},{"name":"Dielectric 3","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.419811249,1,1],"metallicFactor":0,"roughnessFactor":0.5}},{"name":"Dielectric 4","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.419811249,1,1],"metallicFactor":0,"roughnessFactor":0.75}},{"name":"Dielectric 5","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.419811249,1,1],"metallicFactor":0}}],"meshes":[{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":1}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":2}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":3}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":4}]}],"scene":0,"scenes":[{"name":"Dielectric","nodes":[10]}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Sphere","mesh":0},{"name":"sphere 1","children":[0]},{"name":"Sphere","mesh":1},{"name":"sphere 2","children":[2],"translation":[0,0,1]},{"name":"Sphere","mesh":2},{"name":"sphere 3","children":[4],"translation":[0,0,2]},{"name":"Sphere","mesh":3},{"name":"sphere 4","children":[6],"translation":[0,0,3]},{"name":"Sphere","mesh":4},{"name":"sphere 5","children":[8],"translation":[0,0,4]},{"name":"Dielectric","children":[1,3,5,7,9],"translation":[-8,0,0]}],"buffers":[{"uri":"Dielectric.bin","byteLength":24576}],"bufferViews":[{"buffer":0,"byteLength":9216},{"buffer":0,"byteLength":11520,"byteOffset":9216,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20736,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":1,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":2304,"type":"SCALAR"}],"materials":[{"name":"Dielectric 1","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.147178546,1,1],"metallicFactor":0,"roughnessFactor":0}},{"name":"Dielectric 2","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.147178546,1,1],"metallicFactor":0,"roughnessFactor":0.25}},{"name":"Dielectric 3","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.147178546,1,1],"metallicFactor":0,"roughnessFactor":0.5}},{"name":"Dielectric 4","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.147178546,1,1],"metallicFactor":0,"roughnessFactor":0.75}},{"name":"Dielectric 5","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.147178546,1,1],"metallicFactor":0}}],"meshes":[{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":1}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":2}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":3}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":4}]}],"scene":0,"scenes":[{"name":"Dielectric","nodes":[10]}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/HDRP/DoubleSided.gltf.txt b/Tests/Resources/ExportTargets/HDRP/DoubleSided.gltf.txt index 69454f3d..0919cc18 100644 --- a/Tests/Resources/ExportTargets/HDRP/DoubleSided.gltf.txt +++ b/Tests/Resources/ExportTargets/HDRP/DoubleSided.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.13f1 glTFast 4.8.5"},"nodes":[{"name":"DoubleSided","mesh":0,"translation":[-18,0,0],"rotation":[-0.5,-0.5,-0.5,0.5]}],"buffers":[{"uri":"DoubleSided.bin","byteLength":152}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"}],"materials":[{"name":"DoubleSided","pbrMetallicRoughness":{"baseColorFactor":[0,0.08719418,1,1],"metallicFactor":0,"roughnessFactor":0.7},"doubleSided":true}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]}],"scene":0,"scenes":[{"name":"DoubleSided","nodes":[0]}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"DoubleSided","mesh":0,"translation":[-18,0,0],"rotation":[-0.5,-0.5,-0.5,0.5]}],"buffers":[{"uri":"DoubleSided.bin","byteLength":152}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"}],"materials":[{"name":"DoubleSided","pbrMetallicRoughness":{"baseColorFactor":[0,0.008149115,1,1],"metallicFactor":0,"roughnessFactor":0.7},"doubleSided":true}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]}],"scene":0,"scenes":[{"name":"DoubleSided","nodes":[0]}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/HDRP/MetallicSmoothnessOcclusionTexture.gltf.txt b/Tests/Resources/ExportTargets/HDRP/MetallicSmoothnessOcclusionTexture.gltf.txt index ab3f239e..50f21166 100644 --- a/Tests/Resources/ExportTargets/HDRP/MetallicSmoothnessOcclusionTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/HDRP/MetallicSmoothnessOcclusionTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.21f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicSmoothnessOcclusionTexture","children":[0,2],"translation":[-28,0,0]}],"buffers":[{"uri":"MetallicSmoothnessOcclusionTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"MetallicSmoothnessOcclusionTexture_MaskMap.jpg","uri":"MetallicSmoothnessOcclusionTexture_MaskMap.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicSmoothnessOcclusionTexture","pbrMetallicRoughness":{"baseColorFactor":[0.305882275,0.9437239,1,1],"metallicRoughnessTexture":{"index":0}},"occlusionTexture":{"index":0}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicSmoothnessOcclusionTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicSmoothnessOcclusionTexture","children":[0,2],"translation":[-28,0,0]}],"buffers":[{"uri":"MetallicSmoothnessOcclusionTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"MetallicSmoothnessOcclusionTexture_MaskMap.jpg","uri":"MetallicSmoothnessOcclusionTexture_MaskMap.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicSmoothnessOcclusionTexture","pbrMetallicRoughness":{"baseColorFactor":[0.0761853456,0.87672466,1,1],"metallicRoughnessTexture":{"index":0}},"occlusionTexture":{"index":0}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicSmoothnessOcclusionTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/HDRP/MetallicSmoothnessTexture.gltf.txt b/Tests/Resources/ExportTargets/HDRP/MetallicSmoothnessTexture.gltf.txt index 938b7243..e45e95b1 100644 --- a/Tests/Resources/ExportTargets/HDRP/MetallicSmoothnessTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/HDRP/MetallicSmoothnessTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.21f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicSmoothnessTexture","children":[0,2],"translation":[-27,0,0]}],"buffers":[{"uri":"MetallicSmoothnessTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"MetallicSmoothnessTexture_MaskMap.jpg","uri":"MetallicSmoothnessTexture_MaskMap.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicSmoothnessTexture","pbrMetallicRoughness":{"baseColorFactor":[0.305882275,1,0.38926816,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicSmoothnessTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicSmoothnessTexture","children":[0,2],"translation":[-27,0,0]}],"buffers":[{"uri":"MetallicSmoothnessTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"MetallicSmoothnessTexture_MaskMap.jpg","uri":"MetallicSmoothnessTexture_MaskMap.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicSmoothnessTexture","pbrMetallicRoughness":{"baseColorFactor":[0.0761853456,1,0.125470772,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicSmoothnessTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/HDRP/MetallicTexture.gltf.txt b/Tests/Resources/ExportTargets/HDRP/MetallicTexture.gltf.txt index 8a3a790b..a869aa02 100644 --- a/Tests/Resources/ExportTargets/HDRP/MetallicTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/HDRP/MetallicTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.21f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicTexture","children":[0,2],"translation":[-26,0,0]}],"buffers":[{"uri":"MetallicTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"MetallicTexture_MaskMap.jpg","uri":"MetallicTexture_MaskMap.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicTexture","pbrMetallicRoughness":{"baseColorFactor":[0.305882275,1,0.38926816,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicTexture","children":[0,2],"translation":[-26,0,0]}],"buffers":[{"uri":"MetallicTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"MetallicTexture_MaskMap.jpg","uri":"MetallicTexture_MaskMap.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicTexture","pbrMetallicRoughness":{"baseColorFactor":[0.0761853456,1,0.125470772,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/HDRP/OcclusionTexture.gltf.txt b/Tests/Resources/ExportTargets/HDRP/OcclusionTexture.gltf.txt index 67a50483..3b995aea 100644 --- a/Tests/Resources/ExportTargets/HDRP/OcclusionTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/HDRP/OcclusionTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.21f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"OcclusionTexture","children":[0,2],"translation":[-20,0,0]}],"buffers":[{"uri":"OcclusionTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"OcclusionTexture_MaskMap.jpg","uri":"OcclusionTexture_MaskMap.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"OcclusionTexture","pbrMetallicRoughness":{"baseColorFactor":[1,0.704480767,0.30660373,1],"metallicFactor":0,"roughnessFactor":0.7},"occlusionTexture":{"index":0}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"OcclusionTexture","nodes":[3]}],"textures":[{"source":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"OcclusionTexture","children":[0,2],"translation":[-20,0,0]}],"buffers":[{"uri":"OcclusionTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"OcclusionTexture_MaskMap.jpg","uri":"OcclusionTexture_MaskMap.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"OcclusionTexture","pbrMetallicRoughness":{"baseColorFactor":[1,0.4543959,0.0765513852,1],"metallicFactor":0,"roughnessFactor":0.7},"occlusionTexture":{"index":0}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"OcclusionTexture","nodes":[3]}],"textures":[{"source":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/HDRP/OcclusionTextureStrength.gltf.txt b/Tests/Resources/ExportTargets/HDRP/OcclusionTextureStrength.gltf.txt index cfaa5e14..143cf065 100644 --- a/Tests/Resources/ExportTargets/HDRP/OcclusionTextureStrength.gltf.txt +++ b/Tests/Resources/ExportTargets/HDRP/OcclusionTextureStrength.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.21f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"OcclusionTextureStrength","children":[0,2],"translation":[-21,0,0]}],"extensionsRequired":["KHR_texture_transform"],"extensionsUsed":["KHR_texture_transform"],"buffers":[{"uri":"OcclusionTextureStrength.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"OcclusionTextureStrength_MaskMap.jpg","uri":"OcclusionTextureStrength_MaskMap.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"OcclusionTextureStrength","pbrMetallicRoughness":{"baseColorFactor":[1,0.704480767,0.30660373,1],"metallicFactor":0},"occlusionTexture":{"index":0,"extensions":{"KHR_texture_transform":{"offset":[0,-0.5],"scale":[2,1.5]}},"strength":0.230000019}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"OcclusionTextureStrength","nodes":[3]}],"textures":[{"source":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"OcclusionTextureStrength","children":[0,2],"translation":[-21,0,0]}],"extensionsRequired":["KHR_texture_transform"],"extensionsUsed":["KHR_texture_transform"],"buffers":[{"uri":"OcclusionTextureStrength.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"OcclusionTextureStrength_MaskMap.jpg","uri":"OcclusionTextureStrength_MaskMap.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"OcclusionTextureStrength","pbrMetallicRoughness":{"baseColorFactor":[1,0.4543959,0.0765513852,1],"metallicFactor":0},"occlusionTexture":{"index":0,"extensions":{"KHR_texture_transform":{"offset":[0,-0.5],"scale":[2,1.5]}},"strength":0.230000019}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"OcclusionTextureStrength","nodes":[3]}],"textures":[{"source":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/HDRP/SmoothnessTexture.gltf.txt b/Tests/Resources/ExportTargets/HDRP/SmoothnessTexture.gltf.txt index af87dc1b..ab04452a 100644 --- a/Tests/Resources/ExportTargets/HDRP/SmoothnessTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/HDRP/SmoothnessTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.21f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"SmoothnessTexture","children":[0,2],"translation":[-25,0,0]}],"buffers":[{"uri":"SmoothnessTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"SmoothnessTexture_MaskMap.jpg","uri":"SmoothnessTexture_MaskMap.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"SmoothnessTexture","pbrMetallicRoughness":{"baseColorFactor":[0.305882275,1,0.38926816,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"SmoothnessTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"SmoothnessTexture","children":[0,2],"translation":[-25,0,0]}],"buffers":[{"uri":"SmoothnessTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"SmoothnessTexture_MaskMap.jpg","uri":"SmoothnessTexture_MaskMap.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"SmoothnessTexture","pbrMetallicRoughness":{"baseColorFactor":[0.0761853456,1,0.125470772,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"SmoothnessTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/HDRP/Submesh.gltf.txt b/Tests/Resources/ExportTargets/HDRP/Submesh.gltf.txt index a0510482..598e6bc0 100644 --- a/Tests/Resources/ExportTargets/HDRP/Submesh.gltf.txt +++ b/Tests/Resources/ExportTargets/HDRP/Submesh.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2020.3.41f1 glTFast 4.8.5"},"nodes":[{"name":"Submesh","mesh":0,"translation":[-1,0,0]}],"buffers":[{"uri":"Submesh.bin","byteLength":204}],"bufferViews":[{"buffer":0,"byteLength":12},{"buffer":0,"byteLength":192,"byteOffset":12,"byteStride":48}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC4","byteOffset":24},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC2","byteOffset":40},{"bufferView":0,"componentType":5123,"count":3,"type":"SCALAR"},{"bufferView":0,"componentType":5123,"count":3,"type":"SCALAR","byteOffset":6}],"materials":[{"name":"Blue","pbrMetallicRoughness":{"baseColorFactor":[0.09848101,0.160967588,0.9063317,1],"metallicFactor":0,"roughnessFactor":0.5}},{"name":"Red","pbrMetallicRoughness":{"baseColorFactor":[1,0,0,1],"metallicFactor":0,"roughnessFactor":0.5}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TANGENT":2,"TEXCOORD_0":3},"indices":4,"material":0},{"attributes":{"POSITION":0,"NORMAL":1,"TANGENT":2,"TEXCOORD_0":3},"indices":5,"material":1}]}],"scene":0,"scenes":[{"name":"Submesh","nodes":[0]}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Submesh","mesh":0,"translation":[-1,0,0]}],"buffers":[{"uri":"Submesh.bin","byteLength":204}],"bufferViews":[{"buffer":0,"byteLength":12},{"buffer":0,"byteLength":192,"byteOffset":12,"byteStride":48}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC4","byteOffset":24},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC2","byteOffset":40},{"bufferView":0,"componentType":5123,"count":3,"type":"SCALAR"},{"bufferView":0,"componentType":5123,"count":3,"type":"SCALAR","byteOffset":6}],"materials":[{"name":"Blue","pbrMetallicRoughness":{"baseColorFactor":[0.009788704,0.022219114,0.8,1],"metallicFactor":0,"roughnessFactor":0.5}},{"name":"Red","pbrMetallicRoughness":{"baseColorFactor":[1,0,0,1],"metallicFactor":0,"roughnessFactor":0.5}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TANGENT":2,"TEXCOORD_0":3},"indices":4,"material":0},{"attributes":{"POSITION":0,"NORMAL":1,"TANGENT":2,"TEXCOORD_0":3},"indices":5,"material":1}]}],"scene":0,"scenes":[{"name":"Submesh","nodes":[0]}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/HDRP/Unlit.gltf.txt b/Tests/Resources/ExportTargets/HDRP/Unlit.gltf.txt index d06a08f3..da437eaa 100644 --- a/Tests/Resources/ExportTargets/HDRP/Unlit.gltf.txt +++ b/Tests/Resources/ExportTargets/HDRP/Unlit.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.13f1 glTFast 4.8.5"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"Unlit","children":[0,2],"translation":[-15,0,0]}],"extensionsRequired":["KHR_materials_unlit"],"extensionsUsed":["KHR_materials_unlit"],"buffers":[{"uri":"Unlit.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"materials":[{"name":"Unlit","pbrMetallicRoughness":{"baseColorFactor":[1,0.558888555,0,1],"metallicFactor":0},"extensions":{"KHR_materials_unlit":{}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"Unlit","nodes":[3]}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"Unlit","children":[0,2],"translation":[-15,0,0]}],"extensionsRequired":["KHR_materials_unlit"],"extensionsUsed":["KHR_materials_unlit"],"buffers":[{"uri":"Unlit.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"materials":[{"name":"Unlit","pbrMetallicRoughness":{"baseColorFactor":[1,0.2726522,0,1],"metallicFactor":0},"extensions":{"KHR_materials_unlit":{}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"Unlit","nodes":[3]}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/MetallicSmoothnessOcclusionTexture.gltf.txt b/Tests/Resources/ExportTargets/MetallicSmoothnessOcclusionTexture.gltf.txt index e8184f26..128cb3dd 100644 --- a/Tests/Resources/ExportTargets/MetallicSmoothnessOcclusionTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/MetallicSmoothnessOcclusionTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.21f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicSmoothnessOcclusionTexture","children":[0,2],"translation":[-28,0,0]}],"buffers":[{"uri":"MetallicSmoothnessOcclusionTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"metallic-smoothness.jpg","uri":"metallic-smoothness.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicSmoothnessOcclusionTexture","pbrMetallicRoughness":{"baseColorFactor":[0.305882335,0.9437239,1,1],"metallicRoughnessTexture":{"index":0}},"occlusionTexture":{"index":0}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicSmoothnessOcclusionTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicSmoothnessOcclusionTexture","children":[0,2],"translation":[-28,0,0]}],"buffers":[{"uri":"MetallicSmoothnessOcclusionTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"metallic-smoothness.jpg","uri":"metallic-smoothness.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicSmoothnessOcclusionTexture","pbrMetallicRoughness":{"baseColorFactor":[0.07618536,0.87672466,1,1],"metallicRoughnessTexture":{"index":0}},"occlusionTexture":{"index":0}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicSmoothnessOcclusionTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/MetallicSmoothnessTexture.gltf.txt b/Tests/Resources/ExportTargets/MetallicSmoothnessTexture.gltf.txt index 87abbea6..472e2511 100644 --- a/Tests/Resources/ExportTargets/MetallicSmoothnessTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/MetallicSmoothnessTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.21f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicSmoothnessTexture","children":[0,2],"translation":[-27,0,0]}],"buffers":[{"uri":"MetallicSmoothnessTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"metallic-smoothness.jpg","uri":"metallic-smoothness.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicSmoothnessTexture","pbrMetallicRoughness":{"baseColorFactor":[0.305882335,1,0.389268219,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicSmoothnessTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicSmoothnessTexture","children":[0,2],"translation":[-27,0,0]}],"buffers":[{"uri":"MetallicSmoothnessTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"metallic-smoothness.jpg","uri":"metallic-smoothness.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicSmoothnessTexture","pbrMetallicRoughness":{"baseColorFactor":[0.07618536,1,0.1254708,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicSmoothnessTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/MetallicTexture.gltf.txt b/Tests/Resources/ExportTargets/MetallicTexture.gltf.txt index 29b3aa91..1b0e45e7 100644 --- a/Tests/Resources/ExportTargets/MetallicTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/MetallicTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.21f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicTexture","children":[0,2],"translation":[-26,0,0]}],"buffers":[{"uri":"MetallicTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"metallic.jpg","uri":"metallic.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicTexture","pbrMetallicRoughness":{"baseColorFactor":[0.305882335,1,0.389268219,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicTexture","children":[0,2],"translation":[-26,0,0]}],"buffers":[{"uri":"MetallicTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"metallic.jpg","uri":"metallic.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicTexture","pbrMetallicRoughness":{"baseColorFactor":[0.07618536,1,0.1254708,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/OcclusionTexture.gltf.txt b/Tests/Resources/ExportTargets/OcclusionTexture.gltf.txt index 5ca3d54d..091339e3 100644 --- a/Tests/Resources/ExportTargets/OcclusionTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/OcclusionTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.21f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"OcclusionTexture","children":[0,2],"translation":[-20,0,0]}],"buffers":[{"uri":"OcclusionTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"occlusion.jpg","uri":"occlusion.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"OcclusionTexture","pbrMetallicRoughness":{"baseColorFactor":[1,0.704480767,0.3066038,1],"metallicFactor":0,"roughnessFactor":0.7},"occlusionTexture":{"index":0}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"OcclusionTexture","nodes":[3]}],"textures":[{"source":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"OcclusionTexture","children":[0,2],"translation":[-20,0,0]}],"buffers":[{"uri":"OcclusionTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"occlusion.jpg","uri":"occlusion.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"OcclusionTexture","pbrMetallicRoughness":{"baseColorFactor":[1,0.4543959,0.0765514,1],"metallicFactor":0,"roughnessFactor":0.7},"occlusionTexture":{"index":0}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"OcclusionTexture","nodes":[3]}],"textures":[{"source":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/OcclusionTextureStrength.gltf.txt b/Tests/Resources/ExportTargets/OcclusionTextureStrength.gltf.txt index 9af3259f..e9954062 100644 --- a/Tests/Resources/ExportTargets/OcclusionTextureStrength.gltf.txt +++ b/Tests/Resources/ExportTargets/OcclusionTextureStrength.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.21f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"OcclusionTextureStrength","children":[0,2],"translation":[-21,0,0]}],"extensionsRequired":["KHR_texture_transform"],"extensionsUsed":["KHR_texture_transform"],"buffers":[{"uri":"OcclusionTextureStrength.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"occlusion.jpg","uri":"occlusion.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"OcclusionTextureStrength","pbrMetallicRoughness":{"baseColorFactor":[1,0.704480767,0.3066038,1],"metallicFactor":0},"occlusionTexture":{"index":0,"extensions":{"KHR_texture_transform":{"offset":[0,-0.5],"scale":[2,1.5]}},"strength":0.23}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"OcclusionTextureStrength","nodes":[3]}],"textures":[{"source":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"OcclusionTextureStrength","children":[0,2],"translation":[-21,0,0]}],"extensionsRequired":["KHR_texture_transform"],"extensionsUsed":["KHR_texture_transform"],"buffers":[{"uri":"OcclusionTextureStrength.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"occlusion.jpg","uri":"occlusion.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"OcclusionTextureStrength","pbrMetallicRoughness":{"baseColorFactor":[1,0.4543959,0.0765514,1],"metallicFactor":0},"occlusionTexture":{"index":0,"extensions":{"KHR_texture_transform":{"offset":[0,-0.5],"scale":[2,1.5]}},"strength":0.23}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"OcclusionTextureStrength","nodes":[3]}],"textures":[{"source":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/SmoothnessTexture.gltf.txt b/Tests/Resources/ExportTargets/SmoothnessTexture.gltf.txt index f1caddfe..a9c502a0 100644 --- a/Tests/Resources/ExportTargets/SmoothnessTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/SmoothnessTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.21f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"SmoothnessTexture","children":[0,2],"translation":[-25,0,0]}],"buffers":[{"uri":"SmoothnessTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"smoothness.jpg","uri":"smoothness.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"SmoothnessTexture","pbrMetallicRoughness":{"baseColorFactor":[0.305882335,1,0.389268219,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"SmoothnessTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"SmoothnessTexture","children":[0,2],"translation":[-25,0,0]}],"buffers":[{"uri":"SmoothnessTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"smoothness.jpg","uri":"smoothness.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"SmoothnessTexture","pbrMetallicRoughness":{"baseColorFactor":[0.07618536,1,0.1254708,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"SmoothnessTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/Submesh.gltf.txt b/Tests/Resources/ExportTargets/Submesh.gltf.txt index e7a43157..04db958e 100644 --- a/Tests/Resources/ExportTargets/Submesh.gltf.txt +++ b/Tests/Resources/ExportTargets/Submesh.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2020.3.41f1 glTFast 4.8.5"},"nodes":[{"name":"Submesh","mesh":0,"translation":[-1,0,0]}],"buffers":[{"uri":"Submesh.bin","byteLength":204}],"bufferViews":[{"buffer":0,"byteLength":12},{"buffer":0,"byteLength":192,"byteOffset":12,"byteStride":48}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC4","byteOffset":24},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC2","byteOffset":40},{"bufferView":0,"componentType":5123,"count":3,"type":"SCALAR"},{"bufferView":0,"componentType":5123,"count":3,"type":"SCALAR","byteOffset":6}],"materials":[{"name":"Blue","pbrMetallicRoughness":{"baseColorFactor":[0.09848107,0.160967648,0.9063317,1],"metallicFactor":0,"roughnessFactor":0.5}},{"name":"Red","pbrMetallicRoughness":{"baseColorFactor":[1,0,0,1],"metallicFactor":0,"roughnessFactor":0.5}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TANGENT":2,"TEXCOORD_0":3},"indices":4,"material":0},{"attributes":{"POSITION":0,"NORMAL":1,"TANGENT":2,"TEXCOORD_0":3},"indices":5,"material":1}]}],"scene":0,"scenes":[{"name":"Submesh","nodes":[0]}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Submesh","mesh":0,"translation":[-1,0,0]}],"buffers":[{"uri":"Submesh.bin","byteLength":204}],"bufferViews":[{"buffer":0,"byteLength":12},{"buffer":0,"byteLength":192,"byteOffset":12,"byteStride":48}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC4","byteOffset":24},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC2","byteOffset":40},{"bufferView":0,"componentType":5123,"count":3,"type":"SCALAR"},{"bufferView":0,"componentType":5123,"count":3,"type":"SCALAR","byteOffset":6}],"materials":[{"name":"Blue","pbrMetallicRoughness":{"baseColorFactor":[0.009788709,0.0222191215,0.8,1],"metallicFactor":0,"roughnessFactor":0.5}},{"name":"Red","pbrMetallicRoughness":{"baseColorFactor":[1,0,0,1],"metallicFactor":0,"roughnessFactor":0.5}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TANGENT":2,"TEXCOORD_0":3},"indices":4,"material":0},{"attributes":{"POSITION":0,"NORMAL":1,"TANGENT":2,"TEXCOORD_0":3},"indices":5,"material":1}]}],"scene":0,"scenes":[{"name":"Submesh","nodes":[0]}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/URP/Dielectric.gltf.txt b/Tests/Resources/ExportTargets/URP/Dielectric.gltf.txt index 9a7edc87..6c15d41a 100644 --- a/Tests/Resources/ExportTargets/URP/Dielectric.gltf.txt +++ b/Tests/Resources/ExportTargets/URP/Dielectric.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2020.3.41f1 glTFast 5.0.0-exp.1"},"nodes":[{"name":"Sphere","mesh":0},{"name":"sphere 1","children":[0]},{"name":"Sphere","mesh":1},{"name":"sphere 2","children":[2],"translation":[0,0,1]},{"name":"Sphere","mesh":2},{"name":"sphere 3","children":[4],"translation":[0,0,2]},{"name":"Sphere","mesh":3},{"name":"sphere 4","children":[6],"translation":[0,0,3]},{"name":"Sphere","mesh":4},{"name":"sphere 5","children":[8],"translation":[0,0,4]},{"name":"Dielectric","children":[1,3,5,7,9],"translation":[-8,0,0]}],"buffers":[{"uri":"Dielectric.bin","byteLength":24576}],"bufferViews":[{"buffer":0,"byteLength":9216},{"buffer":0,"byteLength":11520,"byteOffset":9216,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20736,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":1,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":2304,"type":"SCALAR"}],"materials":[{"name":"Dielectric 1","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.419811279,1,1],"metallicFactor":0,"roughnessFactor":0}},{"name":"Dielectric 2","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.419811279,1,1],"metallicFactor":0,"roughnessFactor":0.25}},{"name":"Dielectric 3","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.419811279,1,1],"metallicFactor":0,"roughnessFactor":0.5}},{"name":"Dielectric 4","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.419811279,1,1],"metallicFactor":0,"roughnessFactor":0.75}},{"name":"Dielectric 5","pbrMetallicRoughness":{"baseColorFactor":[0.7077749,0.419811279,1,1],"metallicFactor":0}}],"meshes":[{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":1}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":2}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":3}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":4}]}],"scene":0,"scenes":[{"name":"Dielectric","nodes":[10]}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Sphere","mesh":0},{"name":"sphere 1","children":[0]},{"name":"Sphere","mesh":1},{"name":"sphere 2","children":[2],"translation":[0,0,1]},{"name":"Sphere","mesh":2},{"name":"sphere 3","children":[4],"translation":[0,0,2]},{"name":"Sphere","mesh":3},{"name":"sphere 4","children":[6],"translation":[0,0,3]},{"name":"Sphere","mesh":4},{"name":"sphere 5","children":[8],"translation":[0,0,4]},{"name":"Dielectric","children":[1,3,5,7,9],"translation":[-8,0,0]}],"buffers":[{"uri":"Dielectric.bin","byteLength":24576}],"bufferViews":[{"buffer":0,"byteLength":9216},{"buffer":0,"byteLength":11520,"byteOffset":9216,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20736,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":1,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":2304,"type":"SCALAR"}],"materials":[{"name":"Dielectric 1","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.14717856,1,1],"metallicFactor":0,"roughnessFactor":0}},{"name":"Dielectric 2","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.14717856,1,1],"metallicFactor":0,"roughnessFactor":0.25}},{"name":"Dielectric 3","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.14717856,1,1],"metallicFactor":0,"roughnessFactor":0.5}},{"name":"Dielectric 4","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.14717856,1,1],"metallicFactor":0,"roughnessFactor":0.75}},{"name":"Dielectric 5","pbrMetallicRoughness":{"baseColorFactor":[0.45914036,0.14717856,1,1],"metallicFactor":0}}],"meshes":[{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":1}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":2}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":3}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":4}]}],"scene":0,"scenes":[{"name":"Dielectric","nodes":[10]}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/URP/DoubleSided.gltf.txt b/Tests/Resources/ExportTargets/URP/DoubleSided.gltf.txt index eb4c8fdd..0919cc18 100644 --- a/Tests/Resources/ExportTargets/URP/DoubleSided.gltf.txt +++ b/Tests/Resources/ExportTargets/URP/DoubleSided.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2020.3.41f1 glTFast 5.0.0-exp.1"},"nodes":[{"name":"DoubleSided","mesh":0,"translation":[-18,0,0],"rotation":[-0.5,-0.5,-0.5,0.5]}],"buffers":[{"uri":"DoubleSided.bin","byteLength":152}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"}],"materials":[{"name":"DoubleSided","pbrMetallicRoughness":{"baseColorFactor":[0,0.08719418,1,1],"metallicFactor":0,"roughnessFactor":0.7},"doubleSided":true}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]}],"scene":0,"scenes":[{"name":"DoubleSided","nodes":[0]}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"DoubleSided","mesh":0,"translation":[-18,0,0],"rotation":[-0.5,-0.5,-0.5,0.5]}],"buffers":[{"uri":"DoubleSided.bin","byteLength":152}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"}],"materials":[{"name":"DoubleSided","pbrMetallicRoughness":{"baseColorFactor":[0,0.008149115,1,1],"metallicFactor":0,"roughnessFactor":0.7},"doubleSided":true}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]}],"scene":0,"scenes":[{"name":"DoubleSided","nodes":[0]}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/URP/MetallicSmoothnessOcclusionTexture.gltf.txt b/Tests/Resources/ExportTargets/URP/MetallicSmoothnessOcclusionTexture.gltf.txt index 777e5a12..128cb3dd 100644 --- a/Tests/Resources/ExportTargets/URP/MetallicSmoothnessOcclusionTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/URP/MetallicSmoothnessOcclusionTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2022.2.12f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicSmoothnessOcclusionTexture","children":[0,2],"translation":[-28,0,0]}],"buffers":[{"uri":"MetallicSmoothnessOcclusionTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"metallic-smoothness.jpg","uri":"metallic-smoothness.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicSmoothnessOcclusionTexture","pbrMetallicRoughness":{"baseColorFactor":[0.305882275,0.9437239,1,1],"metallicRoughnessTexture":{"index":0}},"occlusionTexture":{"index":0}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicSmoothnessOcclusionTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicSmoothnessOcclusionTexture","children":[0,2],"translation":[-28,0,0]}],"buffers":[{"uri":"MetallicSmoothnessOcclusionTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"metallic-smoothness.jpg","uri":"metallic-smoothness.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicSmoothnessOcclusionTexture","pbrMetallicRoughness":{"baseColorFactor":[0.07618536,0.87672466,1,1],"metallicRoughnessTexture":{"index":0}},"occlusionTexture":{"index":0}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicSmoothnessOcclusionTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/URP/MetallicSmoothnessTexture.gltf.txt b/Tests/Resources/ExportTargets/URP/MetallicSmoothnessTexture.gltf.txt index 1ed3f5a3..472e2511 100644 --- a/Tests/Resources/ExportTargets/URP/MetallicSmoothnessTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/URP/MetallicSmoothnessTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2022.2.12f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicSmoothnessTexture","children":[0,2],"translation":[-27,0,0]}],"buffers":[{"uri":"MetallicSmoothnessTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"metallic-smoothness.jpg","uri":"metallic-smoothness.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicSmoothnessTexture","pbrMetallicRoughness":{"baseColorFactor":[0.305882275,1,0.38926816,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicSmoothnessTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicSmoothnessTexture","children":[0,2],"translation":[-27,0,0]}],"buffers":[{"uri":"MetallicSmoothnessTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"metallic-smoothness.jpg","uri":"metallic-smoothness.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicSmoothnessTexture","pbrMetallicRoughness":{"baseColorFactor":[0.07618536,1,0.1254708,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicSmoothnessTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/URP/MetallicTexture.gltf.txt b/Tests/Resources/ExportTargets/URP/MetallicTexture.gltf.txt index b82d8e06..1b0e45e7 100644 --- a/Tests/Resources/ExportTargets/URP/MetallicTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/URP/MetallicTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2022.2.12f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicTexture","children":[0,2],"translation":[-26,0,0]}],"buffers":[{"uri":"MetallicTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"metallic.jpg","uri":"metallic.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicTexture","pbrMetallicRoughness":{"baseColorFactor":[0.305882275,1,0.38926816,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"MetallicTexture","children":[0,2],"translation":[-26,0,0]}],"buffers":[{"uri":"MetallicTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"metallic.jpg","uri":"metallic.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"MetallicTexture","pbrMetallicRoughness":{"baseColorFactor":[0.07618536,1,0.1254708,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"MetallicTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/URP/OcclusionTexture.gltf.txt b/Tests/Resources/ExportTargets/URP/OcclusionTexture.gltf.txt index fed3b3d8..091339e3 100644 --- a/Tests/Resources/ExportTargets/URP/OcclusionTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/URP/OcclusionTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2022.2.12f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"OcclusionTexture","children":[0,2],"translation":[-20,0,0]}],"buffers":[{"uri":"OcclusionTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"occlusion.jpg","uri":"occlusion.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"OcclusionTexture","pbrMetallicRoughness":{"baseColorFactor":[1,0.704480767,0.30660373,1],"metallicFactor":0,"roughnessFactor":0.7},"occlusionTexture":{"index":0}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"OcclusionTexture","nodes":[3]}],"textures":[{"source":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"OcclusionTexture","children":[0,2],"translation":[-20,0,0]}],"buffers":[{"uri":"OcclusionTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"occlusion.jpg","uri":"occlusion.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"OcclusionTexture","pbrMetallicRoughness":{"baseColorFactor":[1,0.4543959,0.0765514,1],"metallicFactor":0,"roughnessFactor":0.7},"occlusionTexture":{"index":0}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"OcclusionTexture","nodes":[3]}],"textures":[{"source":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/URP/OcclusionTextureStrength.gltf.txt b/Tests/Resources/ExportTargets/URP/OcclusionTextureStrength.gltf.txt index 01408a65..e9954062 100644 --- a/Tests/Resources/ExportTargets/URP/OcclusionTextureStrength.gltf.txt +++ b/Tests/Resources/ExportTargets/URP/OcclusionTextureStrength.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2022.2.12f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"OcclusionTextureStrength","children":[0,2],"translation":[-21,0,0]}],"extensionsRequired":["KHR_texture_transform"],"extensionsUsed":["KHR_texture_transform"],"buffers":[{"uri":"OcclusionTextureStrength.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"occlusion.jpg","uri":"occlusion.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"OcclusionTextureStrength","pbrMetallicRoughness":{"baseColorFactor":[1,0.704480767,0.30660373,1],"metallicFactor":0},"occlusionTexture":{"index":0,"extensions":{"KHR_texture_transform":{"offset":[0,-0.5],"scale":[2,1.5]}},"strength":0.23}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"OcclusionTextureStrength","nodes":[3]}],"textures":[{"source":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"OcclusionTextureStrength","children":[0,2],"translation":[-21,0,0]}],"extensionsRequired":["KHR_texture_transform"],"extensionsUsed":["KHR_texture_transform"],"buffers":[{"uri":"OcclusionTextureStrength.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"occlusion.jpg","uri":"occlusion.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"OcclusionTextureStrength","pbrMetallicRoughness":{"baseColorFactor":[1,0.4543959,0.0765514,1],"metallicFactor":0},"occlusionTexture":{"index":0,"extensions":{"KHR_texture_transform":{"offset":[0,-0.5],"scale":[2,1.5]}},"strength":0.23}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"OcclusionTextureStrength","nodes":[3]}],"textures":[{"source":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/URP/SmoothnessTexture.gltf.txt b/Tests/Resources/ExportTargets/URP/SmoothnessTexture.gltf.txt index cb263ab7..a9c502a0 100644 --- a/Tests/Resources/ExportTargets/URP/SmoothnessTexture.gltf.txt +++ b/Tests/Resources/ExportTargets/URP/SmoothnessTexture.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2022.2.12f1 glTFast 5.0.4"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"SmoothnessTexture","children":[0,2],"translation":[-25,0,0]}],"buffers":[{"uri":"SmoothnessTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"smoothness.jpg","uri":"smoothness.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"SmoothnessTexture","pbrMetallicRoughness":{"baseColorFactor":[0.305882275,1,0.38926816,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"SmoothnessTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"SmoothnessTexture","children":[0,2],"translation":[-25,0,0]}],"buffers":[{"uri":"SmoothnessTexture.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"images":[{"name":"smoothness.jpg","uri":"smoothness.jpg","mimeType":"image/jpeg"}],"materials":[{"name":"SmoothnessTexture","pbrMetallicRoughness":{"baseColorFactor":[0.07618536,1,0.1254708,1],"metallicRoughnessTexture":{"index":0}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"samplers":[{"magFilter":9728,"minFilter":9728}],"scene":0,"scenes":[{"name":"SmoothnessTexture","nodes":[3]}],"textures":[{"source":0,"sampler":0}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/URP/Submesh.gltf.txt b/Tests/Resources/ExportTargets/URP/Submesh.gltf.txt index d0f01696..04db958e 100644 --- a/Tests/Resources/ExportTargets/URP/Submesh.gltf.txt +++ b/Tests/Resources/ExportTargets/URP/Submesh.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2020.3.41f1 glTFast 5.0.0-exp.1"},"nodes":[{"name":"Submesh","mesh":0,"translation":[-1,0,0]}],"buffers":[{"uri":"Submesh.bin","byteLength":204}],"bufferViews":[{"buffer":0,"byteLength":12},{"buffer":0,"byteLength":192,"byteOffset":12,"byteStride":48}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC4","byteOffset":24},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC2","byteOffset":40},{"bufferView":0,"componentType":5123,"count":3,"type":"SCALAR"},{"bufferView":0,"componentType":5123,"count":3,"type":"SCALAR","byteOffset":6}],"materials":[{"name":"Blue","pbrMetallicRoughness":{"baseColorFactor":[0.09848104,0.160967618,0.9063317,1],"metallicFactor":0,"roughnessFactor":0.5}},{"name":"Red","pbrMetallicRoughness":{"baseColorFactor":[1,0,0,1],"metallicFactor":0,"roughnessFactor":0.5}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TANGENT":2,"TEXCOORD_0":3},"indices":4,"material":0},{"attributes":{"POSITION":0,"NORMAL":1,"TANGENT":2,"TEXCOORD_0":3},"indices":5,"material":1}]}],"scene":0,"scenes":[{"name":"Submesh","nodes":[0]}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Submesh","mesh":0,"translation":[-1,0,0]}],"buffers":[{"uri":"Submesh.bin","byteLength":204}],"bufferViews":[{"buffer":0,"byteLength":12},{"buffer":0,"byteLength":192,"byteOffset":12,"byteStride":48}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC4","byteOffset":24},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC2","byteOffset":40},{"bufferView":0,"componentType":5123,"count":3,"type":"SCALAR"},{"bufferView":0,"componentType":5123,"count":3,"type":"SCALAR","byteOffset":6}],"materials":[{"name":"Blue","pbrMetallicRoughness":{"baseColorFactor":[0.009788709,0.0222191215,0.8,1],"metallicFactor":0,"roughnessFactor":0.5}},{"name":"Red","pbrMetallicRoughness":{"baseColorFactor":[1,0,0,1],"metallicFactor":0,"roughnessFactor":0.5}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TANGENT":2,"TEXCOORD_0":3},"indices":4,"material":0},{"attributes":{"POSITION":0,"NORMAL":1,"TANGENT":2,"TEXCOORD_0":3},"indices":5,"material":1}]}],"scene":0,"scenes":[{"name":"Submesh","nodes":[0]}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/URP/Unlit.gltf.txt b/Tests/Resources/ExportTargets/URP/Unlit.gltf.txt index 72981da3..7b1f5d59 100644 --- a/Tests/Resources/ExportTargets/URP/Unlit.gltf.txt +++ b/Tests/Resources/ExportTargets/URP/Unlit.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2020.3.41f1 glTFast 5.0.0-exp.1"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"Unlit","children":[0,2],"translation":[-15,0,0]}],"extensionsRequired":["KHR_materials_unlit"],"extensionsUsed":["KHR_materials_unlit"],"buffers":[{"uri":"Unlit.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"materials":[{"name":"Unlit","pbrMetallicRoughness":{"baseColorFactor":[1,0.5588886,0,1],"metallicFactor":0},"extensions":{"KHR_materials_unlit":{}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"Unlit","nodes":[3]}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"Unlit","children":[0,2],"translation":[-15,0,0]}],"extensionsRequired":["KHR_materials_unlit"],"extensionsUsed":["KHR_materials_unlit"],"buffers":[{"uri":"Unlit.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"materials":[{"name":"Unlit","pbrMetallicRoughness":{"baseColorFactor":[1,0.272652268,0,1],"metallicFactor":0},"extensions":{"KHR_materials_unlit":{}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"Unlit","nodes":[3]}]} \ No newline at end of file diff --git a/Tests/Resources/ExportTargets/Unlit.gltf.txt b/Tests/Resources/ExportTargets/Unlit.gltf.txt index 1c0223c1..da437eaa 100644 --- a/Tests/Resources/ExportTargets/Unlit.gltf.txt +++ b/Tests/Resources/ExportTargets/Unlit.gltf.txt @@ -1 +1 @@ -{"asset":{"version":"2.0","generator":"Unity 2021.3.12f1 glTFast 4.8.5"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"Unlit","children":[0,2],"translation":[-15,0,0]}],"extensionsRequired":["KHR_materials_unlit"],"extensionsUsed":["KHR_materials_unlit"],"buffers":[{"uri":"Unlit.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"materials":[{"name":"Unlit","pbrMetallicRoughness":{"baseColorFactor":[1,0.5588886,0,1],"metallicFactor":0},"extensions":{"KHR_materials_unlit":{}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"Unlit","nodes":[3]}]} \ No newline at end of file +{"asset":{"version":"2.0","generator":"Unity 2020.3.48f1 glTFast 6.6.0"},"nodes":[{"name":"Plane","mesh":0,"translation":[0,0,1]},{"name":"Sphere","mesh":1},{"name":"sphere","children":[1],"rotation":[0,0.7071068,0,0.7071068]},{"name":"Unlit","children":[0,2],"translation":[-15,0,0]}],"extensionsRequired":["KHR_materials_unlit"],"extensionsUsed":["KHR_materials_unlit"],"buffers":[{"uri":"Unlit.bin","byteLength":24728}],"bufferViews":[{"buffer":0,"byteLength":24},{"buffer":0,"byteLength":96,"byteOffset":24,"byteStride":24},{"buffer":0,"byteLength":32,"byteOffset":120,"byteStride":8},{"buffer":0,"byteLength":9216,"byteOffset":152},{"buffer":0,"byteLength":11520,"byteOffset":9368,"byteStride":24},{"buffer":0,"byteLength":3840,"byteOffset":20888,"byteStride":8}],"accessors":[{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","max":[0.5,0,0.5],"min":[-0.5,0,-0.5]},{"bufferView":1,"componentType":5126,"count":4,"type":"VEC3","byteOffset":12},{"bufferView":2,"componentType":5126,"count":4,"type":"VEC2"},{"bufferView":0,"componentType":5125,"count":6,"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5]},{"bufferView":4,"componentType":5126,"count":480,"type":"VEC3","byteOffset":12},{"bufferView":5,"componentType":5126,"count":480,"type":"VEC2"},{"bufferView":3,"componentType":5125,"count":2304,"type":"SCALAR"}],"materials":[{"name":"Unlit","pbrMetallicRoughness":{"baseColorFactor":[1,0.2726522,0,1],"metallicFactor":0},"extensions":{"KHR_materials_unlit":{}}}],"meshes":[{"name":"Plane","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"name":"Sphere","primitives":[{"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}],"scene":0,"scenes":[{"name":"Unlit","nodes":[3]}]} \ No newline at end of file diff --git a/Tests/Runtime/Scripts/Export/ExportTests.cs b/Tests/Runtime/Scripts/Export/ExportTests.cs index 71dba871..a2ba829f 100644 --- a/Tests/Runtime/Scripts/Export/ExportTests.cs +++ b/Tests/Runtime/Scripts/Export/ExportTests.cs @@ -13,6 +13,7 @@ using System.Collections; using System.IO; using System.Linq; +using System.Text.RegularExpressions; using System.Threading.Tasks; using GLTFast.Export; @@ -52,6 +53,11 @@ class ExportTests : IPrebuildSetup const string k_SceneNameUniversal = "ExportSceneUniversal"; const string k_ScenesPath = "/Tests/Runtime/Export/Scenes/"; + + const string k_ColorPropertyPattern = @"\.(?\w*[cC]olor\w*)(\[\d+\])?$"; + static readonly Regex k_ColorPropertyRegex = new Regex(k_ColorPropertyPattern, RegexOptions.CultureInvariant, TimeSpan.FromSeconds(1)); + + #if UNITY_EDITOR static void UpdateObjectLists() { @@ -797,10 +803,15 @@ static void CompareGltfJsonTokenRecursively(JToken tokenA, JToken tokenB) switch (a.Type) { case JTokenType.Float: - case JTokenType.Integer: var expected = a.Value(); var actual = b.Value(); - Assert.That(actual, Is.EqualTo(expected).Within(6E-08f), $"Value mismatch at {a.Path}."); + var isColor = k_ColorPropertyRegex.Match(a.Path).Success; + // Colors usually undergo a gamma to linear conversion, hence a bit more tolerance. + var tolerance = isColor ? 6E-06f : 6E-08f; + Assert.That(actual, Is.EqualTo(expected).Within(tolerance), $"Value mismatch at {a.Path}."); + break; + case JTokenType.Integer: + Assert.AreEqual(a.Value(), b.Value(), $"Value mismatch at {a.Path}."); break; case JTokenType.String: Assert.AreEqual(a.Value(), b.Value(), $"Value mismatch at {a.Path}."); diff --git a/Tests/Runtime/Scripts/Export/MaterialExportTests.cs b/Tests/Runtime/Scripts/Export/MaterialExportTests.cs index b598ae08..414a04b7 100644 --- a/Tests/Runtime/Scripts/Export/MaterialExportTests.cs +++ b/Tests/Runtime/Scripts/Export/MaterialExportTests.cs @@ -23,7 +23,7 @@ protected void BaseColorTest(RenderPipeline renderPipeline) var material = ConvertMaterial("BaseColor", out _, renderPipeline); Assert.IsNotNull(material.pbrMetallicRoughness); - Assert.AreEqual(new[] { .484529138f, .7353569f, .880825f, 1 }, material.pbrMetallicRoughness.baseColorFactor); + Assert.AreEqual(new[] { .199999973f, .5, .75f, 1 }, material.pbrMetallicRoughness.baseColorFactor); } protected void BaseColorTextureTest(RenderPipeline renderPipeline) @@ -343,7 +343,7 @@ protected void OmniTest(RenderPipeline renderPipeline) Assert.IsInstanceOf(gltfWriter.imageExports[0]); Assert.IsNotNull(material.pbrMetallicRoughness); - Assert.AreEqual(new[] { .9f, .8f, .7f, 1 }, material.pbrMetallicRoughness.baseColorFactor); + Assert.AreEqual(new[] { 0.787412345f, 0.603827417f, 0.447988421f, 1 }, material.pbrMetallicRoughness.baseColorFactor); var baseColorTexture = material.pbrMetallicRoughness.baseColorTexture; Assert.IsNotNull(baseColorTexture); Assert.AreEqual(0, baseColorTexture.index); @@ -419,7 +419,7 @@ out Schema.Material material Assert.IsInstanceOf(gltfWriter.imageExports[0]); Assert.IsNotNull(material.pbrMetallicRoughness); - Assert.AreEqual(new[] { .9f, .8f, .7f, 1 }, material.pbrMetallicRoughness.baseColorFactor); + Assert.AreEqual(new[] { 0.787412345f, 0.603827417f, 0.447988421f, 1 }, material.pbrMetallicRoughness.baseColorFactor); var texture = material.pbrMetallicRoughness.baseColorTexture; Assert.IsNotNull(texture); Assert.AreEqual(0, texture.index); From ee5e68b9a55a917a086fbd76338b333163ef70fb Mon Sep 17 00:00:00 2001 From: Andreas Atteneder Date: Mon, 24 Jun 2024 17:13:45 +0200 Subject: [PATCH 06/10] fix: Built-in render pipeline material export selection (#161) * doc: Made `GltfUnlitMaterialExporter`'s summary more explicit. * fix(export): glTFast shader based materials and textures are exported correctly when using the default render pipeline. feat: MetaMaterialExportBuiltIn, for universal material export in built-in render pipeline projects. * fix: Deprecated `MetaMaterialExport`, which was public on accident. * refactor: Made MetaMaterialExport classes singletons to avoid piling up instances. * fix: Added missing entries to the API documentation. * doc: XML docs for `MetaMaterialExport`. --- CHANGELOG.md | 5 ++ Documentation~/config.json | 2 +- .../Export/GltfUnlitMaterialExporter.cs | 2 +- Runtime/Scripts/Export/MaterialExport.cs | 10 +-- Runtime/Scripts/Export/MetaMaterialExport.cs | 68 +++++++++------- .../Export/MetaMaterialExportBuiltIn.cs | 78 +++++++++++++++++++ .../Export/MetaMaterialExportBuiltIn.cs.meta | 11 +++ 7 files changed, 142 insertions(+), 34 deletions(-) create mode 100644 Runtime/Scripts/Export/MetaMaterialExportBuiltIn.cs create mode 100644 Runtime/Scripts/Export/MetaMaterialExportBuiltIn.cs.meta diff --git a/CHANGELOG.md b/CHANGELOG.md index d71852c0..1f740bd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - (Import) Prefabs imported from glTF assets (at design-time) don't have the glTF logo icon assigned to them anymore. This makes it more consistent with other file types (like FBX; fixes [#557](https://github.com/atteneder/glTFast/issues/557)). +### Deprecated +- `MetaMaterialExport`. Always use `MaterialExport.GetDefaultMaterialExport` to get the correct material export. + ### Fixed +- (Export) glTFast shader based materials and textures are exported correctly when using the default render pipeline. +- Added missing entries to the API documentation. - (Export) Base colors are now in correct, linear color space. ## [6.6.0] - 2024-05-29 diff --git a/Documentation~/config.json b/Documentation~/config.json index aefb35be..df2b0d87 100644 --- a/Documentation~/config.json +++ b/Documentation~/config.json @@ -1,3 +1,3 @@ { - "DefineConstants": "DRACO_UNITY;KTX_UNITY;KTX_UNITY_1_3_OR_NEWER;KTX_UNITY_2_2_OR_NEWER;USING_URP;USING_HDRP;USING_HDRP_10_OR_NEWER;UNITY_PHYSICS;UNITY_IMAGECONVERSION;UNITY_WEBREQUEST_TEXTURE;MESHOPT;USING_URP_12_OR_NEWER;UNITY_SHADER_GRAPH_12_OR_NEWER;UNITY_ANIMATION;UNITY_ENTITIES_GRAPHICS;NEWTONSOFT_JSON" + "DefineConstants": "DRACO_UNITY;KTX_UNITY;KTX_UNITY_1_3_OR_NEWER;KTX_UNITY_2_2_OR_NEWER;USING_URP;USING_HDRP;USING_HDRP_10_OR_NEWER;UNITY_PHYSICS;UNITY_IMAGECONVERSION;UNITY_WEBREQUEST_TEXTURE;MESHOPT;USING_URP_12_OR_NEWER;UNITY_SHADER_GRAPH;UNITY_SHADER_GRAPH_12_OR_NEWER;UNITY_ANIMATION;UNITY_ENTITIES_GRAPHICS;NEWTONSOFT_JSON" } \ No newline at end of file diff --git a/Runtime/Scripts/Export/GltfUnlitMaterialExporter.cs b/Runtime/Scripts/Export/GltfUnlitMaterialExporter.cs index 22ff4b03..6d1d23d3 100644 --- a/Runtime/Scripts/Export/GltfUnlitMaterialExporter.cs +++ b/Runtime/Scripts/Export/GltfUnlitMaterialExporter.cs @@ -13,7 +13,7 @@ namespace GLTFast.Export { /// - /// Converts Unity Materials that use a glTFast shader to glTF materials + /// Converts Unity Materials that use the glTFast shader `glTF/Unlit` to glTF materials /// public class GltfUnlitMaterialExporter : IMaterialExport { diff --git a/Runtime/Scripts/Export/MaterialExport.cs b/Runtime/Scripts/Export/MaterialExport.cs index c3cba947..737c0ebc 100644 --- a/Runtime/Scripts/Export/MaterialExport.cs +++ b/Runtime/Scripts/Export/MaterialExport.cs @@ -31,20 +31,20 @@ public static IMaterialExport GetDefaultMaterialExport() case RenderPipeline.BuiltIn: case RenderPipeline.Universal: #if UNITY_SHADER_GRAPH - s_MaterialExport = new MetaMaterialExport< + s_MaterialExport = MetaMaterialExportShaderGraphs< StandardMaterialExport, GltfShaderGraphMaterialExporter - >(); + >.Instance; #else - s_MaterialExport = new StandardMaterialExport(); + s_MaterialExport = MetaMaterialExportBuiltIn.Instance; #endif break; #if USING_HDRP case RenderPipeline.HighDefinition: - s_MaterialExport = new MetaMaterialExport< + s_MaterialExport = MetaMaterialExportShaderGraphs< HighDefinitionMaterialExport, GltfHdrpMaterialExporter - >(); + >.Instance; break; #endif default: diff --git a/Runtime/Scripts/Export/MetaMaterialExport.cs b/Runtime/Scripts/Export/MetaMaterialExport.cs index 08375032..d4624244 100644 --- a/Runtime/Scripts/Export/MetaMaterialExport.cs +++ b/Runtime/Scripts/Export/MetaMaterialExport.cs @@ -11,18 +11,52 @@ namespace GLTFast.Export using Logging; using Schema; + /// + [Obsolete("Use MaterialExport.GetDefaultMaterialExport instead.")] + // TODO: Make private in next major release public class MetaMaterialExport : IMaterialExport where TLitExport : IMaterialExport, new() where TGltfShaderGraphExport : IMaterialExport, new() { - static IMaterialExport s_LitMaterialExport; - static IMaterialExport s_GltfBuiltInMaterialExport; - static IMaterialExport s_GltfShaderGraphMaterialExport; - static IMaterialExport s_GltfUnlitMaterialExport; + /// + public bool ConvertMaterial( + UnityEngine.Material uMaterial, + out Material material, + IGltfWritable gltf, + ICodeLogger logger + ) + { + return MetaMaterialExportShaderGraphs + .Instance + .ConvertMaterial(uMaterial, out material, gltf, logger); + } + } + + /// + /// Picks a fitting material exporter, based on the used shader. + /// + /// Fallback material exporter for Unity Standard/Lit shaders. + /// Material exporter for glTFast shader graphs. + class MetaMaterialExportShaderGraphs : + IMaterialExport + where TLitExport : IMaterialExport, new() + where TGltfShaderGraphExport : IMaterialExport, new() + { + static TLitExport s_LitMaterialExport; + static TGltfShaderGraphExport s_GltfShaderGraphMaterialExport; + + MetaMaterialExportShaderGraphs() { } + public static MetaMaterialExportShaderGraphs Instance { get; } = + new MetaMaterialExportShaderGraphs(); /// - public bool ConvertMaterial(UnityEngine.Material uMaterial, out Material material, IGltfWritable gltf, ICodeLogger logger) + public bool ConvertMaterial( + UnityEngine.Material uMaterial, + out Material material, + IGltfWritable gltf, + ICodeLogger logger + ) { IMaterialExport materialExport; @@ -30,13 +64,7 @@ public bool ConvertMaterial(UnityEngine.Material uMaterial, out Material materia #if UNITY_SHADER_GRAPH if (name.StartsWith("Shader Graphs/glTF-")) { - if (name.LastIndexOf("nlit") >= 0) - { - // Unlit shader - s_GltfUnlitMaterialExport ??= new GltfUnlitMaterialExporter(); - materialExport = s_GltfUnlitMaterialExport; - } - else + if (!MetaMaterialExportBuiltIn.TryFindMatchingGltfUnlitMaterialExport(name, out materialExport)) { s_GltfShaderGraphMaterialExport ??= new TGltfShaderGraphExport(); materialExport = s_GltfShaderGraphMaterialExport; @@ -44,21 +72,7 @@ public bool ConvertMaterial(UnityEngine.Material uMaterial, out Material materia } else #endif - if (name.StartsWith("glTF/")) - { - if (name.LastIndexOf("nlit") >= 0) - { - // Unlit shader - s_GltfUnlitMaterialExport ??= new GltfUnlitMaterialExporter(); - materialExport = s_GltfUnlitMaterialExport; - } - else - { - s_GltfBuiltInMaterialExport ??= new GltfBuiltInShaderMaterialExporter(); - materialExport = s_GltfBuiltInMaterialExport; - } - } - else + if (!MetaMaterialExportBuiltIn.TryFindMatchingGltfMaterialExport(name, out materialExport)) { s_LitMaterialExport ??= new TLitExport(); materialExport = s_LitMaterialExport; diff --git a/Runtime/Scripts/Export/MetaMaterialExportBuiltIn.cs b/Runtime/Scripts/Export/MetaMaterialExportBuiltIn.cs new file mode 100644 index 00000000..f17ebf8c --- /dev/null +++ b/Runtime/Scripts/Export/MetaMaterialExportBuiltIn.cs @@ -0,0 +1,78 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System; +using UnityEngine; + +namespace GLTFast.Export +{ + using Logging; + using Schema; + + class MetaMaterialExportBuiltIn : IMaterialExport + { + static IMaterialExport s_LitMaterialExport; + static IMaterialExport s_GltfBuiltInMaterialExport; + static IMaterialExport s_GltfUnlitMaterialExport; + + MetaMaterialExportBuiltIn() { } + public static IMaterialExport Instance { get; } = new MetaMaterialExportBuiltIn(); + + /// + public bool ConvertMaterial( + UnityEngine.Material uMaterial, + out Material material, + IGltfWritable gltf, + ICodeLogger logger + ) + { + var materialExport = FindMatchingMaterialExport(uMaterial.shader.name); + return materialExport.ConvertMaterial(uMaterial, out material, gltf, logger); + } + + static IMaterialExport FindMatchingMaterialExport(string shaderName) + { + if (!TryFindMatchingGltfMaterialExport(shaderName, out var materialExport)) + { + s_LitMaterialExport ??= new StandardMaterialExport(); + materialExport = s_LitMaterialExport; + } + return materialExport; + } + + internal static bool TryFindMatchingGltfMaterialExport(string shaderName, out IMaterialExport materialExport) + { + if (shaderName.StartsWith("glTF/")) + { + if (TryFindMatchingGltfUnlitMaterialExport(shaderName, out materialExport)) + { + return true; + } + + s_GltfBuiltInMaterialExport ??= new GltfBuiltInShaderMaterialExporter(); + materialExport = s_GltfBuiltInMaterialExport; + return true; + } + + materialExport = null; + return false; + } + + internal static bool TryFindMatchingGltfUnlitMaterialExport( + string shaderName, + out IMaterialExport materialExport + ) + { + if (shaderName.LastIndexOf("nlit") >= 0) + { + // Unlit shader + s_GltfUnlitMaterialExport ??= new GltfUnlitMaterialExporter(); + materialExport = s_GltfUnlitMaterialExport; + return true; + } + + materialExport = null; + return false; + } + } +} diff --git a/Runtime/Scripts/Export/MetaMaterialExportBuiltIn.cs.meta b/Runtime/Scripts/Export/MetaMaterialExportBuiltIn.cs.meta new file mode 100644 index 00000000..c62210ce --- /dev/null +++ b/Runtime/Scripts/Export/MetaMaterialExportBuiltIn.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 312797c5e915b49378d46e3b89b975a1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From d65dda28994bee287e78ac361c74d92671699d8d Mon Sep 17 00:00:00 2001 From: Andreas Atteneder Date: Mon, 24 Jun 2024 17:55:48 +0200 Subject: [PATCH 07/10] feat: Load from stream (#163) * Add support for loading from stream * fix: StreamExtension is not required in 2022 LTS or newer, since those versions support implicit cast from NativeArray to ReadOnlySpan. * fix: Proper error when loading glTF-binary over 2GB in size. fix: Loading glTF binary to completion if stream has not all bytes available upon first `ReadAsync`. * feat(test): Added test for LoadStream. --------- Co-authored-by: Sandro Forster --- CHANGELOG.md | 2 + Runtime/Scripts/Export/StreamExtension.cs | 2 + Runtime/Scripts/GltfImport.cs | 92 +++++++++++++++++------ Runtime/Scripts/Logging/LogMessages.cs | 5 ++ Runtime/Scripts/StreamExtension.cs | 35 +++++++++ Runtime/Scripts/StreamExtension.cs.meta | 11 +++ Tests/Runtime/Scripts/Import/LoadTests.cs | 57 ++++++++++++++ 7 files changed, 181 insertions(+), 23 deletions(-) mode change 100644 => 100755 Runtime/Scripts/GltfImport.cs create mode 100644 Runtime/Scripts/StreamExtension.cs create mode 100644 Runtime/Scripts/StreamExtension.cs.meta diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f740bd3..89924ceb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - (Import) Support for [materials variants extension](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_variants). - Serialization support for material extensions IOR, Sheen and Specular. +- (Import) Ability to load a glTF from a generic `Stream` (`GltfImport.LoadStream`; thanks [sandr01d][sandr01d] for [#10](https://github.com/Unity-Technologies/com.unity.cloud.gltfast/pull/10)). ### Changed - (Import) Prefabs imported from glTF assets (at design-time) don't have the glTF logo icon assigned to them anymore. This makes it more consistent with other file types (like FBX; fixes [#557](https://github.com/atteneder/glTFast/issues/557)). @@ -1202,6 +1203,7 @@ This release contains multiple breaking changes. Please read the [upgrade guide] [mikejurka]: https://github.com/mikejurka [ReadyPlayerMe]: https://readyplayer.me [rt-nikowiss]: https://github.com/rt-nikowiss +[sandr01d]: https://github.com/sandr01d [NyxStudio]: https://github.com/NyxStudio [zharry]: https://github.com/zharry [weichx]: https://gist.github.com/weichx diff --git a/Runtime/Scripts/Export/StreamExtension.cs b/Runtime/Scripts/Export/StreamExtension.cs index 39a2d775..ae2df602 100644 --- a/Runtime/Scripts/Export/StreamExtension.cs +++ b/Runtime/Scripts/Export/StreamExtension.cs @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: 2023 Unity Technologies and the glTFast authors // SPDX-License-Identifier: Apache-2.0 +#if !UNITY_2022_2_OR_NEWER using System; using System.IO; using UnityEngine; @@ -34,3 +35,4 @@ public static void Write(this Stream stream, IEnumerable array) #endif } } +#endif diff --git a/Runtime/Scripts/GltfImport.cs b/Runtime/Scripts/GltfImport.cs old mode 100644 new mode 100755 index ef9ef666..16483637 --- a/Runtime/Scripts/GltfImport.cs +++ b/Runtime/Scripts/GltfImport.cs @@ -21,7 +21,7 @@ using System.Threading.Tasks; using System.Threading; using System; - +using System.Text; using GLTFast.Addons; using GLTFast.Jobs; #if MEASURE_TIMINGS @@ -471,17 +471,43 @@ public async Task LoadFile( CancellationToken cancellationToken = default ) { - var firstBytes = new byte[4]; - #if UNITY_2021_3_OR_NEWER && NET_STANDARD_2_1 await using #endif var fs = new FileStream(localPath, FileMode.Open, FileAccess.Read); - var bytesRead = await fs.ReadAsync(firstBytes, 0, firstBytes.Length, cancellationToken); + var result = await LoadStream(fs, uri, importSettings, cancellationToken); + fs.Dispose(); + return result; + } - if (bytesRead != firstBytes.Length) + /// + /// Load glTF from a stream. + /// + /// Stream of the glTF or glTF-Binary + /// Base URI for relative paths of external buffers or images + /// Import Settings ( for details) + /// Token to submit cancellation requests. The default value is None. + /// True if loading was successful, false otherwise + public async Task LoadStream( + Stream stream, + Uri uri = null, + ImportSettings importSettings = null, + CancellationToken cancellationToken = default) + { + if (!stream.CanRead) { - m_Logger?.Error(LogCode.Download, "Failed reading first bytes", localPath); + m_Logger?.Error(LogCode.StreamError, "Not readable"); + return false; + } + + var initialStreamPosition = stream.CanSeek + ? stream.Position + : -1L; + + var firstBytes = new byte[4]; + if (!await stream.ReadToArrayAsync(firstBytes, 0, firstBytes.Length, cancellationToken)) + { + m_Logger?.Error(LogCode.StreamError, "First bytes"); return false; } @@ -489,32 +515,52 @@ public async Task LoadFile( if (GltfGlobals.IsGltfBinary(firstBytes)) { - var data = new byte[fs.Length]; - for (var i = 0; i < firstBytes.Length; i++) + // Read the rest of the header + var glbHeader = new byte[8]; + if (!await stream.ReadToArrayAsync(glbHeader, 0, glbHeader.Length, cancellationToken)) { - data[i] = firstBytes[i]; + m_Logger?.Error(LogCode.StreamError, "glb header"); + return false; } - var length = (int)fs.Length - 4; - var read = await fs.ReadAsync(data, 4, length, cancellationToken); - fs.Close(); - if (read != length) + // Length of the entire glTF, including the header + var length = BitConverter.ToUInt32(glbHeader, 4); + if (length >= int.MaxValue) { - m_Logger?.Error(LogCode.Download, "Failed reading data", localPath); + // glTF-binary supports up to 2^32 = 4GB, but C# arrays have a 2^31 (2GB) limit. + m_Logger?.Error("glb exceeds 2GB limit."); return false; } + var data = new byte[length]; + Array.Copy(firstBytes, data, firstBytes.Length); + Array.Copy(glbHeader, 0, data, firstBytes.Length, glbHeader.Length); + // The amount of bytes we've already read + var offset = firstBytes.Length + glbHeader.Length; + var pendingBytes = (int)length - offset; + + if (!await stream.ReadToArrayAsync(data, offset, pendingBytes, cancellationToken)) + { + m_Logger?.Error(LogCode.StreamError, "glb data"); + } return await LoadGltfBinary(data, uri, importSettings, cancellationToken); } - fs.Close(); + var reader = new StreamReader(stream); + string json; + if (stream.CanSeek) + { + stream.Seek(initialStreamPosition, SeekOrigin.Begin); + json = await reader.ReadToEndAsync(); + } + else + { + // TODO: String concat likely leads to another copy in memory and bad performance. + json = Encoding.UTF8.GetString(firstBytes) + await reader.ReadToEndAsync(); + } - return await LoadGltfJson( -#if UNITY_2021_3_OR_NEWER - await File.ReadAllTextAsync(localPath,cancellationToken), -#else - File.ReadAllText(localPath), -#endif - uri, - importSettings, cancellationToken); + reader.Dispose(); + + return !cancellationToken.IsCancellationRequested + && await LoadGltfJson(json, uri, importSettings, cancellationToken); } /// diff --git a/Runtime/Scripts/Logging/LogMessages.cs b/Runtime/Scripts/Logging/LogMessages.cs index 96cc568e..9108aa3e 100644 --- a/Runtime/Scripts/Logging/LogMessages.cs +++ b/Runtime/Scripts/Logging/LogMessages.cs @@ -242,6 +242,10 @@ public enum LogCode : uint /// Inconsistent use of vertex color attribute. /// InconsistentVertexColorUsage, + /// + /// Stream read error. + /// + StreamError, } /// @@ -299,6 +303,7 @@ This may result in low performance and high memory usage. Try optimizing the glT { LogCode.ShaderMissing, $"Shader \"{{0}}\" is missing. Make sure to include it in the build (see {GltfGlobals.GltfPackageName}/Documentation~/ProjectSetup.md#materials-and-shader-variants )" }, { LogCode.SkinMissing, "Skin missing" }, { LogCode.SparseAccessor, "Sparse Accessor not supported ({0})" }, + { LogCode.StreamError, "Stream error: {0}." }, { LogCode.TextureDownloadFailed, "Download texture {1} failed: {0}" }, { LogCode.TextureInvalidType, "Invalid {0} texture type (material: {1})" }, { LogCode.TextureLoadFailed, "Texture #{0} not loaded" }, diff --git a/Runtime/Scripts/StreamExtension.cs b/Runtime/Scripts/StreamExtension.cs new file mode 100644 index 00000000..3e5f46c2 --- /dev/null +++ b/Runtime/Scripts/StreamExtension.cs @@ -0,0 +1,35 @@ +// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors +// SPDX-License-Identifier: Apache-2.0 + +using System; +using System.IO; +using System.Threading; +using UnityEngine; + +using System.Threading.Tasks; + +namespace GLTFast +{ + static class StreamExtension + { + public static async Task ReadToArrayAsync( + this Stream stream, + byte[] destination, + int offset, + int length, + CancellationToken cancellationToken + ) + { + int readBytes; + var pendingBytes = length; + do + { + readBytes = await stream.ReadAsync(destination, offset, pendingBytes, cancellationToken); + pendingBytes -= readBytes; + offset += readBytes; + } while (pendingBytes > 0 && readBytes > 0); + + return pendingBytes <= 0; + } + } +} diff --git a/Runtime/Scripts/StreamExtension.cs.meta b/Runtime/Scripts/StreamExtension.cs.meta new file mode 100644 index 00000000..3c3e9a96 --- /dev/null +++ b/Runtime/Scripts/StreamExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d2c0632470c474a8086dc993f838e7a0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Runtime/Scripts/Import/LoadTests.cs b/Tests/Runtime/Scripts/Import/LoadTests.cs index 971d0d4a..6b801314 100644 --- a/Tests/Runtime/Scripts/Import/LoadTests.cs +++ b/Tests/Runtime/Scripts/Import/LoadTests.cs @@ -8,6 +8,7 @@ using UnityEngine; using Object = UnityEngine.Object; using GLTFast.Logging; +using UnityEngine.TestTools; namespace GLTFast.Tests.Import { @@ -158,6 +159,29 @@ public IEnumerator LoadBinary(GltfTestCaseSet testCaseSet, GltfTestCase testCase Object.Destroy(go); } + [GltfTestCase("glTF-test-models", 2, k_RelativeUriFilter)] + public IEnumerator LoadStream(GltfTestCaseSet testCaseSet, GltfTestCase testCase) + { + var path = Path.Combine(testCaseSet.RootPath, testCase.relativeUri); + Debug.Log($"Testing {path}"); + var stream = new FileStream(path, FileMode.Open); + var go = new GameObject(); + var deferAgent = new UninterruptedDeferAgent(); + var logger = new ConsoleLogger(); + using var gltf = new GltfImport(deferAgent: deferAgent, logger: logger); + var task = gltf.LoadStream(stream, new Uri(path)); + yield return Utils.WaitForTask(task); + stream.Dispose(); + var success = task.Result; + Assert.IsTrue(success); + var instantiator = new GameObjectInstantiator(gltf, go.transform, logger); + task = gltf.InstantiateMainSceneAsync(instantiator); + yield return Utils.WaitForTask(task); + success = task.Result; + Assert.IsTrue(success); + Object.Destroy(go); + } + [GltfTestCase("glTF-test-models", 2, k_RelativeUriFilter)] public IEnumerator LoadJson(GltfTestCaseSet testCaseSet, GltfTestCase testCase) { @@ -183,5 +207,38 @@ public IEnumerator LoadJson(GltfTestCaseSet testCaseSet, GltfTestCase testCase) Assert.IsTrue(success); Object.Destroy(go); } + + [UnityTest] + public IEnumerator LoadStreamBigGltf() + { + // Create header-only glTF-binary that's too big (4GB). + var stream = new MemoryStream(); + // glTF magic + stream.Write(BitConverter.GetBytes(GltfGlobals.GltfBinaryMagic), 0, 4); + // glTF version + stream.Write(BitConverter.GetBytes(2u), 0, 4); + // Total size + stream.Write(BitConverter.GetBytes(uint.MaxValue), 0, 4); + stream.Seek(0, SeekOrigin.Begin); + + var deferAgent = new UninterruptedDeferAgent(); + var logger = new CollectingLogger(); + using var gltf = new GltfImport(deferAgent: deferAgent, logger: logger); + var task = gltf.LoadStream(stream); + yield return Utils.WaitForTask(task); + stream.Dispose(); + var success = task.Result; + Assert.IsFalse(success); + LoggerTest.AssertLogger( + logger, + new[] + { + new LogItem( + LogType.Error, + LogCode.None, + "glb exceeds 2GB limit." + ) + }); + } } } From b42173f5d8799a40725e7be42b5a6e1a34f4c003 Mon Sep 17 00:00:00 2001 From: Andreas Atteneder Date: Mon, 24 Jun 2024 19:42:48 +0200 Subject: [PATCH 08/10] fix: Alpha mode blend now works as expected in HDRP 11 and newer as well (fixes https://github.com/atteneder/glTFast/issues/699). (#164) --- CHANGELOG.md | 1 + .../Scripts/Material/HighDefinitionRPMaterialGenerator.cs | 3 +++ Runtime/Scripts/Material/MaterialProperty.cs | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89924ceb..5dd06250 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - (Export) glTFast shader based materials and textures are exported correctly when using the default render pipeline. - Added missing entries to the API documentation. - (Export) Base colors are now in correct, linear color space. +- Alpha mode blend now works as expected in HDRP 11 and newer as well (fixes [#699](https://github.com/atteneder/glTFast/issues/699)). ## [6.6.0] - 2024-05-29 diff --git a/Runtime/Scripts/Material/HighDefinitionRPMaterialGenerator.cs b/Runtime/Scripts/Material/HighDefinitionRPMaterialGenerator.cs index 2c3b6178..d00abbe8 100644 --- a/Runtime/Scripts/Material/HighDefinitionRPMaterialGenerator.cs +++ b/Runtime/Scripts/Material/HighDefinitionRPMaterialGenerator.cs @@ -180,6 +180,9 @@ protected override void SetShaderModeBlend(Schema.MaterialBase gltfMaterial, Mat material.SetFloat(AlphaDstBlendProperty, (int)BlendMode.OneMinusSrcAlpha);//10 material.SetFloat(MaterialProperty.DstBlend, (int)BlendMode.OneMinusSrcAlpha);//10 material.SetFloat(MaterialProperty.SrcBlend, (int) BlendMode.SrcAlpha);//5 +#if UNITY_2021_1_OR_NEWER + material.SetFloat(MaterialProperty.EnableBlendModePreserveSpecularLighting, 0); +#endif } #endif // USING_HDRP_10_OR_NEWER } diff --git a/Runtime/Scripts/Material/MaterialProperty.cs b/Runtime/Scripts/Material/MaterialProperty.cs index 9e95c8ef..f8e60053 100644 --- a/Runtime/Scripts/Material/MaterialProperty.cs +++ b/Runtime/Scripts/Material/MaterialProperty.cs @@ -3,6 +3,9 @@ using System; using UnityEngine; +#if USING_HDRP +using UnityEngine.Rendering.HighDefinition; +#endif namespace GLTFast.Materials { @@ -112,6 +115,10 @@ public static class MaterialProperty public static readonly int AlphaCutoffEnable = Shader.PropertyToID("_AlphaCutoffEnable"); /// Shader property ID for property _DoubleSidedEnable public static readonly int DoubleSidedEnable = Shader.PropertyToID("_DoubleSidedEnable"); +#if UNITY_2021_1_OR_NEWER + /// Shader property ID for property _EnableBlendModePreserveSpecularLighting + public static readonly int EnableBlendModePreserveSpecularLighting = Shader.PropertyToID(HDMaterialProperties.kEnableBlendModePreserveSpecularLighting); +#endif /// Shader property ID for property _SurfaceType public static readonly int SurfaceType = Shader.PropertyToID("_SurfaceType"); #endif From ab363089a57df53bb817b4b459fda09e7112e26f Mon Sep 17 00:00:00 2001 From: Andreas Atteneder Date: Tue, 25 Jun 2024 14:39:26 +0200 Subject: [PATCH 09/10] fix(export): Fixed mesh min/max when using Draco compression. (#165) --- CHANGELOG.md | 1 + Runtime/Scripts/Export/GltfWriter.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dd06250..f75dc52e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added missing entries to the API documentation. - (Export) Base colors are now in correct, linear color space. - Alpha mode blend now works as expected in HDRP 11 and newer as well (fixes [#699](https://github.com/atteneder/glTFast/issues/699)). +- (Export) Fixed mesh min/max when using Draco compression. ## [6.6.0] - 2024-05-29 diff --git a/Runtime/Scripts/Export/GltfWriter.cs b/Runtime/Scripts/Export/GltfWriter.cs index fb572ae5..495933ed 100755 --- a/Runtime/Scripts/Export/GltfWriter.cs +++ b/Runtime/Scripts/Export/GltfWriter.cs @@ -1301,13 +1301,13 @@ async Task BakeMeshDraco(int meshId, UnityEngine.Mesh.MeshData meshData) var extents = bounds.extents; accessor.min = new[] { - center.x-extents.x, + -center.x-extents.x, center.y-extents.y, center.z-extents.z }; accessor.max = new[] { - center.x+extents.x, + -center.x+extents.x, center.y+extents.y, center.z+extents.z }; From 50838b97cb3d3490b7e05f7e115d844fbcaea58e Mon Sep 17 00:00:00 2001 From: Andreas Atteneder Date: Tue, 25 Jun 2024 16:33:13 +0200 Subject: [PATCH 10/10] Release 6.7.0 --- 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 f75dc52e..fdb737e3 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.7.0] - 2024-06-25 ### Added - (Import) Support for [materials variants extension](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_variants). diff --git a/Runtime/Scripts/Export/Constants.cs b/Runtime/Scripts/Export/Constants.cs index dea1832e..12109be4 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.6.0"; + public const string version = "6.7.0"; internal const string mimeTypePNG = "image/png"; internal const string mimeTypeJPG = "image/jpeg"; diff --git a/package.json b/package.json index b622ae79..35e0296f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.unity.cloud.gltfast", - "version": "6.6.0", + "version": "6.7.0", "displayName": "Unity glTFast", "description": "Use glTFast to import and export glTF 3D files efficiently at runtime or in the Editor", "unity": "2020.3",