コード例 #1
0
        public static void CreateSH9AssetFromCubeMapAsync(Cubemap cubemap)
        {
            var proj = new SH9Project();
            var req  = proj.FromCubeMapAsync(cubemap, (shc) => {
                var cubePath     = AssetDatabase.GetAssetPath(cubemap);
                var shcAssetPath = cubePath + "_shc.asset";
                var shcAsset     = AssetDatabase.LoadAssetAtPath <SHCAssetObject>(shcAssetPath);
                if (!shcAsset)
                {
                    shcAsset = SHCAssetObject.CreateInstance <SHCAssetObject>();
                    AssetDatabase.CreateAsset(shcAsset, shcAssetPath);
                }
                shcAsset.parameters = shc;
                EditorUtility.SetDirty(shcAsset);
                AssetDatabase.SaveAssets();
            });

            System.Action callUpdate = null;
            callUpdate = () => {
                EditorApplication.delayCall += () => {
                    req.Update();
                    if (!req.done)
                    {
                        callUpdate();
                    }
                };
            };
            callUpdate();
        }
コード例 #2
0
        /// <summary>
        /// 从SH9重建CubeMap
        /// </summary>
        public static void ReconstructCubemapFromSH9(SHCAssetObject sh9)
        {
            var sh9Array = sh9.parameters;
            var rec      = new SH9Reconstruct();
            var req      = rec.CreateTextureAsync(sh9Array, (rt) => {
                var path = AssetDatabase.GetAssetPath(sh9) + ".jpg";
                SaveRenderTextureTo(rt, path);
                Debug.Log("save file to " + path);
            });

            UpdateGPUAsyncRequest(req);
        }
コード例 #3
0
        public static void ReconstructCubemapFromSelectedSH9()
        {
            SHCAssetObject sh9 = null;

            foreach (var o in Selection.objects)
            {
                if (o is SHCAssetObject c)
                {
                    sh9 = c;
                    break;
                }
            }
            if (!sh9)
            {
                return;
            }
            ReconstructCubemapFromSH9(sh9);
        }