Пример #1
0
 void OnEnable()
 {
     titleContent = new GUIContent("Bake Cubemap Textures");
     imageFormat  = (BabylonImageFormat)ExporterWindow.exportationOptions.ImageEncodingOptions;
     if (convertCube == null && Selection.activeObject is Cubemap)
     {
         convertCube = Selection.activeObject as Cubemap;
     }
 }
Пример #2
0
 void OnEnable()
 {
     titleContent       = new GUIContent("Texture Atlas Skin");
     textureAtlasShader = Shader.Find("BabylonJS/System/Standard Material");
     textureAtlasFormat = (BabylonImageFormat)ExporterWindow.exportationOptions.ImageEncodingOptions;
     if (skinMeshRenderer == null && Selection.activeObject is SkinnedMeshRenderer)
     {
         skinMeshRenderer = Selection.activeObject as SkinnedMeshRenderer;
     }
 }
Пример #3
0
 public static bool WriteImage(this Texture2D source, string filename, BabylonImageFormat format)
 {
     if (format == BabylonImageFormat.PNG)
     {
         return(source.WriteImagePNG(filename));
     }
     else
     {
         return(source.WriteImageJPG(filename));
     }
 }
Пример #4
0
 public void OnGUI()
 {
     // Update texture atlas window
     EditorGUILayout.Space();
     skinMeshRenderer = EditorGUILayout.ObjectField("Skin Mesh Renderer:", skinMeshRenderer, typeof(SkinnedMeshRenderer), true) as SkinnedMeshRenderer;
     EditorGUILayout.Space();
     bakeTextureMaps = EditorGUILayout.Toggle("Bake Texture Maps:", bakeTextureMaps);
     EditorGUILayout.Space();
     bakeAlphaEncoding = EditorGUILayout.Toggle("Bake Image Alpha:", bakeAlphaEncoding);
     EditorGUILayout.Space();
     EditorGUI.BeginDisabledGroup(true);
     EditorGUI.EndDisabledGroup();
     textureAtlasSize = (int)EditorGUILayout.Slider("Texture Atlas Size:", textureAtlasSize, 128, 8192);
     EditorGUILayout.Space();
     EditorGUI.BeginDisabledGroup(true);
     textureAtlasShader = EditorGUILayout.ObjectField("Texture Atlas Shader:", textureAtlasShader, typeof(Shader), true) as Shader;
     EditorGUILayout.Space();
     textureAtlasFormat = (BabylonImageFormat)EditorGUILayout.EnumPopup("Texture Atlas Format:", textureAtlasFormat, GUILayout.ExpandWidth(true));
     EditorGUILayout.Space();
     EditorGUI.EndDisabledGroup();
     textureImageScaling = (BabylonTextureScale)EditorGUILayout.EnumPopup("Texture Image Scale:", textureImageScaling, GUILayout.ExpandWidth(true));
     EditorGUILayout.Space();
     maxTextureImageSize = (int)EditorGUILayout.Slider("Texture Image Max:", maxTextureImageSize, 0, 4096);
     EditorGUILayout.Space();
     linearInterpolation = EditorGUILayout.Toggle("Use Linear Interpolation:", linearInterpolation);
     EditorGUILayout.Space();
     updateSkinRenderer = EditorGUILayout.Toggle("Update Skin Renderers:", updateSkinRenderer);
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     if (GUILayout.Button("Bake Texture Atlas Skin"))
     {
         if (skinMeshRenderer)
         {
             Bake();
         }
         if (!skinMeshRenderer)
         {
             ExporterWindow.ShowMessage("You must select a skin mesh renderer");
         }
     }
 }
Пример #5
0
        public static bool WriteImage(this Texture2D source, string filename, BabylonImageFormat format)
        {
            bool result = false;

            if (source == null)
            {
                return(result);
            }
            FileStream file = new FileStream(filename, FileMode.Create, FileAccess.Write);

            try {
                byte[] bytes = null;
                if (format == BabylonImageFormat.PNG)
                {
                    bytes = source.EncodeToPNG();
                }
                else
                {
                    bytes = source.EncodeToJPG(ExporterWindow.exportationOptions.DefaultTextureQuality);
                }
                if (bytes != null)
                {
                    MemoryStream buffer = new MemoryStream(bytes);
                    buffer.Position = 0;
                    buffer.CopyTo(file, CopyToOptions.FlushFinal);
                    buffer.Close();
                    buffer.Dispose();
                    buffer = null;
                    bytes  = null;
                    result = File.Exists(filename);
                }
            } catch (Exception ex) {
                UnityEngine.Debug.LogException(ex);
            } finally {
                file.Close();
            }
            return(result);
        }
Пример #6
0
 public void OnGUI()
 {
     EditorGUILayout.Space();
     cubemapTool = (BabylonCubemapTool)EditorGUILayout.EnumPopup("Cubemap Texture Tool:", cubemapTool, GUILayout.ExpandWidth(true));
     EditorGUILayout.Space();
     if (cubemapTool == BabylonCubemapTool.PixelPerfectTools)
     {
         splitLabel = "Open Pixel Perfect";
         if (this.maxSize.y != 94.0f)
         {
             this.maxSize = new Vector2(500.0f, 94.0f);
             this.minSize = this.maxSize;
         }
     }
     else if (cubemapTool == BabylonCubemapTool.ReflectionProbes)
     {
         splitLabel = "Bake Reflection Probe";
         if (this.maxSize.y != 222.0f)
         {
             this.maxSize = new Vector2(500.0f, 222.0f);
             this.minSize = this.maxSize;
         }
     }
     else
     {
         splitLabel = "Bake Cubemap Faces";
         if (this.maxSize.y != 248.0f)
         {
             this.maxSize = new Vector2(500.0f, 248.0f);
             this.minSize = this.maxSize;
         }
     }
     if (cubemapTool == BabylonCubemapTool.CubemapSplitter || cubemapTool == BabylonCubemapTool.ReflectionProbes)
     {
         imageLibrary = (BabylonImageLibrary)EditorGUILayout.EnumPopup("Default Image Library:", imageLibrary, GUILayout.ExpandWidth(true));
         EditorGUILayout.Space();
         convertCube = EditorGUILayout.ObjectField("Source Cubemap Image:", convertCube, typeof(Cubemap), false) as Cubemap;
         EditorGUILayout.Space();
     }
     if (cubemapTool == BabylonCubemapTool.CubemapSplitter)
     {
         imageFormat = (BabylonImageFormat)EditorGUILayout.EnumPopup("Output Image Format:", imageFormat, GUILayout.ExpandWidth(true));
         EditorGUILayout.Space();
     }
     if (cubemapTool == BabylonCubemapTool.ReflectionProbes)
     {
         reflectionType = (BabylonProbeFormat)EditorGUILayout.EnumPopup("Reflection Probe Size:", reflectionType, GUILayout.ExpandWidth(true));
         EditorGUILayout.Space();
     }
     if (cubemapTool == BabylonCubemapTool.CubemapSplitter)
     {
         createSkyboxMaterial = EditorGUILayout.Toggle("Create Skybox Material:", createSkyboxMaterial);
         EditorGUILayout.Space();
     }
     keepGeneratorOpen = EditorGUILayout.Toggle("Keep Generator Open:", keepGeneratorOpen);
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     if (GUILayout.Button(splitLabel))
     {
         if (cubemapTool == BabylonCubemapTool.PixelPerfectTools)
         {
             bool   jpeg     = (imageFormat == BabylonImageFormat.JPEG);
             string splitter = (ExporterWindow.PixelPrefect + "?jpeg=" + jpeg.ToString().ToLower());
             Application.OpenURL(splitter);
             this.Close();
         }
         else
         {
             if (convertCube)
             {
                 Bake();
             }
             if (!convertCube)
             {
                 ExporterWindow.ShowMessage("You must select a cubemap");
             }
         }
     }
 }
Пример #7
0
 public void OnGUI()
 {
     splitLabel = "Bake Cubemap Textures";
     if (this.maxSize.y != 602f)
     {
         this.maxSize = new Vector2(500.0f, 602.0f);
         this.minSize = this.maxSize;
     }
     EditorGUILayout.Space();
     convertCube = EditorGUILayout.ObjectField("Source Cubemap Image:", convertCube, typeof(Cubemap), false) as Cubemap;
     EditorGUILayout.Space();
     generateSkybox = EditorGUILayout.Toggle("Create Skybox:", generateSkybox);
     EditorGUILayout.Space();
     EditorGUI.BeginDisabledGroup(generateSkybox == false);
     skyboxOption = (BabylonSkyboxOption)EditorGUILayout.EnumPopup("Skybox Option:", skyboxOption, GUILayout.ExpandWidth(true));
     EditorGUILayout.Space();
     if (skyboxOption == BabylonSkyboxOption.SixSidedCubemap)
     {
         skyboxSplitter = (BabylonImageFormat)EditorGUILayout.EnumPopup("Skybox Format:", skyboxSplitter, GUILayout.ExpandWidth(true));
         EditorGUILayout.Space();
     }
     else if (skyboxOption == BabylonSkyboxOption.DirectDrawSurface)
     {
         skyboxConverter = (BabylonFilterFormat)EditorGUILayout.EnumPopup("Skybox Format:", skyboxConverter, GUILayout.ExpandWidth(true));
         EditorGUILayout.Space();
     }
     EditorGUI.EndDisabledGroup();
     generateRadiance = EditorGUILayout.Toggle("Generate Radiance:", generateRadiance);
     EditorGUILayout.Space();
     EditorGUI.BeginDisabledGroup(generateRadiance == false);
     radianceSize = (BabylonReflectionProbe)EditorGUILayout.EnumPopup("Radiance Size:", radianceSize, GUILayout.ExpandWidth(true));
     EditorGUILayout.Space();
     excludeBase = EditorGUILayout.Toggle("Exclude Base:", excludeBase);
     EditorGUILayout.Space();
     glossScale = (int)EditorGUILayout.Slider("Gloss Scale", glossScale, 0, 20);
     EditorGUILayout.Space();
     gloassBias = (int)EditorGUILayout.Slider("Gloss Bias", gloassBias, 0, 10);
     EditorGUILayout.Space();
     EditorGUI.EndDisabledGroup();
     EditorGUILayout.LabelField(new GUIContent("Filtering Options"), EditorStyles.boldLabel);
     EditorGUILayout.Space();
     filterOutput = (BabylonCubemapFormat)EditorGUILayout.EnumPopup("Filter Output:", filterOutput, GUILayout.ExpandWidth(true));
     EditorGUILayout.Space();
     filterLighting = (BabylonCubemapLight)EditorGUILayout.EnumPopup("Filter Lighting:", filterLighting, GUILayout.ExpandWidth(true));
     EditorGUILayout.Space();
     EditorGUILayout.LabelField(new GUIContent("Processing Options"), EditorStyles.boldLabel);
     EditorGUILayout.Space();
     inputGammaNumerator = (float)EditorGUILayout.Slider("Input Numerator", inputGammaNumerator, 0.0f, 10.0f);
     EditorGUILayout.Space();
     inputGammaDenominator = (float)EditorGUILayout.Slider("Input Denominator", inputGammaDenominator, 0.0f, 10.0f);
     EditorGUILayout.Space();
     outputGammaNumerator = (float)EditorGUILayout.Slider("Output Numerator", outputGammaNumerator, 0.0f, 10.0f);
     EditorGUILayout.Space();
     outputGammaDenominator = (float)EditorGUILayout.Slider("Output Denominator", outputGammaDenominator, 0.0f, 10.0f);
     EditorGUILayout.Space();
     numberOfCpus = (int)EditorGUILayout.Slider("Number Of Processors", numberOfCpus, 1, 32);
     EditorGUILayout.Space();
     EditorGUI.BeginDisabledGroup(generateSkybox == false);
     createSkyboxMaterial = EditorGUILayout.Toggle("Create Skybox Material:", createSkyboxMaterial);
     EditorGUILayout.Space();
     EditorGUI.EndDisabledGroup();
     keepGeneratorOpen = EditorGUILayout.Toggle("Keep Generator Open:", keepGeneratorOpen);
     EditorGUILayout.Space();
     if (GUILayout.Button(splitLabel))
     {
         if (convertCube)
         {
             Bake();
         }
         if (!convertCube)
         {
             ExporterWindow.ShowMessage("You must select a cubemap");
         }
     }
 }