LoadMaterial() public méthode

public LoadMaterial ( ) : Material[]
Résultat Material[]
        void loadMaterials(glTFLoader ctx)
        {
            glTFLoader.Material[] mats = ctx.LoadMaterial();
            materials = new Material[mats.Length];

            for (int i = 0; i < mats.Length; i++)
            {
                materials[i] = new Material {
                    workflow        = (float)mats[i].workflow,
                    baseColorFactor = mats[i].baseColorFactor,
                    emissiveFactor  = mats[i].emissiveFactor,
                    metallicFactor  = mats[i].metallicFactor,
                    roughnessFactor = mats[i].roughnessFactor,

                    baseColorTextureSet = mats[i].baseColorTexture,
                    phyDescTex          = mats[i].metallicRoughnessTexture,
                    normalTex           = mats[i].normalTexture,
                    aoTex       = mats[i].occlusionTexture,
                    emissiveTex = mats[i].emissiveTexture,

                    TexCoord0 = mats[i].availableAttachments,
                    TexCoord1 = mats[i].availableAttachments1,

                    alphaMask       = 0f,
                    alphaMaskCutoff = 0.0f,
                    diffuseFactor   = new Vector4(0),
                    specularFactor  = new Vector4(0)
                };
            }
        }
        void loadMaterials(glTFLoader ctx, DescriptorSetLayout layout, params AttachmentType[] attachments)
        {
            glTFLoader.Material[] mats = ctx.LoadMaterial();
            materials      = new Material[mats.Length];
            descriptorSets = new DescriptorSet[mats.Length];

            if (attachments.Length == 0)
            {
                throw new InvalidOperationException("At least one attachment is required for Model.WriteMaterialDescriptor");
            }

            descriptorPool = new DescriptorPool(dev, (uint)materials.Length,
                                                new VkDescriptorPoolSize(VkDescriptorType.CombinedImageSampler, (uint)(attachments.Length * materials.Length))
                                                );
            descriptorPool.SetName("descPool gltfTextures");

            for (int i = 0; i < mats.Length; i++)
            {
                materials[i] = new Material {
                    workflow        = (float)mats[i].workflow,
                    baseColorFactor = mats[i].baseColorFactor,
                    emissiveFactor  = mats[i].emissiveFactor,
                    metallicFactor  = mats[i].metallicFactor,
                    roughnessFactor = mats[i].roughnessFactor,
                    TexCoord0       = mats[i].availableAttachments,
                    TexCoord1       = mats[i].availableAttachments1,
                    alphaMask       = 0f,
                    alphaMaskCutoff = 0.0f,
                    diffuseFactor   = new Vector4(0),
                    specularFactor  = new Vector4(0)
                };

                descriptorSets[i] = descriptorPool.Allocate(layout);
                descriptorSets[i].Handle.SetDebugMarkerName(dev, "descSet " + mats[i].Name);

                VkDescriptorSetLayoutBinding dslb =
                    new VkDescriptorSetLayoutBinding(0, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler);

                using (DescriptorSetWrites2 uboUpdate = new DescriptorSetWrites2(dev)) {
                    for (uint a = 0; a < attachments.Length; a++)
                    {
                        dslb.binding = a;
                        switch (attachments[a])
                        {
                        case AttachmentType.None:
                            break;

                        case AttachmentType.Color:
                            if (mats[i].availableAttachments.HasFlag(AttachmentType.Color))
                            {
                                uboUpdate.AddWriteInfo(descriptorSets[i], dslb, textures[(int)mats[i].baseColorTexture].Descriptor);
                            }
                            break;

                        case AttachmentType.Normal:
                            if (mats[i].availableAttachments.HasFlag(AttachmentType.Normal))
                            {
                                uboUpdate.AddWriteInfo(descriptorSets[i], dslb, textures[(int)mats[i].normalTexture].Descriptor);
                            }
                            break;

                        case AttachmentType.AmbientOcclusion:
                            if (mats[i].availableAttachments.HasFlag(AttachmentType.AmbientOcclusion))
                            {
                                uboUpdate.AddWriteInfo(descriptorSets[i], dslb, textures[(int)mats[i].occlusionTexture].Descriptor);
                            }
                            break;

                        case AttachmentType.PhysicalProps:
                            if (mats[i].availableAttachments.HasFlag(AttachmentType.PhysicalProps))
                            {
                                uboUpdate.AddWriteInfo(descriptorSets[i], dslb, textures[(int)mats[i].metallicRoughnessTexture].Descriptor);
                            }
                            break;

                        case AttachmentType.Metal:
                            break;

                        case AttachmentType.Roughness:
                            break;

                        case AttachmentType.Emissive:
                            if (mats[i].availableAttachments.HasFlag(AttachmentType.Emissive))
                            {
                                uboUpdate.AddWriteInfo(descriptorSets[i], dslb, textures[(int)mats[i].emissiveTexture].Descriptor);
                            }
                            break;
                        }
                    }
                    uboUpdate.Update();
                }
            }
        }