예제 #1
0
        static MaterialBindType _GetBindType(UnlitMaterial unlit, string property)
        {
            switch (property)
            {
            // case UV_PROPERTY:
            //     return MaterialBindType.UvOffset;

            case COLOR_PROPERTY:
                return(MaterialBindType.Color);
            }

            throw new NotImplementedException();
        }
예제 #2
0
        static string _GetProperty(UnlitMaterial unlit, MaterialBindType bindType)
        {
            switch (bindType)
            {
            // case MaterialBindType.UvOffset:
            // case MaterialBindType.UvScale:
            //     return UV_PROPERTY;

            case MaterialBindType.Color:
                return(COLOR_PROPERTY);
            }

            throw new NotImplementedException();
        }
예제 #3
0
        public VrmLib.Material Export10(UnityEngine.Material src, GetOrCreateTextureDelegate map)
        {
            switch (src.shader.name)
            {
            case "VRM/MToon":
            {
                var def = MToon.Utils.GetMToonParametersFromMaterial(src);
                return(new VrmLib.MToonMaterial(src.name)
                    {
                        Definition = def.ToVrmLib(src, map),
                    });
            }

            case "Unlit/Color":
                return(new VrmLib.UnlitMaterial(src.name)
                {
                    BaseColorFactor = src.color.FromUnitySrgbToLinear(),
                });

            case "Unlit/Texture":
                return(new VrmLib.UnlitMaterial(src.name)
                {
                    BaseColorTexture = map(src, src.mainTexture as Texture2D, VrmLib.Texture.ColorSpaceTypes.Srgb, VrmLib.Texture.TextureTypes.Default),
                });

            case "Unlit/Transparent":
                return(new VrmLib.UnlitMaterial(src.name)
                {
                    BaseColorTexture = map(src, src.mainTexture as Texture2D, VrmLib.Texture.ColorSpaceTypes.Srgb, VrmLib.Texture.TextureTypes.Default),
                    AlphaMode = VrmLib.AlphaModeType.BLEND,
                });

            case "Unlit/Transparent Cutout":
                return(new VrmLib.UnlitMaterial(src.name)
                {
                    BaseColorTexture = map(src, src.mainTexture as Texture2D, VrmLib.Texture.ColorSpaceTypes.Srgb, VrmLib.Texture.TextureTypes.Default),
                    AlphaMode = VrmLib.AlphaModeType.MASK,
                    AlphaCutoff = src.GetFloat("_Cutoff"),
                });

            case "UniGLTF/UniUnlit":
            case "VRM/UniUnlit":
            {
                var material = new VrmLib.UnlitMaterial(src.name)
                {
                    BaseColorFactor  = src.color.FromUnitySrgbToLinear(),
                    BaseColorTexture = map(src, src.mainTexture as Texture2D, VrmLib.Texture.ColorSpaceTypes.Srgb, VrmLib.Texture.TextureTypes.Default),
                    AlphaMode        = GetAlphaMode(src),
                    DoubleSided      = UniGLTF.UniUnlit.Utils.GetCullMode(src) == UniGLTF.UniUnlit.UniUnlitCullMode.Off,
                };
                if (material.AlphaMode == VrmLib.AlphaModeType.MASK)
                {
                    material.AlphaCutoff = src.GetFloat("_Cutoff");
                }
                // TODO: VertexColorMode
                return(material);
            }

            default:
                return(ExportStandard(src, map));
            }
        }