Пример #1
0
        public static bool TryGetTextureFromMaterialProperty(GltfData data, glTF_VRM_Material vrmMaterial, string textureKey, out (SubAssetKey, TextureDescriptor) texture)
        {
            // 任意の shader の import を許容する
            if (/*vrmMaterial.shader == MToon.Utils.ShaderName &&*/ vrmMaterial.textureProperties.TryGetValue(textureKey, out var textureIdx))
            {
                var(offset, scale) = (new Vector2(0, 0), new Vector2(1, 1));
                if (TryGetTextureOffsetAndScale(vrmMaterial, textureKey, out var os))
                {
                    offset = os.offset;
                    scale  = os.scale;
                }

                switch (textureKey)
                {
                case MToon.Utils.PropBumpMap:
                    texture = GltfTextureImporter.CreateNormal(data, textureIdx, offset, scale);
                    break;

                default:
                    texture = GltfTextureImporter.CreateSrgb(data, textureIdx, offset, scale);
                    break;
                }
                return(true);
            }

            texture = default;
            return(false);
        }
Пример #2
0
        public static (SubAssetKey, TextureImportParam) Create(GltfParser parser, int index, Vector2 offset, Vector2 scale, string prop, float metallicFactor, float roughnessFactor)
        {
            switch (prop)
            {
            case TextureImportParam.NORMAL_PROP:
                return(GltfTextureImporter.CreateNormal(parser, index, offset, scale));

            default:
                return(GltfTextureImporter.CreateSRGB(parser, index, offset, scale));

            case TextureImportParam.OCCLUSION_PROP:
            case TextureImportParam.METALLIC_GLOSS_PROP:
                throw new NotImplementedException();
            }
        }