示例#1
0
        /// <summary>
        /// Concatenates multiple tables into one single texture 2D array
        /// </summary>
        /// <param name="_tablesFileNames"></param>
        /// <param name="_targetFileName"></param>
        /// <param name="_foramt"></param>
        static void ExportTexture(FileInfo[] _tablesFileNames, FileInfo _targetFileName, ImageUtility.PIXEL_FORMAT _format)
        {
            // Load tables
            LTC[][,]        tables = new LTC[_tablesFileNames.Length][, ];
            for (int i = 0; i < _tablesFileNames.Length; i++)
            {
                int validResultsCount;
                LTC[,]  table = FitterForm.LoadTable(_tablesFileNames[i], out validResultsCount);
                if (validResultsCount != table.Length)
                {
                    throw new Exception("Not all table results are valid!");
                }

                tables[i] = table;
                if (i != 0 && (table.GetLength(0) != tables[0].GetLength(0) || table.GetLength(1) != tables[0].GetLength(1)))
                {
                    throw new Exception("Table dimensions mismatch!");
                }
            }

            // Create the Texture2DArray
            uint W = (uint)tables[0].GetLength(0);
            uint H = (uint)tables[0].GetLength(1);

            ImageUtility.ImagesMatrix M = new ImageUtility.ImagesMatrix();
            M.InitTexture2DArray(W, H, (uint)tables.Length, 1);
            M.AllocateImageFiles(_format, new ImageUtility.ColorProfile(ImageUtility.ColorProfile.STANDARD_PROFILE.LINEAR));

            for (int i = 0; i < tables.Length; i++)
            {
                LTC[,]  table = tables[i];
//              ImageUtility.ImageFile	I = new ImageUtility.ImageFile( W, H, _format, profile );
//              M[(uint) i][0][0] = I;

                double largest           = 0;
                ImageUtility.ImageFile I = M[(uint)i][0][0];
                I.WritePixels((uint _X, uint _Y, ref float4 _color) => {
                    LTC ltc = table[_X, _Y];

                    const double tol = 1e-6;
//                  if ( Mathf.Abs( ltc.invM[2,2] - 1 ) > tol )
//                      throw new Exception( "Not one!" );
                    if (Mathf.Abs(ltc.invM[0, 1]) > tol || Mathf.Abs(ltc.invM[1, 0]) > tol || Mathf.Abs(ltc.invM[1, 2]) > tol || Mathf.Abs(ltc.invM[2, 1]) > tol)
                    {
                        throw new Exception("Not zero!");
                    }

                    largest       = Math.Max(largest, Math.Abs(ltc.invM[2, 2] - 1));
                    double factor = 1.0 / ltc.invM[2, 2];

                    _color.x = (float)(factor * ltc.invM[0, 0]);
                    _color.y = (float)(factor * ltc.invM[0, 2]);
                    _color.z = (float)(factor * ltc.invM[1, 1]);
                    _color.w = (float)(factor * ltc.invM[2, 0]);
                });
            }
            M.DDSSaveFile(_targetFileName, ImageUtility.COMPONENT_FORMAT.AUTO);
        }
示例#2
0
        public static void      DummyLoadWebPage(Uri _URL, WebPageSourceAvailable _onSourceAvailable, WebPagePieceRendered _onPieceRendered, WebPageSuccess _onSuccess, WebPageError _onError)
        {
//				string	content = "DUMMY CONTENT!";

            string content = "<blockquote class=\"twitter-tweet\"><p lang=\"en\" dir=\"ltr\">Appropriate for December. <a href=\"https://t.co/dzNBXmcreS\">pic.twitter.com/dzNBXmcreS</a></p>&mdash; In Otter News (@Otter_News)" +
                             "<a href=\"https://twitter.com/Otter_News/status/1204733982149160960?ref_src=twsrc%5Etfw\">December 11, 2019</a></blockquote> <script async src=\"https://platform.twitter.com/widgets.js\" charset=\"utf-8\"></script>";

/*string	content = @"<blockquote class=""Tweet h-entry js-tweetIdInfo subject expanded"" cite=""https://twitter.com/Poulin2012/status/1204065818432167937"" data-tweet-id=""1204065818432167937"" data-scribe=""section:subject"">
 *  <div class=""Tweet-header"">
 *    <a class=""TweetAuthor-avatar  Identity-avatar u-linkBlend"" data-scribe=""element:user_link"" href=""https://twitter.com/Poulin2012"" aria-label=""Alexis Poulin (nom d'utilisateur : Poulin2012)""><img class=""Avatar"" data-scribe=""element:avatar"" data-src-2x=""https://pbs.twimg.com/profile_images/1110858983357771778/aTqqWLFY_bigger.jpg"" alt="""" data-src-1x=""https://pbs.twimg.com/profile_images/1110858983357771778/aTqqWLFY_normal.jpg"" src=""https://pbs.twimg.com/profile_images/1110858983357771778/aTqqWLFY_normal.jpg""></a>
 *
 *
 *
 *
 * <div class=""TweetAuthor js-inViewportScribingTarget"" data-scribe=""component:author"">
 * <a class=""TweetAuthor-link Identity u-linkBlend"" data-scribe=""element:user_link"" href=""https://twitter.com/Poulin2012"" aria-label=""Alexis Poulin (nom d'utilisateur : Poulin2012)"">
 *  <div class=""TweetAuthor-nameScreenNameContainer"">
 *    <span class=""TweetAuthor-decoratedName"">
 *      <span class=""TweetAuthor-name Identity-name customisable-highlight"" title=""Alexis Poulin"" data-scribe=""element:name"">Alexis Poulin</span>
 *      <span class=""TweetAuthor-verifiedBadge"" data-scribe=""element:verified_badge""><div class=""Icon Icon--verified "" aria-label=""Compte certifié"" title=""Compte certifié"" role=""img""></div>
 * <b class=""u-hiddenVisually"">✔</b></span>
 *    </span>
 *    <span class=""TweetAuthor-screenName Identity-screenName"" title=""@Poulin2012"" data-scribe=""element:screen_name"" dir=""ltr"">@Poulin2012</span>
 *  </div>
 * </a>
 * </div>
 *
 *      <div class=""Tweet-brand"">
 *        <a href=""https://twitter.com/Poulin2012/status/1204065818432167937"" data-scribe=""element:logo""><span class=""FollowButton-bird""><div class=""Icon Icon--twitter "" aria-label=""Voir sur Twitter"" title=""Voir sur Twitter"" role=""presentation""></div>
 * </span></a>
 *      </div>
 *  </div>
 *  <div class=""Tweet-body e-entry-content"" data-scribe=""component:tweet"">
 *
 *    <div class=""Tweet-target js-inViewportScribingTarget""></div>
 *    <p class=""Tweet-text e-entry-title"" lang=""fr"" dir=""ltr"">A propos de «&nbsp;la haine&nbsp;» qui visiblement en novlangue veut dire «&nbsp;capter des images de violences policières&nbsp;»... <a href=""https://t.co/6W9zbPCuCG"" rel=""nofollow noopener"" dir=""ltr"" data-expanded-url=""https://twitter.com/davduf/status/1204059641413586946"" class=""link customisable"" target=""_blank"" title=""https://twitter.com/davduf/status/1204059641413586946"" data-tweet-id=""1204059641413586946"" data-tweet-item-type=""23"" data-scribe=""element:url""><span class=""u-hiddenVisually"">https://</span>twitter.com/davduf/status/<span class=""u-hiddenVisually"">1204059641413586946&nbsp;</span>…</a></p>
 *
 *
 *
 *      <div class=""Tweet-card"">
 * <div class=""QuoteTweet"" tabindex=""0"" data-scribe=""section:quote"">
 * <a class=""QuoteTweet-link"" data-tweet-id=""1204059641413586946"" data-tweet-item-type=""23"" href=""https://twitter.com/davduf/status/1204059641413586946"" target=""_blank"" rel=""noopener"">
 *  <div class=""QuoteTweet-nonMediaContainer"">
 *
 *
 *
 * <div class=""TweetAuthor js-inViewportScribingTarget TweetAuthor--oneLine"" data-scribe=""component:author"">
 *
 *  <div class=""TweetAuthor-nameScreenNameContainer"">
 *    <span class=""TweetAuthor-decoratedName"">
 *      <span class=""TweetAuthor-name Identity-name customisable-highlight"" title=""David Dufresne"" data-scribe=""element:name"">David Dufresne</span>
 *      <span class=""TweetAuthor-verifiedBadge"" data-scribe=""element:verified_badge""><div class=""Icon Icon--verified "" aria-label=""Compte certifié"" title=""Compte certifié"" role=""img""></div>
 * <b class=""u-hiddenVisually"">✔</b></span>
 *    </span>
 *    <span class=""TweetAuthor-screenName Identity-screenName"" title=""@davduf"" data-scribe=""element:screen_name"" dir=""ltr"">@davduf</span>
 *  </div>
 *
 * </div>
 *
 *    <div></div>
 *    <p class=""QuoteTweet-text e-entry-title"" lang=""fr"" dir=""ltr"">Le sénateur Grand, profitant de la proposition de loi de « Lutte contre la haine »  sur internet (PPL), propose une amande de 15 000 € pour captation d'image de policiers. <span class=""PrettyLink-prefix"">#</span><span class=""PrettyLink-value"">ViolencesPolicières</span> <span class=""PrettyLink-prefix"">#</span><span class=""PrettyLink-value"">LibertédInformer</span><br><br>Source: <span class=""u-hiddenVisually"">http://www.</span>senat.fr/amendements/co<span class=""u-hiddenVisually"">mmissions/2018-2019/645/Amdt_COM-13.html&nbsp;</span>…</p>
 *  </div>
 *  <div class=""QuotedTweet-media"">
 *
 * <article class=""MediaCard
 *
 *         customisable-border"" data-scribe=""component:card"" dir=""ltr"">
 * <div class=""MediaCard-media"" data-scribe=""element:photo"">
 *
 *  <div class=""MediaCard-widthConstraint js-cspForcedStyle"" style=""max-width: 1200px"" data-style=""max-width: 1200px"">
 *    <div class=""MediaCard-mediaContainer js-cspForcedStyle MediaCard--roundedBottom"" style=""padding-bottom: 68.9167%"" data-style=""padding-bottom: 68.9167%"">
 *      <div class=""MediaCard-mediaAsset NaturalImage"">
 *        <img class=""NaturalImage-image"" data-image=""https://pbs.twimg.com/media/ELWt20_W4AAea8q"" data-image-format=""png"" width=""1200"" height=""827"" title=""Voir l'image sur Twitter"" alt=""Voir l'image sur Twitter"" src=""https://pbs.twimg.com/media/ELWt20_W4AAea8q?format=png&amp;name=small"">
 *      </div>
 *    </div>
 *  </div>
 * </div>
 * </article>
 *
 *
 *
 * </div>
 * </a>
 * </div>
 * </div>
 *
 *
 *    <div class=""TweetInfo"">
 *      <div class=""TweetInfo-like"">
 * <a class=""TweetInfo-heart"" title=""J'aime"" href=""https://twitter.com/intent/like?tweet_id=1204065818432167937"" data-scribe=""component:actions"">
 * <div data-scribe=""element:heart""><div class=""Icon Icon--heart "" aria-label=""J'aime"" title=""J'aime"" role=""img""></div>
 * </div>
 * <span class=""TweetInfo-heartStat"" data-scribe=""element:heart_count"">704</span>
 * </a>
 * </div>
 *      <div class=""TweetInfo-timeGeo"">
 *
 * <a class=""u-linkBlend u-url customisable-highlight long-permalink"" data-datetime=""2019-12-09T15:50:36+0000"" data-scribe=""element:full_timestamp"" href=""https://twitter.com/Poulin2012/status/1204065818432167937"">
 *
 *
 *
 *
 *
 *
 *
 *
 * <time class=""dt-updated"" datetime=""2019-12-09T15:50:36+0000"" pubdate="""" title=""Heure de publication : 09 décembre 2019 15:50:36 (UTC)"">10:50 - 9 déc. 2019</time></a></div>
 *      <div class=""tweet-InformationCircle"" data-scribe=""element:notice""><a href=""https://support.twitter.com/articles/20175256"" class=""Icon Icon--informationCircleWhite js-inViewportScribingTarget"" title=""Informations sur les Publicités Twitter et confidentialité""><span class=""u-hiddenVisually"">Informations sur les Publicités Twitter et confidentialité</span></a>
 * </div>
 *    </div>
 *  </div>
 * </blockquote>";
 * //*/
//				string	title = "dummy title";

//				return new Fiche( _title, _URL, null, Fiche.BuildHTMLDocument( title, content ) );


            string dummyTitle = "Dummy Title";
            string dummyHTML  = BuildHTMLDocument(dummyTitle, content);

            uint seed = (uint)_URL.GetHashCode();

            ImageUtility.ImageFile dummyPage = new ImageUtility.ImageFile(Fiche.ChunkWebPageSnapshot.ms_defaultWebPageWidth, Fiche.ChunkWebPageSnapshot.ms_defaultWebPageHeight, ImageUtility.PIXEL_FORMAT.BGRA8, new ImageUtility.ColorProfile(ImageUtility.ColorProfile.STANDARD_PROFILE.sRGB));
            dummyPage.WritePixels((uint _X, uint _Y, ref float4 _color) => {
                _color.x = Mathf.Sin(0.1f * (seed + _X));
                _color.y = Mathf.Sin(0.123f * (seed + _Y));
                _color.z = Mathf.Sin(0.01234f * (seed + _X + _Y));
                _color.w = 1.0f;
            });

            // Notify
            _onSourceAvailable(dummyTitle, dummyHTML, null);
            _onPieceRendered(0, new Rectangle(0, 0, (int)Fiche.ChunkWebPageSnapshot.ms_defaultWebPageWidth, (int)Fiche.ChunkWebPageSnapshot.ms_defaultWebPageHeight), dummyPage);
            _onSuccess();
        }
示例#3
0
        void    GenerateMaterial(AxFService.AxFFile.Material _material, System.IO.DirectoryInfo _targetDirectory, TEXTURE_TYPE[] _textureTypes, string[] _textureGUIDs)
        {
            string templateTexture = "    - <TEX_VARIABLE_NAME>:\n" +
                                     "        m_Texture: {fileID: <FILE ID>, guid: <GUID>, type: 3}\n" +
                                     "        m_Scale: {x: 1, y: 1}\n" +
                                     "        m_Offset: {x: 0, y: 0}\n";

            string materialContent = Properties.Resources.TemplateMaterial;

            //////////////////////////////////////////////////////////////////////////
            // Generate textures array
            bool   hasClearCoat            = false;
            bool   hasHeightMap            = false;
            string texturesArray           = "";
            float  specularLobeScaleFactor = 1.0f;
            float  BRDFColorScaleFactor    = 1.0f;
            float  BTFFlakeScaleFactor     = 1.0f;

            for (int textureIndex = 0; textureIndex < _textureTypes.Length; textureIndex++)
            {
                AxFService.AxFFile.Material.Texture texture = _material.Textures[textureIndex];
//				int		fileID = 2800000 + textureIndex;
                int    fileID       = 2800000;
                string GUID         = _textureGUIDs[textureIndex];
                string variableName = null;
                switch (_textureTypes[textureIndex])
                {
                case TEXTURE_TYPE.ANISOTROPY_ANGLE:             variableName = "_SVBRDF_AnisotropicRotationAngleMap"; break;

                case TEXTURE_TYPE.CLEARCOAT_COLOR:              variableName = "_SVBRDF_ClearCoatColorMap_sRGB"; hasClearCoat = true; break;

                case TEXTURE_TYPE.CLEARCOAT_IOR:                variableName = "_SVBRDF_ClearCoatIORMap_sRGB"; hasClearCoat = true; break;

                case TEXTURE_TYPE.CLEARCOAT_NORMAL:             variableName = "_SVBRDF_ClearCoatNormalMap"; hasClearCoat = true; break;

                case TEXTURE_TYPE.DIFFUSE_COLOR:                variableName = "_SVBRDF_DiffuseColorMap_sRGB"; break;

                case TEXTURE_TYPE.FRESNEL:                              variableName = "_SVBRDF_FresnelMap_sRGB"; break;

                case TEXTURE_TYPE.HEIGHT:                               variableName = "_SVBRDF_HeightMap"; hasHeightMap = true; break;

                case TEXTURE_TYPE.NORMAL:                               variableName = "_SVBRDF_NormalMap"; break;

                case TEXTURE_TYPE.OPACITY:                              variableName = "_SVBRDF_OpacityMap"; break;

                case TEXTURE_TYPE.SPECULAR_COLOR:               variableName = "_SVBRDF_SpecularColorMap_sRGB"; break;

                case TEXTURE_TYPE.SPECULAR_LOBE:                variableName = "_SVBRDF_SpecularLobeMap"; specularLobeScaleFactor = Mathf.Max(1, texture.MaxValue); break;

                // Car Paint
                case TEXTURE_TYPE.BRDF_COLOR:                   variableName = "_CarPaint_BRDFColorMap_sRGB"; BRDFColorScaleFactor = Mathf.Max(1, texture.MaxValue); break;

                case TEXTURE_TYPE.BTF_FLAKES:                   variableName = "_CarPaint_BTFFlakesMap_sRGB"; BTFFlakeScaleFactor = Mathf.Max(1, texture.MaxValue); break;

                default:
                    throw new Exception("Unsupported texture type! Can't match to variable name...");
                }
                string textureEntry = templateTexture.Replace("<FILE ID>", fileID.ToString());
                textureEntry   = textureEntry.Replace("<GUID>", GUID);
                textureEntry   = textureEntry.Replace("<TEX_VARIABLE_NAME>", variableName);
                texturesArray += textureEntry;
            }


            //////////////////////////////////////////////////////////////////////////
            // Generate uniforms array
            string uniformsArray = "";
            string colorsArray   = "";

            uniformsArray += "    - _materialSizeU_mm: 10\n";
            uniformsArray += "    - _materialSizeV_mm: 10\n";

            switch (_material.Type)
            {
            case AxFService.AxFFile.Material.TYPE.SVBRDF:   uniformsArray += "    - _AxF_BRDFType: 0\n"; break;

            case AxFService.AxFFile.Material.TYPE.CARPAINT: uniformsArray += "    - _AxF_BRDFType: 1\n"; break;

            case AxFService.AxFFile.Material.TYPE.BTF:              uniformsArray += "    - _AxF_BRDFType: 2\n"; break;
            }

            switch (_material.Type)
            {
            case AxFService.AxFFile.Material.TYPE.SVBRDF: {
                // Setup flags
                uint flags = 0;
                flags |= _material.IsAnisotropic ? 1U : 0;
                flags |= hasClearCoat ? 2U : 0;
                flags |= _material.GetPropertyInt("cc_no_refraction", 0) == 1 ? 0 : 4U;                                                 // Explicitly use no refraction
                flags |= hasHeightMap ? 8U : 0;

                uniformsArray += "    - _flags: " + flags + "\n";

                // Setup SVBRDF diffuse & specular types
                uint BRDFType = 0;
                BRDFType |= (uint)_material.DiffuseType;
                BRDFType |= ((uint)_material.SpecularType) << 1;

                uniformsArray += "    - _SVBRDF_BRDFType: " + BRDFType + "\n";

                // Setup SVBRDF fresnel and specular variants
                uint BRDFVariants = 0;
                BRDFVariants |= ((uint)_material.FresnelVariant & 3);
                switch (_material.SpecularVariant)
                {
                // Ward variants
                case AxFService.AxFFile.Material.SVBRDF_SPECULAR_VARIANT.GEISLERMORODER:        BRDFVariants |= 0U << 2; break;

                case AxFService.AxFFile.Material.SVBRDF_SPECULAR_VARIANT.DUER:                          BRDFVariants |= 1U << 2; break;

                case AxFService.AxFFile.Material.SVBRDF_SPECULAR_VARIANT.WARD:                          BRDFVariants |= 2U << 2; break;

                // Blinn variants
                case AxFService.AxFFile.Material.SVBRDF_SPECULAR_VARIANT.ASHIKHMIN_SHIRLEY:     BRDFVariants |= 0U << 4; break;

                case AxFService.AxFFile.Material.SVBRDF_SPECULAR_VARIANT.BLINN:                         BRDFVariants |= 1U << 4; break;

                case AxFService.AxFFile.Material.SVBRDF_SPECULAR_VARIANT.VRAY:                          BRDFVariants |= 2U << 4; break;

                case AxFService.AxFFile.Material.SVBRDF_SPECULAR_VARIANT.LEWIS:                         BRDFVariants |= 3U << 4; break;
                }

                uniformsArray += "    - _SVBRDF_BRDFVariants: " + BRDFVariants + "\n";

                // Write scale factor for specular lobe
                uniformsArray += "    - _SVBRDF_SpecularLobeMap_Scale: " + specularLobeScaleFactor + "\n";

                float heightMapSize_mm = 0.0f;                                  // @TODO!
                uniformsArray += "    - _SVBRDF_heightMapMax_mm: " + heightMapSize_mm + "\n";

                break;
            }

            case AxFService.AxFFile.Material.TYPE.CARPAINT: {
                // Setup flags
                uint flags = 0;
                flags |= _material.IsAnisotropic ? 1U : 0;
                flags |= hasClearCoat ? 2U : 0;
                flags |= _material.GetPropertyInt("cc_no_refraction", 0) == 1 ? 0 : 4U;                                                 // Explicitly use no refraction
//							flags |= hasHeightMap ? 8U : 0;

                uniformsArray += "    - _flags: " + flags + "\n";

                uniformsArray += "    - _CarPaint_CT_diffuse: " + _material.GetPropertyFloat("CT_diffuse", 0) + "\n";
                uniformsArray += "    - _CarPaint_IOR: " + _material.GetPropertyFloat("IOR", 1) + "\n";
                uniformsArray += "    - _CarPaint_maxThetaI: " + _material.GetPropertyInt("max_thetaI", 0) + "\n";
                uniformsArray += "    - _CarPaint_numThetaF: " + _material.GetPropertyInt("num_thetaF", 0) + "\n";
                uniformsArray += "    - _CarPaint_numThetaI: " + _material.GetPropertyInt("num_thetaI", 0) + "\n";

                // Write scale factor for BRDF color
                uniformsArray += "    - _CarPaint_BRDFColorMap_Scale: " + BRDFColorScaleFactor + "\n";
                uniformsArray += "    - _CarPaint_BTFFlakesMap_Scale: " + BTFFlakeScaleFactor + "\n";

                // =========================================================================================
                // Setup simple arrays as colors
                float[] CT_F0s = _material.GetPropertyRaw("CT_F0s") as float[];
                if (CT_F0s == null || CT_F0s.Length != 3)
                {
                    throw new Exception("Expected 3 float values for F0!");
                }

                float[] CT_coeffs = _material.GetPropertyRaw("CT_coeffs") as float[];
                if (CT_coeffs == null || CT_coeffs.Length != 3)
                {
                    throw new Exception("Expected 3 float values for coefficients!");
                }

                float[] CT_spreads = _material.GetPropertyRaw("CT_spreads") as float[];
                if (CT_spreads == null || CT_spreads.Length != 3)
                {
                    throw new Exception("Expected 3 float values for spreads!");
                }

                uniformsArray += "    - _CarPaint_lobesCount: " + CT_F0s.Length + "\n";

                colorsArray += "    - _CarPaint_CT_F0s: {r: " + CT_F0s[0] + ", g: " + CT_F0s[1] + ", b: " + CT_F0s[2] + ", a: 0 }\n";
                colorsArray += "    - _CarPaint_CT_coeffs: {r: " + CT_coeffs[0] + ", g: " + CT_coeffs[1] + ", b: " + CT_coeffs[2] + ", a: 0 }\n";
                colorsArray += "    - _CarPaint_CT_spreads: {r: " + CT_spreads[0] + ", g: " + CT_spreads[1] + ", b: " + CT_spreads[2] + ", a: 0 }\n";

                // =========================================================================================
                // Create a custom texture for sliceLUT
                int[] thetaFI_sliceLUT = _material.GetPropertyRaw("thetaFI_sliceLUT") as int[];
                if (thetaFI_sliceLUT == null)
                {
                    throw new Exception("Slice LUT not found!");
                }

                ImageUtility.ImageFile texSliceLUT = new ImageUtility.ImageFile((uint)thetaFI_sliceLUT.Length, 1, ImageUtility.PIXEL_FORMAT.R8, new ImageUtility.ColorProfile(ImageUtility.ColorProfile.STANDARD_PROFILE.LINEAR));
                texSliceLUT.WritePixels((uint _X, uint _Y, ref float4 _color) => {
                        _color.x = thetaFI_sliceLUT[_X] / 255.0f;
                    });

                System.IO.FileInfo targetTextureFileName = new System.IO.FileInfo(System.IO.Path.Combine(_targetDirectory.FullName, _material.Name, "sliceLUT.png"));
                texSliceLUT.Save(targetTextureFileName, ImageUtility.ImageFile.FILE_FORMAT.PNG);
                string GUID = GenerateMeta(targetTextureFileName, checkBoxGenerateMeta.Checked, checkBoxOverwriteExistingMeta.Checked, false, false, false, false);

                string textureEntry = templateTexture.Replace("<FILE ID>", 2800000.ToString());
                textureEntry   = textureEntry.Replace("<GUID>", GUID);
                textureEntry   = textureEntry.Replace("<TEX_VARIABLE_NAME>", "_CarPaint_thetaFI_sliceLUTMap");
                texturesArray += textureEntry;

                break;
            }

            default:
                throw new Exception("TODO! Support feeding variables to other BRDF types!");
            }


            //////////////////////////////////////////////////////////////////////////
            // Replace placeholders in template
            materialContent = materialContent.Replace("<TEXTURES ARRAY>", texturesArray);
            materialContent = materialContent.Replace("<UNIFORMS ARRAY>", uniformsArray);
            materialContent = materialContent.Replace("<COLORS ARRAY>", colorsArray);


            // Write target file
            System.IO.FileInfo materialFileName = new System.IO.FileInfo(System.IO.Path.Combine(_targetDirectory.FullName, _material.Name, "material.mat"));
            using (System.IO.StreamWriter S = materialFileName.CreateText())
                S.Write(materialContent);
        }