Ejemplo n.º 1
0
 Texture2D       LoadFalseColors(FileInfo _fileName)
 {
     using (ImageUtility.ImageFile sourceImage = new ImageUtility.ImageFile(_fileName, ImageUtility.ImageFile.FILE_FORMAT.PNG)) {
         ImageUtility.ImageFile convertedImage = new ImageUtility.ImageFile();
         convertedImage.ConvertFrom(sourceImage, ImageUtility.PIXEL_FORMAT.BGRA8);
         using (ImageUtility.ImagesMatrix image = new ImageUtility.ImagesMatrix(convertedImage, ImageUtility.ImagesMatrix.IMAGE_TYPE.sRGB))
             return(new Texture2D(m_device, image, ImageUtility.COMPONENT_FORMAT.UNORM_sRGB));
     }
 }
Ejemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try {
                m_device.Init(panelOutput.Handle, false, true);
            }
            catch (Exception _e) {
                m_device = null;
                MessageBox.Show("Failed to initialize DX device!\n\n" + _e.Message, "Heat Wave Test", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            m_CB_Main = new ConstantBuffer <CB_Main>(m_device, 0);

            m_shader_HeatDiffusion0 = new Shader(m_device, new FileInfo("./Shaders/HeatDiffusion.hlsl"), VERTEX_FORMAT.Pt4, "VS", null, "PS");
            m_shader_HeatDiffusion1 = new Shader(m_device, new FileInfo("./Shaders/HeatDiffusion2.hlsl"), VERTEX_FORMAT.Pt4, "VS", null, "PS");
            m_shader_RenderHeatMap  = new Shader(m_device, new FileInfo("./Shaders/RenderHeatMap.hlsl"), VERTEX_FORMAT.Pt4, "VS", null, "PS");
            m_shader_DrawObstacles  = new Shader(m_device, new FileInfo("./Shaders/DrawObstacles.hlsl"), VERTEX_FORMAT.Pt4, "VS", null, "PS");

            m_tex_HeatMap_Staging   = new Texture2D(m_device, (uint)GRAPH_SIZE, (uint)GRAPH_SIZE, 1, 1, ImageUtility.PIXEL_FORMAT.RGBA32F, ImageUtility.COMPONENT_FORMAT.AUTO, true, false, null);
            m_tex_HeatMap0          = new Texture2D(m_device, (uint)GRAPH_SIZE, (uint)GRAPH_SIZE, 1, 1, ImageUtility.PIXEL_FORMAT.RGBA32F, ImageUtility.COMPONENT_FORMAT.AUTO, false, false, null);
            m_tex_HeatMap1          = new Texture2D(m_device, (uint)GRAPH_SIZE, (uint)GRAPH_SIZE, 1, 1, ImageUtility.PIXEL_FORMAT.RGBA32F, ImageUtility.COMPONENT_FORMAT.AUTO, false, false, null);
            m_tex_Obstacles0        = new Texture2D(m_device, (uint)GRAPH_SIZE + 2, (uint)GRAPH_SIZE + 2, 1, 1, ImageUtility.PIXEL_FORMAT.RGBA8, ImageUtility.COMPONENT_FORMAT.UNORM, false, false, null);
            m_tex_Obstacles1        = new Texture2D(m_device, (uint)GRAPH_SIZE + 2, (uint)GRAPH_SIZE + 2, 1, 1, ImageUtility.PIXEL_FORMAT.RGBA8, ImageUtility.COMPONENT_FORMAT.UNORM, false, false, null);
            m_tex_Obstacles_Staging = new Texture2D(m_device, (uint)GRAPH_SIZE + 2, (uint)GRAPH_SIZE + 2, 1, 1, ImageUtility.PIXEL_FORMAT.RGBA8, ImageUtility.COMPONENT_FORMAT.UNORM, true, false, null);
            ClearObstacles();
            buttonResetObstacles_Click(null, EventArgs.Empty);

            m_tex_Search         = new Texture2D(m_device, (uint)GRAPH_SIZE, (uint)GRAPH_SIZE, 1, 1, ImageUtility.PIXEL_FORMAT.RGBA8, ImageUtility.COMPONENT_FORMAT.UNORM, false, false, null);
            m_tex_Search_Staging = new Texture2D(m_device, (uint)GRAPH_SIZE, (uint)GRAPH_SIZE, 1, 1, ImageUtility.PIXEL_FORMAT.RGBA8, ImageUtility.COMPONENT_FORMAT.UNORM, true, false, null);

            // Load false colors
            using (ImageUtility.ImageFile sourceImage = new ImageUtility.ImageFile(new FileInfo("../../Data/Images/Gradients/Magma.png"), ImageUtility.ImageFile.FILE_FORMAT.PNG)) {
                ImageUtility.ImageFile convertedImage = new ImageUtility.ImageFile();
                convertedImage.ConvertFrom(sourceImage, ImageUtility.PIXEL_FORMAT.BGRA8);
                using (ImageUtility.ImagesMatrix image = new ImageUtility.ImagesMatrix(convertedImage, ImageUtility.ImagesMatrix.IMAGE_TYPE.sRGB))
                    m_tex_FalseColors0 = new Texture2D(m_device, image, ImageUtility.COMPONENT_FORMAT.UNORM_sRGB);
            }
            using (ImageUtility.ImageFile sourceImage = new ImageUtility.ImageFile(new FileInfo("../../Data/Images/Gradients/Viridis.png"), ImageUtility.ImageFile.FILE_FORMAT.PNG)) {
                ImageUtility.ImageFile convertedImage = new ImageUtility.ImageFile();
                convertedImage.ConvertFrom(sourceImage, ImageUtility.PIXEL_FORMAT.BGRA8);
                using (ImageUtility.ImagesMatrix image = new ImageUtility.ImagesMatrix(convertedImage, ImageUtility.ImagesMatrix.IMAGE_TYPE.sRGB))
                    m_tex_FalseColors1 = new Texture2D(m_device, image, ImageUtility.COMPONENT_FORMAT.UNORM_sRGB);
            }

//			BuildGraph();

            Application.Idle += Application_Idle;
        }
Ejemplo n.º 3
0
 public Texture2D        Image2Texture(System.IO.FileInfo _fileName, ImageUtility.COMPONENT_FORMAT _componentFormat)
 {
     ImageUtility.ImagesMatrix images = null;
     if (_fileName.Extension.ToLower() == ".dds")
     {
         images = new ImageUtility.ImagesMatrix();
         images.DDSLoadFile(_fileName);
     }
     else
     {
         ImageUtility.ImageFile image = new ImageUtility.ImageFile(_fileName);
         if (image.PixelFormat != ImageUtility.PIXEL_FORMAT.BGRA8)
         {
             ImageUtility.ImageFile badImage = image;
             image = new ImageUtility.ImageFile();
             image.ConvertFrom(badImage, ImageUtility.PIXEL_FORMAT.BGRA8);
             badImage.Dispose();
         }
         images = new ImageUtility.ImagesMatrix(new ImageUtility.ImageFile[1, 1] {
             { image }
         });
     }
     return(new Texture2D(m_device, images, _componentFormat));
 }
Ejemplo n.º 4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try {
                m_device.Init(panelOutput.Handle, false, true);
            } catch (Exception _e) {
                m_device = null;
                MessageBox.Show("Failed to initialize DX device!\n\n" + _e.Message, "Heat Wave Test", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try {
                //////////////////////////////////////////////////////////////////////////
                // Load the graph we need to simulate
                m_graph = new ProtoParser.Graph();

//				FileInfo	file = new FileInfo( "../../../AI/Projects/Semantic Memory/Tests/Birds Database/Tools/ProtoParser/Concepts.graph" );
                FileInfo file = new FileInfo("../../../AI/Projects/Semantic Memory/Tests/Birds Database/Tools/ProtoParser/TestGraph.graph");
                if (!file.Exists)
                {
                    file = new FileInfo("./Graphs/TestGraph.graph");
                }

                using (FileStream S = file.OpenRead())
                    using (BinaryReader R = new BinaryReader(S))
                        m_graph.Read(R);

                ProtoParser.Neuron[] neurons = m_graph.Neurons;
                m_nodesCount = (uint)neurons.Length;

/*
 * m_nodesCount = 2;
 * neurons = new ProtoParser.Neuron[2];
 * neurons[0] = new ProtoParser.Neuron();
 * neurons[1] = new ProtoParser.Neuron();
 * neurons[0].LinkChild( neurons[1] );
 * //*/


                //////////////////////////////////////////////////////////////////////////
                m_CB_Main       = new ConstantBuffer <CB_Main>(m_device, 0);
                m_CB_Simulation = new ConstantBuffer <CB_Simulation>(m_device, 1);
                m_CB_Text       = new ConstantBuffer <CB_Text>(m_device, 2);

                m_shader_ComputeForces = new ComputeShader(m_device, new FileInfo("./Shaders/SimulateGraph.hlsl"), "CS");
                m_shader_Simulate      = new ComputeShader(m_device, new FileInfo("./Shaders/SimulateGraph.hlsl"), "CS2");
        #if RENDER_GRAPH_PROPER
                m_shader_RenderGraphNode = new Shader(m_device, new FileInfo("./Shaders/RenderGraph2.hlsl"), VERTEX_FORMAT.Pt4, "VS", null, "PS");
                m_shader_RenderGraphLink = new Shader(m_device, new FileInfo("./Shaders/RenderGraph2.hlsl"), VERTEX_FORMAT.Pt4, "VS2", null, "PS2");
        #else
                m_shader_RenderGraph = new Shader(m_device, new FileInfo("./Shaders/RenderGraph.hlsl"), VERTEX_FORMAT.Pt4, "VS", null, "PS");
        #endif

                m_shader_RenderText = new Shader(m_device, new FileInfo("./Shaders/RenderText.hlsl"), VERTEX_FORMAT.Pt4, "VS", null, "PS");

                // Build node info
                m_SB_Nodes = new StructuredBuffer <SB_NodeInfo>(m_device, m_nodesCount, true);

                m_neuron2ID = new Dictionary <ProtoParser.Neuron, uint>(neurons.Length);

                float maxMass = 0.0f;
                for (int neuronIndex = 0; neuronIndex < m_nodesCount; neuronIndex++)
                {
                    ProtoParser.Neuron N = neurons[neuronIndex];
                    m_neuron2ID[N] = (uint)neuronIndex;

                    uint linksCount = (uint)(N.ParentsCount + N.ChildrenCount + N.FeaturesCount);
                    //				m_SB_Nodes.m[neuronIndex].m_mass = (1 + 10.0f * linksCount) / (0.1f + N.Distance2Root);			// Works with S=1e4 D=-1e3
                    //				m_SB_Nodes.m[neuronIndex].m_mass = (1 + 1.0f * linksCount) / (0.01f + 0.0f * N.Distance2Root);	// Works with S=1e4 D=-1e3
                    //				m_SB_Nodes.m[neuronIndex].m_mass = (1 + 0.1f * linksCount) / (0.1f + N.Distance2Root);			// Works with S=10 D=-10
                    m_SB_Nodes.m[neuronIndex].m_mass       = 100.0f * (1 + 1.0f * linksCount);                  // Works with S=1e4 D=-1e3
                    m_SB_Nodes.m[neuronIndex].m_linkOffset = m_totalLinksCount;
                    m_SB_Nodes.m[neuronIndex].m_linksCount = linksCount;
                    m_SB_Nodes.m[neuronIndex].m_flags      = 0U;

                    maxMass = Mathf.Max(maxMass, m_SB_Nodes.m[neuronIndex].m_mass);

                    m_totalLinksCount += linksCount;
                }

                m_SB_Nodes.m[0].m_mass = 1e4f;

                m_SB_Nodes.Write();

                // Build node links
                m_SB_Links        = new StructuredBuffer <uint>(m_device, m_totalLinksCount, true);
                m_SB_LinkSources  = new StructuredBuffer <uint>(m_device, m_totalLinksCount, true);
                m_totalLinksCount = 0;
                for (int neuronIndex = 0; neuronIndex < m_nodesCount; neuronIndex++)
                {
                    ProtoParser.Neuron N = neurons[neuronIndex];
                    foreach (ProtoParser.Neuron O in N.Parents)
                    {
                        m_SB_LinkSources.m[m_totalLinksCount] = (uint)neuronIndex;
                        m_SB_Links.m[m_totalLinksCount++]     = m_neuron2ID[O];
                    }
                    foreach (ProtoParser.Neuron O in N.Children)
                    {
                        m_SB_LinkSources.m[m_totalLinksCount] = (uint)neuronIndex;
                        m_SB_Links.m[m_totalLinksCount++]     = m_neuron2ID[O];
                    }
                    foreach (ProtoParser.Neuron O in N.Features)
                    {
                        m_SB_LinkSources.m[m_totalLinksCount] = (uint)neuronIndex;
                        m_SB_Links.m[m_totalLinksCount++]     = m_neuron2ID[O];
                    }
                }
                m_SB_Links.Write();
                m_SB_LinkSources.Write();

                // Setup initial CB
                m_CB_Main.m._nodesCount   = m_nodesCount;
                m_CB_Main.m._resX         = (uint)panelOutput.Width;
                m_CB_Main.m._resY         = (uint)panelOutput.Height;
                m_CB_Main.m._maxMass      = maxMass;
                m_CB_Main.m._cameraCenter = float2.Zero;
                m_CB_Main.m._cameraSize.Set(10.0f, 10.0f);
                m_CB_Main.m._hoveredNodeIndex = ~0U;
                m_CB_Main.UpdateData();

                // Initialize sim buffers
                m_SB_Forces      = new StructuredBuffer <float2>(m_device, m_nodesCount * m_nodesCount, false);
                m_SB_NodeSims[0] = new StructuredBuffer <SB_NodeSim>(m_device, m_nodesCount, true);
                m_SB_NodeSims[1] = new StructuredBuffer <SB_NodeSim>(m_device, m_nodesCount, true);

                buttonReset_Click(null, EventArgs.Empty);

                //			m_shader_HeatDiffusion = new Shader( m_device, new FileInfo( "./Shaders/HeatDiffusion.hlsl" ), VERTEX_FORMAT.Pt4, "VS", null, "PS", null );

                //          m_tex_Search = new Texture2D( m_device, (uint) GRAPH_SIZE, (uint) GRAPH_SIZE, 1, 1, ImageUtility.PIXEL_FORMAT.RGBA8, ImageUtility.COMPONENT_FORMAT.UNORM, false, false, null );
                //          m_tex_Search_Staging = new Texture2D( m_device, (uint) GRAPH_SIZE, (uint) GRAPH_SIZE, 1, 1, ImageUtility.PIXEL_FORMAT.RGBA8, ImageUtility.COMPONENT_FORMAT.UNORM, true, false, null );

                // Load false colors
                //			using ( ImageUtility.ImageFile sourceImage = new ImageUtility.ImageFile( new FileInfo( "../../Images/Gradients/Viridis.png" ), ImageUtility.ImageFile.FILE_FORMAT.PNG ) ) {
                using (ImageUtility.ImageFile sourceImage = new ImageUtility.ImageFile(new FileInfo("../../Images/Gradients/Magma.png"), ImageUtility.ImageFile.FILE_FORMAT.PNG)) {
                    ImageUtility.ImageFile convertedImage = new ImageUtility.ImageFile();
                    convertedImage.ConvertFrom(sourceImage, ImageUtility.PIXEL_FORMAT.BGRA8);
                    using (ImageUtility.ImagesMatrix image = new ImageUtility.ImagesMatrix(convertedImage, ImageUtility.ImagesMatrix.IMAGE_TYPE.sRGB))
                        m_tex_FalseColors = new Texture2D(m_device, image, ImageUtility.COMPONENT_FORMAT.UNORM_sRGB);
                }

                // Prepare font atlas
                m_SB_Text = new StructuredBuffer <SB_Letter>(m_device, 1024U, true);
                BuildFont();

                Application.Idle += Application_Idle;
            } catch (Exception _e) {
                m_device = null;
                MessageBox.Show("Failed to initialize shaders!\n\n" + _e.Message, "Heat Wave Test", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Ejemplo n.º 5
0
        void    DumpMaterial(AxFService.AxFFile.Material _material, System.IO.DirectoryInfo _targetDirectory)
        {
            System.IO.DirectoryInfo fullTargetDirectory = new System.IO.DirectoryInfo(System.IO.Path.Combine(_targetDirectory.FullName, _material.Name));
            if (!fullTargetDirectory.Exists)
            {
                fullTargetDirectory.Create();
            }

            AxFService.AxFFile.Material.Texture[] textures = _material.Textures;
            TEXTURE_TYPE[] textureTypes  = new TEXTURE_TYPE[textures.Length];
            string[]       GUIDs         = new string[textures.Length];
            bool           allGUIDsValid = true;

            for (int textureIndex = 0; textureIndex < textures.Length; textureIndex++)
            {
                AxFService.AxFFile.Material.Texture texture = textures[textureIndex];

                TEXTURE_TYPE textureType = TEXTURE_TYPE.UNKNOWN;
                switch (texture.Name.ToLower())
                {
                case "diffusecolor":    textureType = TEXTURE_TYPE.DIFFUSE_COLOR; break;

                case "specularcolor":   textureType = TEXTURE_TYPE.SPECULAR_COLOR; break;

                case "normal":                  textureType = TEXTURE_TYPE.NORMAL; break;

                case "fresnel":                 textureType = TEXTURE_TYPE.FRESNEL; break;

                case "specularlobe":    textureType = TEXTURE_TYPE.SPECULAR_LOBE; break;

                case "anisorotation":   textureType = TEXTURE_TYPE.ANISOTROPY_ANGLE; break;

                case "height":                  textureType = TEXTURE_TYPE.HEIGHT; break;

                case "opacity":                 textureType = TEXTURE_TYPE.OPACITY; break;

                case "clearcoatcolor":  textureType = TEXTURE_TYPE.CLEARCOAT_COLOR; break;

                case "clearcoatnormal": textureType = TEXTURE_TYPE.CLEARCOAT_NORMAL; break;

                case "clearcoatior":    textureType = TEXTURE_TYPE.CLEARCOAT_IOR; break;

                // Car Paint
                case "brdfcolors":              textureType = TEXTURE_TYPE.BRDF_COLOR; break;

                case "btfflakes":               textureType = TEXTURE_TYPE.BTF_FLAKES; break;

                default:
                    throw new Exception("Unsupported texture type \"" + texture.Name + "\"!");
                }

                textureTypes[textureIndex] = textureType;

                bool sRGB        = ((int)textureType & (int)TEXTURE_TYPE.FLAG_sRGB) != 0;
                bool isNormalMap = ((int)textureType & (int)TEXTURE_TYPE.FLAG_NORMAL) != 0;
                bool isIOR       = ((int)textureType & (int)TEXTURE_TYPE.FLAG_IOR) != 0;
                bool isAngle     = ((int)textureType & (int)TEXTURE_TYPE.FLAG_ANGLE) != 0;
                bool isArray     = ((int)textureType & (int)TEXTURE_TYPE.FLAG_2DARRAY) != 0;
                bool scale       = ((int)textureType & (int)TEXTURE_TYPE.FLAG_SCALE_BY_MAX) != 0 && texture.MaxValue > 1;

                System.IO.FileInfo targetTextureFileName = new System.IO.FileInfo(System.IO.Path.Combine(fullTargetDirectory.FullName, texture.Name + ".png"));

//*

//				// Dump as DDS
//				texture.Images.DDSSaveFile( new System.IO.FileInfo( @"D:\Workspaces\Unity Labs\AxF\AxF Shader\Assets\AxF Materials\X-Rite_14-LTH_Red_GoatLeather_4405_2479\" + texture.Name + ".dds" ), texture.ComponentFormat );

                // Individual dump as RGBA8 files
//              ImageUtility.ImageFile	source = texture.Images[0][0][0];
//              ImageUtility.ImageFile	temp = new ImageUtility.ImageFile();
//              //temp.ConvertFrom( source, ImageUtility.PIXEL_FORMAT.BGRA8 );
//              temp.ToneMapFrom( source, ( float3 _HDR, ref float3 _LDR ) => { _LDR =_HDR; } );
//              temp.Save( new System.IO.FileInfo( @"D:\Workspaces\Unity Labs\AxF\AxF Shader\Assets\AxF Materials\X-Rite_14-LTH_Red_GoatLeather_4405_2479\" + texture.Name + ".png" ), ImageUtility.ImageFile.FILE_FORMAT.PNG );

                uint mipsCount = texture.Images[0].MipLevelsCount;
                for (uint mipIndex = 0; mipIndex < mipsCount; mipIndex++)
                {
                    // Individual dump as RGBA16 files
                    ImageUtility.ImageFile source = texture.Images[0][mipIndex][0];

                    float factor = 1.0f;
                    if (scale)
                    {
                        factor = 1.0f / texture.MaxValue;                               // Apply scale
                    }

//                  if ( textureType == TEXTURE_TYPE.BRDF_COLOR ) {
//                      Random	R = new Random();
//                      source.ReadWritePixels( ( uint _X, uint _Y, ref float4 _color ) => {
//                          _color.x = (0.5f+_X) / 63.0f;
//                          _color.y = (0.5f+_X) / 63.0f;
//                          _color.z = (0.5f+_X) / 63.0f;
//                          _color.w = (float) R.NextDouble();
//
//                          // Apply sRGB
//                          _color.x = Mathf.Pow( Math.Max( 0.0f, _color.x ), 1.0f / 2.2f );
//                          _color.y = Mathf.Pow( Math.Max( 0.0f, _color.y ), 1.0f / 2.2f );
//                          _color.z = Mathf.Pow( Math.Max( 0.0f, _color.z ), 1.0f / 2.2f );
//
//                      } );
//                  } else
                    if (sRGB)
                    {
                        source.ReadWritePixels((uint _X, uint _Y, ref float4 _color) => {
                            _color.x = Mathf.Pow(Math.Max(0.0f, factor * _color.x), 1.0f / 2.2f);
                            _color.y = Mathf.Pow(Math.Max(0.0f, factor * _color.y), 1.0f / 2.2f);
                            _color.z = Mathf.Pow(Math.Max(0.0f, factor * _color.z), 1.0f / 2.2f);
                            //						_color.w = 1.0f;
                        });
                    }

                    if (isNormalMap)
                    {
                        source.ReadWritePixels((uint _X, uint _Y, ref float4 _color) => {
                            _color.x = 0.5f * (1.0f + _color.x);
                            _color.y = 0.5f * (1.0f + _color.y);
                            _color.z = 0.5f * (1.0f + _color.z);
                        });
                    }

                    if (isIOR)
                    {
                        // Transform into F0
                        source.ReadWritePixels((uint _X, uint _Y, ref float4 _color) => {
                            if (float.IsNaN(_color.x))
                            {
                                _color.x = 1.2f;
                            }
                            if (float.IsNaN(_color.y))
                            {
                                _color.y = 1.2f;
                            }
                            if (float.IsNaN(_color.z))
                            {
                                _color.z = 1.2f;
                            }

                            _color.x = (_color.x - 1.0f) / (_color.x + 1.0f);                                   // We apply the square below, during the sRGB conversion
                            _color.y = (_color.y - 1.0f) / (_color.y + 1.0f);
                            _color.z = (_color.z - 1.0f) / (_color.z + 1.0f);
                            _color.x = Mathf.Pow(Mathf.Max(0.0f, _color.x), 2.0f / 2.2f);                                               // <= Notice the 2/2.2 here!
                            _color.y = Mathf.Pow(Mathf.Max(0.0f, _color.y), 2.0f / 2.2f);
                            _color.z = Mathf.Pow(Mathf.Max(0.0f, _color.z), 2.0f / 2.2f);
                        });
                        sRGB = true;                            // Also encoded as sRGB now
                    }

                    if (isAngle)
                    {
                        // Renormalize
                        source.ReadWritePixels((uint _X, uint _Y, ref float4 _color) => {
                            _color.x = 0.5f * (1.0f + _color.x * Mathf.INVPI);
                            _color.y = 0.5f * (1.0f + _color.y * Mathf.INVPI);
                            _color.z = 0.5f * (1.0f + _color.z * Mathf.INVPI);
                        });
                    }

                    ImageUtility.ImageFile temp = new ImageUtility.ImageFile();
//					if ( texture.Name.ToLower() == "diffusecolor" )
//						temp.ToneMapFrom( source, ( float3 _HDR, ref float3 _LDR ) => { _LDR =_HDR; } );	// 8-bits for diffuse otherwise unity doesn't like it... :'(
//					else
                    temp.ConvertFrom(source, ImageUtility.PIXEL_FORMAT.RGBA16);

                    System.IO.FileInfo targetMipTextureFileName = mipIndex > 0 ? new System.IO.FileInfo(System.IO.Path.Combine(fullTargetDirectory.FullName, texture.Name + "_mip" + mipIndex + ".png"))
                                                                                                                                                                : targetTextureFileName;

                    temp.Save(targetMipTextureFileName, ImageUtility.ImageFile.FILE_FORMAT.PNG);
//                  System.IO.FileInfo	targetMipTextureFileName = new System.IO.FileInfo( System.IO.Path.Combine( fullTargetDirectory.FullName, texture.Name + ".tif" ) );
//                  temp.Save( targetMipTextureFileName, ImageUtility.ImageFile.FILE_FORMAT.TIFF );

                    // Generate or read meta file
                    string GUID = GenerateMeta(targetMipTextureFileName, checkBoxGenerateMeta.Checked, checkBoxOverwriteExistingMeta.Checked, sRGB, isNormalMap, isIOR, isArray);
                    if (mipIndex == 0)
                    {
                        GUIDs[textureIndex] = GUID;
                        allGUIDsValid      &= GUID != null;
                    }
                }
//*/
            }

            if (!checkBoxGenerateMat.Checked)
            {
                return;
            }
            if (!allGUIDsValid)
            {
                throw new Exception("Not all texture GUIDs are valid! Can't generate material file!");
            }

            GenerateMaterial(_material, _targetDirectory, textureTypes, GUIDs);
        }