Browse Source

Added support for KHR_Materials_Specular

Vicente Penades 4 years ago
parent
commit
804f455cc5

+ 2 - 1
build/SharpGLTF.CodeGen/Constants.cs

@@ -22,7 +22,7 @@ namespace SharpGLTF
         /// <summary>
         /// <summary>
         /// Directory of the main schema within the download repo directory
         /// Directory of the main schema within the download repo directory
         /// </summary>
         /// </summary>
-        public static string MainSchemaDir => System.IO.Path.Combine(LocalRepoDirectory, "specification", "2.0", "schema", "2020-12");
+        public static string MainSchemaDir => System.IO.Path.Combine(LocalRepoDirectory, "specification", "2.0", "schema");
 
 
         /// <summary>
         /// <summary>
         /// schema source code file path
         /// schema source code file path
@@ -49,6 +49,7 @@ namespace SharpGLTF
             public static string PbrClearCoat => _Path("KHR_materials_clearcoat", "glTF.KHR_materials_clearcoat.schema.json");
             public static string PbrClearCoat => _Path("KHR_materials_clearcoat", "glTF.KHR_materials_clearcoat.schema.json");
             public static string PbrTransmission => _Path("KHR_materials_transmission", "glTF.KHR_materials_transmission.schema.json");
             public static string PbrTransmission => _Path("KHR_materials_transmission", "glTF.KHR_materials_transmission.schema.json");
             public static string PbrSheen => _Path("KHR_materials_sheen", "glTF.KHR_materials_sheen.schema.json");
             public static string PbrSheen => _Path("KHR_materials_sheen", "glTF.KHR_materials_sheen.schema.json");
+            public static string PbrSpecular => _Path("KHR_materials_specular", "glTF.KHR_materials_specular.schema.json");
             public static string MaterialIor => _Path("KHR_materials_ior", "glTF.KHR_materials_ior.schema.json");
             public static string MaterialIor => _Path("KHR_materials_ior", "glTF.KHR_materials_ior.schema.json");
             public static string Unlit => _Path("KHR_materials_unlit", "glTF.KHR_materials_unlit.schema.json");
             public static string Unlit => _Path("KHR_materials_unlit", "glTF.KHR_materials_unlit.schema.json");
             public static string LightsPunctual_Model => _Path("KHR_lights_punctual", "glTF.KHR_lights_punctual.schema.json");
             public static string LightsPunctual_Model => _Path("KHR_lights_punctual", "glTF.KHR_lights_punctual.schema.json");

+ 21 - 2
build/SharpGLTF.CodeGen/Program.cs

@@ -31,7 +31,8 @@ namespace SharpGLTF
             _ProcessKhronosUnlitExtension();
             _ProcessKhronosUnlitExtension();
             _ProcessKhronosIorExtension();
             _ProcessKhronosIorExtension();
             _ProcessKhronosSheenExtension();
             _ProcessKhronosSheenExtension();
-            _ProcessKhronosClearCoatExtension();
+            _ProcessKhronosSpecularExtension();
+            _ProcessKhronosClearCoatExtension();            
             _ProcessKhronosTransmissionExtension();
             _ProcessKhronosTransmissionExtension();
             _ProcessKhronosSpecularGlossinessExtension();
             _ProcessKhronosSpecularGlossinessExtension();
 
 
@@ -198,6 +199,23 @@ namespace SharpGLTF
             ProcessSchema("ext.ClearCoat.g", ctx);
             ProcessSchema("ext.ClearCoat.g", ctx);
         }
         }
 
 
+        private static void _ProcessKhronosSpecularExtension()
+        {
+            var ctx = LoadSchemaContext(Constants.KhronosExtensions.PbrSpecular);
+            ctx.IgnoredByCodeEmitter("glTF Property");
+            ctx.IgnoredByCodeEmitter("glTF Child of Root Property");
+            ctx.IgnoredByCodeEmitter("Texture Info");
+            ctx.IgnoredByCodeEmitter("Material Normal Texture Info");
+
+            ctx.FindClass("KHR_materials_specular glTF extension")
+                .GetField("specularColorFactor")
+                .SetDataType(typeof(System.Numerics.Vector3), true)
+                .SetDefaultValue("Vector3.One")
+                .SetItemsRange(0);
+
+            ProcessSchema("ext.pbrSpecular.g", ctx);
+        }
+
         private static void _ProcessKhronosTransmissionExtension()
         private static void _ProcessKhronosTransmissionExtension()
         {
         {
             var ctx = LoadSchemaContext(Constants.KhronosExtensions.PbrTransmission);
             var ctx = LoadSchemaContext(Constants.KhronosExtensions.PbrTransmission);
@@ -404,7 +422,8 @@ namespace SharpGLTF
             newEmitter.SetRuntimeName("LINEAR-LINEAR_MIPMAP_LINEAR-LINEAR_MIPMAP_NEAREST-NEAREST-NEAREST_MIPMAP_LINEAR-NEAREST_MIPMAP_NEAREST", "TextureMipMapFilter");
             newEmitter.SetRuntimeName("LINEAR-LINEAR_MIPMAP_LINEAR-LINEAR_MIPMAP_NEAREST-NEAREST-NEAREST_MIPMAP_LINEAR-NEAREST_MIPMAP_NEAREST", "TextureMipMapFilter");
 
 
             newEmitter.SetRuntimeName("KHR_materials_pbrSpecularGlossiness glTF extension", "MaterialPBRSpecularGlossiness");
             newEmitter.SetRuntimeName("KHR_materials_pbrSpecularGlossiness glTF extension", "MaterialPBRSpecularGlossiness");
-            newEmitter.SetRuntimeName("KHR_materials_unlit glTF extension", "MaterialUnlit");            
+            newEmitter.SetRuntimeName("KHR_materials_unlit glTF extension", "MaterialUnlit");
+            newEmitter.SetRuntimeName("KHR_materials_specular glTF extension", "MaterialSpecular");
             newEmitter.SetRuntimeName("KHR_materials_clearcoat glTF extension", "MaterialClearCoat");
             newEmitter.SetRuntimeName("KHR_materials_clearcoat glTF extension", "MaterialClearCoat");
             newEmitter.SetRuntimeName("KHR_materials_transmission glTF extension", "MaterialTransmission");
             newEmitter.SetRuntimeName("KHR_materials_transmission glTF extension", "MaterialTransmission");
             newEmitter.SetRuntimeName("KHR_materials_sheen glTF extension", "MaterialSheen");
             newEmitter.SetRuntimeName("KHR_materials_sheen glTF extension", "MaterialSheen");

+ 72 - 0
src/SharpGLTF.Core/Schema2/Generated/ext.pbrSpecular.g.cs

@@ -0,0 +1,72 @@
+// <auto-generated/>
+
+//------------------------------------------------------------------------------------------------
+//      This file has been programatically generated; DON´T EDIT!
+//------------------------------------------------------------------------------------------------
+
+#pragma warning disable SA1001
+#pragma warning disable SA1027
+#pragma warning disable SA1028
+#pragma warning disable SA1121
+#pragma warning disable SA1205
+#pragma warning disable SA1309
+#pragma warning disable SA1402
+#pragma warning disable SA1505
+#pragma warning disable SA1507
+#pragma warning disable SA1508
+#pragma warning disable SA1652
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Numerics;
+using System.Text.Json;
+
+namespace SharpGLTF.Schema2
+{
+	using Collections;
+
+	/// <summary>
+	/// glTF extension that defines the strength of the specular reflection.
+	/// </summary>
+	partial class MaterialSpecular : ExtraProperties
+	{
+	
+		private static readonly Vector3 _specularColorFactorDefault = Vector3.One;
+		private Vector3? _specularColorFactor = _specularColorFactorDefault;
+		
+		private TextureInfo _specularColorTexture;
+		
+		private const Double _specularFactorDefault = 1;
+		private const Double _specularFactorMinimum = 0;
+		private const Double _specularFactorMaximum = 1;
+		private Double? _specularFactor = _specularFactorDefault;
+		
+		private TextureInfo _specularTexture;
+		
+	
+		protected override void SerializeProperties(Utf8JsonWriter writer)
+		{
+			base.SerializeProperties(writer);
+			SerializeProperty(writer, "specularColorFactor", _specularColorFactor, _specularColorFactorDefault);
+			SerializePropertyObject(writer, "specularColorTexture", _specularColorTexture);
+			SerializeProperty(writer, "specularFactor", _specularFactor, _specularFactorDefault);
+			SerializePropertyObject(writer, "specularTexture", _specularTexture);
+		}
+	
+		protected override void DeserializeProperty(string jsonPropertyName, ref Utf8JsonReader reader)
+		{
+			switch (jsonPropertyName)
+			{
+				case "specularColorFactor": _specularColorFactor = DeserializePropertyValue<Vector3?>(ref reader); break;
+				case "specularColorTexture": _specularColorTexture = DeserializePropertyValue<TextureInfo>(ref reader); break;
+				case "specularFactor": _specularFactor = DeserializePropertyValue<Double?>(ref reader); break;
+				case "specularTexture": _specularTexture = DeserializePropertyValue<TextureInfo>(ref reader); break;
+				default: base.DeserializeProperty(jsonPropertyName,ref reader); break;
+			}
+		}
+	
+	}
+
+}

+ 1 - 0
src/SharpGLTF.Core/Schema2/gltf.ExtensionsFactory.cs

@@ -31,6 +31,7 @@ namespace SharpGLTF.Schema2
             RegisterExtension<Material, MaterialUnlit>("KHR_materials_unlit");
             RegisterExtension<Material, MaterialUnlit>("KHR_materials_unlit");
             RegisterExtension<Material, MaterialSheen>("KHR_materials_sheen");
             RegisterExtension<Material, MaterialSheen>("KHR_materials_sheen");
             RegisterExtension<Material, MaterialIOR>("KHR_materials_ior");
             RegisterExtension<Material, MaterialIOR>("KHR_materials_ior");
+            RegisterExtension<Material, MaterialSpecular>("KHR_materials_specular");
             RegisterExtension<Material, MaterialClearCoat>("KHR_materials_clearcoat");
             RegisterExtension<Material, MaterialClearCoat>("KHR_materials_clearcoat");
             RegisterExtension<Material, MaterialTransmission>("KHR_materials_transmission");
             RegisterExtension<Material, MaterialTransmission>("KHR_materials_transmission");
             RegisterExtension<Material, MaterialPBRSpecularGlossiness>("KHR_materials_pbrSpecularGlossiness");
             RegisterExtension<Material, MaterialPBRSpecularGlossiness>("KHR_materials_pbrSpecularGlossiness");

+ 88 - 2
src/SharpGLTF.Core/Schema2/gltf.MaterialsFactory.cs

@@ -18,6 +18,7 @@ namespace SharpGLTF.Schema2
             this.RemoveExtensions<MaterialUnlit>();
             this.RemoveExtensions<MaterialUnlit>();
             this.RemoveExtensions<MaterialSheen>();
             this.RemoveExtensions<MaterialSheen>();
             this.RemoveExtensions<MaterialClearCoat>();
             this.RemoveExtensions<MaterialClearCoat>();
+            this.RemoveExtensions<MaterialSpecular>();
             this.RemoveExtensions<MaterialTransmission>();
             this.RemoveExtensions<MaterialTransmission>();
             this.RemoveExtensions<MaterialPBRSpecularGlossiness>();
             this.RemoveExtensions<MaterialPBRSpecularGlossiness>();
         }
         }
@@ -48,9 +49,10 @@ namespace SharpGLTF.Schema2
 
 
             foreach (var extn in extensionNames)
             foreach (var extn in extensionNames)
             {
             {
+                if (extn == "Sheen") this.UseExtension<MaterialSheen>();
+                if (extn == "Specular") this.UseExtension<MaterialSpecular>();
                 if (extn == "ClearCoat") this.UseExtension<MaterialClearCoat>();
                 if (extn == "ClearCoat") this.UseExtension<MaterialClearCoat>();
                 if (extn == "Transmission") this.UseExtension<MaterialTransmission>();
                 if (extn == "Transmission") this.UseExtension<MaterialTransmission>();
-                if (extn == "Sheen") this.UseExtension<MaterialSheen>();
             }
             }
         }
         }
 
 
@@ -113,6 +115,13 @@ namespace SharpGLTF.Schema2
                 foreach (var c in channels) yield return c;
                 foreach (var c in channels) yield return c;
             }
             }
 
 
+            var specular = this.GetExtension<MaterialSpecular>();
+            if (specular != null)
+            {
+                var channels = specular.GetChannels(this);
+                foreach (var c in channels) yield return c;
+            }
+
             yield return new MaterialChannel
             yield return new MaterialChannel
                 (
                 (
                 this, "Normal",
                 this, "Normal",
@@ -542,5 +551,82 @@ namespace SharpGLTF.Schema2
             if (_ior < 1) throw new ArgumentOutOfRangeException(nameof(IndexOfRefraction));
             if (_ior < 1) throw new ArgumentOutOfRangeException(nameof(IndexOfRefraction));
         }
         }
     }
     }
-}
 
 
+    internal sealed partial class MaterialSpecular
+    {
+        #pragma warning disable CA1801 // Review unused parameters
+        internal MaterialSpecular(Material material) { }
+        #pragma warning restore CA1801 // Review unused parameters
+
+        protected override IEnumerable<ExtraProperties> GetLogicalChildren()
+        {
+            return base.GetLogicalChildren().ConcatElements(_specularColorTexture, _specularTexture);
+        }
+
+        private TextureInfo _GetSpecularColorTexture(bool create)
+        {
+            if (create && _specularColorTexture == null) _specularColorTexture = new TextureInfo();
+            return _specularColorTexture;
+        }
+
+        private TextureInfo _GetSpecularFactorTexture(bool create)
+        {
+            if (create && _specularTexture == null) _specularTexture = new TextureInfo();
+            return _specularTexture;
+        }
+
+        public Vector3 SpecularColor
+        {
+            get => _specularColorFactor.AsValue(_specularColorFactorDefault);
+            set => _specularColorFactor = value.AsNullable(_specularColorFactorDefault);
+        }
+
+        public static float SpecularFactorDefault => (float)_specularFactorDefault;
+
+        public float SpecularFactor
+        {
+            get => (float)_specularFactor.AsValue(_specularFactorDefault);
+            set => _specularFactor = ((double)value).AsNullable(_specularFactorDefault, _specularFactorMinimum, _specularFactorMaximum);
+        }
+
+        public IEnumerable<MaterialChannel> GetChannels(Material material)
+        {
+            yield return new MaterialChannel
+                (
+                material,
+                "SpecularColor",
+                _GetSpecularColorTexture,
+                _specularColorFactorDefault,
+                () => this.SpecularColor,
+                value => this.SpecularColor = value
+                );
+
+            yield return new MaterialChannel
+                (
+                material,
+                "SpecularFactor",
+                _GetSpecularFactorTexture,
+                SpecularFactorDefault,
+                () => this.SpecularFactor,
+                value => this.SpecularFactor = value
+                );
+        }
+
+        protected override void OnValidateContent(ValidationContext validate)
+        {
+            base.OnValidateContent(validate);
+
+            if (_specularColorFactor.HasValue)
+            {
+                Guard.MustBeBetweenOrEqualTo(_specularColorFactor.Value.X, 0, float.MaxValue, nameof(_specularColorFactor));
+                Guard.MustBeBetweenOrEqualTo(_specularColorFactor.Value.Y, 0, float.MaxValue, nameof(_specularColorFactor));
+                Guard.MustBeBetweenOrEqualTo(_specularColorFactor.Value.Z, 0, float.MaxValue, nameof(_specularColorFactor));
+            }
+
+            if (_specularFactor.HasValue)
+            {
+                Guard.MustBeBetweenOrEqualTo(_specularFactor.Value, _specularFactorMinimum, _specularFactorMaximum, nameof(_specularFactor));
+            }
+        }
+    }
+}

+ 3 - 31
src/SharpGLTF.Toolkit/Materials/ChannelBuilder.cs

@@ -10,7 +10,7 @@ namespace SharpGLTF.Materials
     /// Represents a material channel at <see cref="MaterialBuilder"/>.
     /// Represents a material channel at <see cref="MaterialBuilder"/>.
     /// </summary>
     /// </summary>
     [System.Diagnostics.DebuggerDisplay("{_GetDebuggerDisplay(),nq}")]
     [System.Diagnostics.DebuggerDisplay("{_GetDebuggerDisplay(),nq}")]
-    public class ChannelBuilder
+    public partial class ChannelBuilder
     {
     {
         #region debug
         #region debug
 
 
@@ -32,6 +32,7 @@ namespace SharpGLTF.Materials
                     case KnownChannel.Normal:
                     case KnownChannel.Normal:
                     case KnownChannel.ClearCoatNormal:
                     case KnownChannel.ClearCoatNormal:
                     case KnownChannel.Occlusion:
                     case KnownChannel.Occlusion:
+                    case KnownChannel.SpecularFactor:
                         txt += $" {Parameter.X}"; break;
                         txt += $" {Parameter.X}"; break;
 
 
                     case KnownChannel.Emissive:
                     case KnownChannel.Emissive:
@@ -39,6 +40,7 @@ namespace SharpGLTF.Materials
 
 
                     case KnownChannel.Diffuse:
                     case KnownChannel.Diffuse:
                     case KnownChannel.BaseColor:
                     case KnownChannel.BaseColor:
+                    case KnownChannel.SpecularColor:
                         txt += $" ({rgba})"; break;
                         txt += $" ({rgba})"; break;
 
 
                     case KnownChannel.MetallicRoughness:
                     case KnownChannel.MetallicRoughness:
@@ -162,36 +164,6 @@ namespace SharpGLTF.Materials
             this.Parameter = _GetDefaultParameter(_Key);
             this.Parameter = _GetDefaultParameter(_Key);
         }
         }
 
 
-        private static Vector4 _GetDefaultParameter(KnownChannel key)
-        {
-            switch (key)
-            {
-                case KnownChannel.Emissive: return Vector4.Zero;
-
-                case KnownChannel.Normal:
-                case KnownChannel.ClearCoatNormal:
-                case KnownChannel.Occlusion:
-                    return  Vector4.UnitX;
-
-                case KnownChannel.BaseColor:
-                case KnownChannel.Diffuse:
-                    return Vector4.One;
-
-                case KnownChannel.MetallicRoughness: return new Vector4(1, 1, 0, 0);
-                case KnownChannel.SpecularGlossiness: return Vector4.One;
-
-                case KnownChannel.ClearCoat: return Vector4.Zero;
-                case KnownChannel.ClearCoatRoughness: return Vector4.Zero;
-
-                case KnownChannel.Transmission: return Vector4.Zero;
-
-                case KnownChannel.SheenColor: return Vector4.Zero;
-                case KnownChannel.SheenRoughness: return Vector4.Zero;
-
-                default: throw new NotImplementedException();
-            }
-        }
-
         public TextureBuilder UseTexture()
         public TextureBuilder UseTexture()
         {
         {
             if (Texture == null) Texture = new TextureBuilder(this);
             if (Texture == null) Texture = new TextureBuilder(this);

+ 40 - 1
src/SharpGLTF.Toolkit/Materials/MaterialEnums.cs

@@ -1,5 +1,6 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.Numerics;
 using System.Text;
 using System.Text;
 
 
 namespace SharpGLTF.Materials
 namespace SharpGLTF.Materials
@@ -33,6 +34,44 @@ namespace SharpGLTF.Materials
         Transmission,
         Transmission,
 
 
         SheenColor,
         SheenColor,
-        SheenRoughness
+        SheenRoughness,
+
+        SpecularColor,
+        SpecularFactor,
+    }
+
+    partial class ChannelBuilder
+    {
+        private static Vector4 _GetDefaultParameter(KnownChannel key)
+        {
+            switch (key)
+            {
+                case KnownChannel.Emissive: return Vector4.Zero;
+
+                case KnownChannel.Normal:
+                case KnownChannel.ClearCoatNormal:
+                case KnownChannel.Occlusion:
+                case KnownChannel.SpecularFactor:
+                    return Vector4.UnitX;
+
+                case KnownChannel.BaseColor:
+                case KnownChannel.Diffuse:
+                case KnownChannel.SpecularColor:
+                    return Vector4.One;
+
+                case KnownChannel.MetallicRoughness: return new Vector4(1, 1, 0, 0);
+                case KnownChannel.SpecularGlossiness: return Vector4.One;
+
+                case KnownChannel.ClearCoat: return Vector4.Zero;
+                case KnownChannel.ClearCoatRoughness: return Vector4.Zero;
+
+                case KnownChannel.Transmission: return Vector4.Zero;
+
+                case KnownChannel.SheenColor: return Vector4.Zero;
+                case KnownChannel.SheenRoughness: return Vector4.Zero;
+
+                default: throw new NotImplementedException();
+            }
+        }
     }
     }
 }
 }

+ 12 - 3
src/SharpGLTF.Toolkit/Schema2/MaterialExtensions.cs

@@ -266,6 +266,7 @@ namespace SharpGLTF.Schema2
             srcMaterial.CopyChannelsTo(dstMaterial, "ClearCoat", "ClearCoatRoughness", "ClearCoatNormal");
             srcMaterial.CopyChannelsTo(dstMaterial, "ClearCoat", "ClearCoatRoughness", "ClearCoatNormal");
             srcMaterial.CopyChannelsTo(dstMaterial, "Transmission");
             srcMaterial.CopyChannelsTo(dstMaterial, "Transmission");
             srcMaterial.CopyChannelsTo(dstMaterial, "SheenColor", "SheenRoughness");
             srcMaterial.CopyChannelsTo(dstMaterial, "SheenColor", "SheenRoughness");
+            srcMaterial.CopyChannelsTo(dstMaterial, "SpecularColor", "SpecularFactor");
         }
         }
 
 
         private static void _CopyDefaultTo(Material srcMaterial, MaterialBuilder dstMaterial)
         private static void _CopyDefaultTo(Material srcMaterial, MaterialBuilder dstMaterial)
@@ -355,15 +356,21 @@ namespace SharpGLTF.Schema2
             dstMaterial.DoubleSided = srcMaterial.DoubleSided;
             dstMaterial.DoubleSided = srcMaterial.DoubleSided;
             dstMaterial.IndexOfRefraction = srcMaterial.IndexOfRefraction;
             dstMaterial.IndexOfRefraction = srcMaterial.IndexOfRefraction;
 
 
-            var hasClearCoat = srcMaterial.GetChannel("ClearCoat") != null
+            var hasClearCoat
+                = srcMaterial.GetChannel("ClearCoat") != null
                 || srcMaterial.GetChannel("ClearCoatRoughness") != null
                 || srcMaterial.GetChannel("ClearCoatRoughness") != null
                 || srcMaterial.GetChannel("ClearCoatNormal") != null;
                 || srcMaterial.GetChannel("ClearCoatNormal") != null;
 
 
             var hasTransmission = srcMaterial.GetChannel("Transmission") != null;
             var hasTransmission = srcMaterial.GetChannel("Transmission") != null;
 
 
-            var hasSheen = srcMaterial.GetChannel("SheenColor") != null
+            var hasSheen
+                = srcMaterial.GetChannel("SheenColor") != null
                 || srcMaterial.GetChannel("SheenRoughness") != null;
                 || srcMaterial.GetChannel("SheenRoughness") != null;
 
 
+            var hasSpecular
+                = srcMaterial.GetChannel("SpecularColor") != null
+                || srcMaterial.GetChannel("SpecularFactor") != null;
+
             srcMaterial.CopyChannelsTo(dstMaterial, "Normal", "Occlusion", "Emissive");
             srcMaterial.CopyChannelsTo(dstMaterial, "Normal", "Occlusion", "Emissive");
 
 
             MaterialBuilder defMaterial = null;
             MaterialBuilder defMaterial = null;
@@ -381,7 +388,8 @@ namespace SharpGLTF.Schema2
                     (
                     (
                     hasClearCoat ? "ClearCoat" : null,
                     hasClearCoat ? "ClearCoat" : null,
                     hasTransmission ? "Transmission" : null,
                     hasTransmission ? "Transmission" : null,
-                    hasSheen ? "Sheen" : null);
+                    hasSheen ? "Sheen" : null,
+                    hasSpecular ? "Specular" : null);
 
 
                 defMaterial = srcMaterial;
                 defMaterial = srcMaterial;
             }
             }
@@ -400,6 +408,7 @@ namespace SharpGLTF.Schema2
                 defMaterial.CopyChannelsTo(dstMaterial, "ClearCoat", "ClearCoatRoughness", "ClearCoatNormal");
                 defMaterial.CopyChannelsTo(dstMaterial, "ClearCoat", "ClearCoatRoughness", "ClearCoatNormal");
                 defMaterial.CopyChannelsTo(dstMaterial, "Transmission");
                 defMaterial.CopyChannelsTo(dstMaterial, "Transmission");
                 defMaterial.CopyChannelsTo(dstMaterial, "SheenColor", "SheenRoughness");
                 defMaterial.CopyChannelsTo(dstMaterial, "SheenColor", "SheenRoughness");
+                defMaterial.CopyChannelsTo(dstMaterial, "SpecularColor", "SpecularFactor");
             }
             }
         }
         }
 
 

+ 2 - 0
tests/SharpGLTF.Core.Tests/Schema2/LoadAndSave/LoadGeneratedTests.cs

@@ -38,6 +38,8 @@ namespace SharpGLTF.Schema2.LoadAndSave
             {
             {
                 // System.Diagnostics.Debug.Assert(!filePath.EndsWith("Buffer_Interleaved_03.gltf"));
                 // System.Diagnostics.Debug.Assert(!filePath.EndsWith("Buffer_Interleaved_03.gltf"));
 
 
+                if (filePath.EndsWith("Compatibility_05.gltf")) continue; // contains a REQUIRED Material_QuantumRendering
+
                 var gltfJson = filePath.EndsWith(".gltf") ? System.IO.File.ReadAllText(filePath) : string.Empty;
                 var gltfJson = filePath.EndsWith(".gltf") ? System.IO.File.ReadAllText(filePath) : string.Empty;
 
 
                 var report = GltfValidator.ValidationReport.Validate(filePath);                
                 var report = GltfValidator.ValidationReport.Validate(filePath);                

+ 2 - 2
tests/SharpGLTF.Core.Tests/Schema2/LoadAndSave/LoadSampleTests.cs

@@ -95,8 +95,8 @@ namespace SharpGLTF.Schema2.LoadAndSave
         [TestCase("\\glTF-IBL\\")]
         [TestCase("\\glTF-IBL\\")]
         [TestCase("\\glTF-Binary\\")]
         [TestCase("\\glTF-Binary\\")]
         [TestCase("\\glTF-Embedded\\")]
         [TestCase("\\glTF-Embedded\\")]
-        [TestCase("\\glTF-Quantized\\")]
-        [TestCase("\\glTF-pbrSpecularGlossiness\\")]
+        // [TestCase("\\glTF-Quantized\\")] // removed from tests
+        // [TestCase("\\glTF-pbrSpecularGlossiness\\")] // removed from tests
         public void LoadModelsFromKhronosSamples(string section)
         public void LoadModelsFromKhronosSamples(string section)
         {
         {
             TestContext.CurrentContext.AttachShowDirLink();
             TestContext.CurrentContext.AttachShowDirLink();

+ 3 - 1
tests/SharpGLTF.Core.Tests/Validation/InvalidFilesTests.cs

@@ -58,7 +58,9 @@ namespace SharpGLTF.Validation
         {
         {
             var files = TestFiles
             var files = TestFiles
                 .GetKhronosValidationPaths()
                 .GetKhronosValidationPaths()
-                .Where(item => item.EndsWith(".gltf"));
+                .Where(item => item.EndsWith(".gltf"))
+                .Where(item => !item.Contains("KHR_materials_variants"))
+                .Where(item => !item.Contains("KHR_materials_volume"));
 
 
             foreach (var f in files)
             foreach (var f in files)
             {
             {