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)); CommonProperties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue)); 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) { var planeNormalsValue = new[] { new Vector3(0.0f, 0.0f, 1.0f), new Vector3(0.0f, 0.0f, 1.0f), new Vector3(0.0f, 0.0f, 1.0f), new Vector3(0.0f, 0.0f, 1.0f), }; meshPrimitive.Normals = planeNormalsValue; meshPrimitive.Material.NormalTexture = new Runtime.Texture { Source = normalImage }; properties.Add(new Property(PropertyName.NormalTexture, normalImage)); } void SetNormalScale(List <Property> properties, Runtime.Material material) { material.NormalScale = 10.0f; properties.Add(new Property(PropertyName.NormalTextureScale, material.NormalScale)); } void SetOcclusionTexture(List <Property> properties, Runtime.Material material) { material.OcclusionTexture = new Runtime.Texture { Source = occlusionImage }; properties.Add(new Property(PropertyName.OcclusionTexture, occlusionImage)); } void SetOcclusionStrength(List <Property> properties, Runtime.Material material) { material.OcclusionStrength = 0.5f; properties.Add(new Property(PropertyName.OcclusionTextureStrength, material.OcclusionStrength)); } void SetEmissiveTexture(List <Property> properties, Runtime.Material material) { material.EmissiveTexture = new Runtime.Texture { Source = emissiveImage }; properties.Add(new Property(PropertyName.EmissiveTexture, emissiveImage)); } 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)); } 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_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)); 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)); } void SetBaseColorTexture(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness) { metallicRoughness.BaseColorTexture = new Runtime.Texture { Source = baseColorTextureImage }; properties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage)); } 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(); }
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)); } 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)); } void SetMetallicRoughnessTexture(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness) { metallicRoughness.MetallicRoughnessTexture = new Runtime.Texture { Source = metallicRoughnessTextureImage }; properties.Add(new Property(PropertyName.MetallicRoughnessTexture, metallicRoughnessTextureImage)); } void SetMetallicFactor(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness) { metallicRoughness.MetallicFactor = 0.0f; properties.Add(new Property(PropertyName.MetallicFactor, metallicRoughness.MetallicFactor)); } void SetRoughnessFactor(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness) { metallicRoughness.RoughnessFactor = 0.0f; properties.Add(new Property(PropertyName.RoughnessFactor, metallicRoughness.RoughnessFactor)); } 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(); }