private BabylonMaterial DumpShaderMaterial(Material material)
        {
            if (materialsDictionary.ContainsKey(material.name))
            {
                return materialsDictionary[material.name];
            }

            var babylonShaderMaterial = new BabylonShaderMaterial
            {
                name = material.name,
                id = Guid.NewGuid().ToString(),
            };

            ExporterWindow.ReportProgress(1, "Exporting glsl material: " + material.name);

            List<string> tnames = material.GetTextureNames();
            foreach (string tname in tnames)
            {
                BabylonTexture tdata = DumpTextureFromMaterial(material, tname);
                if (tdata != null)
                {
                    babylonShaderMaterial.textures.Add(tname, tdata);
                }
            }

            List<string> fnames = material.GetFloatNames();
            foreach (string fname in fnames)
            {
                float fdata = material.GetFloat(fname);
                babylonShaderMaterial.floats.Add(fname, fdata);
            }

            List<string> rnames = material.GetRangeNames();
            foreach (string rname in rnames)
            {
                float rdata = material.GetFloat(rname);
                babylonShaderMaterial.floats.Add(rname, rdata);
            }

            List<string> cnames = material.GetColorNames();
            foreach (string cname in cnames)
            {
                Color cdata = material.GetColor(cname);
                babylonShaderMaterial.vectors4.Add(cname, cdata.ToFloat());
            }

            List<string> vnames = material.GetVectorNames();
            foreach (string vname in vnames)
            {
                Vector4 vdata = material.GetVector(vname);
                babylonShaderMaterial.vectors4.Add(vname, vdata.ToFloat());
            }

            Shader shader = material.shader;
            string filename = AssetDatabase.GetAssetPath(shader);
            string program = Tools.LoadTextAsset(filename);
            string basename = shader.name.Replace("BabylonJS/", "").Replace("/", "_").Replace(" ", "");
            string outpath = (!String.IsNullOrEmpty(exportationOptions.DefaultShaderFolder)) ? exportationOptions.DefaultShaderFolder : OutputPath;

            var shaderpath = new Dictionary<string, string>();
            List<string> attributeList = new List<string>();
            List<string> uniformList = new List<string>();
            List<string> samplerList = new List<string>();
            List<string> defineList = new List<string>();
            string babylonOptions = GetShaderProgramSection(basename, program, BabylonProgramSection.Babylon);
            string[] babylonLines = babylonOptions.Split('\n');
            foreach (string babylonLine in babylonLines)
            {
                if (babylonLine.IndexOf("attributes", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    string[] attributes = babylonLine.Split(':');
                    if (attributes != null && attributes.Length > 1)
                    {
                        string abuffer = attributes[1].Replace("[", "").Replace("]", "");
                        if (!String.IsNullOrEmpty(abuffer))
                        {
                            abuffer = abuffer.Trim();
                            string[] adata = abuffer.Split(',');
                            if (adata != null && adata.Length > 0)
                            {
                                foreach (string aoption in adata)
                                {
                                    string aoption_buffer = aoption.Trim().Replace("\"", "").Trim();
                                    if (!String.IsNullOrEmpty(aoption_buffer))
                                    {
                                        attributeList.Add(aoption_buffer);
                                    }
                                }
                            }
                        }
                    }
                }
                else if (babylonLine.IndexOf("uniforms", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    string[] uniforms = babylonLine.Split(':');
                    if (uniforms != null && uniforms.Length > 1)
                    {
                        string ubuffer = uniforms[1].Replace("[", "").Replace("]", "");
                        if (!String.IsNullOrEmpty(ubuffer))
                        {
                            ubuffer = ubuffer.Trim();
                            string[] udata = ubuffer.Split(',');
                            if (udata != null && udata.Length > 0)
                            {
                                foreach (string uoption in udata)
                                {
                                    string uoption_buffer = uoption.Trim().Replace("\"", "").Trim();
                                    if (!String.IsNullOrEmpty(uoption_buffer))
                                    {
                                        uniformList.Add(uoption_buffer);
                                    }
                                }
                            }
                        }
                    }
                }
                else if (babylonLine.IndexOf("samplers", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    string[] samplers = babylonLine.Split(':');
                    if (samplers != null && samplers.Length > 1)
                    {
                        string sbuffer = samplers[1].Replace("[", "").Replace("]", "");
                        if (!String.IsNullOrEmpty(sbuffer))
                        {
                            sbuffer = sbuffer.Trim();
                            string[] sdata = sbuffer.Split(',');
                            if (sdata != null && sdata.Length > 0)
                            {
                                foreach (string soption in sdata)
                                {
                                    string soption_buffer = soption.Trim().Replace("\"", "").Trim();
                                    if (!String.IsNullOrEmpty(soption_buffer))
                                    {
                                        samplerList.Add(soption_buffer);
                                    }
                                }
                            }
                        }
                    }
                }
                else if (babylonLine.IndexOf("defines", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    string[] defines = babylonLine.Split(':');
                    if (defines != null && defines.Length > 1)
                    {
                        string dbuffer = defines[1].Replace("[", "").Replace("]", "");
                        if (!String.IsNullOrEmpty(dbuffer))
                        {
                            dbuffer = dbuffer.Trim();
                            string[] ddata = dbuffer.Split(',');
                            if (ddata != null && ddata.Length > 0)
                            {
                                foreach (string doption in ddata)
                                {
                                    string doption_buffer = doption.Trim().Replace("\"", "").Trim();
                                    if (!String.IsNullOrEmpty(doption_buffer))
                                    {
                                        defineList.Add(doption_buffer);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            babylonShaderMaterial.options = new BabylonShaderOptions();
            babylonShaderMaterial.options.attributes = attributeList.ToArray();
            babylonShaderMaterial.options.uniforms = uniformList.ToArray();
            babylonShaderMaterial.options.samplers = samplerList.ToArray();
            babylonShaderMaterial.options.defines = defineList.ToArray();

            string vertexProgram = GetShaderProgramSection(basename, program, BabylonProgramSection.Vertex);
            var vertextFile = Path.Combine(outpath, basename + ".vertex.fx");
            if (exportationOptions.EmbeddedShaders)
            {
                shaderpath.Add("vertexElement", ("base64:" + Tools.FormatBase64(vertexProgram)));
            }
            else
            {
                File.WriteAllText(vertextFile, vertexProgram);
            }

            string fragmentProgram = GetShaderProgramSection(basename, program, BabylonProgramSection.Fragment);
            var fragmentFile = Path.Combine(outpath, basename + ".fragment.fx");
            if (exportationOptions.EmbeddedShaders)
            {
                shaderpath.Add("fragmentElement", ("base64:" + Tools.FormatBase64(fragmentProgram)));
            }
            else
            {
                File.WriteAllText(fragmentFile, fragmentProgram);
            }

            babylonShaderMaterial.shaderPath = (exportationOptions.EmbeddedShaders) ? (object)shaderpath : (object)basename;
            materialsDictionary.Add(babylonShaderMaterial.name, babylonShaderMaterial);
            return babylonShaderMaterial;
        }