diff --git a/CHANGELOG.md b/CHANGELOG.md
index 53d622b..c7d78f3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+#1.1.8
+- Reverted gltfast version to 5.0.0
+
#1.1.7
- Updated gltfast to 6.16.1
diff --git a/Runtime/GLTFastWrappers/DecentralandMaterialGenerator.cs b/Runtime/GLTFastWrappers/DecentralandMaterialGenerator.cs
index 3ed8d0b..0a09564 100644
--- a/Runtime/GLTFastWrappers/DecentralandMaterialGenerator.cs
+++ b/Runtime/GLTFastWrappers/DecentralandMaterialGenerator.cs
@@ -32,18 +32,15 @@ public DecentralandMaterialGenerator(string shaderName, bool preserveMaxAlpha =
///
/// Here we convert a GLTFMaterial into our Material using our shaders
///
- ///
- ///
- ///
- public override Material GenerateMaterial(MaterialBase gltfMaterial, IGltfReadable gltf, bool pointsSupport = false)
+ public override Material GenerateMaterial(int materialIndex, GLTFastMaterial gltfMaterial, IGltfReadable gltf, bool pointsSupport = false)
{
material = new Material(shader);
- SetMaterialName(gltfMaterial);
+ SetMaterialName(materialIndex, gltfMaterial);
- if (gltfMaterial.Extensions?.KHR_materials_pbrSpecularGlossiness != null)
+ if (gltfMaterial.extensions?.KHR_materials_pbrSpecularGlossiness != null)
{
- var specGloss = gltfMaterial.Extensions.KHR_materials_pbrSpecularGlossiness;
+ var specGloss = gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness;
SetColor(specGloss.DiffuseColor.gamma);
SetSpecularColor(specGloss.SpecularColor);
@@ -56,21 +53,21 @@ public override Material GenerateMaterial(MaterialBase gltfMaterial, IGltfReadab
// (according to extension specification)
else
{
- PbrMetallicRoughnessBase roughness = gltfMaterial.PbrMetallicRoughness;
+ PbrMetallicRoughness roughness = gltfMaterial.pbrMetallicRoughness;
if (roughness != null)
{
SetColor(roughness.BaseColor.gamma);
- SetBaseMapTexture(roughness.BaseColorTexture, gltf);
+ SetBaseMapTexture(roughness.baseColorTexture, gltf);
SetMetallic(roughness.metallicFactor);
- SetMetallicRoughnessTexture(gltf, roughness.MetallicRoughnessTexture, roughness.roughnessFactor);
+ SetMetallicRoughnessTexture(gltf, roughness.metallicRoughnessTexture, roughness.roughnessFactor);
}
}
- SetBumpMapTexture(gltfMaterial.NormalTexture, gltf);
- SetOcclusionTexture(gltfMaterial.OcclusionTexture, gltf);
+ SetBumpMapTexture(gltfMaterial.normalTexture, gltf);
+ SetOcclusionTexture(gltfMaterial.occlusionTexture, gltf);
SetEmissiveColor(gltfMaterial.Emissive);
- SetEmissiveTexture(gltfMaterial.EmissiveTexture, gltf);
+ SetEmissiveTexture(gltfMaterial.emissiveTexture, gltf);
SetAlphaMode(gltfMaterial.GetAlphaMode(), gltfMaterial.alphaCutoff);
SetDoubleSided(gltfMaterial.doubleSided);
@@ -79,7 +76,7 @@ public override Material GenerateMaterial(MaterialBase gltfMaterial, IGltfReadab
}
// This step is important if we want to keep the functionality of skin and hair colouring
- private void SetMaterialName(MaterialBase gltfMaterial)
+ private void SetMaterialName(int materialIndex, GLTFastMaterial gltfMaterial)
{
material.name = "material";
@@ -93,6 +90,8 @@ private void SetMaterialName(MaterialBase gltfMaterial)
if (originalName.Contains("hair"))
material.name += "_hair";
}
+
+ material.name += $"_{materialIndex}";
}
private void SetEmissiveColor(Color gltfMaterialEmissive)
@@ -105,7 +104,7 @@ private void SetEmissiveColor(Color gltfMaterialEmissive)
}
}
- private void SetEmissiveTexture(TextureInfoBase emissiveTexture, IGltfReadable gltf)
+ private void SetEmissiveTexture(TextureInfo emissiveTexture, IGltfReadable gltf)
{
if (TrySetTexture(
emissiveTexture,
@@ -122,7 +121,7 @@ private void SetEmissiveTexture(TextureInfoBase emissiveTexture, IGltfReadable g
}
}
- private void SetOcclusionTexture(OcclusionTextureInfoBase occlusionTexture, IGltfReadable gltf)
+ private void SetOcclusionTexture(OcclusionTextureInfo occlusionTexture, IGltfReadable gltf)
{
if (TrySetTexture(
occlusionTexture,
@@ -139,7 +138,7 @@ private void SetOcclusionTexture(OcclusionTextureInfoBase occlusionTexture, IGlt
}
}
- private void SetBumpMapTexture(NormalTextureInfoBase textureInfo, IGltfReadable gltf)
+ private void SetBumpMapTexture(NormalTextureInfo textureInfo, IGltfReadable gltf)
{
if (TrySetTexture(
textureInfo,
@@ -157,7 +156,7 @@ private void SetBumpMapTexture(NormalTextureInfoBase textureInfo, IGltfReadable
}
}
- private void SetMetallicRoughnessTexture(IGltfReadable gltf, TextureInfoBase textureInfo, float roughnessFactor)
+ private void SetMetallicRoughnessTexture(IGltfReadable gltf, TextureInfo textureInfo, float roughnessFactor)
{
if (TrySetTexture(
textureInfo,
@@ -202,7 +201,7 @@ private void SetSpecularMapTexture(TextureInfo textureInfo, IGltfReadable gltf)
}
}
- private void SetBaseMapTexture(TextureInfoBase textureInfo, IGltfReadable gltf)
+ private void SetBaseMapTexture(TextureInfo textureInfo, IGltfReadable gltf)
{
TrySetTexture(
textureInfo,
diff --git a/Runtime/GLTFastWrappers/DefaultMaterialGenerator.cs b/Runtime/GLTFastWrappers/DefaultMaterialGenerator.cs
index 2648cb3..80e95d2 100644
--- a/Runtime/GLTFastWrappers/DefaultMaterialGenerator.cs
+++ b/Runtime/GLTFastWrappers/DefaultMaterialGenerator.cs
@@ -1,9 +1,7 @@
using GLTFast;
using GLTFast.Materials;
-using GLTFast.Schema;
using System;
using UnityEngine;
-using Material = UnityEngine.Material;
namespace DCL.GLTFast.Wrappers
{
@@ -15,26 +13,28 @@ internal class DefaultMaterialGenerator : ShaderGraphMaterialGenerator
{
private const float CUSTOM_EMISSIVE_FACTOR = 5f;
- public override Material GenerateMaterial(MaterialBase gltfMaterial, IGltfReadable gltf, bool pointsSupport = false)
+ public override Material GenerateMaterial(int materialIndex, global::GLTFast.Schema.Material gltfMaterial, IGltfReadable gltf, bool pointsSupport = false)
{
- Material generatedMaterial = base.GenerateMaterial(gltfMaterial, gltf, pointsSupport);
+ Material generatedMaterial = base.GenerateMaterial(materialIndex, gltfMaterial, gltf);
- SetMaterialName(generatedMaterial, gltfMaterial);
+ SetMaterialName(generatedMaterial, materialIndex, gltfMaterial);
- if (gltfMaterial.Emissive != Color.black) { generatedMaterial.SetColor(MaterialProperty.EmissiveFactor, gltfMaterial.Emissive * CUSTOM_EMISSIVE_FACTOR); }
+ if (gltfMaterial.Emissive != Color.black) { generatedMaterial.SetColor(EmissiveFactorProperty, gltfMaterial.Emissive * CUSTOM_EMISSIVE_FACTOR); }
return generatedMaterial;
// This step is important if we want to keep the functionality of skin and hair colouring
- void SetMaterialName(Material material, MaterialBase materialBase)
+ void SetMaterialName(Material material, int materialIndex, global::GLTFast.Schema.Material gltfMaterial)
{
material.name = "material";
- if (materialBase.name.Contains("skin", StringComparison.InvariantCultureIgnoreCase))
+ if (gltfMaterial.name.Contains("skin", StringComparison.InvariantCultureIgnoreCase))
material.name += "_skin";
- if (materialBase.name.Contains("hair", StringComparison.InvariantCultureIgnoreCase))
+ if (gltfMaterial.name.Contains("hair", StringComparison.InvariantCultureIgnoreCase))
material.name += "_hair";
+
+ material.name += $"_{materialIndex}";
}
}
}
diff --git a/package.json b/package.json
index 6459232..3454e68 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "com.decentraland.unity-shared-dependencies",
- "version": "1.1.7",
+ "version": "1.1.8",
"displayName": "Decentraland.SharedDependencies",
"description": "This package contains shared dependencies between unity-renderer, aang-renderer and asset-bundle-converter repositories, this includes gltf importer wrappers, shaders and wearable utils",
"unity": "2021.3",