Esempio n. 1
0
        private static bool skyToGUI(Texture skyCube, bool skyHDR, mset.SHEncoding skySH, mset.CubemapGUI cubeGUI, string skyName, bool updatePreview)
        {
            bool dirty    = false;
            bool dirtyGUI = false;

            //sky -> cubeGUI
            dirtyGUI       |= cubeGUI.HDR != skyHDR;
            cubeGUI.HDR     = skyHDR;
            cubeGUI.skyName = skyName;

            RenderTexture RT = skyCube as RenderTexture;

            if (cubeGUI.input != skyCube)
            {
                if (RT)
                {
                    cubeGUI.setReference(RT, RT.useMipMap);
                }
                else if (skyCube)
                {
                    string path = AssetDatabase.GetAssetPath(skyCube);
                    cubeGUI.setReference(path, cubeGUI.mipmapped);
                }
                else
                {
                    cubeGUI.clear();
                }
                //dirty = true;
            }

            if (RT && skySH != null)
            {
                if (cubeGUI.SH != null && !skySH.equals(cubeGUI.SH))
                {
                    cubeGUI.SH.copyFrom(skySH);
                    cubeGUI.SH.copyToBuffer();
                    //dirty = true;
                }
            }

            if (dirtyGUI && updatePreview)
            {
                cubeGUI.updatePreview();
            }
            return(dirty);
        }
Esempio n. 2
0
        private static bool GUIToSky(ref Texture skyCube, ref bool skyHDR, mset.SHEncoding skySH, mset.CubemapGUI cubeGUI)
        {
            //cubeGUI -> sky
            bool    prevHDR   = cubeGUI.HDR;
            Texture prevInput = cubeGUI.input;

            cubeGUI.drawGUI();

            skyCube = cubeGUI.input;
            skyHDR  = cubeGUI.HDR;

            bool dirty = false;


            //copy spherical harmonics if they've changed
            if (cubeGUI.computeSH)
            {
                if (skySH != null)
                {
                    if (cubeGUI.SH == null)
                    {
                        skySH.clearToBlack();
                        dirty = true;
                    }
                    else if (!skySH.equals(cubeGUI.SH))
                    {
                        skySH.copyFrom(cubeGUI.SH);
                        dirty = true;
                    }
                    skySH.copyToBuffer();
                }
            }


            //return true if the cubeGUI gui changed any parameters
            dirty |= prevHDR != cubeGUI.HDR;
            dirty |= prevInput != cubeGUI.input;
            return(dirty);
        }