diff --git a/.gitignore b/.gitignore
index 41a3509c..0cd58c60 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################
+/.vs
/Source/.vs
/Source/bin
/Source/obj
diff --git a/README.md b/README.md
index 4b772a4f..34bce380 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@ So far, this project covers these requirements, with more to come:
- Material Alphas
- Primitive Attributes
- Texture Samplers
+- Specular Glossiness
## What is the feature roadmap?
Please refer to the [Feature Roadmap](https://github.com/bghgary/glTF-Asset-Generator/issues/63)
diff --git a/Source/AssetGenerator.csproj b/Source/AssetGenerator.csproj
index 5d866bcf..fa5dda94 100644
--- a/Source/AssetGenerator.csproj
+++ b/Source/AssetGenerator.csproj
@@ -59,13 +59,16 @@
+
+
+
-
+
@@ -73,6 +76,7 @@
+
@@ -81,20 +85,29 @@
+
+
+
+
+
+
-
- Always
-
-
- Always
-
-
- Always
-
-
- Always
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Source/AssetGeneratorTests/Runtime/GLTFTests.cs b/Source/AssetGeneratorTests/Runtime/GLTFTests.cs
index ddd7d5ff..44a3507b 100644
--- a/Source/AssetGeneratorTests/Runtime/GLTFTests.cs
+++ b/Source/AssetGeneratorTests/Runtime/GLTFTests.cs
@@ -27,7 +27,7 @@ public void BuildGLTFTest()
Generator = "Unit Test",
Copyright = "Unit Tester",
};
- gltf.Asset = asset.ConvertToAsset();
+ gltf.Asset = asset.ConvertToSchema();
Data geometryData = new Data("test.bin");
Runtime.GLTF wrapper = new GLTF();
wrapper.BuildGLTF(ref gltf, geometryData);
diff --git a/Source/AssetGeneratorTests/Runtime/ImageTests.cs b/Source/AssetGeneratorTests/Runtime/ImageTests.cs
index f3ca939e..d5e9db46 100644
--- a/Source/AssetGeneratorTests/Runtime/ImageTests.cs
+++ b/Source/AssetGeneratorTests/Runtime/ImageTests.cs
@@ -17,7 +17,7 @@ public void ConvertToImageTest()
Runtime.Image rImage = new Runtime.Image();
rImage.Uri = "test.png";
- glTFLoader.Schema.Image image = rImage.ConvertToImage();
+ glTFLoader.Schema.Image image = rImage.ConvertToSchema();
Assert.IsTrue(image.Uri.Equals(rImage.Uri));
}
}
diff --git a/Source/AssetGeneratorTests/Runtime/MeshPrimitiveTests.cs b/Source/AssetGeneratorTests/Runtime/MeshPrimitiveTests.cs
index db073c1f..66861888 100644
--- a/Source/AssetGeneratorTests/Runtime/MeshPrimitiveTests.cs
+++ b/Source/AssetGeneratorTests/Runtime/MeshPrimitiveTests.cs
@@ -30,6 +30,7 @@ public void GetMinMaxPositionsTest()
[TestMethod()]
public void ConvertToMeshPrimitiveTest()
{
+ Runtime.GLTF gltf = new GLTF();
List bufferViews = new List();
List accessors = new List();
List textures = new List();
@@ -41,7 +42,7 @@ public void ConvertToMeshPrimitiveTest()
int bufferIndex = 0;
MeshPrimitive meshPrim = new MeshPrimitive();
- meshPrim.ConvertToMeshPrimitive(bufferViews, accessors, samplers, images, textures, materials, geometryData, ref buffer, bufferIndex);
+ meshPrim.ConvertToSchema(gltf, bufferViews, accessors, samplers, images, textures, materials, geometryData, ref buffer, bufferIndex);
}
[TestMethod()]
public void GetMorphTargetsTest()
@@ -64,6 +65,7 @@ public void GetMorphTargetsTest()
new Vector3(0.0f, 0.0f, -1.0f),
new Vector3(0.0f, 0.0f, -1.0f)
};
+ Runtime.GLTF gltf = new GLTF();
List bufferViews = new List();
List accessors = new List();
List textures = new List();
@@ -90,7 +92,7 @@ public void GetMorphTargetsTest()
meshPrim.morphTargetWeight = 0;
Mesh mesh = new Mesh();
mesh.AddPrimitive(meshPrim);
- glTFLoader.Schema.Mesh m = mesh.ConvertToMesh(bufferViews, accessors, samplers, images, textures, materials, geometryData, ref buffer, bufferIndex);
+ glTFLoader.Schema.Mesh m = mesh.ConvertToSchema(gltf, bufferViews, accessors, samplers, images, textures, materials, geometryData, ref buffer, bufferIndex);
Assert.IsTrue(m.Primitives[0].Targets.Count() > 0);
Assert.IsTrue(m.Weights.Count() > 0);
}
@@ -108,6 +110,7 @@ public void ColorAttributeEnumTest()
[TestMethod()]
public void IndicesTest()
{
+ Runtime.GLTF gltf = new GLTF();
List bufferViews = new List();
List accessors = new List();
List textures = new List();
@@ -147,7 +150,7 @@ public void IndicesTest()
new Vector2(0.0f, 0.0f)
}
};
- glTFLoader.Schema.MeshPrimitive sMeshPrimitive = meshPrimitive.ConvertToMeshPrimitive(bufferViews, accessors, samplers, images, textures, materials, geometryData, ref buffer, bufferIndex);
+ glTFLoader.Schema.MeshPrimitive sMeshPrimitive = meshPrimitive.ConvertToSchema(gltf, bufferViews, accessors, samplers, images, textures, materials, geometryData, ref buffer, bufferIndex);
Assert.AreEqual(sMeshPrimitive.Indices, 2); // indices is third bufferview, or index 2
Assert.AreEqual(accessors[2].Count, 6); // should be siz index values
diff --git a/Source/AssetGeneratorTests/Runtime/MeshTests.cs b/Source/AssetGeneratorTests/Runtime/MeshTests.cs
index 5bd119dc..37dbf690 100644
--- a/Source/AssetGeneratorTests/Runtime/MeshTests.cs
+++ b/Source/AssetGeneratorTests/Runtime/MeshTests.cs
@@ -28,6 +28,7 @@ public void AddPrimitiveTest()
[TestMethod()]
public void ConvertToMeshTest()
{
+ Runtime.GLTF gltf = new GLTF();
List bufferViews = new List();
List accessors = new List();
List textures = new List();
@@ -40,7 +41,7 @@ public void ConvertToMeshTest()
int buffer_index = 0;
- m.ConvertToMesh(bufferViews, accessors, samplers, images, textures, materials, geometryData, ref buffer, buffer_index);
+ m.ConvertToSchema(gltf, bufferViews, accessors, samplers, images, textures, materials, geometryData, ref buffer, buffer_index);
}
}
}
\ No newline at end of file
diff --git a/Source/AssetGeneratorTests/Runtime/SamplerTests.cs b/Source/AssetGeneratorTests/Runtime/SamplerTests.cs
index 356ef69a..17d7711f 100644
--- a/Source/AssetGeneratorTests/Runtime/SamplerTests.cs
+++ b/Source/AssetGeneratorTests/Runtime/SamplerTests.cs
@@ -15,7 +15,7 @@ public class SamplerTests
public void ConvertToSamplerTest()
{
Runtime.Sampler rsampler = new Runtime.Sampler();
- glTFLoader.Schema.Sampler sampler = rsampler.ConvertToSampler();
+ glTFLoader.Schema.Sampler sampler = rsampler.ConvertToSchema();
}
}
diff --git a/Source/ComboHelper.cs b/Source/ComboHelper.cs
index 9b222167..92d61b7c 100644
--- a/Source/ComboHelper.cs
+++ b/Source/ComboHelper.cs
@@ -3,7 +3,7 @@
namespace AssetGenerator
{
- public static class ComboHelper
+ internal static class ComboHelper
{
public static List> AttributeCombos(Test test)
{
@@ -108,17 +108,17 @@ public static List> AttributeCombos(Test test)
foreach (var x in combos[1])
{
// Keep property if it is the first found or is binary
- if (x.attributeGroup == 0 || (x.attributeGroup > 0 && !keep.Any()))
+ if (x.propertyGroup == 0 || (x.propertyGroup > 0 && !keep.Any()))
{
keep.Add(x);
}
- else if (x.attributeGroup > 0)
+ else if (x.propertyGroup > 0)
{
bool alreadyKept = false;
foreach (var y in keep)
{
// Don't keep the nonbinary property if there is already one of that set on the list
- if (y.attributeGroup == x.attributeGroup)
+ if (y.propertyGroup == x.propertyGroup)
{
alreadyKept = true;
break;
@@ -168,16 +168,16 @@ public static List> AttributeCombos(Test test)
foreach (var attribute in combos[x])
{
// Remove combos that have multiple of the same binary combo
- if (attribute.attributeGroup > 0)
+ if (attribute.propertyGroup > 0)
{
- if (binarySets.Contains(attribute.attributeGroup))
+ if (binarySets.Contains(attribute.propertyGroup))
{
removeTheseCombos.Add(combos[x]);
break;
}
else
{
- binarySets.Add(attribute.attributeGroup);
+ binarySets.Add(attribute.propertyGroup);
}
}
// Removes combos that have a property missing a prerequisite
@@ -242,20 +242,25 @@ public static List> AttributeCombos(Test test)
return finalResult;
}
- public static List CustomComboCreation(Property attributeA, Property attributeB = null, Property attributeC = null)
+ public static List CustomComboCreation(Property propertyA, Property propertyB = null, Property propertyC = null, Property propertyD = null)
{
List newCombo = new List();
- newCombo.Add(attributeA);
+ newCombo.Add(propertyA);
- if (attributeB != null)
+ if (propertyB != null)
{
- newCombo.Add(attributeB);
+ newCombo.Add(propertyB);
}
- if (attributeC != null)
+ if (propertyC != null)
{
- newCombo.Add(attributeC);
+ newCombo.Add(propertyC);
+ }
+
+ if (propertyD != null)
+ {
+ newCombo.Add(propertyD);
}
return newCombo;
diff --git a/Source/Common.cs b/Source/Common.cs
index e9a16717..892fa68d 100644
--- a/Source/Common.cs
+++ b/Source/Common.cs
@@ -3,7 +3,7 @@
namespace AssetGenerator
{
- public class Common
+ internal class Common
{
///
/// Creates a triangle model using the glTF wrapper
diff --git a/Source/Data.cs b/Source/Data.cs
index 5c47d506..be8eae61 100644
--- a/Source/Data.cs
+++ b/Source/Data.cs
@@ -5,7 +5,7 @@
namespace AssetGenerator
{
- public class Data
+ internal class Data
{
public string Name { get; private set; }
public BinaryWriter Writer { get; private set; }
@@ -16,7 +16,7 @@ public Data(string name)
this.Writer = new BinaryWriter(new MemoryStream());
}
}
- public struct Vector4
+ internal struct Vector4
{
public float x;
public float y;
@@ -57,7 +57,7 @@ public float[] ToArray()
}
}
- public struct Vector3
+ internal struct Vector3
{
public float x;
public float y;
@@ -94,7 +94,7 @@ public float[] ToArray()
return result;
}
}
- public struct Vector2
+ internal struct Vector2
{
public float x;
public float y;
@@ -133,7 +133,7 @@ public float[] ToArray()
///
/// Matrix struct which represents a 4x4 matrix
///
- public class Matrix4x4
+ internal class Matrix4x4
{
public Vector4[] Rows { get; set; }
@@ -180,7 +180,7 @@ public float[] ToArray()
///
/// Defines a Quaternion where x, y and z represent the axis, and w is the angle in radians
///
- public class Quaternion
+ internal class Quaternion
{
public Vector4 Components { get; private set; }
///
diff --git a/Source/FileHelper.cs b/Source/FileHelper.cs
index f6bfda9d..52c63c29 100644
--- a/Source/FileHelper.cs
+++ b/Source/FileHelper.cs
@@ -2,10 +2,11 @@
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
+using System.Reflection;
namespace AssetGenerator
{
- public static class FileHelper
+ internal static class FileHelper
{
public static void ClearOldFiles(string executingAssemblyFolder, string assetFolder)
{
@@ -35,20 +36,26 @@ public static void ClearOldFiles(string executingAssemblyFolder, string assetFol
}
}
- public static void CopyImageFiles(string executingAssemblyFolder, string assetFolder, List usedImages)
+ public static void CopyImageFiles(Assembly executingAssembly, string executingAssemblyFolder, string assetFolder, List usedImages)
{
- var imageFolder = Path.Combine(executingAssemblyFolder, "ImageDependencies");
+ var imageFolder = Path.Combine(executingAssemblyFolder, "Tests");
if (usedImages.Count > 0)
{
foreach (var image in usedImages)
{
- if (File.Exists(Path.Combine(imageFolder, image.Uri)))
+ // Reads the template file
+ string imageSourcePath = "AssetGenerator.Tests." + image.Uri;
+ string imageDestinationPath = Path.Combine(assetFolder, image.Uri);
+ using (Stream stream = executingAssembly.GetManifestResourceStream(imageSourcePath))
{
- File.Copy(Path.Combine(imageFolder, image.Uri), Path.Combine(assetFolder, image.Uri), true);
- }
- else
- {
- Debug.WriteLine(imageFolder + " does not exist");
+ if (stream == null)
+ {
+ throw new ArgumentException("No such image", image.Uri);
+ }
+ using (Stream output = File.OpenWrite(imageDestinationPath))
+ {
+ stream.CopyTo(output);
+ }
}
}
}
diff --git a/Source/ImageDependencies/lambert2_occlusionRoughnessMetallic.png b/Source/ImageDependencies/lambert2_occlusionRoughnessMetallic.png
deleted file mode 100644
index 6cf58732..00000000
Binary files a/Source/ImageDependencies/lambert2_occlusionRoughnessMetallic.png and /dev/null differ
diff --git a/Source/LogStringHelper.cs b/Source/LogStringHelper.cs
index e535505f..c2831ff1 100644
--- a/Source/LogStringHelper.cs
+++ b/Source/LogStringHelper.cs
@@ -30,7 +30,7 @@ public static string ConvertTestValueToString(Property param)
valueType.Equals(typeof(List)))
{
// Generates a name for nonBinary attributes
- if (param.attributeGroup > 0)
+ if (param.propertyGroup > 0)
{
output = GenerateNonbinaryName(param.name.ToString());
}
@@ -42,7 +42,7 @@ public static string ConvertTestValueToString(Property param)
else if (valueType.Equals(typeof(Runtime.Image)))
{
// 18 is normal cell height
- output = String.Format("
", param.value.Uri);
+ output = String.Format("
", param.value.Uri);
}
else // Likely a type that is easy to convert
{
diff --git a/Source/Logs.cs b/Source/Logs.cs
index 2015afda..0b190893 100644
--- a/Source/Logs.cs
+++ b/Source/Logs.cs
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
-using System.Linq;
+using System.Reflection;
using System.Text;
using System.IO;
@@ -10,7 +10,7 @@ class LogBuilder
{
StringBuilder csv = new StringBuilder();
StringBuilder md = new StringBuilder();
- List mdLogHeader = new List();
+ //List mdLogHeader = new List();
List> mdLogPrereqs = new List>();
List> mdLog = new List>();
string lastName = null;
@@ -23,18 +23,13 @@ public LogBuilder()
public void SetupHeader(Test test)
{
// Setup the log file header
- mdLogHeader.Add("The following table shows the properties that are set for every model. ");
- mdLogHeader.Add("No attributes are explicitly set in every model generated by this test, other than those in the base model. ");
- mdLogHeader.Add("The following table shows the properties that are set for a given model. ");
- mdLogHeader.Add("All values of Byte and Short are normalized unsigned. ");
-
if (test.requiredProperty != null)
{
// List attributes that are set in every generated model (prerequisites)
mdLogPrereqs.Add(new List()); // First line of table must be blank
mdLogPrereqs.Add(new List
{
- "Attribute", // First cells are a static label
+ "Property", // First cells are a static label
"**Values**"
});
mdLogPrereqs.Add(new List
@@ -48,10 +43,10 @@ public void SetupHeader(Test test)
attributeName = test.requiredProperty[i].name.ToString();
attributeName = LogStringHelper.GenerateNameWithSpaces(attributeName);
mdLogPrereqs.Add(new List
- {
- attributeName,
- LogStringHelper.ConvertTestValueToString(test.requiredProperty[i])
- });
+ {
+ attributeName,
+ LogStringHelper.ConvertTestValueToString(test.requiredProperty[i])
+ });
}
}
@@ -68,7 +63,7 @@ public void SetupHeader(Test test)
for (int i = 0; i < test.properties.Count; i++)
{
string attributeName;
- if (test.properties[i].prerequisite != Propertyname.Undefined && test.properties[i].attributeGroup == 0)
+ if (test.properties[i].prerequisite != Propertyname.Undefined && test.properties[i].propertyGroup == 0)
{
attributeName = test.properties[i].prerequisite.ToString() + test.properties[i].name.ToString();
}
@@ -102,9 +97,9 @@ public void SetupTable(Test test, int comboIndex, List> combos)
e.prerequisite == possibleAttribute.prerequisite);
if (attributeIndex != -1)
{
- if (possibleAttribute.attributeGroup > 0)
+ if (possibleAttribute.propertyGroup > 0)
{
- var alreadyUsed = nonBinaryUsed.Exists(x => x == possibleAttribute.attributeGroup);
+ var alreadyUsed = nonBinaryUsed.Exists(x => x == possibleAttribute.propertyGroup);
if (alreadyUsed)
{
// Overwrites the empty cell if a nonbinary of the same time had already been encountered and not used
@@ -114,7 +109,7 @@ public void SetupTable(Test test, int comboIndex, List> combos)
{
// Creates a new cell, since this nonbinary type had not been encountered before
mdLog[logIndex].Add(LogStringHelper.ConvertTestValueToString(possibleAttribute));
- nonBinaryUsed.Add(possibleAttribute.attributeGroup);
+ nonBinaryUsed.Add(possibleAttribute.propertyGroup);
}
}
else
@@ -124,13 +119,13 @@ public void SetupTable(Test test, int comboIndex, List> combos)
}
else
{
- if (possibleAttribute.attributeGroup > 0)
+ if (possibleAttribute.propertyGroup > 0)
{
- var alreadyUsed = nonBinaryUsed.Exists(x => x == possibleAttribute.attributeGroup);
+ var alreadyUsed = nonBinaryUsed.Exists(x => x == possibleAttribute.propertyGroup);
if (!alreadyUsed)
{
mdLog[logIndex].Add(" ");
- nonBinaryUsed.Add(possibleAttribute.attributeGroup);
+ nonBinaryUsed.Add(possibleAttribute.propertyGroup);
}
}
else
@@ -145,48 +140,45 @@ public void SetupTable(Test test, int comboIndex, List> combos)
csv.AppendLine(writeToLog);
}
- public void WriteOut(Test test, string assetFolder)
+ public void WriteOut(Assembly executingAssembly, Test test, string assetFolder)
{
+ string template;
+ string templatePath = "AssetGenerator.Tests." + test.testType.ToString() + ".md";
+
+ // Reads the template file
+ using (Stream stream = executingAssembly.GetManifestResourceStream(templatePath))
+ using (var streamReader = new StreamReader(stream))
+ {
+ template = streamReader.ReadToEnd();
+ }
+
+ // If there are required properties, build the header table and inserts it into the template
if (test.requiredProperty != null)
{
- md.AppendLine(mdLogHeader[0]); // Header for the prerequisite table. Only show if the table has values.
foreach (var line in mdLogPrereqs)
{
md.AppendLine(String.Join(" | ", line));
}
+ template = template.Replace("~~HeaderTable~~", md.ToString());
+ md.Clear();
}
else
{
- md.AppendLine(mdLogHeader[1]); // If there are no prerequisites, this is the header.
- }
-
- md.AppendLine(" "); // Linebreak
- md.AppendLine(mdLogHeader[2]); // Header for test grid table
- foreach (var x in mdLog)
- {
- var resultByte = x.FirstOrDefault(s => s.Contains("Byte"));
- if (resultByte != null)
- {
- md.AppendLine(mdLogHeader[3]);
- break;
- }
- var resultShort = mdLog.FirstOrDefault(s => s.Contains("Short"));
- if (resultShort != null)
- {
- md.AppendLine(mdLogHeader[3]);
- break;
- }
+ template = template.Replace("~~HeaderTable~~", "");
}
+ // Build the table for the test properties and inserts it into the template
foreach (var line in mdLog)
{
md.AppendLine(String.Join(" | ", line));
}
+ template = template.Replace("~~Table~~", md.ToString());
+ // Writes the logs out to file
var logFile = Path.Combine(assetFolder, test.testType.ToString() + "_log.csv");
File.WriteAllText(logFile, csv.ToString());
var mdLogFile = Path.Combine(assetFolder, "README.md");
- File.WriteAllText(mdLogFile, md.ToString());
+ File.WriteAllText(mdLogFile, template);
}
}
}
diff --git a/Source/Program.cs b/Source/Program.cs
index 33a86924..4a1e7184 100644
--- a/Source/Program.cs
+++ b/Source/Program.cs
@@ -38,7 +38,7 @@ private static void Main(string[] args)
FileHelper.ClearOldFiles(executingAssemblyFolder, assetFolder);
Directory.CreateDirectory(assetFolder);
- FileHelper.CopyImageFiles(executingAssemblyFolder, assetFolder, test.usedImages);
+ FileHelper.CopyImageFiles(executingAssembly, executingAssemblyFolder, assetFolder, test.usedImages);
logs.SetupHeader(test);
int numCombos = combos.Count;
@@ -58,7 +58,7 @@ private static void Main(string[] args)
var gltf = new glTFLoader.Schema.Gltf
{
- Asset = asset.ConvertToAsset()
+ Asset = asset.ConvertToSchema()
};
var dataList = new List();
@@ -90,7 +90,7 @@ private static void Main(string[] args)
logs.SetupTable(test, comboIndex, combos);
}
- logs.WriteOut(test, assetFolder);
+ logs.WriteOut(executingAssembly, test, assetFolder);
}
Console.WriteLine("Model Creation Complete!");
Console.WriteLine("Completed in : " + TimeSpan.FromTicks(Stopwatch.GetTimestamp()).ToString());
diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs
index 567654e9..4b5ddb0b 100644
--- a/Source/Properties/AssemblyInfo.cs
+++ b/Source/Properties/AssemblyInfo.cs
@@ -1,4 +1,6 @@
using System.Reflection;
+using System.Runtime.CompilerServices;
[assembly: AssemblyTitle("AssetGenerator.exe")]
[assembly: AssemblyVersion("0.1.0.0")]
+[assembly: InternalsVisibleTo("AssetGeneratorTests")]
diff --git a/Source/Property.cs b/Source/Property.cs
index 3e9ef511..f1aa7736 100644
--- a/Source/Property.cs
+++ b/Source/Property.cs
@@ -5,68 +5,74 @@ public class Property
public Propertyname name { get; }
public dynamic value; // Could be a float, array of floats, string, or enum
public Propertyname prerequisite = Propertyname.Undefined;
- public int attributeGroup;
+ public int propertyGroup;
- public Property(Propertyname attributeName, dynamic attributeValue, Propertyname ParentAttribute = Propertyname.Undefined, int group = 0)
+ public Property(Propertyname propertyName, dynamic propertyValue, Propertyname ParentProperty = Propertyname.Undefined, int group = 0)
{
- name = attributeName;
- value = attributeValue;
- prerequisite = ParentAttribute;
- attributeGroup = group;
+ name = propertyName;
+ value = propertyValue;
+ prerequisite = ParentProperty;
+ propertyGroup = group;
}
}
public enum Propertyname
{
Undefined,
- Name,
- BaseColorFactor,
- BaseColorTexture,
- MetallicFactor,
- RoughnessFactor,
- MetallicRoughnessTexture,
- PbrTextures,
- EmissiveFactor,
- AlphaMode_Mask,
+ AlphaCutoff,
AlphaMode_Blend,
+ AlphaMode_Mask,
AlphaMode_Opaque,
- AlphaCutoff,
- Color_Vector3_Float,
- Color_Vector4_Float,
- Color_Vector3_Byte,
- Color_Vector4_Byte,
- Color_Vector3_Short,
- Color_Vector4_Short,
+ BaseColorFactor,
+ BaseColorTexture,
+ DiffuseFactor,
+ DiffuseTexture,
DoubleSided,
- Sampler,
- MagFilter_Nearest,
+ EmissiveFactor,
+ EmissiveTexture,
+ GlossinessFactor,
MagFilter_Linear,
- MinFilter_Nearest,
+ MagFilter_Nearest,
+ MetallicFactor,
+ MetallicRoughnessTexture,
MinFilter_Linear,
- MinFilter_NearestMipmapNearest,
+ MinFilter_LinearMipmapLinear,
MinFilter_LinearMipmapNearest,
+ MinFilter_Nearest,
MinFilter_NearestMipmapLinear,
- MinFilter_LinearMipmapLinear,
- Normal,
+ MinFilter_NearestMipmapNearest,
+ Name,
+ NormalTexture,
+ OcclusionTexture,
+ PbrTextures,
Position,
- Tangent,
- TexCoord0_Float,
- TexCoord0_Byte,
- TexCoord0_Short,
- TexCoord1_Float,
- TexCoord1_Byte,
- TexCoord1_Short,
+ RoughnessFactor,
+ Sampler,
+ Scale,
+ Source,
+ SpecularFactor,
+ SpecularFactor_Override,
+ SpecularGlossinessTexture,
+ Strength,
+ TexCoord,
+ VertexColor_Vector3_Byte,
+ VertexColor_Vector3_Float,
+ VertexColor_Vector3_Short,
+ VertexColor_Vector4_Byte,
+ VertexColor_Vector4_Float,
+ VertexColor_Vector4_Short,
+ VertexNormal,
+ VertexTangent,
+ VertexUV0_Byte,
+ VertexUV0_Float,
+ VertexUV0_Short,
+ VertexUV1_Byte,
+ VertexUV1_Float,
+ VertexUV1_Short,
WrapS_ClampToEdge,
WrapS_MirroredRepeat,
WrapS_Repeat,
WrapT_ClampToEdge,
WrapT_MirroredRepeat,
WrapT_Repeat,
- Source,
- TexCoord,
- NormalTexture,
- OcclusionTexture,
- EmissiveTexture,
- Scale,
- Strength
}
}
diff --git a/Source/Runtime/Asset.cs b/Source/Runtime/Asset.cs
index 38ba46dc..f19012f3 100644
--- a/Source/Runtime/Asset.cs
+++ b/Source/Runtime/Asset.cs
@@ -10,7 +10,7 @@ namespace AssetGenerator.Runtime
///
/// Abstraction for asset in glTF
///
- public class Asset
+ internal class Asset
{
///
/// Tool that generated this glTF model. Useful for debugging
@@ -34,10 +34,10 @@ public class Asset
public string MinVersion { get; set; }
///
- /// Converts into a glTF loader asset
+ /// Converts asset to schema
///
///
- public glTFLoader.Schema.Asset ConvertToAsset()
+ public glTFLoader.Schema.Asset ConvertToSchema()
{
glTFLoader.Schema.Extras extras = new glTFLoader.Schema.Extras();
diff --git a/Source/Runtime/Extensions/Extension.cs b/Source/Runtime/Extensions/Extension.cs
new file mode 100644
index 00000000..e9a6a6f1
--- /dev/null
+++ b/Source/Runtime/Extensions/Extension.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AssetGenerator.Runtime.Extensions
+{
+ internal abstract class Extension
+ {
+ ///
+ /// The name of the extension
+ ///
+ public abstract string Name { get; }
+
+ ///
+ /// Converts the extension to schema
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public abstract Object ConvertToSchema(Runtime.GLTF gltf, List samplers, List images, List textures);
+ }
+ }
diff --git a/Source/Runtime/Extensions/PbrSpecularGlossiness.cs b/Source/Runtime/Extensions/PbrSpecularGlossiness.cs
new file mode 100644
index 00000000..da9340d7
--- /dev/null
+++ b/Source/Runtime/Extensions/PbrSpecularGlossiness.cs
@@ -0,0 +1,206 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AssetGenerator.Runtime.Extensions
+{
+ internal class PbrSpecularGlossiness : Extension
+ {
+ ///
+ /// The name of the extension
+ ///
+ public override string Name
+ {
+ get
+ {
+ return "KHR_materials_pbrSpecularGlossiness";
+ }
+ }
+ private struct TextureIndices
+ {
+ public int? SamplerIndex;
+ public int? ImageIndex;
+ public int? TextureCoordIndex;
+ }
+ ///
+ /// The reflected diffuse factor of the material
+ ///
+ public Vector4? DiffuseFactor { get; set; }
+ ///
+ /// The diffuse texture
+ ///
+ public Texture DiffuseTexture { get; set; }
+ ///
+ /// The specular RGB color of the material
+ ///
+ public Vector3? SpecularFactor { get; set; }
+ ///
+ /// The glossiness or smoothness of the material
+ ///
+ public float? GlossinessFactor { get; set; }
+ ///
+ /// The specular-glossiness texture
+ ///
+ public Texture SpecularGlossinessTexture { get; set; }
+
+ ///
+ /// Adds a texture to the property components of the GLTFWrapper.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns the indicies of the texture and the texture coordinate as an array of two integers if created. Can also return null if the index is not defined. (
+ private TextureIndices AddTexture(Runtime.Texture gTexture, List samplers, List images, List textures)
+ {
+ List indices = new List();
+ int? samplerIndex = null;
+ int? imageIndex = null;
+ int? textureCoordIndex = null;
+
+ if (gTexture != null)
+ {
+ if (gTexture.Sampler != null)
+ {
+ // If a similar sampler is already being used in the list, reuse that index instead of creating a new sampler object
+ if (samplers.Count > 0)
+ {
+ int findIndex;
+ ObjectSearch samplerSearch = new ObjectSearch(gTexture.Sampler.ConvertToSchema());
+ findIndex = samplers.FindIndex(0, samplers.Count, samplerSearch.Equals);
+ if (findIndex != -1)
+ samplerIndex = findIndex;
+ }
+ if (!samplerIndex.HasValue)
+ {
+ glTFLoader.Schema.Sampler sampler = gTexture.Sampler.ConvertToSchema();
+ samplers.Add(sampler);
+ samplerIndex = samplers.Count() - 1;
+ }
+ }
+ if (gTexture.Source != null)
+ {
+ // If an equivalent image object has already been created, reuse its index instead of creating a new image object
+ glTFLoader.Schema.Image image = gTexture.Source.ConvertToSchema();
+ ObjectSearch imageSearch = new ObjectSearch(image);
+ int findImageIndex = images.FindIndex(0, images.Count, imageSearch.Equals);
+
+ if (findImageIndex != -1)
+ {
+ imageIndex = findImageIndex;
+ }
+
+ if (!imageIndex.HasValue)
+ {
+ images.Add(image);
+ imageIndex = images.Count() - 1;
+ }
+ }
+ glTFLoader.Schema.Texture texture = new glTFLoader.Schema.Texture();
+ if (samplerIndex.HasValue)
+ {
+ texture.Sampler = samplerIndex.Value;
+ }
+ if (imageIndex.HasValue)
+ {
+ texture.Source = imageIndex.Value;
+ }
+ if (gTexture.Name != null)
+ {
+ texture.Name = gTexture.Name;
+ }
+ // If an equivalent texture has already been created, re-use that texture's index instead of creating a new texture
+ int findTextureIndex = -1;
+ if (textures.Count > 0)
+ {
+ ObjectSearch textureSearch = new ObjectSearch(texture);
+ findTextureIndex = textures.FindIndex(textureSearch.Equals);
+ }
+ if (findTextureIndex > -1)
+ {
+ indices.Add(findTextureIndex);
+ }
+ else
+ {
+ textures.Add(texture);
+ indices.Add(textures.Count() - 1);
+ }
+
+ if (gTexture.TexCoordIndex.HasValue)
+ {
+ indices.Add(gTexture.TexCoordIndex.Value);
+ textureCoordIndex = gTexture.TexCoordIndex.Value;
+ }
+ }
+
+ TextureIndices textureIndices = new TextureIndices
+ {
+ SamplerIndex = samplerIndex,
+ ImageIndex = imageIndex,
+ TextureCoordIndex = textureCoordIndex
+ };
+
+ return textureIndices;
+ }
+ ///
+ /// Converts the material to schema
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override Object ConvertToSchema(Runtime.GLTF gltf, List samplers, List images, List textures)
+ {
+ glTFLoader.Schema.MaterialPbrSpecularGlossiness materialPbrSpecularGlossiness = new glTFLoader.Schema.MaterialPbrSpecularGlossiness();
+
+ if (DiffuseFactor.HasValue)
+ {
+ materialPbrSpecularGlossiness.DiffuseFactor = DiffuseFactor.Value.ToArray();
+ }
+ if (DiffuseTexture != null)
+ {
+ TextureIndices textureIndices = AddTexture(DiffuseTexture, samplers, images, textures);
+ materialPbrSpecularGlossiness.DiffuseTexture = new glTFLoader.Schema.TextureInfo();
+ if (textureIndices.ImageIndex.HasValue)
+ {
+ materialPbrSpecularGlossiness.DiffuseTexture.Index = textureIndices.ImageIndex.Value;
+ }
+ if (textureIndices.TextureCoordIndex.HasValue)
+ {
+ materialPbrSpecularGlossiness.DiffuseTexture.TexCoord = textureIndices.TextureCoordIndex.Value;
+ }
+ }
+ if (SpecularFactor.HasValue)
+ {
+ materialPbrSpecularGlossiness.SpecularFactor = SpecularFactor.Value.ToArray();
+ }
+ if (GlossinessFactor.HasValue)
+ {
+ materialPbrSpecularGlossiness.GlossinessFactor = GlossinessFactor.Value;
+ }
+ if (SpecularGlossinessTexture != null)
+ {
+ TextureIndices textureIndices = AddTexture(SpecularGlossinessTexture, samplers, images, textures);
+ materialPbrSpecularGlossiness.SpecularGlossinessTexture = new glTFLoader.Schema.TextureInfo();
+ if (textureIndices.ImageIndex.HasValue)
+ {
+ materialPbrSpecularGlossiness.SpecularGlossinessTexture.Index = textureIndices.ImageIndex.Value;
+ }
+ if (textureIndices.TextureCoordIndex.HasValue)
+ {
+ materialPbrSpecularGlossiness.SpecularGlossinessTexture.TexCoord = textureIndices.TextureCoordIndex.Value;
+ }
+ }
+ if (GlossinessFactor.HasValue)
+ {
+ materialPbrSpecularGlossiness.GlossinessFactor = GlossinessFactor.Value;
+ }
+
+ return materialPbrSpecularGlossiness;
+ }
+ }
+}
diff --git a/Source/Runtime/Extras.cs b/Source/Runtime/Extras.cs
index a9b46530..c72dd09f 100644
--- a/Source/Runtime/Extras.cs
+++ b/Source/Runtime/Extras.cs
@@ -6,7 +6,7 @@
namespace AssetGenerator.Runtime
{
- public class Extras: glTFLoader.Schema.Extras
+ internal class Extras: glTFLoader.Schema.Extras
{
public string Attributes { get; set; }
}
diff --git a/Source/Runtime/GLTF.cs b/Source/Runtime/GLTF.cs
index 459dec34..0de26d64 100644
--- a/Source/Runtime/GLTF.cs
+++ b/Source/Runtime/GLTF.cs
@@ -9,7 +9,7 @@ namespace AssetGenerator.Runtime
///
/// Wrapper class for abstracting the glTF Loader API
///
- public class GLTF
+ internal class GLTF
{
///
/// List of scenes in the gltf wrapper
@@ -19,6 +19,10 @@ public class GLTF
/// index of the main scene
///
public int? MainScene { get; set; }
+
+ public List ExtensionsUsed { get; set; }
+ public List ExtensionsRequired { get; set; }
+
///
/// Initializes the gltf wrapper
///
@@ -40,9 +44,9 @@ public void BuildGLTF(ref glTFLoader.Schema.Gltf gltf, Data geometryData)
{
if (Asset != null)
{
- gltf.Asset = Asset.ConvertToAsset();
+ gltf.Asset = Asset.ConvertToSchema();
}
-
+
// local variables for generating gltf indices
List buffers = new List();
List bufferViews = new List();
@@ -71,7 +75,8 @@ public void BuildGLTF(ref glTFLoader.Schema.Gltf gltf, Data geometryData)
{
Runtime.Mesh gMesh = gscene.Meshes[mesh_index];
- glTFLoader.Schema.Mesh m = gMesh.ConvertToMesh(bufferViews, accessors, samplers, images, textures, materials, geometryData, ref gBuffer, buffer_index);
+ glTFLoader.Schema.Mesh m = gMesh.ConvertToSchema(this, bufferViews, accessors, samplers, images, textures, materials, geometryData, ref gBuffer, buffer_index);
+
meshes.Add(m);
glTFLoader.Schema.Node node = new glTFLoader.Schema.Node
@@ -151,6 +156,11 @@ public void BuildGLTF(ref glTFLoader.Schema.Gltf gltf, Data geometryData)
{
gltf.Scene = MainScene.Value;
}
+ if (ExtensionsUsed != null)
+ {
+ gltf.ExtensionsUsed = ExtensionsUsed.ToArray();
+ }
+
}
}
}
diff --git a/Source/Runtime/Image.cs b/Source/Runtime/Image.cs
index dd99a9f1..0c783697 100644
--- a/Source/Runtime/Image.cs
+++ b/Source/Runtime/Image.cs
@@ -9,7 +9,7 @@ namespace AssetGenerator.Runtime
///
/// Wrapper for Image class
///
- public class Image
+ internal class Image
{
///
/// The location of the image file, or a data uri containing texture data as an encoded string
@@ -29,7 +29,7 @@ public class Image
/// converts the Runtime image to a glTF Image
///
/// Returns a gltf Image object
- public glTFLoader.Schema.Image ConvertToImage()
+ public glTFLoader.Schema.Image ConvertToSchema()
{
glTFLoader.Schema.Image image = new glTFLoader.Schema.Image
{
diff --git a/Source/Runtime/KHRMaterialSpecularGlossinessExtension.cs b/Source/Runtime/KHRMaterialSpecularGlossinessExtension.cs
new file mode 100644
index 00000000..49811fcd
--- /dev/null
+++ b/Source/Runtime/KHRMaterialSpecularGlossinessExtension.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AssetGenerator.Runtime
+{
+ public class KHRMaterialSpecularGlossinessExtension: glTFLoader.Schema.Extension
+ {
+ public float[] DiffuseFactor { get; set; }
+ public glTFLoader.Schema.TextureInfo DiffuseTexture { get; set; }
+ public float[] SpecularFactor { get; set; }
+ public float? GlossinessFactor { get; set; }
+ public glTFLoader.Schema.TextureInfo SpecularGlossinessTexture { get; set; }
+ }
+}
diff --git a/Source/Runtime/Material.cs b/Source/Runtime/Material.cs
index 7aac3844..93b5d4f9 100644
--- a/Source/Runtime/Material.cs
+++ b/Source/Runtime/Material.cs
@@ -9,9 +9,9 @@ namespace AssetGenerator.Runtime
///
/// Wrapper for glTF loader's Material
///
- public class Material
+ internal class Material
{
- public struct TextureIndices
+ private struct TextureIndices
{
public int? SamplerIndex;
public int? ImageIndex;
@@ -24,7 +24,7 @@ public struct TextureIndices
///
/// A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering methodology
///
- public Runtime.MetallicRoughnessMaterial MetallicRoughnessMaterial { get; set; }
+ public Runtime.PbrMetallicRoughness MetallicRoughnessMaterial { get; set; }
///
/// Texture that contains tangent-space normal information
///
@@ -63,6 +63,10 @@ public struct TextureIndices
/// The alpha cutoff value of the material
///
public float? AlphaCutoff { get; set; }
+
+ public List Extensions { get; set; }
+
+
///
/// Adds a texture to the property components of the GLTFWrapper.
///
@@ -72,7 +76,7 @@ public struct TextureIndices
///
///
/// Returns the indicies of the texture and the texture coordinate as an array of two integers if created. Can also return null if the index is not defined. (
- public TextureIndices AddTexture(Runtime.Texture gTexture, List samplers, List images, List textures, glTFLoader.Schema.Material material)
+ private TextureIndices AddTexture(Runtime.Texture gTexture, List samplers, List images, List textures, glTFLoader.Schema.Material material)
{
List indices = new List();
int? samplerIndex = null;
@@ -87,14 +91,14 @@ public TextureIndices AddTexture(Runtime.Texture gTexture, List 0)
{
int findIndex;
- ObjectSearch samplerSearch = new ObjectSearch(gTexture.Sampler.ConvertToSampler());
+ ObjectSearch samplerSearch = new ObjectSearch(gTexture.Sampler.ConvertToSchema());
findIndex = samplers.FindIndex(0, samplers.Count, samplerSearch.Equals);
if (findIndex != -1)
samplerIndex = findIndex;
}
if (!samplerIndex.HasValue)
{
- glTFLoader.Schema.Sampler sampler = gTexture.Sampler.ConvertToSampler();
+ glTFLoader.Schema.Sampler sampler = gTexture.Sampler.ConvertToSchema();
samplers.Add(sampler);
samplerIndex = samplers.Count() - 1;
}
@@ -102,7 +106,7 @@ public TextureIndices AddTexture(Runtime.Texture gTexture, List imageSearch = new ObjectSearch(image);
int findImageIndex = images.FindIndex(0, images.Count, imageSearch.Equals);
@@ -170,13 +174,13 @@ public TextureIndices AddTexture(Runtime.Texture gTexture, List
///
/// Returns a Material object, and updates the properties of the GLTFWrapper
- public glTFLoader.Schema.Material CreateMaterial(List samplers, List images, List textures)
+ public glTFLoader.Schema.Material ConvertToSchema(Runtime.GLTF gltf, List samplers, List images, List textures)
{
glTFLoader.Schema.Material material = new glTFLoader.Schema.Material();
- material.PbrMetallicRoughness = new glTFLoader.Schema.MaterialPbrMetallicRoughness();
-
+
if (MetallicRoughnessMaterial != null)
{
+ material.PbrMetallicRoughness = new glTFLoader.Schema.MaterialPbrMetallicRoughness();
if (MetallicRoughnessMaterial.BaseColorFactor != null)
{
material.PbrMetallicRoughness.BaseColorFactor = new[]
@@ -301,8 +305,33 @@ public glTFLoader.Schema.Material CreateMaterial(List
{
material.DoubleSided = DoubleSided.Value;
}
+ if (Extensions != null)
+ {
+ if (material.Extensions == null)
+ {
+ material.Extensions = new Dictionary();
+ }
+ if (gltf.ExtensionsUsed != null)
+ {
+ gltf.ExtensionsUsed = new List();
+ }
+ foreach (var extension in Extensions)
+ {
+ material.Extensions.Add(extension.Name, extension.ConvertToSchema(gltf, samplers, images, textures));
+ if (gltf.ExtensionsUsed == null)
+ {
+ gltf.ExtensionsUsed = new List(new[] { extension.Name });
+
+ }
+ else if (!gltf.ExtensionsUsed.Contains(extension.Name))
+ {
+ gltf.ExtensionsUsed.Add(extension.Name);
+ }
+
+ }
+ }
+
return material;
}
-
}
}
diff --git a/Source/Runtime/MaterialSpecularGlossiness.cs b/Source/Runtime/MaterialSpecularGlossiness.cs
new file mode 100644
index 00000000..0c706007
--- /dev/null
+++ b/Source/Runtime/MaterialSpecularGlossiness.cs
@@ -0,0 +1,183 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AssetGenerator.Runtime
+{
+ public class MaterialSpecularGlossiness
+ {
+ public struct TextureIndices
+ {
+ public int? SamplerIndex;
+ public int? ImageIndex;
+ public int? TextureCoordIndex;
+ }
+ ///
+ /// The reflected diffuse factor of the material
+ ///
+ public Vector4 DiffuseFactor { get; set; }
+ ///
+ /// The diffuse texture
+ ///
+ public Texture DiffuseTexture { get; set; }
+ ///
+ /// The specular RGB color of the material
+ ///
+ public Vector3 SpecularFactor { get; set; }
+ ///
+ /// The glossiness or smoothness of the material
+ ///
+ public float? GlossinessFactor { get; set; }
+ ///
+ /// The specular-glossiness texture
+ ///
+ public Texture SpecularGlossinessTexture { get; set; }
+
+ ///
+ /// Adds a texture to the property components of the GLTFWrapper.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns the indicies of the texture and the texture coordinate as an array of two integers if created. Can also return null if the index is not defined. (
+ public TextureIndices AddTexture(Runtime.Texture gTexture, List samplers, List images, List textures)
+ {
+ List indices = new List();
+ int? samplerIndex = null;
+ int? imageIndex = null;
+ int? textureCoordIndex = null;
+
+ if (gTexture != null)
+ {
+ if (gTexture.Sampler != null)
+ {
+ // If a similar sampler is already being used in the list, reuse that index instead of creating a new sampler object
+ if (samplers.Count > 0)
+ {
+ int findIndex;
+ ObjectSearch samplerSearch = new ObjectSearch(gTexture.Sampler.ConvertToSampler());
+ findIndex = samplers.FindIndex(0, samplers.Count, samplerSearch.Equals);
+ if (findIndex != -1)
+ samplerIndex = findIndex;
+ }
+ if (!samplerIndex.HasValue)
+ {
+ glTFLoader.Schema.Sampler sampler = gTexture.Sampler.ConvertToSampler();
+ samplers.Add(sampler);
+ samplerIndex = samplers.Count() - 1;
+ }
+ }
+ if (gTexture.Source != null)
+ {
+ // If an equivalent image object has already been created, reuse its index instead of creating a new image object
+ glTFLoader.Schema.Image image = gTexture.Source.ConvertToImage();
+ ObjectSearch imageSearch = new ObjectSearch(image);
+ int findImageIndex = images.FindIndex(0, images.Count, imageSearch.Equals);
+
+ if (findImageIndex != -1)
+ {
+ imageIndex = findImageIndex;
+ }
+
+ if (!imageIndex.HasValue)
+ {
+ images.Add(image);
+ imageIndex = images.Count() - 1;
+ }
+ }
+ glTFLoader.Schema.Texture texture = new glTFLoader.Schema.Texture();
+ if (samplerIndex.HasValue)
+ {
+ texture.Sampler = samplerIndex.Value;
+ }
+ if (imageIndex.HasValue)
+ {
+ texture.Source = imageIndex.Value;
+ }
+ if (gTexture.Name != null)
+ {
+ texture.Name = gTexture.Name;
+ }
+ // If an equivalent texture has already been created, re-use that texture's index instead of creating a new texture
+ int findTextureIndex = -1;
+ if (textures.Count > 0)
+ {
+ ObjectSearch textureSearch = new ObjectSearch(texture);
+ findTextureIndex = textures.FindIndex(textureSearch.Equals);
+ }
+ if (findTextureIndex > -1)
+ {
+ indices.Add(findTextureIndex);
+ }
+ else
+ {
+ textures.Add(texture);
+ indices.Add(textures.Count() - 1);
+ }
+
+ if (gTexture.TexCoordIndex.HasValue)
+ {
+ indices.Add(gTexture.TexCoordIndex.Value);
+ textureCoordIndex = gTexture.TexCoordIndex.Value;
+ }
+ }
+
+ TextureIndices textureIndices = new TextureIndices
+ {
+ SamplerIndex = samplerIndex,
+ ImageIndex = imageIndex,
+ TextureCoordIndex = textureCoordIndex
+ };
+
+ return textureIndices;
+ }
+ public glTFLoader.Schema.Extension ConvertToMaterialSpecularGlossinessExtension(List samplers, List images, List textures, List material)
+ {
+ var kHRMaterialSpecularGlossinessExtension = new KHRMaterialSpecularGlossinessExtension();
+ if (DiffuseFactor != null)
+ {
+ kHRMaterialSpecularGlossinessExtension.DiffuseFactor = DiffuseFactor.ToArray();
+ }
+ if (DiffuseTexture != null)
+ {
+ TextureIndices textureIndices = AddTexture(DiffuseTexture, samplers, images, textures);
+ kHRMaterialSpecularGlossinessExtension.DiffuseTexture = new glTFLoader.Schema.TextureInfo();
+ if (textureIndices.ImageIndex.HasValue)
+ {
+ kHRMaterialSpecularGlossinessExtension.DiffuseTexture.Index = textureIndices.ImageIndex.Value;
+ }
+ if (textureIndices.TextureCoordIndex.HasValue)
+ {
+ kHRMaterialSpecularGlossinessExtension.DiffuseTexture.TexCoord = textureIndices.TextureCoordIndex.Value;
+ }
+ }
+ if (SpecularFactor != null)
+ {
+ kHRMaterialSpecularGlossinessExtension.SpecularFactor = SpecularFactor.ToArray();
+ }
+ if (GlossinessFactor.HasValue)
+ {
+ kHRMaterialSpecularGlossinessExtension.GlossinessFactor = GlossinessFactor.Value;
+ }
+ if (SpecularGlossinessTexture != null)
+ {
+ TextureIndices textureIndices = AddTexture(SpecularGlossinessTexture, samplers, images, textures);
+ kHRMaterialSpecularGlossinessExtension.SpecularGlossinessTexture = new glTFLoader.Schema.TextureInfo();
+ if (textureIndices.ImageIndex.HasValue)
+ {
+ kHRMaterialSpecularGlossinessExtension.SpecularGlossinessTexture.Index = textureIndices.ImageIndex.Value;
+ }
+ if (textureIndices.TextureCoordIndex.HasValue)
+ {
+ kHRMaterialSpecularGlossinessExtension.SpecularGlossinessTexture.TexCoord = textureIndices.TextureCoordIndex.Value;
+ }
+ }
+
+ return kHRMaterialSpecularGlossinessExtension;
+ }
+ }
+}
diff --git a/Source/Runtime/Mesh.cs b/Source/Runtime/Mesh.cs
index 73b1b42b..47df6eca 100644
--- a/Source/Runtime/Mesh.cs
+++ b/Source/Runtime/Mesh.cs
@@ -9,7 +9,7 @@ namespace AssetGenerator.Runtime
///
/// Wrapper for glTF loader's Mesh
///
- public class Mesh
+ internal class Mesh
{
///
/// The user-defined name of this mesh.
@@ -53,7 +53,7 @@ public void AddPrimitive(Runtime.MeshPrimitive meshPrimitive)
MeshPrimitives.Add(meshPrimitive);
}
///
- /// Converts the wrapped mesh into a GLTF Mesh object.
+ /// Converts the mesh to schema
///
///
///
@@ -64,7 +64,7 @@ public void AddPrimitive(Runtime.MeshPrimitive meshPrimitive)
///
///
/// glTFLoader.Schema.Mesh
- public glTFLoader.Schema.Mesh ConvertToMesh(List bufferViews, List accessors, List samplers, List images, List textures, List materials, Data geometryData, ref glTFLoader.Schema.Buffer buffer, int bufferIndex)
+ public glTFLoader.Schema.Mesh ConvertToSchema(Runtime.GLTF gltf, List bufferViews, List accessors, List samplers, List images, List textures, List materials, Data geometryData, ref glTFLoader.Schema.Buffer buffer, int bufferIndex)
{
glTFLoader.Schema.Mesh mesh = new glTFLoader.Schema.Mesh();
List primitives = new List(MeshPrimitives.Count);
@@ -73,7 +73,7 @@ public glTFLoader.Schema.Mesh ConvertToMesh(List b
// indices in the lists
foreach (Runtime.MeshPrimitive gPrimitive in MeshPrimitives)
{
- glTFLoader.Schema.MeshPrimitive mPrimitive = gPrimitive.ConvertToMeshPrimitive(bufferViews, accessors, samplers, images, textures, materials, geometryData, ref buffer, bufferIndex);
+ glTFLoader.Schema.MeshPrimitive mPrimitive = gPrimitive.ConvertToSchema(gltf, bufferViews, accessors, samplers, images, textures, materials, geometryData, ref buffer, bufferIndex);
if (gPrimitive.MorphTargets != null && gPrimitive.MorphTargets.Count() > 0)
{
List > morphTargetAttributes = gPrimitive.GetMorphTargets(bufferViews, accessors, ref buffer, geometryData, ref weights, bufferIndex);
diff --git a/Source/Runtime/MeshPrimitive.cs b/Source/Runtime/MeshPrimitive.cs
index a858b239..f3df09ba 100644
--- a/Source/Runtime/MeshPrimitive.cs
+++ b/Source/Runtime/MeshPrimitive.cs
@@ -9,7 +9,7 @@ namespace AssetGenerator.Runtime
///
/// Runtime abstraction for glTF Mesh Primitive
///
- public class MeshPrimitive
+ internal class MeshPrimitive
{
///
/// Specifies which component type to use when defining the color accessor
@@ -83,10 +83,12 @@ public enum TextureCoordsComponentTypeEnum { FLOAT, NORMALIZED_USHORT, NORMALIZE
///
public float morphTargetWeight { get; set; }
+ public enum ModeEnum {POINTS, LINES, LINE_LOOP, LINE_STRIP, TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN };
+
///
/// Sets the mode of the primitive to render.
///
- public glTFLoader.Schema.MeshPrimitive.ModeEnum Mode { get; set; }
+ public ModeEnum? Mode { get; set; }
///
/// Computes and returns the minimum and maximum positions for the mesh primitive.
@@ -94,6 +96,7 @@ public enum TextureCoordsComponentTypeEnum { FLOAT, NORMALIZED_USHORT, NORMALIZE
/// Returns the result as an array of two vectors, minimum and maximum respectively
public Vector3[] GetMinMaxPositions()
{
+
//get the max and min values
Vector3 minVal = new Vector3
{
@@ -192,7 +195,7 @@ private glTFLoader.Schema.Accessor CreateAccessor(int bufferviewIndex, int? byte
return accessor;
}
///
- /// Converts the wrapped mesh primitive into gltf mesh primitives, as well as updates the indices in the lists
+ /// Converts the mesh primitive to schema
///
///
///
@@ -203,7 +206,7 @@ private glTFLoader.Schema.Accessor CreateAccessor(int bufferviewIndex, int? byte
///
///
/// MeshPrimitive instance
- public glTFLoader.Schema.MeshPrimitive ConvertToMeshPrimitive(List bufferViews, List accessors, List samplers, List images, List textures, List materials, Data geometryData, ref glTFLoader.Schema.Buffer buffer, int bufferIndex)
+ public glTFLoader.Schema.MeshPrimitive ConvertToSchema(Runtime.GLTF gltf, List bufferViews, List accessors, List samplers, List images, List textures, List materials, Data geometryData, ref glTFLoader.Schema.Buffer buffer, int bufferIndex)
{
Dictionary attributes = new Dictionary();
glTFLoader.Schema.MeshPrimitive mPrimitive = new glTFLoader.Schema.MeshPrimitive();
@@ -440,7 +443,7 @@ public glTFLoader.Schema.MeshPrimitive ConvertToMeshPrimitive(List
///
- public class ObjectSearch
+ internal class ObjectSearch
{
public ObjectSearch(T obj)
{
diff --git a/Source/Runtime/MetallicRoughnessMaterial.cs b/Source/Runtime/PbrMetallicRoughness.cs
similarity index 96%
rename from Source/Runtime/MetallicRoughnessMaterial.cs
rename to Source/Runtime/PbrMetallicRoughness.cs
index a27caf2e..85f3c62f 100644
--- a/Source/Runtime/MetallicRoughnessMaterial.cs
+++ b/Source/Runtime/PbrMetallicRoughness.cs
@@ -9,7 +9,7 @@ namespace AssetGenerator.Runtime
///
/// GLTF Wrapper for glTF loader's MetallicRoughness
///
- public class MetallicRoughnessMaterial
+ internal class PbrMetallicRoughness
{
///
/// The main texture that will be applied to the object.
diff --git a/Source/Runtime/Sampler.cs b/Source/Runtime/Sampler.cs
index 7557ab3a..aac659c3 100644
--- a/Source/Runtime/Sampler.cs
+++ b/Source/Runtime/Sampler.cs
@@ -9,7 +9,7 @@ namespace AssetGenerator.Runtime
///
/// Wrapper for glTF loader's Sampler. The sampler descibe the wrapping and scaling of textures.
///
- public class Sampler
+ internal class Sampler
{
///
/// Magnification filter
@@ -32,10 +32,10 @@ public class Sampler
///
public string Name { get; set; }
///
- /// Converts the GLTFSampler into a glTF loader Sampler object.
+ /// Converts the GLTFSampler into schema
///
/// Returns a Sampler object
- public glTFLoader.Schema.Sampler ConvertToSampler()
+ public glTFLoader.Schema.Sampler ConvertToSchema()
{
glTFLoader.Schema.Sampler sampler = new glTFLoader.Schema.Sampler();
if (MagFilter.HasValue)
diff --git a/Source/Runtime/Scene.cs b/Source/Runtime/Scene.cs
index f0d1f6c9..5750c19e 100644
--- a/Source/Runtime/Scene.cs
+++ b/Source/Runtime/Scene.cs
@@ -9,7 +9,7 @@ namespace AssetGenerator.Runtime
///
/// Wrapper for glTF loader's Scene
///
- public class Scene
+ internal class Scene
{
///
/// List of meshes in the scene
diff --git a/Source/Runtime/Texture.cs b/Source/Runtime/Texture.cs
index 9ed51a0f..92a1cb74 100644
--- a/Source/Runtime/Texture.cs
+++ b/Source/Runtime/Texture.cs
@@ -9,7 +9,7 @@ namespace AssetGenerator.Runtime
///
/// Wrapper for glTF loader's Texture
///
- public class Texture
+ internal class Texture
{
///
/// Image source for the texture
diff --git a/Source/Schema/MaterialPbrSpecularGlossiness.cs b/Source/Schema/MaterialPbrSpecularGlossiness.cs
new file mode 100644
index 00000000..51185906
--- /dev/null
+++ b/Source/Schema/MaterialPbrSpecularGlossiness.cs
@@ -0,0 +1,280 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+///
+/// NOTE: This will eventually move to the C# loader
+///
+namespace glTFLoader.Schema
+{
+ using System.Linq;
+ using System.Runtime.Serialization;
+
+
+ public class MaterialPbrSpecularGlossiness
+ {
+
+ ///
+ /// Backing field for DiffuseFactor.
+ ///
+ private float[] m_diffuseFactor = new float[] {
+ 1F,
+ 1F,
+ 1F,
+ 1F};
+
+ ///
+ /// Backing field for DiffuseTexture.
+ ///
+ private TextureInfo m_diffuseTexture;
+
+ ///
+ /// Backing field for SpecularFactor.
+ ///
+ private float[] m_specularFactor = new float[] {
+ 1F,
+ 1F,
+ 1F};
+
+ ///
+ /// Backing field for GlossinessFactor.
+ ///
+ private float m_glossinessFactor = 1F;
+
+ ///
+ /// Backing field for SpecularGlossinessTexture.
+ ///
+ private TextureInfo m_specularGlossinessTexture;
+
+ ///
+ /// Backing field for Extensions.
+ ///
+ private System.Collections.Generic.Dictionary m_extensions;
+
+ ///
+ /// Backing field for Extras.
+ ///
+ private Extras m_extras;
+
+ ///
+ /// The reflected diffuse factor of the material.
+ ///
+ [Newtonsoft.Json.JsonConverterAttribute(typeof(glTFLoader.Shared.ArrayConverter))]
+ [Newtonsoft.Json.JsonPropertyAttribute("diffuseFactor")]
+ public float[] DiffuseFactor
+ {
+ get
+ {
+ return this.m_diffuseFactor;
+ }
+ set
+ {
+ if ((value.Length < 4u))
+ {
+ throw new System.ArgumentException("Array not long enough");
+ }
+ if ((value.Length > 4u))
+ {
+ throw new System.ArgumentException("Array too long");
+ }
+ int index = 0;
+ for (index = 0; (index < value.Length); index = (index + 1))
+ {
+ if ((value[index] < 0D))
+ {
+ throw new System.ArgumentOutOfRangeException();
+ }
+ }
+ for (index = 0; (index < value.Length); index = (index + 1))
+ {
+ if ((value[index] > 1D))
+ {
+ throw new System.ArgumentOutOfRangeException();
+ }
+ }
+ this.m_diffuseFactor = value;
+ }
+ }
+
+ ///
+ /// The diffuse texture.
+ ///
+ [Newtonsoft.Json.JsonPropertyAttribute("diffuseTexture")]
+ public TextureInfo DiffuseTexture
+ {
+ get
+ {
+ return this.m_diffuseTexture;
+ }
+ set
+ {
+ this.m_diffuseTexture = value;
+ }
+ }
+
+ ///
+ /// The specular RGB color of the material.
+ ///
+ [Newtonsoft.Json.JsonConverterAttribute(typeof(glTFLoader.Shared.ArrayConverter))]
+ [Newtonsoft.Json.JsonPropertyAttribute("specularFactor")]
+ public float[] SpecularFactor
+ {
+ get
+ {
+ return this.m_specularFactor;
+ }
+ set
+ {
+ if ((value.Length < 3u))
+ {
+ throw new System.ArgumentException("Array not long enough");
+ }
+ if ((value.Length > 3u))
+ {
+ throw new System.ArgumentException("Array too long");
+ }
+ int index = 0;
+ for (index = 0; (index < value.Length); index = (index + 1))
+ {
+ if ((value[index] < 0D))
+ {
+ throw new System.ArgumentOutOfRangeException();
+ }
+ }
+ for (index = 0; (index < value.Length); index = (index + 1))
+ {
+ if ((value[index] > 1D))
+ {
+ throw new System.ArgumentOutOfRangeException();
+ }
+ }
+ this.m_specularFactor = value;
+ }
+ }
+
+ ///
+ /// The glossiness or smoothness of the material.
+ ///
+ [Newtonsoft.Json.JsonPropertyAttribute("glossinessFactor")]
+ public float GlossinessFactor
+ {
+ get
+ {
+ return this.m_glossinessFactor;
+ }
+ set
+ {
+ if ((value < 0D))
+ {
+ throw new System.ArgumentOutOfRangeException("GlossinessFactor", value, "Expected value to be greater than or equal to 0");
+ }
+ if ((value > 1D))
+ {
+ throw new System.ArgumentOutOfRangeException("GlossinessFactor", value, "Expected value to be less than or equal to 1");
+ }
+ this.m_glossinessFactor = value;
+ }
+ }
+
+ ///
+ /// The specular-glossiness texture.
+ ///
+ [Newtonsoft.Json.JsonPropertyAttribute("specularGlossinessTexture")]
+ public TextureInfo SpecularGlossinessTexture
+ {
+ get
+ {
+ return this.m_specularGlossinessTexture;
+ }
+ set
+ {
+ this.m_specularGlossinessTexture = value;
+ }
+ }
+
+ ///
+ /// Dictionary object with extension-specific objects.
+ ///
+ [Newtonsoft.Json.JsonPropertyAttribute("extensions")]
+ public System.Collections.Generic.Dictionary Extensions
+ {
+ get
+ {
+ return this.m_extensions;
+ }
+ set
+ {
+ this.m_extensions = value;
+ }
+ }
+
+ ///
+ /// Application-specific data.
+ ///
+ [Newtonsoft.Json.JsonPropertyAttribute("extras")]
+ public Extras Extras
+ {
+ get
+ {
+ return this.m_extras;
+ }
+ set
+ {
+ this.m_extras = value;
+ }
+ }
+
+ public bool ShouldSerializeDiffuseFactor()
+ {
+ return (m_diffuseFactor.SequenceEqual(new float[] {
+ 1F,
+ 1F,
+ 1F,
+ 1F}) == false);
+ }
+
+ public bool ShouldSerializeDiffuseTexture()
+ {
+ return ((m_diffuseTexture == null)
+ == false);
+ }
+
+ public bool ShouldSerializeSpecularFactor()
+ {
+ return (m_specularFactor.SequenceEqual(new float[] {
+ 1F,
+ 1F,
+ 1F}) == false);
+ }
+
+ public bool ShouldSerializeGlossinessFactor()
+ {
+ return ((m_glossinessFactor == 1F)
+ == false);
+ }
+
+ public bool ShouldSerializeSpecularGlossinessTexture()
+ {
+ return ((m_specularGlossinessTexture == null)
+ == false);
+ }
+
+ public bool ShouldSerializeExtensions()
+ {
+ return ((m_extensions == null)
+ == false);
+ }
+
+ public bool ShouldSerializeExtras()
+ {
+ return ((m_extras == null)
+ == false);
+ }
+ }
+}
diff --git a/Source/Test.cs b/Source/Test.cs
index 7f6deccc..b640f7ab 100644
--- a/Source/Test.cs
+++ b/Source/Test.cs
@@ -2,7 +2,7 @@
namespace AssetGenerator
{
- public class Test
+ internal class Test
{
public TestName testType;
public List properties;
@@ -13,10 +13,15 @@ public class Test
public List specialProperties = new List();
public bool onlyBinaryProperties = true;
public bool noPrerequisite = true;
- public const string texture_Normal = "lambert2_normal.png";
- public const string texture_Emissive = "lambert2_emissive.png";
- public const string texture_BaseColor = "lambert2_baseColor.png";
- public const string texture_OcclusionRoughnessMetallic = "lambert2_occlusionRoughnessMetallic.png";
+ public const string texture_Normal = "panel_normal.png";
+ public const string texture_Emissive = "panel_emissive.png";
+ public const string texture_BaseColor = "panel_baseColor.png";
+ public const string texture_MetallicRoughness = "panel_metallicRoughness.png";
+ public const string texture_Occlusion = "panel_occlusion.png";
+ public const string texture_Diffuse = "panel_diffuse.png";
+ public const string texture_SpecularGlossiness = "panel_specularGlossiness.png";
+ public const string icon_UVspace0 = "UVspaceIcon-0.png";
+ public const string icon_UVspace1 = "UVspaceIcon-1.png";
public Test()
{
@@ -34,6 +39,7 @@ public enum TestName
Material,
Material_Alpha,
Material_MetallicRoughness,
+ Material_SpecularGlossiness,
Texture_Sampler,
Primitive_Attribute,
}
diff --git a/Source/Tests/Material.cs b/Source/Tests/Material.cs
index ec031723..4cb98e6d 100644
--- a/Source/Tests/Material.cs
+++ b/Source/Tests/Material.cs
@@ -20,7 +20,7 @@ public Material()
};
Runtime.Image occlusionTexture = new Runtime.Image
{
- Uri = texture_OcclusionRoughnessMetallic
+ Uri = texture_Occlusion
};
usedImages.Add(emissiveTexture);
usedImages.Add(normalTexture);
@@ -48,7 +48,7 @@ public Material()
};
specialProperties = new List
{
- new Property(Propertyname.Normal, planeNormals),
+ new Property(Propertyname.VertexNormal, planeNormals),
};
specialCombos.Add(ComboHelper.CustomComboCreation(
properties.Find(e => e.name == Propertyname.EmissiveFactor),
@@ -59,7 +59,7 @@ public Material()
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List combo)
{
- material.MetallicRoughnessMaterial = new Runtime.MetallicRoughnessMaterial();
+ material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness();
foreach (Property req in requiredProperty)
{
@@ -88,7 +88,7 @@ public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material ma
material.NormalTexture.Source = property.value;
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Normals =
- specialProperties.Find(e => e.name == Propertyname.Normal).value;
+ specialProperties.Find(e => e.name == Propertyname.VertexNormal).value;
break;
}
case Propertyname.Scale:
diff --git a/Source/Tests/Material.md b/Source/Tests/Material.md
new file mode 100644
index 00000000..cd2d9b65
--- /dev/null
+++ b/Source/Tests/Material.md
@@ -0,0 +1,7 @@
+The following table shows the properties that are set for every model.
+
+~~HeaderTable~~
+
+The following table shows the properties that are set for a given model.
+
+~~Table~~
diff --git a/Source/Tests/Material_Alpha.cs b/Source/Tests/Material_Alpha.cs
index b963919f..6750b2fa 100644
--- a/Source/Tests/Material_Alpha.cs
+++ b/Source/Tests/Material_Alpha.cs
@@ -15,49 +15,86 @@ public Material_Alpha()
Uri = texture_BaseColor
};
usedImages.Add(baseColorTexture);
- requiredProperty = new List
+ List colorCoord = new List()
{
- new Property(Propertyname.BaseColorTexture, baseColorTexture)
+ new Vector4( 0.3f, 0.3f, 0.3f, 0.2f),
+ new Vector4( 0.3f, 0.3f, 0.3f, 0.4f),
+ new Vector4( 0.3f, 0.3f, 0.3f, 0.6f),
+ new Vector4( 0.3f, 0.3f, 0.3f, 0.8f)
};
properties = new List
{
+ new Property(Propertyname.VertexColor_Vector4_Float, colorCoord, group:2),
new Property(Propertyname.AlphaMode_Mask, glTFLoader.Schema.Material.AlphaModeEnum.MASK, group:1),
new Property(Propertyname.AlphaMode_Blend, glTFLoader.Schema.Material.AlphaModeEnum.BLEND, group:1),
new Property(Propertyname.AlphaCutoff, 0.7f),
new Property(Propertyname.DoubleSided, true),
- new Property(Propertyname.BaseColorFactor, new Vector4(1.0f, 1.0f, 1.0f, 0.8f))
+ new Property(Propertyname.BaseColorFactor, new Vector4(1.0f, 1.0f, 1.0f, 0.6f)),
+ new Property(Propertyname.BaseColorTexture, baseColorTexture),
+ };
+ specialProperties = new List
+ {
+ new Property(Propertyname.BaseColorTexture, baseColorTexture),
+ new Property(Propertyname.VertexColor_Vector4_Float, colorCoord, group:2),
};
specialCombos.Add(ComboHelper.CustomComboCreation(
properties.Find(e => e.name == Propertyname.AlphaMode_Mask),
properties.Find(e => e.name == Propertyname.AlphaCutoff)));
specialCombos.Add(ComboHelper.CustomComboCreation(
- properties.Find(e => e.name == Propertyname.AlphaMode_Mask),
- properties.Find(e => e.name == Propertyname.DoubleSided)));
+ properties.Find(e => e.name == Propertyname.DoubleSided),
+ properties.Find(e => e.name == Propertyname.AlphaCutoff),
+ properties.Find(e => e.name == Propertyname.AlphaMode_Mask)));
specialCombos.Add(ComboHelper.CustomComboCreation(
- properties.Find(e => e.name == Propertyname.AlphaMode_Blend),
- properties.Find(e => e.name == Propertyname.DoubleSided)));
+ properties.Find(e => e.name == Propertyname.DoubleSided),
+ properties.Find(e => e.name == Propertyname.AlphaMode_Blend)));
specialCombos.Add(ComboHelper.CustomComboCreation(
properties.Find(e => e.name == Propertyname.AlphaMode_Mask),
properties.Find(e => e.name == Propertyname.BaseColorFactor)));
+ specialCombos.Add(ComboHelper.CustomComboCreation(
+ properties.Find(e => e.name == Propertyname.BaseColorFactor),
+ properties.Find(e => e.name == Propertyname.BaseColorTexture),
+ properties.Find(e => e.name == Propertyname.AlphaMode_Blend),
+ properties.Find(e => e.name == Propertyname.VertexColor_Vector4_Float)));
removeCombos.Add(ComboHelper.CustomComboCreation(
properties.Find(e => e.name == Propertyname.AlphaCutoff)));
removeCombos.Add(ComboHelper.CustomComboCreation(
properties.Find(e => e.name == Propertyname.BaseColorFactor)));
+ removeCombos.Add(ComboHelper.CustomComboCreation(
+ properties.Find(e => e.name == Propertyname.VertexColor_Vector4_Float)));
+ removeCombos.Add(ComboHelper.CustomComboCreation(
+ properties.Find(e => e.name == Propertyname.BaseColorTexture)));
}
- public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List combo)
+ override public List> ApplySpecialProperties(Test test, List> combos)
{
- material.MetallicRoughnessMaterial = new Runtime.MetallicRoughnessMaterial();
- material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture();
-
- foreach (Property req in requiredProperty)
+ // BaseColorTexture is used everywhere except in the empty set
+ var baseColorTexture = specialProperties.Find(e => e.name == Propertyname.BaseColorTexture);
+ foreach (var y in combos)
{
- if (req.name == Propertyname.BaseColorTexture)
+ // Checks if the property is already in that combo, or vertexcolor
+ if ((y.Find(e => e.name == baseColorTexture.name)) == null &&
+ (y.Find(e => LogStringHelper.GenerateNameWithSpaces(e.name.ToString()) ==
+ LogStringHelper.GenerateNameWithSpaces(Propertyname.VertexColor_Vector4_Float.ToString()))) == null)
{
- material.MetallicRoughnessMaterial.BaseColorTexture.Source = req.value;
+ // Skip the empty set
+ if (y.Count > 0)
+ {
+ y.Add(baseColorTexture);
+ }
}
}
+ // Add a AlphaMode_Blend and VertexColor combo to the bottom, so BaseColorTexture isn't split up
+ combos.Add(ComboHelper.CustomComboCreation(
+ properties.Find(e => e.name == Propertyname.AlphaMode_Blend),
+ properties.Find(e => e.name == Propertyname.VertexColor_Vector4_Float)));
+
+ return combos;
+ }
+
+ public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List combo)
+ {
+
foreach (Property property in combo)
{
if (property.name == Propertyname.AlphaMode_Opaque ||
@@ -76,8 +113,27 @@ public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material ma
}
else if (property.name == Propertyname.BaseColorFactor)
{
+ if (material.MetallicRoughnessMaterial == null)
+ {
+ material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness();
+ }
material.MetallicRoughnessMaterial.BaseColorFactor = property.value;
}
+ else if (property.name == Propertyname.BaseColorTexture)
+ {
+ if (material.MetallicRoughnessMaterial == null)
+ {
+ material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness();
+ }
+ material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture();
+ material.MetallicRoughnessMaterial.BaseColorTexture.Source = property.value;
+ }
+ else if (property.name == Propertyname.VertexColor_Vector4_Float)
+ {
+ wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.FLOAT;
+ wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorType = Runtime.MeshPrimitive.ColorTypeEnum.VEC4;
+ wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Colors = property.value;
+ }
}
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Material = material;
diff --git a/Source/Tests/Material_Alpha.md b/Source/Tests/Material_Alpha.md
new file mode 100644
index 00000000..b63ccf91
--- /dev/null
+++ b/Source/Tests/Material_Alpha.md
@@ -0,0 +1,5 @@
+No attributes are explicitly set in every model generated by this test, other than those in the base model.
+
+The following table shows the properties that are set for a given model.
+
+~~Table~~
diff --git a/Source/Tests/Material_MetallicRoughness.cs b/Source/Tests/Material_MetallicRoughness.cs
index 3e05b158..3ce24220 100644
--- a/Source/Tests/Material_MetallicRoughness.cs
+++ b/Source/Tests/Material_MetallicRoughness.cs
@@ -13,38 +13,85 @@ public Material_MetallicRoughness()
{
Uri = texture_BaseColor
};
- Runtime.Image occlusionRoughnessMetallicTexture = new Runtime.Image
+ Runtime.Image metallicRoughnessTexture = new Runtime.Image
{
- Uri = texture_OcclusionRoughnessMetallic
+ Uri = texture_MetallicRoughness
};
usedImages.Add(baseColorTexture);
- usedImages.Add(occlusionRoughnessMetallicTexture);
+ usedImages.Add(metallicRoughnessTexture);
+ List colorCoord = new List()
+ {
+ new Vector4( 1.0f, 0.0f, 0.0f, 0.8f),
+ new Vector4( 0.0f, 0.0f, 1.0f, 0.8f),
+ new Vector4( 1.0f, 0.0f, 0.0f, 0.8f),
+ new Vector4( 0.0f, 0.0f, 1.0f, 0.8f)
+ };
properties = new List
{
+ new Property(Propertyname.VertexColor_Vector3_Float, colorCoord, group:2),
new Property(Propertyname.BaseColorFactor, new Vector4(0.2f, 0.2f, 0.2f, 0.8f)),
- new Property(Propertyname.BaseColorTexture, baseColorTexture),
new Property(Propertyname.MetallicFactor, 0.0f),
new Property(Propertyname.RoughnessFactor, 0.0f),
- new Property(Propertyname.MetallicRoughnessTexture, occlusionRoughnessMetallicTexture)
+ new Property(Propertyname.BaseColorTexture, baseColorTexture),
+ new Property(Propertyname.MetallicRoughnessTexture, metallicRoughnessTexture),
+ };
+ // Not called explicitly, but values are required here to run ApplySpecialProperties
+ specialProperties = new List
+ {
+ new Property(Propertyname.VertexColor_Vector3_Float, colorCoord, group:2),
};
specialCombos.Add(ComboHelper.CustomComboCreation(
- properties.Find(e => e.name == Propertyname.BaseColorTexture),
- properties.Find(e => e.name == Propertyname.BaseColorFactor)));
+ properties.Find(e => e.name == Propertyname.BaseColorFactor),
+ properties.Find(e => e.name == Propertyname.BaseColorTexture)));
specialCombos.Add(ComboHelper.CustomComboCreation(
properties.Find(e => e.name == Propertyname.MetallicRoughnessTexture),
properties.Find(e => e.name == Propertyname.MetallicFactor)));
specialCombos.Add(ComboHelper.CustomComboCreation(
properties.Find(e => e.name == Propertyname.MetallicRoughnessTexture),
properties.Find(e => e.name == Propertyname.RoughnessFactor)));
+ removeCombos.Add(ComboHelper.CustomComboCreation(
+ properties.Find(e => e.name == Propertyname.BaseColorTexture)));
+ }
+
+ override public List> ApplySpecialProperties(Test test, List> combos)
+ {
+ // Test the VertexColor in combo with BaseColorTexture
+ var baseColorTexture = properties.Find(e => e.name == Propertyname.BaseColorTexture);
+ string vertexColorName = LogStringHelper.GenerateNameWithSpaces(Propertyname.VertexColor_Vector3_Float.ToString());
+ string baseColorTextureName = LogStringHelper.GenerateNameWithSpaces(Propertyname.BaseColorTexture.ToString());
+ foreach (var y in combos)
+ {
+ // Checks if combos contain the vertexcolor property
+ if ((y.Find(e => LogStringHelper.GenerateNameWithSpaces(e.name.ToString()) == vertexColorName)) != null)
+ {
+ // Makes sure that BaseColorTexture isn't already in that combo
+ if ((y.Find(e => LogStringHelper.GenerateNameWithSpaces(e.name.ToString()) == baseColorTextureName)) == null)
+ {
+ y.Add(baseColorTexture);
+ }
+ }
+ }
+
+ // Inserts the solo BaseColorTexture model next to the other models that use the texture
+ combos.Insert(3, ComboHelper.CustomComboCreation(
+ properties.Find(e => e.name == Propertyname.BaseColorTexture)));
+
+ return combos;
}
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List combo)
{
+ // Initialize MetallicRoughness for the empty set
+ if (combo.Count == 0)
+ {
+ material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness();
+ }
+
foreach (Property property in combo)
{
if (material.MetallicRoughnessMaterial == null)
{
- material.MetallicRoughnessMaterial = new Runtime.MetallicRoughnessMaterial();
+ material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness();
}
switch (property.name)
@@ -76,6 +123,13 @@ public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material ma
material.MetallicRoughnessMaterial.MetallicRoughnessTexture.Source = property.value;
break;
}
+ case Propertyname.VertexColor_Vector3_Float:
+ {
+ wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.FLOAT;
+ wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorType = Runtime.MeshPrimitive.ColorTypeEnum.VEC3;
+ wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Colors = property.value;
+ break;
+ }
}
}
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Material = material;
diff --git a/Source/Tests/Material_MetallicRoughness.md b/Source/Tests/Material_MetallicRoughness.md
new file mode 100644
index 00000000..b63ccf91
--- /dev/null
+++ b/Source/Tests/Material_MetallicRoughness.md
@@ -0,0 +1,5 @@
+No attributes are explicitly set in every model generated by this test, other than those in the base model.
+
+The following table shows the properties that are set for a given model.
+
+~~Table~~
diff --git a/Source/Tests/Material_SpecularGlossiness.cs b/Source/Tests/Material_SpecularGlossiness.cs
new file mode 100644
index 00000000..47e7e201
--- /dev/null
+++ b/Source/Tests/Material_SpecularGlossiness.cs
@@ -0,0 +1,172 @@
+using System.Collections.Generic;
+
+namespace AssetGenerator.Tests
+{
+ [TestAttribute]
+ class Material_SpecularGlossiness : Test
+ {
+ public Material_SpecularGlossiness()
+ {
+ testType = TestName.Material_SpecularGlossiness;
+ onlyBinaryProperties = false;
+ Runtime.Image diffuseTexture = new Runtime.Image
+ {
+ Uri = texture_Diffuse
+ };
+ Runtime.Image specularGlossinessTexture = new Runtime.Image
+ {
+ Uri = texture_SpecularGlossiness
+ };
+ usedImages.Add(diffuseTexture);
+ usedImages.Add(specularGlossinessTexture);
+ List colorCoord = new List()
+ {
+ new Vector4( 1.0f, 0.0f, 0.0f, 0.8f),
+ new Vector4( 0.0f, 0.0f, 1.0f, 0.8f),
+ new Vector4( 1.0f, 0.0f, 0.0f, 0.8f),
+ new Vector4( 0.0f, 0.0f, 1.0f, 0.8f)
+ };
+ properties = new List
+ {
+ new Property(Propertyname.VertexColor_Vector3_Float, colorCoord, group:2),
+ new Property(Propertyname.DiffuseFactor, new Vector4(0.2f, 0.2f, 0.2f, 0.8f)),
+ new Property(Propertyname.SpecularFactor, new Vector3(0.4f, 0.4f, 0.4f), group:1),
+ new Property(Propertyname.SpecularFactor_Override, new Vector3(0.0f, 0.0f, 0.0f), group:1),
+ new Property(Propertyname.GlossinessFactor, 0.3f),
+ new Property(Propertyname.DiffuseTexture, diffuseTexture),
+ new Property(Propertyname.SpecularGlossinessTexture, specularGlossinessTexture),
+ };
+ // Not called explicitly, but values are required here to run ApplySpecialProperties
+ specialProperties = new List
+ {
+ new Property(Propertyname.SpecularFactor_Override, new Vector3(0.0f, 0.0f, 0.0f), group:1),
+ new Property(Propertyname.VertexColor_Vector3_Float, colorCoord, group:2),
+ };
+ specialCombos.Add(ComboHelper.CustomComboCreation(
+ properties.Find(e => e.name == Propertyname.DiffuseFactor),
+ properties.Find(e => e.name == Propertyname.DiffuseTexture)));
+ specialCombos.Add(ComboHelper.CustomComboCreation(
+ properties.Find(e => e.name == Propertyname.SpecularGlossinessTexture),
+ properties.Find(e => e.name == Propertyname.SpecularFactor)));
+ specialCombos.Add(ComboHelper.CustomComboCreation(
+ properties.Find(e => e.name == Propertyname.SpecularGlossinessTexture),
+ properties.Find(e => e.name == Propertyname.GlossinessFactor)));
+ removeCombos.Add(ComboHelper.CustomComboCreation(
+ properties.Find(e => e.name == Propertyname.DiffuseTexture)));
+ removeCombos.Add(ComboHelper.CustomComboCreation(
+ properties.Find(e => e.name == Propertyname.SpecularFactor_Override)));
+ }
+
+ override public List> ApplySpecialProperties(Test test, List> combos)
+ {
+ // Test the VertexColor in combo with DiffuseTexture
+ var diffuseTexture = properties.Find(e => e.name == Propertyname.DiffuseTexture);
+ string vertexColorName = LogStringHelper.GenerateNameWithSpaces(Propertyname.VertexColor_Vector3_Float.ToString());
+ string diffuseTextureName = LogStringHelper.GenerateNameWithSpaces(Propertyname.DiffuseTexture.ToString());
+ foreach (var y in combos)
+ {
+ // Checks if combos contain the vertexcolor property
+ if ((y.Find(e => LogStringHelper.GenerateNameWithSpaces(e.name.ToString()) == vertexColorName)) != null)
+ {
+ // Makes sure that BaseColorTexture isn't already in that combo
+ if ((y.Find(e => LogStringHelper.GenerateNameWithSpaces(e.name.ToString()) == diffuseTextureName)) == null)
+ {
+ y.Add(diffuseTexture);
+ }
+ }
+ }
+
+ // Inserts the solo DiffuseTexture model next to the other models that use the texture
+ combos.Insert(3, ComboHelper.CustomComboCreation(
+ properties.Find(e => e.name == Propertyname.DiffuseTexture)));
+
+ // When not testing SpecularFactor, set it to all 0s to avoid a default of 1s overriding the diffuse texture
+ var specularFactorOverride = specialProperties.Find(e => e.name == Propertyname.SpecularFactor_Override);
+ foreach (var y in combos)
+ {
+ // Not the empty set, doesn't already have SpecFactor set. is using a DiffuseTexture
+ if (y.Count > 0 &&
+ (y.Find(e => e.name == Propertyname.SpecularFactor)) == null &&
+ (y.Find(e => e.name == Propertyname.DiffuseTexture)) != null)
+ {
+ y.Add(specularFactorOverride);
+ }
+ }
+
+ return combos;
+ }
+
+ public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List combo)
+ {
+ // Initialize SpecGloss for the empty set
+ if (combo.Count == 0)
+ {
+ material.Extensions = new List();
+ material.Extensions.Add(new Runtime.Extensions.PbrSpecularGlossiness());
+ }
+
+ foreach (Property property in combo)
+ {
+ if (material.Extensions == null)
+ {
+ material.Extensions = new List();
+ material.Extensions.Add(new Runtime.Extensions.PbrSpecularGlossiness());
+ }
+
+ var extension = material.Extensions[0] as Runtime.Extensions.PbrSpecularGlossiness;
+
+ switch (property.name)
+ {
+ case Propertyname.DiffuseFactor:
+ {
+ extension.DiffuseFactor = property.value;
+ break;
+ }
+ case Propertyname.SpecularFactor:
+ {
+ extension.SpecularFactor = property.value;
+ break;
+ }
+ case Propertyname.SpecularFactor_Override:
+ {
+ extension.SpecularFactor = property.value;
+ break;
+ }
+ case Propertyname.GlossinessFactor:
+ {
+ extension.GlossinessFactor = property.value;
+ break;
+ }
+ case Propertyname.DiffuseTexture:
+ {
+ extension.DiffuseTexture = new Runtime.Texture();
+ extension.DiffuseTexture.Source = property.value;
+ break;
+ }
+ case Propertyname.SpecularGlossinessTexture:
+ {
+ extension.SpecularGlossinessTexture = new Runtime.Texture();
+ extension.SpecularGlossinessTexture.Source = property.value;
+ break;
+ }
+ case Propertyname.OcclusionTexture:
+ {
+ material.OcclusionTexture = new Runtime.Texture();
+ material.OcclusionTexture.Source = property.value;
+ break;
+ }
+ case Propertyname.VertexColor_Vector3_Float:
+ {
+ wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.FLOAT;
+ wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorType = Runtime.MeshPrimitive.ColorTypeEnum.VEC3;
+ wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Colors = property.value;
+ break;
+ }
+ }
+ }
+ wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Material = material;
+
+ return wrapper;
+ }
+ }
+}
diff --git a/Source/Tests/Material_SpecularGlossiness.md b/Source/Tests/Material_SpecularGlossiness.md
new file mode 100644
index 00000000..b63ccf91
--- /dev/null
+++ b/Source/Tests/Material_SpecularGlossiness.md
@@ -0,0 +1,5 @@
+No attributes are explicitly set in every model generated by this test, other than those in the base model.
+
+The following table shows the properties that are set for a given model.
+
+~~Table~~
diff --git a/Source/Tests/Primitive_Attribute.cs b/Source/Tests/Primitive_Attribute.cs
index 8ff81d4a..d70301cb 100644
--- a/Source/Tests/Primitive_Attribute.cs
+++ b/Source/Tests/Primitive_Attribute.cs
@@ -18,13 +18,18 @@ public Primitive_Attribute()
{
Uri = texture_BaseColor
};
- Runtime.Image OcclusionRoughnessMetallicTexture = new Runtime.Image
+ Runtime.Image uvIcon0 = new Runtime.Image
{
- Uri = texture_OcclusionRoughnessMetallic
+ Uri = icon_UVspace0
+ };
+ Runtime.Image uvIcon1 = new Runtime.Image
+ {
+ Uri = icon_UVspace1
};
usedImages.Add(normalTexture);
usedImages.Add(baseColorTexture);
- usedImages.Add(OcclusionRoughnessMetallicTexture);
+ usedImages.Add(uvIcon0);
+ usedImages.Add(uvIcon1);
List planeNormals = new List()
{
new Vector3( 0.0f, 0.0f,-1.0f),
@@ -34,10 +39,10 @@ public Primitive_Attribute()
};
List uvCoord2 = new List()
{
- new Vector2(0.0f, 1.0f),
- new Vector2(1.0f, 1.0f),
+ new Vector2(0.5f, 0.5f),
+ new Vector2(1.0f, 0.5f),
new Vector2(1.0f, 0.0f),
- new Vector2(0.0f, 0.0f)
+ new Vector2(0.5f, 0.0f)
};
List colorCoord = new List()
{
@@ -55,64 +60,65 @@ public Primitive_Attribute()
};
properties = new List
{
- new Property(Propertyname.Normal, planeNormals),
- new Property(Propertyname.NormalTexture, normalTexture),
- new Property(Propertyname.Tangent, tanCoord),
- new Property(Propertyname.TexCoord0_Float,
+ new Property(Propertyname.VertexNormal, planeNormals),
+ new Property(Propertyname.VertexTangent, tanCoord),
+ new Property(Propertyname.VertexUV0_Float,
Runtime.MeshPrimitive.TextureCoordsComponentTypeEnum.FLOAT, group:1),
- new Property(Propertyname.TexCoord0_Byte,
+ new Property(Propertyname.VertexUV0_Byte,
Runtime.MeshPrimitive.TextureCoordsComponentTypeEnum.NORMALIZED_UBYTE, group:1),
- new Property(Propertyname.TexCoord0_Short,
+ new Property(Propertyname.VertexUV0_Short,
Runtime.MeshPrimitive.TextureCoordsComponentTypeEnum.NORMALIZED_USHORT, group:1),
- new Property(Propertyname.TexCoord1_Float,
- Runtime.MeshPrimitive.TextureCoordsComponentTypeEnum.FLOAT, Propertyname.TexCoord0_Float, 2),
- new Property(Propertyname.TexCoord1_Byte,
- Runtime.MeshPrimitive.TextureCoordsComponentTypeEnum.NORMALIZED_UBYTE, Propertyname.TexCoord0_Byte, 2),
- new Property(Propertyname.TexCoord1_Short,
- Runtime.MeshPrimitive.TextureCoordsComponentTypeEnum.NORMALIZED_USHORT, Propertyname.TexCoord0_Short, 2),
- new Property(Propertyname.Color_Vector3_Float, colorCoord, group:3),
- new Property(Propertyname.Color_Vector3_Byte, colorCoord, group:3),
- new Property(Propertyname.Color_Vector3_Short, colorCoord, group:3),
- new Property(Propertyname.Color_Vector4_Float, colorCoord, group:3),
- new Property(Propertyname.Color_Vector4_Byte, colorCoord, group:3),
- new Property(Propertyname.Color_Vector4_Short, colorCoord, group:3),
+ new Property(Propertyname.VertexUV1_Float,
+ Runtime.MeshPrimitive.TextureCoordsComponentTypeEnum.FLOAT, Propertyname.VertexUV0_Float, 2),
+ new Property(Propertyname.VertexUV1_Byte,
+ Runtime.MeshPrimitive.TextureCoordsComponentTypeEnum.NORMALIZED_UBYTE, Propertyname.VertexUV0_Byte, 2),
+ new Property(Propertyname.VertexUV1_Short,
+ Runtime.MeshPrimitive.TextureCoordsComponentTypeEnum.NORMALIZED_USHORT, Propertyname.VertexUV0_Short, 2),
+ new Property(Propertyname.VertexColor_Vector4_Float, colorCoord, group:3),
+ new Property(Propertyname.VertexColor_Vector4_Byte, colorCoord, group:3),
+ new Property(Propertyname.VertexColor_Vector4_Short, colorCoord, group:3),
+ new Property(Propertyname.VertexColor_Vector3_Float, colorCoord, group:3),
+ new Property(Propertyname.VertexColor_Vector3_Byte, colorCoord, group:3),
+ new Property(Propertyname.VertexColor_Vector3_Short, colorCoord, group:3),
+ new Property(Propertyname.NormalTexture, normalTexture),
new Property(Propertyname.BaseColorTexture, baseColorTexture),
- new Property(Propertyname.MetallicRoughnessTexture, OcclusionRoughnessMetallicTexture),
};
specialProperties = new List
{
- new Property(Propertyname.BaseColorTexture, baseColorTexture),
- new Property(Propertyname.MetallicRoughnessTexture, OcclusionRoughnessMetallicTexture),
new Property(Propertyname.TexCoord, uvCoord2),
- new Property(Propertyname.TexCoord0_Float,
+ new Property(Propertyname.BaseColorTexture, baseColorTexture),
+ new Property(Propertyname.VertexUV0_Float,
Runtime.MeshPrimitive.TextureCoordsComponentTypeEnum.FLOAT, group:1)
};
specialCombos.Add(ComboHelper.CustomComboCreation(
- properties.Find(e => e.name == Propertyname.Normal),
+ properties.Find(e => e.name == Propertyname.VertexUV0_Float),
properties.Find(e => e.name == Propertyname.NormalTexture),
- properties.Find(e => e.name == Propertyname.Tangent)));
+ properties.Find(e => e.name == Propertyname.BaseColorTexture)));
+ specialCombos.Add(ComboHelper.CustomComboCreation(
+ properties.Find(e => e.name == Propertyname.VertexNormal),
+ properties.Find(e => e.name == Propertyname.NormalTexture),
+ properties.Find(e => e.name == Propertyname.VertexTangent)));
specialCombos.Add(ComboHelper.CustomComboCreation(
- properties.Find(e => e.name == Propertyname.Normal),
+ properties.Find(e => e.name == Propertyname.VertexNormal),
properties.Find(e => e.name == Propertyname.NormalTexture)));
removeCombos.Add(ComboHelper.CustomComboCreation(
- properties.Find(e => e.name == Propertyname.Tangent)));
+ properties.Find(e => e.name == Propertyname.VertexTangent)));
removeCombos.Add(ComboHelper.CustomComboCreation(
properties.Find(e => e.name == Propertyname.NormalTexture)));
removeCombos.Add(ComboHelper.CustomComboCreation(
properties.Find(e => e.name == Propertyname.BaseColorTexture)));
- removeCombos.Add(ComboHelper.CustomComboCreation(
- properties.Find(e => e.name == Propertyname.MetallicRoughnessTexture)));
}
override public List> ApplySpecialProperties(Test test, List> combos)
{
- // BaseColorTexture is used everywhere except in the empty set
+ // BaseColorTexture is used everywhere except in the empty set and with vertexcolor
var baseColorTexture = specialProperties.Find(e => e.name == Propertyname.BaseColorTexture);
foreach (var y in combos)
{
- // Checks if the property is already in that combo
- if ((y.Find(e => e.name ==
- baseColorTexture.name)) == null)
+ // Checks if the property is already in that combo, or vertexcolor
+ if ((y.Find(e => e.name == baseColorTexture.name)) == null &&
+ (y.Find(e => LogStringHelper.GenerateNameWithSpaces(e.name.ToString()) ==
+ LogStringHelper.GenerateNameWithSpaces(Propertyname.VertexColor_Vector3_Float.ToString()))) == null)
{
// Skip the empty set
if (y.Count > 0)
@@ -123,41 +129,18 @@ override public List> ApplySpecialProperties(Test test, List e.name == Propertyname.TexCoord0_Float);
+ var vertexUV0 = specialProperties.Find(e => e.name == Propertyname.VertexUV0_Float);
foreach (var y in combos)
{
// Checks if the property is already in that combo
if ((y.Find(e => LogStringHelper.GenerateNameWithSpaces(e.name.ToString()) ==
- LogStringHelper.GenerateNameWithSpaces(texCoord0.name.ToString()))) == null)
+ LogStringHelper.GenerateNameWithSpaces(vertexUV0.name.ToString()))) == null)
{
// If there are already values in the combo, just add this new property
// Otherwise skip the empty set
if (y.Count > 0)
{
- y.Add(texCoord0);
- }
- }
- }
-
- // MetallicRoughtness is added wherever there is a second UV used
- var metallicRoughnessTexture = specialProperties.Find(e => e.name == Propertyname.MetallicRoughnessTexture);
- foreach (var y in combos)
- {
- // Checks the combo uses the uv1 property
- if ((y.Find(e => e.name == Propertyname.TexCoord1_Float)) != null ||
- (y.Find(e => e.name == Propertyname.TexCoord1_Byte)) != null ||
- (y.Find(e => e.name == Propertyname.TexCoord1_Short)) != null)
- {
- // Checks if the property is already in that combo
- if ((y.Find(e => e.name ==
- metallicRoughnessTexture.name)) == null)
- {
- // If there are already values in the combo, just add this new property
- // Otherwise skip the empty set
- if (y.Count > 0)
- {
- y.Add(metallicRoughnessTexture);
- }
+ y.Add(vertexUV0);
}
}
}
@@ -173,60 +156,42 @@ public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material ma
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].TextureCoordSets.RemoveAt(0);
material.MetallicRoughnessMaterial = null;
}
- else
- {
- material.MetallicRoughnessMaterial = new Runtime.MetallicRoughnessMaterial();
- material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture();
- }
foreach (Property property in combo)
{
if (property.name == Propertyname.BaseColorTexture)
{
- material.MetallicRoughnessMaterial.BaseColorTexture.Source = property.value;
- material.MetallicRoughnessMaterial.BaseColorTexture.TexCoordIndex = 0;
- }
- else if (property.name == Propertyname.MetallicRoughnessTexture)
- {
- material.MetallicRoughnessMaterial.MetallicRoughnessTexture = new Runtime.Texture();
- material.MetallicRoughnessMaterial.MetallicRoughnessTexture.Source = property.value;
- material.MetallicRoughnessMaterial.MetallicRoughnessTexture.TexCoordIndex = 1;
-
- if (wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].TextureCoordSets.Count < 2)
+ if (material.MetallicRoughnessMaterial == null)
{
- wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].TextureCoordSets.Add(
- specialProperties.Find(e => e.name == Propertyname.TexCoord).value);
+ material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness();
+ material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture();
}
+ material.MetallicRoughnessMaterial.BaseColorTexture.Source = property.value;
+ material.MetallicRoughnessMaterial.BaseColorTexture.TexCoordIndex = 0;
}
- else if (property.name == Propertyname.Normal)
+ else if (property.name == Propertyname.VertexNormal)
{
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Normals = property.value;
- if (wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].TextureCoordSets.Count < 2)
- {
- wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].TextureCoordSets.Add(
- specialProperties.Find(e => e.name == Propertyname.TexCoord).value);
- }
}
else if (property.name == Propertyname.NormalTexture)
{
material.NormalTexture = new Runtime.Texture();
material.NormalTexture.Source = property.value;
- material.NormalTexture.TexCoordIndex = 1;
-
+ material.NormalTexture.TexCoordIndex = 0;
}
- else if (property.name == Propertyname.Tangent)
+ else if (property.name == Propertyname.VertexTangent)
{
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Tangents = property.value;
}
- else if (property.name == Propertyname.TexCoord0_Float ||
- property.name == Propertyname.TexCoord0_Byte ||
- property.name == Propertyname.TexCoord0_Short)
+ else if (property.name == Propertyname.VertexUV0_Float ||
+ property.name == Propertyname.VertexUV0_Byte ||
+ property.name == Propertyname.VertexUV0_Short)
{
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].TextureCoordsComponentType = property.value;
}
- else if (property.name == Propertyname.TexCoord1_Float ||
- property.name == Propertyname.TexCoord1_Byte ||
- property.name == Propertyname.TexCoord1_Short)
+ else if (property.name == Propertyname.VertexUV1_Float ||
+ property.name == Propertyname.VertexUV1_Byte ||
+ property.name == Propertyname.VertexUV1_Short)
{
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].TextureCoordsComponentType = property.value;
@@ -236,37 +201,37 @@ public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material ma
specialProperties.Find(e => e.name == Propertyname.TexCoord).value);
}
}
- else if (property.name == Propertyname.Color_Vector3_Float)
+ else if (property.name == Propertyname.VertexColor_Vector3_Float)
{
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.FLOAT;
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorType = Runtime.MeshPrimitive.ColorTypeEnum.VEC3;
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Colors = property.value;
}
- else if (property.name == Propertyname.Color_Vector4_Float)
+ else if (property.name == Propertyname.VertexColor_Vector4_Float)
{
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.FLOAT;
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorType = Runtime.MeshPrimitive.ColorTypeEnum.VEC4;
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Colors = property.value;
}
- else if (property.name == Propertyname.Color_Vector3_Byte)
+ else if (property.name == Propertyname.VertexColor_Vector3_Byte)
{
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.NORMALIZED_UBYTE;
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorType = Runtime.MeshPrimitive.ColorTypeEnum.VEC3;
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Colors = property.value;
}
- else if (property.name == Propertyname.Color_Vector4_Byte)
+ else if (property.name == Propertyname.VertexColor_Vector4_Byte)
{
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.NORMALIZED_UBYTE;
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorType = Runtime.MeshPrimitive.ColorTypeEnum.VEC4;
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Colors = property.value;
}
- else if (property.name == Propertyname.Color_Vector3_Short)
+ else if (property.name == Propertyname.VertexColor_Vector3_Short)
{
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.NORMALIZED_USHORT;
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorType = Runtime.MeshPrimitive.ColorTypeEnum.VEC3;
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Colors = property.value;
}
- else if (property.name == Propertyname.Color_Vector4_Short)
+ else if (property.name == Propertyname.VertexColor_Vector4_Short)
{
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.NORMALIZED_USHORT;
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].ColorType = Runtime.MeshPrimitive.ColorTypeEnum.VEC4;
@@ -277,6 +242,18 @@ public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material ma
{
wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].Material = material;
}
+ // Use the second UV if it has been set
+ if (wrapper.Scenes[0].Meshes[0].MeshPrimitives[0].TextureCoordSets.Count > 1)
+ {
+ if (material.NormalTexture != null)
+ {
+ material.NormalTexture.TexCoordIndex = 1;
+ }
+ if (material.MetallicRoughnessMaterial.BaseColorTexture != null)
+ {
+ material.MetallicRoughnessMaterial.BaseColorTexture.TexCoordIndex = 1;
+ }
+ }
return wrapper;
}
diff --git a/Source/Tests/Primitive_Attribute.md b/Source/Tests/Primitive_Attribute.md
new file mode 100644
index 00000000..e6d67e32
--- /dev/null
+++ b/Source/Tests/Primitive_Attribute.md
@@ -0,0 +1,11 @@
+No attributes are explicitly set in every model generated by this test, other than those in the base model.
+
+If both Vertex UV 0 and 1 are set on a model, then all of the textures will use Vertex UV 1.
+
+Vertex UV 0 | Vertex UV 1
+:---: | :---:
+
|
+
+The following table shows the properties that are set for a given model.
+
+~~Table~~
diff --git a/Source/Tests/Texture_Sampler.cs b/Source/Tests/Texture_Sampler.cs
index 8a6273ad..ba4a0bfb 100644
--- a/Source/Tests/Texture_Sampler.cs
+++ b/Source/Tests/Texture_Sampler.cs
@@ -51,7 +51,7 @@ public Texture_Sampler()
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List combo)
{
- material.MetallicRoughnessMaterial = new Runtime.MetallicRoughnessMaterial();
+ material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness();
material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture();
material.MetallicRoughnessMaterial.BaseColorTexture.Sampler = new Runtime.Sampler();
diff --git a/Source/Tests/Texture_Sampler.md b/Source/Tests/Texture_Sampler.md
new file mode 100644
index 00000000..cd2d9b65
--- /dev/null
+++ b/Source/Tests/Texture_Sampler.md
@@ -0,0 +1,7 @@
+The following table shows the properties that are set for every model.
+
+~~HeaderTable~~
+
+The following table shows the properties that are set for a given model.
+
+~~Table~~
diff --git a/Source/Tests/UVspaceIcon-0.png b/Source/Tests/UVspaceIcon-0.png
new file mode 100644
index 00000000..e69c4c52
Binary files /dev/null and b/Source/Tests/UVspaceIcon-0.png differ
diff --git a/Source/Tests/UVspaceIcon-1.png b/Source/Tests/UVspaceIcon-1.png
new file mode 100644
index 00000000..59dd84b2
Binary files /dev/null and b/Source/Tests/UVspaceIcon-1.png differ
diff --git a/Source/Tests/lambert2_AlbedoTransparency.png b/Source/Tests/lambert2_AlbedoTransparency.png
new file mode 100644
index 00000000..3d4ada60
Binary files /dev/null and b/Source/Tests/lambert2_AlbedoTransparency.png differ
diff --git a/Source/Tests/lambert2_SpecularSmoothness.png b/Source/Tests/lambert2_SpecularSmoothness.png
new file mode 100644
index 00000000..9261c9e0
Binary files /dev/null and b/Source/Tests/lambert2_SpecularSmoothness.png differ
diff --git a/Source/ImageDependencies/lambert2_baseColor.png b/Source/Tests/panel_baseColor.png
similarity index 100%
rename from Source/ImageDependencies/lambert2_baseColor.png
rename to Source/Tests/panel_baseColor.png
diff --git a/Source/Tests/panel_diffuse.png b/Source/Tests/panel_diffuse.png
new file mode 100644
index 00000000..3d4ada60
Binary files /dev/null and b/Source/Tests/panel_diffuse.png differ
diff --git a/Source/ImageDependencies/lambert2_emissive.png b/Source/Tests/panel_emissive.png
similarity index 100%
rename from Source/ImageDependencies/lambert2_emissive.png
rename to Source/Tests/panel_emissive.png
diff --git a/Source/Tests/panel_metallicRoughness.png b/Source/Tests/panel_metallicRoughness.png
new file mode 100644
index 00000000..684fe986
Binary files /dev/null and b/Source/Tests/panel_metallicRoughness.png differ
diff --git a/Source/ImageDependencies/lambert2_normal.png b/Source/Tests/panel_normal.png
similarity index 100%
rename from Source/ImageDependencies/lambert2_normal.png
rename to Source/Tests/panel_normal.png
diff --git a/Source/Tests/panel_occlusion.png b/Source/Tests/panel_occlusion.png
new file mode 100644
index 00000000..d08c2597
Binary files /dev/null and b/Source/Tests/panel_occlusion.png differ
diff --git a/Source/Tests/panel_specularGlossiness.png b/Source/Tests/panel_specularGlossiness.png
new file mode 100644
index 00000000..9261c9e0
Binary files /dev/null and b/Source/Tests/panel_specularGlossiness.png differ