public Material_DoubleSided(List <string> imageList) { Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane"); Runtime.Image normalImage = UseTexture(imageList, "Normal_Plane"); // Track the common properties for use in the readme. var doubleSidedValue = true; CommonProperties.Add(new Property(PropertyName.DoubleSided, doubleSidedValue.ToString())); CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString())); Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive> setProperties) { var properties = new List <Property>(); var meshPrimitive = MeshPrimitive.CreateSinglePlane(); meshPrimitive.Material = new Runtime.Material(); meshPrimitive.Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); // Apply the common properties to the gltf. meshPrimitive.Material.DoubleSided = doubleSidedValue; meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture { Source = baseColorTextureImage }; // Apply the properties that are specific to this gltf. setProperties(properties, meshPrimitive); // Create the gltf object. return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new List <Runtime.Node> { new Runtime.Node { Mesh = new Runtime.Mesh { MeshPrimitives = new List <Runtime.MeshPrimitive> { meshPrimitive } }, }, }, }), }); } void SetVertexNormal(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { var planeNormalsValue = MeshPrimitive.GetSinglePlaneNormals(); meshPrimitive.Normals = planeNormalsValue; properties.Add(new Property(PropertyName.VertexNormal, planeNormalsValue.ToReadmeString())); } void SetVertexTangent(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { var planeTangentValue = MeshPrimitive.GetSinglePlaneTangents(); meshPrimitive.Tangents = planeTangentValue; properties.Add(new Property(PropertyName.VertexTangent, planeTangentValue.ToReadmeString())); } void SetNormalTexture(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.Material.NormalTexture = new Runtime.Texture { Source = normalImage }; properties.Add(new Property(PropertyName.NormalTexture, normalImage.ToReadmeString())); } Models = new List <Model> { CreateModel((properties, meshPrimitive) => { // There are no properties set on this model. }), CreateModel((properties, meshPrimitive) => { SetVertexNormal(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive) => { SetVertexNormal(properties, meshPrimitive); SetNormalTexture(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive) => { SetVertexNormal(properties, meshPrimitive); SetVertexTangent(properties, meshPrimitive); SetNormalTexture(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive) => { SetNormalTexture(properties, meshPrimitive); }), }; GenerateUsedPropertiesList(); }
public Mesh_PrimitivesUV(List <string> imageList) { Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane"); Runtime.Image normalImage = UseTexture(imageList, "Normal_Plane"); UseFigure(imageList, "Indices_Primitive0"); UseFigure(imageList, "Indices_Primitive1"); UseFigure(imageList, "UVSpace2"); UseFigure(imageList, "UVSpace3"); UseFigure(imageList, "UVSpace4"); UseFigure(imageList, "UVSpace5"); // Track the common properties for use in the readme. var vertexNormalValue = new List <Vector3> { new Vector3(0.0f, 0.0f, 1.0f), new Vector3(0.0f, 0.0f, 1.0f), new Vector3(0.0f, 0.0f, 1.0f), }; var tangentValue = new List <Vector4> { new Vector4(1.0f, 0.0f, 0.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), }; var vertexColorValue = new List <Vector4> { new Vector4(0.0f, 1.0f, 0.0f, 0.2f), new Vector4(1.0f, 0.0f, 0.0f, 0.2f), new Vector4(0.0f, 0.0f, 1.0f, 0.2f), }; CommonProperties.Add(new Property(PropertyName.VertexNormal, vertexNormalValue.ToReadmeString())); CommonProperties.Add(new Property(PropertyName.VertexTangent, tangentValue.ToReadmeString())); CommonProperties.Add(new Property(PropertyName.VertexColor, vertexColorValue.ToReadmeString())); CommonProperties.Add(new Property(PropertyName.NormalTexture, normalImage.ToReadmeString())); CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString())); Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive, Runtime.MeshPrimitive> setProperties) { var properties = new List <Property>(); List <Runtime.MeshPrimitive> meshPrimitives = MeshPrimitive.CreateMultiPrimitivePlane(); // Apply the common properties to the gltf. foreach (var meshPrimitive in meshPrimitives) { meshPrimitive.TextureCoordSets = new List <List <Vector2> >(); meshPrimitive.Material = new Runtime.Material { MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness { MetallicFactor = 0 } }; } // Apply the properties that are specific to this gltf. setProperties(properties, meshPrimitives[0], meshPrimitives[1]); // Create the gltf object return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new List <Runtime.Node> { new Runtime.Node { Mesh = new Runtime.Mesh { MeshPrimitives = meshPrimitives }, }, }, }), }); } void SetCommonProperties(Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.Normals = vertexNormalValue; meshPrimitive.Tangents = tangentValue; meshPrimitive.Colors = vertexColorValue; meshPrimitive.Material.NormalTexture = new Runtime.Texture { Source = normalImage }; meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture() { Source = baseColorTextureImage }; } void SetNullUV(Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.Material = null; meshPrimitive.TextureCoordSets = null; } void SetPrimitiveZeroVertexUVZero(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { SetCommonProperties(meshPrimitive); meshPrimitive.TextureCoordSets = meshPrimitive.TextureCoordSets.Concat( new[] { new[] { new Vector2(0.0f, 1.0f), new Vector2(1.0f, 0.0f), new Vector2(0.0f, 0.0f), } }); properties.Add(new Property(PropertyName.Primitive0VertexUV0, ":white_check_mark:")); } void SetPrimitiveOneVertexUVZero(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { SetCommonProperties(meshPrimitive); meshPrimitive.TextureCoordSets = meshPrimitive.TextureCoordSets.Concat( new[] { new[] { new Vector2(0.0f, 1.0f), new Vector2(1.0f, 1.0f), new Vector2(1.0f, 0.0f), } }); properties.Add(new Property(PropertyName.Primitive1VertexUV0, ":white_check_mark:")); } void SetPrimitiveZeroVertexUVOne(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { SetCommonProperties(meshPrimitive); meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture.TexCoordIndex = 1; meshPrimitive.Material.NormalTexture.TexCoordIndex = 1; meshPrimitive.TextureCoordSets = meshPrimitive.TextureCoordSets.Concat( new[] { new[] { new Vector2(0.5f, 0.5f), new Vector2(1.0f, 0.0f), new Vector2(0.5f, 0.0f), } }); properties.Add(new Property(PropertyName.Primitive0VertexUV1, ":white_check_mark:")); } void SetPrimitiveOneVertexUVOne(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { SetCommonProperties(meshPrimitive); meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture.TexCoordIndex = 1; meshPrimitive.Material.NormalTexture.TexCoordIndex = 1; meshPrimitive.TextureCoordSets = meshPrimitive.TextureCoordSets.Concat( new[] { new[] { new Vector2(0.5f, 0.5f), new Vector2(1.0f, 0.5f), new Vector2(1.0f, 0.0f), } }); properties.Add(new Property(PropertyName.Primitive1VertexUV1, ":white_check_mark:")); } Models = new List <Model> { CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetNullUV(meshPrimitiveZero); SetNullUV(meshPrimitiveOne); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero); SetNullUV(meshPrimitiveOne); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne); SetNullUV(meshPrimitiveZero); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero); SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero); SetPrimitiveZeroVertexUVOne(properties, meshPrimitiveZero); SetNullUV(meshPrimitiveOne); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne); SetPrimitiveOneVertexUVOne(properties, meshPrimitiveOne); SetNullUV(meshPrimitiveZero); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero); SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne); SetPrimitiveOneVertexUVOne(properties, meshPrimitiveOne); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero); SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne); SetPrimitiveZeroVertexUVOne(properties, meshPrimitiveZero); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero); SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne); SetPrimitiveZeroVertexUVOne(properties, meshPrimitiveZero); SetPrimitiveOneVertexUVOne(properties, meshPrimitiveOne); }), }; GenerateUsedPropertiesList(); }
public Node_Attribute(List <string> imageList) { Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Nodes"); Runtime.Image normalImage = UseTexture(imageList, "Normal_Nodes"); Runtime.Image metallicRoughnessTextureImage = UseTexture(imageList, "MetallicRoughness_Nodes"); // Track the common properties for use in the readme. CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString())); CommonProperties.Add(new Property(PropertyName.NormalTexture, normalImage.ToReadmeString())); CommonProperties.Add(new Property(PropertyName.MetallicRoughnessTexture, metallicRoughnessTextureImage.ToReadmeString())); Model CreateModel(Action <List <Property>, Runtime.Node> setProperties) { var properties = new List <Property>(); List <Runtime.Node> nodes = Nodes.CreateMultiNode(); // Apply the common properties to the gltf. foreach (var node in nodes) { node.Mesh.MeshPrimitives.First().Material = new Runtime.Material { NormalTexture = new Runtime.Texture { Source = normalImage }, MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness { BaseColorTexture = new Runtime.Texture { Source = baseColorTextureImage }, MetallicRoughnessTexture = new Runtime.Texture { Source = metallicRoughnessTextureImage }, }, }; } // Apply the properties that are specific to this gltf. setProperties(properties, nodes[1]); // Create the gltf object. return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new[] { nodes[0] } }) }); } void SetTranslation(List <Property> properties, Runtime.Node node) { node.Translation = new Vector3(-2.0f, 2.0f, -2.0f); properties.Add(new Property(PropertyName.Translation, node.Translation.ToReadmeString())); } void SetTranslationX(List <Property> properties, Runtime.Node node) { node.Translation = new Vector3(-2.0f, 0.0f, 0.0f); properties.Add(new Property(PropertyName.Translation, node.Translation.ToReadmeString())); } void SetTranslationY(List <Property> properties, Runtime.Node node) { node.Translation = new Vector3(0.0f, 2.0f, 0.0f); properties.Add(new Property(PropertyName.Translation, node.Translation.ToReadmeString())); } void SetTranslationZ(List <Property> properties, Runtime.Node node) { node.Translation = new Vector3(0.0f, 0.0f, -2.0f); properties.Add(new Property(PropertyName.Translation, node.Translation.ToReadmeString())); } void SetRotation(List <Property> properties, Runtime.Node node) { var rotation = new Quaternion(0.0f, 1.0f, 0.0f, 0.0f); node.Rotation = rotation; properties.Add(new Property(PropertyName.Rotation, rotation.ToReadmeString())); } void SetScale(List <Property> properties, Runtime.Node node) { node.Scale = new Vector3(1.2f, 1.2f, 1.2f); properties.Add(new Property(PropertyName.Scale, node.Scale.ToReadmeString())); } void SetMatrix(List <Property> properties, Runtime.Node node) { Matrix4x4 matrixT = Matrix4x4.CreateTranslation(new Vector3(-2.0f, 2.0f, -2.0f)); Matrix4x4 matrixR = Matrix4x4.CreateRotationY(FloatMath.Pi); Matrix4x4 matrixS = Matrix4x4.CreateScale(1.2f); Matrix4x4 matrixTRS = Matrix4x4.Multiply(Matrix4x4.Multiply(matrixS, matrixR), matrixT); node.Matrix = matrixTRS; properties.Add(new Property(PropertyName.Matrix, matrixTRS.ToReadmeString())); } Models = new List <Model> { CreateModel((properties, node) => { // There are no properties set on this model. }), CreateModel((properties, node) => { SetTranslation(properties, node); }), CreateModel((properties, node) => { SetTranslationX(properties, node); }), CreateModel((properties, node) => { SetTranslationY(properties, node); }), CreateModel((properties, node) => { SetTranslationZ(properties, node); }), CreateModel((properties, node) => { SetRotation(properties, node); }), CreateModel((properties, node) => { SetScale(properties, node); }), CreateModel((properties, node) => { SetTranslation(properties, node); SetRotation(properties, node); SetScale(properties, node); }), CreateModel((properties, node) => { SetMatrix(properties, node); }), }; GenerateUsedPropertiesList(); }
public Node_NegativeScale(List <string> imageList) { Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Nodes"); Runtime.Image normalImage = UseTexture(imageList, "Normal_Nodes"); Runtime.Image metallicRoughnessTextureImage = UseTexture(imageList, "MetallicRoughness_Nodes"); // Track the common properties for use in the readme. var translationValue = new Vector3(0, 2, 0); Matrix4x4 matrixTranslationValue = Matrix4x4.CreateTranslation(translationValue); CommonProperties.Add(new Property(PropertyName.Translation, translationValue.ToReadmeString())); CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString())); CommonProperties.Add(new Property(PropertyName.NormalTexture, normalImage.ToReadmeString())); CommonProperties.Add(new Property(PropertyName.MetallicRoughnessTexture, metallicRoughnessTextureImage.ToReadmeString())); Model CreateModel(Action <List <Property>, Runtime.Node, Runtime.Node> setProperties) { var properties = new List <Property>(); List <Runtime.Node> nodes = Nodes.CreateMultiNode(); // Apply the common properties to the gltf. foreach (var node in nodes) { node.Mesh.MeshPrimitives.First().Material = new Runtime.Material { NormalTexture = new Runtime.Texture { Source = normalImage }, MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness { BaseColorTexture = new Runtime.Texture { Source = baseColorTextureImage }, MetallicRoughnessTexture = new Runtime.Texture { Source = metallicRoughnessTextureImage }, }, }; } // Apply the properties that are specific to this gltf. setProperties(properties, nodes[0], nodes[1]); // Applies a translation to avoid clipping the other node. // Models with a matrix applied have the translation applied in that matrix. if (properties.Find(e => e.Name == PropertyName.Matrix) == null) { nodes[1].Translation = translationValue; } // Create the gltf object. return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new[] { nodes[0] } }) }); } void SetMatrixScaleX(List <Property> properties, Runtime.Node node) { node.Matrix = Matrix4x4.Multiply(Matrix4x4.CreateScale(new Vector3(-1.0f, 1.0f, 1.0f)), matrixTranslationValue); properties.Add(new Property(PropertyName.Matrix, node.Matrix.ToReadmeString())); } void SetMatrixScaleXY(List <Property> properties, Runtime.Node node) { node.Matrix = Matrix4x4.Multiply(Matrix4x4.CreateScale(new Vector3(-1.0f, -1.0f, 1.0f)), matrixTranslationValue); properties.Add(new Property(PropertyName.Matrix, node.Matrix.ToReadmeString())); } void SetMatrixScaleXYZ(List <Property> properties, Runtime.Node node) { node.Matrix = Matrix4x4.Multiply(Matrix4x4.CreateScale(new Vector3(-1.0f, -1.0f, -1.0f)), matrixTranslationValue); properties.Add(new Property(PropertyName.Matrix, node.Matrix.ToReadmeString())); } void SetScaleX(List <Property> properties, Runtime.Node node) { node.Scale = new Vector3(-1.0f, 1.0f, 1.0f); properties.Add(new Property(PropertyName.Scale, node.Scale.ToReadmeString())); } void SetScaleXY(List <Property> properties, Runtime.Node node) { node.Scale = new Vector3(-1.0f, -1.0f, 1.0f); properties.Add(new Property(PropertyName.Scale, node.Scale.ToReadmeString())); } void SetScaleXYZ(List <Property> properties, Runtime.Node node) { node.Scale = new Vector3(-1.0f, -1.0f, -1.0f); properties.Add(new Property(PropertyName.Scale, node.Scale.ToReadmeString())); } void SetVertexNormal(List <Property> properties, Runtime.Node nodeZero, Runtime.Node nodeOne) { var normals = Nodes.GetMultiNodeNormals(); nodeZero.Mesh.MeshPrimitives.First().Normals = normals; nodeOne.Mesh.MeshPrimitives.First().Normals = normals; properties.Add(new Property(PropertyName.VertexNormal, ":white_check_mark:")); } void SetVertexTangent(List <Property> properties, Runtime.Node nodeZero, Runtime.Node nodeOne) { var tangents = Nodes.GetMultiNodeTangents(); nodeZero.Mesh.MeshPrimitives.First().Tangents = tangents; nodeOne.Mesh.MeshPrimitives.First().Tangents = tangents; properties.Add(new Property(PropertyName.VertexTangent, ":white_check_mark:")); } Models = new List <Model> { CreateModel((properties, nodeZero, nodeOne) => { // There are no properties set on this model. }), CreateModel((properties, nodeZero, nodeOne) => { SetMatrixScaleX(properties, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetMatrixScaleXY(properties, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetMatrixScaleXYZ(properties, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleX(properties, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleXY(properties, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleXYZ(properties, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleX(properties, nodeOne); SetVertexNormal(properties, nodeZero, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleXY(properties, nodeOne); SetVertexNormal(properties, nodeZero, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleXYZ(properties, nodeOne); SetVertexNormal(properties, nodeZero, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleX(properties, nodeOne); SetVertexNormal(properties, nodeZero, nodeOne); SetVertexTangent(properties, nodeZero, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleXY(properties, nodeOne); SetVertexNormal(properties, nodeZero, nodeOne); SetVertexTangent(properties, nodeZero, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleXYZ(properties, nodeOne); SetVertexNormal(properties, nodeZero, nodeOne); SetVertexTangent(properties, nodeZero, nodeOne); }), }; GenerateUsedPropertiesList(); }
public Material_SpecularGlossiness(List <string> imageList) { Runtime.Image diffuseTextureImage = UseTexture(imageList, "Diffuse_Plane"); Runtime.Image specularGlossinessTextureImage = UseTexture(imageList, "SpecularGlossiness_Plane"); Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_X"); // Track the common properties for use in the readme. CommonProperties.Add(new Property(PropertyName.ExtensionUsed, "Specular Glossiness")); CommonProperties.Add(new Property(PropertyName.ExtensionRequired, "Specular Glossiness")); CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString())); Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive, Runtime.Material, KHR_materials_pbrSpecularGlossiness> setProperties) { var properties = new List <Property>(); var meshPrimitive = MeshPrimitive.CreateSinglePlane(); var extension = new KHR_materials_pbrSpecularGlossiness(); meshPrimitive.Material = new Runtime.Material(); meshPrimitive.Material.Extensions = new List <Extension> { extension }; meshPrimitive.Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); // Apply the common properties to the gltf. meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture { Source = baseColorTextureImage }; // Apply the properties that are specific to this gltf. setProperties(properties, meshPrimitive, meshPrimitive.Material, extension); // Create the gltf object. return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new[] { new Runtime.Node { Mesh = new Runtime.Mesh { MeshPrimitives = new[] { meshPrimitive } }, }, }, }, extensionsUsed: new List <string> { "KHR_materials_pbrSpecularGlossiness" }, extensionsRequired: new List <string> { "KHR_materials_pbrSpecularGlossiness" }), }); } void SetVertexColor(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { var vertexColors = new[] { 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), new Vector4(1.0f, 0.0f, 0.0f, 0.8f) }; meshPrimitive.ColorComponentType = ColorComponentTypeEnum.FLOAT; meshPrimitive.ColorType = ColorTypeEnum.VEC3; meshPrimitive.Colors = vertexColors; properties.Add(new Property(PropertyName.VertexColor, "Vector3 Float")); } void SetDiffuseTexture(List <Property> properties, KHR_materials_pbrSpecularGlossiness extension) { extension.DiffuseTexture = new Runtime.Texture { Source = diffuseTextureImage }; properties.Add(new Property(PropertyName.DiffuseTexture, diffuseTextureImage.ToReadmeString())); } void SetDiffuseFactor(List <Property> properties, KHR_materials_pbrSpecularGlossiness extension) { var diffuseFactorValue = new Vector4(0.2f, 0.2f, 0.2f, 0.8f); extension.DiffuseFactor = diffuseFactorValue; properties.Add(new Property(PropertyName.DiffuseFactor, diffuseFactorValue.ToReadmeString())); } void SetSpecularGlossinessTexture(List <Property> properties, KHR_materials_pbrSpecularGlossiness extension) { extension.SpecularGlossinessTexture = new Runtime.Texture { Source = specularGlossinessTextureImage }; properties.Add(new Property(PropertyName.SpecularGlossinessTexture, specularGlossinessTextureImage.ToReadmeString())); } void SetSpecularFactor(List <Property> properties, KHR_materials_pbrSpecularGlossiness extension) { var specularFactorValue = new Vector3(0.4f, 0.4f, 0.4f); extension.SpecularFactor = specularFactorValue; properties.Add(new Property(PropertyName.SpecularFactor, specularFactorValue.ToReadmeString())); } void SetSpecularFactorToZero(List <Property> properties, KHR_materials_pbrSpecularGlossiness extension) { var specularFactorValue = new Vector3(0.0f, 0.0f, 0.0f); extension.SpecularFactor = specularFactorValue; properties.Add(new Property(PropertyName.SpecularFactor, specularFactorValue.ToReadmeString())); } void SetGlossinessFactor(List <Property> properties, KHR_materials_pbrSpecularGlossiness extension) { extension.GlossinessFactor = 0.3f; properties.Add(new Property(PropertyName.GlossinessFactor, extension.GlossinessFactor.ToReadmeString())); } Models = new List <Model> { CreateModel((properties, meshPrimitive, material, extension) => { // There are no properties set on this model. }), CreateModel((properties, meshPrimitive, material, extension) => { SetVertexColor(properties, meshPrimitive); SetSpecularFactorToZero(properties, extension); }), CreateModel((properties, meshPrimitive, material, extension) => { SetDiffuseTexture(properties, extension); SetSpecularFactorToZero(properties, extension); }), CreateModel((properties, meshPrimitive, material, extension) => { SetDiffuseFactor(properties, extension); SetSpecularFactorToZero(properties, extension); }), CreateModel((properties, meshPrimitive, material, extension) => { SetSpecularGlossinessTexture(properties, extension); }), CreateModel((properties, meshPrimitive, material, extension) => { SetSpecularFactor(properties, extension); }), CreateModel((properties, meshPrimitive, material, extension) => { SetGlossinessFactor(properties, extension); }), CreateModel((properties, meshPrimitive, material, extension) => { SetVertexColor(properties, meshPrimitive); SetDiffuseTexture(properties, extension); SetSpecularFactorToZero(properties, extension); }), CreateModel((properties, meshPrimitive, material, extension) => { SetDiffuseTexture(properties, extension); SetDiffuseFactor(properties, extension); SetSpecularFactorToZero(properties, extension); }), CreateModel((properties, meshPrimitive, material, extension) => { SetDiffuseTexture(properties, extension); SetGlossinessFactor(properties, extension); }), CreateModel((properties, meshPrimitive, material, extension) => { SetSpecularGlossinessTexture(properties, extension); SetSpecularFactor(properties, extension); }), CreateModel((properties, meshPrimitive, material, extension) => { SetSpecularGlossinessTexture(properties, extension); SetGlossinessFactor(properties, extension); }), CreateModel((properties, meshPrimitive, material, extension) => { SetDiffuseTexture(properties, extension); SetSpecularFactor(properties, extension); SetGlossinessFactor(properties, extension); }), CreateModel((properties, meshPrimitive, material, extension) => { SetVertexColor(properties, meshPrimitive); SetDiffuseTexture(properties, extension); SetDiffuseFactor(properties, extension); SetSpecularGlossinessTexture(properties, extension); SetSpecularFactor(properties, extension); SetGlossinessFactor(properties, extension); }), }; GenerateUsedPropertiesList(); }
public Buffer_Interleaved(List <string> imageList) { Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Grey"); // Track the common properties for use in the readme. CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString())); Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive> setProperties) { var properties = new List <Property>(); Runtime.MeshPrimitive meshPrimitive = MeshPrimitive.CreateSinglePlane(); // Apply the common properties to the gltf. meshPrimitive.Interleave = true; meshPrimitive.Colors = new[] { new Vector4(0.0f, 1.0f, 0.0f, 0.2f), new Vector4(1.0f, 0.0f, 0.0f, 0.2f), new Vector4(1.0f, 1.0f, 0.0f, 0.2f), new Vector4(0.0f, 0.0f, 1.0f, 0.2f), }; meshPrimitive.Material = new Runtime.Material { MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness { BaseColorTexture = new Runtime.Texture { Source = baseColorTextureImage, Sampler = new Runtime.Sampler(), }, }, }; // Apply the properties that are specific to this gltf. setProperties(properties, meshPrimitive); // Create the gltf object. return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new[] { new Runtime.Node { Mesh = new Runtime.Mesh { MeshPrimitives = new[] { meshPrimitive } }, }, }, }), }); } void SetUvTypeFloat(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.TextureCoordsComponentType = TextureCoordsComponentTypeEnum.FLOAT; properties.Add(new Property(PropertyName.VertexUV0, "Float")); } void SetUvTypeTypeByte(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.TextureCoordsComponentType = TextureCoordsComponentTypeEnum.NORMALIZED_UBYTE; properties.Add(new Property(PropertyName.VertexUV0, "Byte")); } void SetUvTypeTypeShort(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.TextureCoordsComponentType = TextureCoordsComponentTypeEnum.NORMALIZED_USHORT; properties.Add(new Property(PropertyName.VertexUV0, "Short")); } void SetColorTypeFloat(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.ColorComponentType = ColorComponentTypeEnum.FLOAT; meshPrimitive.ColorType = ColorTypeEnum.VEC3; properties.Add(new Property(PropertyName.VertexColor, "Vector3 Float")); } void SetColorTypeByte(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.ColorComponentType = ColorComponentTypeEnum.NORMALIZED_UBYTE; meshPrimitive.ColorType = ColorTypeEnum.VEC3; properties.Add(new Property(PropertyName.VertexColor, "Vector3 Byte")); } void SetColorTypeShort(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.ColorComponentType = ColorComponentTypeEnum.NORMALIZED_USHORT; meshPrimitive.ColorType = ColorTypeEnum.VEC3; properties.Add(new Property(PropertyName.VertexColor, "Vector3 Short")); } Models = new List <Model> { CreateModel((properties, meshPrimitive) => { SetUvTypeFloat(properties, meshPrimitive); SetColorTypeFloat(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive) => { SetUvTypeFloat(properties, meshPrimitive); SetColorTypeByte(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive) => { SetUvTypeFloat(properties, meshPrimitive); SetColorTypeShort(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive) => { SetUvTypeTypeByte(properties, meshPrimitive); SetColorTypeFloat(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive) => { SetUvTypeTypeShort(properties, meshPrimitive); SetColorTypeFloat(properties, meshPrimitive); }), }; GenerateUsedPropertiesList(); }
public Material_AlphaMask(List <string> imageList) { Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane"); // Track the common properties for use in the readme. var alphaModeValue = AlphaModeEnum.MASK; CommonProperties.Add(new Property(PropertyName.AlphaMode, alphaModeValue.ToReadmeString())); CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString())); Model CreateModel(Action <List <Property>, Runtime.Material, Runtime.PbrMetallicRoughness> setProperties) { var properties = new List <Property>(); var meshPrimitive = MeshPrimitive.CreateSinglePlane(); meshPrimitive.Material = new Runtime.Material(); meshPrimitive.Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); // Apply the common properties to the gltf. meshPrimitive.Material.AlphaMode = alphaModeValue; meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture { Source = baseColorTextureImage }; // Apply the properties that are specific to this gltf. setProperties(properties, meshPrimitive.Material, meshPrimitive.Material.MetallicRoughnessMaterial); // Create the gltf object. return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new[] { new Runtime.Node { Mesh = new Runtime.Mesh { MeshPrimitives = new List <Runtime.MeshPrimitive> { meshPrimitive } }, }, }, }), }); } void SetAlphaCutoff_Low(List <Property> properties, Runtime.Material material) { material.AlphaCutoff = 0.4f; properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff.ToReadmeString())); } void SetAlphaCutoff_High(List <Property> properties, Runtime.Material material) { material.AlphaCutoff = 0.7f; properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff.ToReadmeString())); } void SetAlphaCutoff_Multiplied(List <Property> properties, Runtime.Material material) { material.AlphaCutoff = 0.6f; properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff.ToReadmeString())); } void SetAlphaCutoff_All(List <Property> properties, Runtime.Material material) { material.AlphaCutoff = 1.1f; properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff.ToReadmeString())); } void SetAlphaCutoff_None(List <Property> properties, Runtime.Material material) { material.AlphaCutoff = 0.0f; properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff.ToReadmeString())); } void SetBaseColorFactor(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness) { var baseColorFactorValue = new Vector4(1.0f, 1.0f, 1.0f, 0.7f); metallicRoughness.BaseColorFactor = baseColorFactorValue; properties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue.ToReadmeString())); } Models = new List <Model> { CreateModel((properties, material, metallicRoughness) => { // There are no properties set on this model. }), CreateModel((properties, material, metallicRoughness) => { SetAlphaCutoff_Low(properties, material); }), CreateModel((properties, material, metallicRoughness) => { SetAlphaCutoff_High(properties, material); }), CreateModel((properties, material, metallicRoughness) => { SetAlphaCutoff_All(properties, material); }), CreateModel((properties, material, metallicRoughness) => { SetAlphaCutoff_None(properties, material); }), CreateModel((properties, material, metallicRoughness) => { SetAlphaCutoff_Low(properties, material); SetBaseColorFactor(properties, metallicRoughness); }), CreateModel((properties, material, metallicRoughness) => { SetAlphaCutoff_Multiplied(properties, material); SetBaseColorFactor(properties, metallicRoughness); }), }; GenerateUsedPropertiesList(); }
public Material_Mixed(List <string> imageList) { Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_X"); UseFigure(imageList, "UVSpace2"); UseFigure(imageList, "UVSpace3"); // Track the common properties for use in the readme. CommonProperties.Add(new Property(PropertyName.ExtensionUsed, "Specular Glossiness")); CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString())); Model CreateModel(Action <List <Property>, Runtime.Material, Runtime.Material> setProperties) { var properties = new List <Property>(); var meshPrimitives = MeshPrimitive.CreateMultiPrimitivePlane(); var baseColorTexture = new Runtime.Texture { Source = baseColorTextureImage }; meshPrimitives[0].Material = new Runtime.Material(); meshPrimitives[0].Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); meshPrimitives[1].Material = new Runtime.Material(); meshPrimitives[1].Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); // Apply the common properties to the gltf. meshPrimitives[0].Material.MetallicRoughnessMaterial.BaseColorTexture = baseColorTexture; meshPrimitives[1].Material.MetallicRoughnessMaterial.BaseColorTexture = baseColorTexture; // Apply the properties that are specific to this gltf. setProperties(properties, meshPrimitives[0].Material, meshPrimitives[1].Material); // Create the gltf object. return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new[] { new Runtime.Node { Mesh = new Runtime.Mesh { MeshPrimitives = meshPrimitives }, }, }, }, extensionsUsed: new List <string>() { "KHR_materials_pbrSpecularGlossiness" }), }); } void SetSpecularGlossiness0(List <Property> properties, Runtime.Material material0) { material0.Extensions = new List <Runtime.Extensions.Extension> { new Runtime.Extensions.KHR_materials_pbrSpecularGlossiness() }; properties.Add(new Property(PropertyName.SpecularGlossinessOnMaterial0, ":white_check_mark:")); } void SetSpecularGlossiness1(List <Property> properties, Runtime.Material material1) { material1.Extensions = new List <Runtime.Extensions.Extension> { new Runtime.Extensions.KHR_materials_pbrSpecularGlossiness() }; properties.Add(new Property(PropertyName.SpecularGlossinessOnMaterial1, ":white_check_mark:")); } void NoSpecularGlossiness0(List <Property> properties) { properties.Add(new Property(PropertyName.SpecularGlossinessOnMaterial0, ":x:")); } void NoSpecularGlossiness1(List <Property> properties) { properties.Add(new Property(PropertyName.SpecularGlossinessOnMaterial1, ":x:")); } Models = new List <Model> { CreateModel((properties, material0, material1) => { SetSpecularGlossiness0(properties, material0); SetSpecularGlossiness1(properties, material1); }), CreateModel((properties, material0, material1) => { NoSpecularGlossiness0(properties); NoSpecularGlossiness1(properties); }), CreateModel((properties, material0, material1) => { SetSpecularGlossiness0(properties, material0); NoSpecularGlossiness1(properties); }), }; GenerateUsedPropertiesList(); }
public Mesh_PrimitiveAttribute(List <string> imageList) { Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane"); Runtime.Image normalImage = UseTexture(imageList, "Normal_Plane"); // Track the common properties for use in the readme. CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString())); Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive> setProperties) { var properties = new List <Property>(); var meshPrimitive = MeshPrimitive.CreateSinglePlane(); meshPrimitive.Material = new Runtime.Material(); // Apply the common properties to the gltf. meshPrimitive.Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness { BaseColorTexture = new Runtime.Texture { Source = baseColorTextureImage } }; // Apply the properties that are specific to this gltf. setProperties(properties, meshPrimitive); // Create the gltf object. return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new List <Runtime.Node> { new Runtime.Node { Mesh = new Runtime.Mesh { MeshPrimitives = new List <Runtime.MeshPrimitive> { meshPrimitive } }, }, }, }), }); } void SetVertexUVFloat(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.TextureCoordsComponentType = TextureCoordsComponentTypeEnum.FLOAT; properties.Add(new Property(PropertyName.VertexUV0, meshPrimitive.TextureCoordsComponentType.ToReadmeString())); } void SetVertexUVByte(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.TextureCoordsComponentType = TextureCoordsComponentTypeEnum.NORMALIZED_UBYTE; properties.Add(new Property(PropertyName.VertexUV0, meshPrimitive.TextureCoordsComponentType.ToReadmeString())); } void SetVertexUVShort(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.TextureCoordsComponentType = TextureCoordsComponentTypeEnum.NORMALIZED_USHORT; properties.Add(new Property(PropertyName.VertexUV0, meshPrimitive.TextureCoordsComponentType.ToReadmeString())); } void SetVertexNormal(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { var planeNormalsValue = MeshPrimitive.GetSinglePlaneNormals(); meshPrimitive.Normals = planeNormalsValue; properties.Add(new Property(PropertyName.VertexNormal, planeNormalsValue.ToReadmeString())); } void SetVertexTangent(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { var planeTangentValue = new List <Vector4> { new Vector4(1.0f, 0.0f, 0.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f) }; meshPrimitive.Tangents = planeTangentValue; properties.Add(new Property(PropertyName.VertexTangent, planeTangentValue.ToReadmeString())); } void SetNormalTexture(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.Material.NormalTexture = new Runtime.Texture { Source = normalImage }; properties.Add(new Property(PropertyName.NormalTexture, normalImage.ToReadmeString())); } Models = new List <Model> { CreateModel((properties, meshPrimitive) => { SetVertexUVFloat(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive) => { SetVertexUVByte(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive) => { SetVertexUVShort(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive) => { SetVertexUVFloat(properties, meshPrimitive); SetVertexNormal(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive) => { SetVertexUVFloat(properties, meshPrimitive); SetNormalTexture(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive) => { SetVertexUVFloat(properties, meshPrimitive); SetVertexNormal(properties, meshPrimitive); SetNormalTexture(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive) => { SetVertexUVFloat(properties, meshPrimitive); SetVertexNormal(properties, meshPrimitive); SetVertexTangent(properties, meshPrimitive); SetNormalTexture(properties, meshPrimitive); }), }; GenerateUsedPropertiesList(); }
public Texture_Sampler(List <string> imageList) { Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane"); // Track the common properties for use in the readme. CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString())); Model CreateModel(Action <List <Property>, Runtime.Sampler> setProperties) { var properties = new List <Property>(); Runtime.MeshPrimitive meshPrimitive = MeshPrimitive.CreateSinglePlane(); meshPrimitive.Material = new Runtime.Material { MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness { BaseColorTexture = new Runtime.Texture { Source = baseColorTextureImage, Sampler = new Runtime.Sampler(), }, }, }; // Apply the common properties to the gltf. meshPrimitive.TextureCoordSets = new List <List <Vector2> > { new List <Vector2>() { new Vector2(1.3f, 1.3f), new Vector2(-0.3f, 1.3f), new Vector2(-0.3f, -0.3f), new Vector2(1.3f, -0.3f), } }; // Apply the properties that are specific to this gltf. setProperties(properties, meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture.Sampler); // Create the gltf object. return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new List <Runtime.Node> { new Runtime.Node { Mesh = new Runtime.Mesh { MeshPrimitives = new List <Runtime.MeshPrimitive> { meshPrimitive } }, }, }, }), }); } void SetWrapT(List <Property> properties, Runtime.Sampler sampler, WrapTEnum enumValue) { sampler.WrapT = enumValue; properties.Add(new Property(PropertyName.WrapT, enumValue.ToReadmeString())); } void SetWrapS(List <Property> properties, Runtime.Sampler sampler, WrapSEnum enumValue) { sampler.WrapS = enumValue; properties.Add(new Property(PropertyName.WrapS, sampler.WrapS.ToReadmeString())); } void SetMagFilter(List <Property> properties, Runtime.Sampler sampler, MagFilterEnum enumValue) { sampler.MagFilter = enumValue; properties.Add(new Property(PropertyName.MagFilter, enumValue.ToReadmeString())); } void SetMinFilter(List <Property> properties, Runtime.Sampler sampler, MinFilterEnum enumValue) { sampler.MinFilter = enumValue; properties.Add(new Property(PropertyName.MinFilter, enumValue.ToReadmeString())); } Models = new List <Model> { CreateModel((properties, sampler) => { // There are no properties set on this model. }), CreateModel((properties, sampler) => { SetWrapT(properties, sampler, WrapTEnum.CLAMP_TO_EDGE); }), CreateModel((properties, sampler) => { SetWrapT(properties, sampler, WrapTEnum.MIRRORED_REPEAT); }), CreateModel((properties, sampler) => { SetWrapS(properties, sampler, WrapSEnum.CLAMP_TO_EDGE); }), CreateModel((properties, sampler) => { SetWrapS(properties, sampler, WrapSEnum.MIRRORED_REPEAT); }), CreateModel((properties, sampler) => { SetMagFilter(properties, sampler, MagFilterEnum.NEAREST); }), CreateModel((properties, sampler) => { SetMagFilter(properties, sampler, MagFilterEnum.LINEAR); }), CreateModel((properties, sampler) => { SetMinFilter(properties, sampler, MinFilterEnum.NEAREST); }), CreateModel((properties, sampler) => { SetMinFilter(properties, sampler, MinFilterEnum.LINEAR); }), CreateModel((properties, sampler) => { SetMinFilter(properties, sampler, MinFilterEnum.NEAREST_MIPMAP_NEAREST); }), CreateModel((properties, sampler) => { SetMinFilter(properties, sampler, MinFilterEnum.LINEAR_MIPMAP_NEAREST); }), CreateModel((properties, sampler) => { SetMinFilter(properties, sampler, MinFilterEnum.NEAREST_MIPMAP_LINEAR); }), CreateModel((properties, sampler) => { SetMinFilter(properties, sampler, MinFilterEnum.LINEAR_MIPMAP_LINEAR); }), CreateModel((properties, sampler) => { SetWrapT(properties, sampler, WrapTEnum.CLAMP_TO_EDGE); SetWrapS(properties, sampler, WrapSEnum.CLAMP_TO_EDGE); SetMagFilter(properties, sampler, MagFilterEnum.NEAREST); SetMinFilter(properties, sampler, MinFilterEnum.NEAREST); }), }; GenerateUsedPropertiesList(); }
public Material(List <string> imageList) { Runtime.Image emissiveImage = UseTexture(imageList, "Emissive_Plane"); Runtime.Image normalImage = UseTexture(imageList, "Normal_Plane"); Runtime.Image occlusionImage = UseTexture(imageList, "Occlusion_Plane"); // Track the common properties for use in the readme. var metallicFactorValue = 0.0f; var baseColorFactorValue = new Vector4(0.2f, 0.2f, 0.2f, 1.0f); CommonProperties.Add(new Property(PropertyName.MetallicFactor, metallicFactorValue.ToReadmeString())); CommonProperties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue.ToReadmeString())); Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive, Runtime.Material> setProperties) { var properties = new List <Property>(); Runtime.MeshPrimitive meshPrimitive = MeshPrimitive.CreateSinglePlane(includeTextureCoords: false); // Apply the common properties to the gltf. meshPrimitive.Material = new Runtime.Material { MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness { MetallicFactor = metallicFactorValue, BaseColorFactor = baseColorFactorValue, } }; // Apply the properties that are specific to this gltf. setProperties(properties, meshPrimitive, meshPrimitive.Material); // Create the gltf object. return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new List <Runtime.Node> { new Runtime.Node { Mesh = new Runtime.Mesh { MeshPrimitives = new List <Runtime.MeshPrimitive> { meshPrimitive } }, }, }, }), }); } void SetNormalTexture(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.Normals = MeshPrimitive.GetSinglePlaneNormals(); meshPrimitive.Material.NormalTexture = new Runtime.Texture { Source = normalImage }; properties.Add(new Property(PropertyName.NormalTexture, normalImage.ToReadmeString())); } void SetNormalScale(List <Property> properties, Runtime.Material material) { material.NormalScale = 10.0f; properties.Add(new Property(PropertyName.NormalTextureScale, material.NormalScale.ToReadmeString())); } void SetOcclusionTexture(List <Property> properties, Runtime.Material material) { material.OcclusionTexture = new Runtime.Texture { Source = occlusionImage }; properties.Add(new Property(PropertyName.OcclusionTexture, occlusionImage.ToReadmeString())); } void SetOcclusionStrength(List <Property> properties, Runtime.Material material) { material.OcclusionStrength = 0.5f; properties.Add(new Property(PropertyName.OcclusionTextureStrength, material.OcclusionStrength.ToReadmeString())); } void SetEmissiveTexture(List <Property> properties, Runtime.Material material) { material.EmissiveTexture = new Runtime.Texture { Source = emissiveImage }; properties.Add(new Property(PropertyName.EmissiveTexture, emissiveImage.ToReadmeString())); } void SetEmissiveFactor(List <Property> properties, Runtime.Material material) { var emissiveFactorValue = new Vector3(1.0f, 1.0f, 1.0f); material.EmissiveFactor = emissiveFactorValue; properties.Add(new Property(PropertyName.EmissiveFactor, emissiveFactorValue.ToReadmeString())); } Models = new List <Model> { CreateModel((properties, meshPrimitive, material) => { // There are no properties set on this model. }), CreateModel((properties, meshPrimitive, material) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetNormalTexture(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive, material) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetOcclusionTexture(properties, material); }), CreateModel((properties, meshPrimitive, material) => { SetEmissiveFactor(properties, material); }), CreateModel((properties, meshPrimitive, material) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetNormalTexture(properties, meshPrimitive); SetNormalScale(properties, material); }), CreateModel((properties, meshPrimitive, material) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetOcclusionTexture(properties, material); SetOcclusionStrength(properties, material); }), CreateModel((properties, meshPrimitive, material) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetEmissiveTexture(properties, material); SetEmissiveFactor(properties, material); }), CreateModel((properties, meshPrimitive, material) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetNormalTexture(properties, meshPrimitive); SetNormalScale(properties, material); SetOcclusionTexture(properties, material); SetOcclusionStrength(properties, material); SetEmissiveTexture(properties, material); SetEmissiveFactor(properties, material); }), }; GenerateUsedPropertiesList(); }
public Material_MetallicRoughness(List <string> imageList) { Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane"); Runtime.Image metallicRoughnessTextureImage = UseTexture(imageList, "MetallicRoughness_Plane"); // There are no common properties in this model group. Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive, Runtime.PbrMetallicRoughness> setProperties) { var properties = new List <Property>(); var meshPrimitive = MeshPrimitive.CreateSinglePlane(includeTextureCoords: false); // Apply the properties that are specific to this gltf. meshPrimitive.Material = new Runtime.Material { MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness() }; setProperties(properties, meshPrimitive, meshPrimitive.Material.MetallicRoughnessMaterial); // Create the gltf object. return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new[] { new Runtime.Node { Mesh = new Runtime.Mesh { MeshPrimitives = new List <Runtime.MeshPrimitive> { meshPrimitive } }, }, }, }), }); } void SetVertexColor(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { var vertexColors = new[] { 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), new Vector4(1.0f, 0.0f, 0.0f, 0.8f), }; meshPrimitive.ColorComponentType = ColorComponentTypeEnum.FLOAT; meshPrimitive.ColorType = ColorTypeEnum.VEC3; meshPrimitive.Colors = vertexColors; properties.Add(new Property(PropertyName.VertexColor, "Vector3 Float")); } void SetBaseColorTexture(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness) { metallicRoughness.BaseColorTexture = new Runtime.Texture { Source = baseColorTextureImage }; properties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString())); } void SetBaseColorFactor(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness) { var baseColorFactorValue = new Vector4(0.2f, 0.2f, 0.2f, 0.8f); metallicRoughness.BaseColorFactor = baseColorFactorValue; properties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue.ToReadmeString())); } void SetMetallicRoughnessTexture(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness) { metallicRoughness.MetallicRoughnessTexture = new Runtime.Texture { Source = metallicRoughnessTextureImage }; properties.Add(new Property(PropertyName.MetallicRoughnessTexture, metallicRoughnessTextureImage.ToReadmeString())); } void SetMetallicFactor(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness) { metallicRoughness.MetallicFactor = 0.0f; properties.Add(new Property(PropertyName.MetallicFactor, metallicRoughness.MetallicFactor.ToReadmeString())); } void SetRoughnessFactor(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness) { metallicRoughness.RoughnessFactor = 0.0f; properties.Add(new Property(PropertyName.RoughnessFactor, metallicRoughness.RoughnessFactor.ToReadmeString())); } Models = new List <Model> { CreateModel((properties, meshPrimitive, metallicRoughness) => { // There are no properties set on this model. }), CreateModel((properties, meshPrimitive, metallicRoughness) => { SetVertexColor(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetBaseColorTexture(properties, metallicRoughness); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { SetBaseColorFactor(properties, metallicRoughness); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetMetallicRoughnessTexture(properties, metallicRoughness); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { SetMetallicFactor(properties, metallicRoughness); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { SetRoughnessFactor(properties, metallicRoughness); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetVertexColor(properties, meshPrimitive); SetBaseColorTexture(properties, metallicRoughness); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetBaseColorTexture(properties, metallicRoughness); SetBaseColorFactor(properties, metallicRoughness); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetMetallicRoughnessTexture(properties, metallicRoughness); SetMetallicFactor(properties, metallicRoughness); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetMetallicRoughnessTexture(properties, metallicRoughness); SetRoughnessFactor(properties, metallicRoughness); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetVertexColor(properties, meshPrimitive); SetBaseColorTexture(properties, metallicRoughness); SetBaseColorFactor(properties, metallicRoughness); SetMetallicRoughnessTexture(properties, metallicRoughness); SetMetallicFactor(properties, metallicRoughness); SetRoughnessFactor(properties, metallicRoughness); }), }; GenerateUsedPropertiesList(); }
public Material_AlphaBlend(List <string> imageList) { Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane"); // Track the common properties for use in the readme. var alphaModeValue = AlphaModeEnum.BLEND; CommonProperties.Add(new Property(PropertyName.AlphaMode, alphaModeValue.ToReadmeString())); Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive, Runtime.PbrMetallicRoughness> setProperties) { var properties = new List <Property>(); Runtime.MeshPrimitive meshPrimitive = MeshPrimitive.CreateSinglePlane(includeTextureCoords: false); // Apply the common properties to the gltf. meshPrimitive.Material = new Runtime.Material { MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness { MetallicFactor = 0 }, AlphaMode = alphaModeValue, }; // Apply the properties that are specific to this gltf. setProperties(properties, meshPrimitive, meshPrimitive.Material.MetallicRoughnessMaterial); // Create the gltf object. return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new[] { new Runtime.Node { Mesh = new Runtime.Mesh { MeshPrimitives = new[] { meshPrimitive } }, }, }, }), }); } void SetNoMetallicRoughness(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.Material.MetallicRoughnessMaterial = null; } void SetBaseColorFactor(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness) { var baseColorFactorValue = new Vector4(1.0f, 1.0f, 1.0f, 0.7f); metallicRoughness.BaseColorFactor = baseColorFactorValue; properties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue.ToReadmeString())); } void SetBaseColorTexture(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness) { metallicRoughness.BaseColorTexture = new Runtime.Texture { Source = baseColorTextureImage }; properties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString())); } void SetVertexColor(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { var vertexColors = new[] { new Vector4(0.3f, 0.3f, 0.3f, 0.4f), new Vector4(0.3f, 0.3f, 0.3f, 0.2f), new Vector4(0.3f, 0.3f, 0.3f, 0.8f), new Vector4(0.3f, 0.3f, 0.3f, 0.6f), }; meshPrimitive.ColorComponentType = ColorComponentTypeEnum.FLOAT; meshPrimitive.ColorType = ColorTypeEnum.VEC4; meshPrimitive.Colors = vertexColors; properties.Add(new Property(PropertyName.VertexColor, "Vector4 Float")); } Models = new List <Model> { CreateModel((properties, meshPrimitive, metallicRoughness) => { SetVertexColor(properties, meshPrimitive); SetNoMetallicRoughness(properties, meshPrimitive); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetBaseColorTexture(properties, metallicRoughness); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { SetBaseColorFactor(properties, metallicRoughness); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetVertexColor(properties, meshPrimitive); SetBaseColorTexture(properties, metallicRoughness); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { SetVertexColor(properties, meshPrimitive); SetBaseColorFactor(properties, metallicRoughness); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetBaseColorTexture(properties, metallicRoughness); SetBaseColorFactor(properties, metallicRoughness); }), CreateModel((properties, meshPrimitive, metallicRoughness) => { meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets(); SetVertexColor(properties, meshPrimitive); SetBaseColorTexture(properties, metallicRoughness); SetBaseColorFactor(properties, metallicRoughness); }), }; GenerateUsedPropertiesList(); }