Example #1
0
 public static void detectColorSpace(ref Sky sky)
 {
     sky.linearSpace = PlayerSettings.colorSpace == ColorSpace.Linear;
     #if UNITY_IPHONE || UNITY_ANDROID
         sky.linearSpace = false; // no sRGB on mobile
     #endif
 }
Example #2
0
    private static void copySky(mset.Sky dest, mset.Sky src)
    {
        dest.diffuseCube  = src.diffuseCube;
        dest.specularCube = src.specularCube;
        dest.skyboxCube   = src.skyboxCube;

        dest.masterIntensity = src.masterIntensity;
        dest.skyIntensity    = src.skyIntensity;
        dest.specIntensity   = src.specIntensity;
        dest.diffIntensity   = src.diffIntensity;
        dest.camExposure     = src.camExposure;

        dest.specIntensityLM = src.specIntensityLM;
        dest.diffIntensityLM = src.diffIntensityLM;

        dest.hdrSky  = src.hdrSky;
        dest.hdrSpec = src.hdrSpec;
        dest.hdrDiff = src.hdrDiff;

        dest.showSkybox           = src.showSkybox;
        dest.linearSpace          = src.linearSpace;
        dest.autoDetectColorSpace = src.autoDetectColorSpace;         //for inspector use
        dest.hasDimensions        = src.hasDimensions;
        dest.autoApply            = src.autoApply;

        if (src.SH != null)
        {
            if (dest.SH == null)
            {
                dest.SH = new mset.SHEncoding();
            }
            dest.SH.copyFrom(src.SH);
        }
    }
Example #3
0
 public static void detectColorSpace(ref mset.Sky sky)
 {
     sky.LinearSpace = PlayerSettings.colorSpace == ColorSpace.Linear;
                 #if UNITY_IPHONE || UNITY_ANDROID
     sky.LinearSpace = false;                     // no sRGB on mobile
                 #endif
 }
Example #4
0
        public static void generateSH(ref mset.Sky sky)
        {
            if (sky.SH == null)
            {
                sky.SH = new mset.SHEncoding();
            }

            skyToGUI(ref sky.skyboxCube, ref sky.hdrSky, refSKY, false);
            skyToGUI(ref sky.diffuseCube, ref sky.hdrDiff, refDIM, false);
            skyToGUI(ref sky.specularCube, ref sky.hdrSpec, refSIM, false);

            if (refSIM.cube != null)
            {
                refSIM.projectToSH(ref sky.SH);
                mset.SHUtil.convolve(ref sky.SH);
            }
            else if (refDIM.cube != null)
            {
                refDIM.projectToSH(ref sky.SH);
            }
            else if (refSKY.cube != null)
            {
                refSKY.projectToSH(ref sky.SH);
                mset.SHUtil.convolve(ref sky.SH);
            }

            if (sky.SH != null)
            {
                sky.SH.copyToBuffer();
            }
        }
Example #5
0
    // Update is called once per frame
    void Update()
    {
        mset.SkyManager manager = mset.SkyManager.Get();
        if (manager && manager.GlobalSky)
        {
            mset.Sky globalSky = manager.GlobalSky;

            if (Input.GetKeyDown(KeyCode.S))
            {
                spinning = !spinning;
            }

            if (Input.GetKeyDown(KeyCode.Equals) || Input.GetKeyDown(KeyCode.KeypadEquals))
            {
                targetExposure = Mathf.Min(targetExposure + 0.2f, 2f);
            }
            if (Input.GetKeyDown(KeyCode.Minus) || Input.GetKeyDown(KeyCode.KeypadMinus))
            {
                targetExposure = Mathf.Max(0.05f, targetExposure - 0.2f);
            }

            if (Mathf.Abs(globalSky.CamExposure - targetExposure) > 0.01f)
            {
                globalSky.CamExposure = 0.95f * globalSky.CamExposure + 0.05f * targetExposure;
            }
            else
            {
                globalSky.CamExposure = targetExposure;
            }
        }
    }
Example #6
0
    public static mset.Sky addSky()
    {
        GameObject go = new GameObject("Sky");

        go.AddComponent <mset.Sky>();
        go.name = "Sky";
        Selection.activeGameObject = go;
        mset.Sky sky = go.GetComponent <mset.Sky>();
        mset.Util.RegisterCreatedObjectUndo(go, "Add Sky");
        return(sky);
    }
Example #7
0
        public void OnEnable()
        {
            mset.Sky sky = target as mset.Sky;
            if (sky.SH == null)
            {
                sky.SH = new mset.SHEncoding();
            }
            if (sky.CustomSH != null)
            {
                sky.SH.copyFrom(sky.CustomSH.SH);
            }
            sky.SH.copyToBuffer();

            camExposure     = sky.CamExposure;
            masterIntensity = sky.MasterIntensity;
            skyIntensity    = sky.SkyIntensity;
            diffIntensity   = sky.DiffIntensity;
            specIntensity   = sky.SpecIntensity;
            diffIntensityLM = sky.DiffIntensityLM;
            specIntensityLM = sky.SpecIntensityLM;

            refSKY.HDR = sky.HDRSky;
            refSIM.HDR = sky.HDRSpec;

            refSKY.sky = sky;
            refSIM.sky = sky;

            if (sky.HasDimensions)
            {
                projCenter = sky.Dimensions.center;
            }
            else
            {
                projCenter = sky.transform.position;
            }

            mset.SkyApplicator app = sky.gameObject.GetComponent <mset.SkyApplicator>();
            if (app)
            {
                appCenter = app.TriggerDimensions.center;
            }
            else
            {
                appCenter = sky.transform.position;
            }
            //forceDirty = true;
        }
Example #8
0
 //for the sake of the apply to selection buttons...
 private void OnSelectionChange()
 {
     mset.BeastConfig.RefreshConfig();
     uiSelectedSky = null;
     if (Selection.activeGameObject)
     {
         uiSelectedSky = Selection.activeGameObject.GetComponent <mset.Sky>();
     }
     if (Selection.GetFiltered(typeof(Light), SelectionMode.Deep).Length > 0)
     {
         repaintOften = true;
     }
     else
     {
         repaintOften = false;
     }
     this.Repaint();
 }
Example #9
0
        public void OnEnable()
        {
            mset.Sky sky = target as mset.Sky;

            camExposure     = sky.camExposure;
            masterIntensity = sky.masterIntensity;
            skyIntensity    = sky.skyIntensity;
            diffIntensity   = sky.diffIntensity;
            specIntensity   = sky.specIntensity;
            diffIntensityLM = sky.diffIntensityLM;
            specIntensityLM = sky.specIntensityLM;

            refSKY.HDR = sky.hdrSky;
            refSIM.HDR = sky.hdrSpec;
            refDIM.HDR = sky.hdrDiff;

            //forceDirty = true;
        }
Example #10
0
    public static mset.Sky addSky(string name)
    {
        if (name.Length == 0)
        {
            name = "Sky";
        }
        GameObject go = new GameObject(name);

        if (Camera.current)
        {
            go.transform.position = Camera.current.transform.position + Camera.current.transform.forward * 10f;
        }
        go.AddComponent <mset.Sky>();
        go.name = name;
        Selection.activeGameObject = go;
        mset.Sky sky = go.GetComponent <mset.Sky>();
        mset.EditorUtil.RegisterCreatedObjectUndo(go, "Add Sky");
        return(sky);
    }
Example #11
0
    public static void UpgradeSkies()
    {
        Component[] all = GameObject.FindObjectsOfType(typeof(Transform)) as Component[];
        mset.Util.RegisterUndo(all as UnityEngine.Object[], "Upgrade Skies");

        //Create a dummy game object, add a namespaced Sky to it, find its serialized script type
        GameObject refObj = new GameObject("_dummy_sky");

        mset.Sky           refSky     = refObj.AddComponent <mset.Sky>();
        SerializedObject   refSr      = new SerializedObject(refSky);
        SerializedProperty scriptType = refSr.FindProperty("m_Script");

        int count = 0;

        //Find all old sky objects, swap out the Sky script references to mset.Sky
        for (int i = 0; i < all.Length; ++i)
        {
            GameObject obj = all[i].gameObject;
            if (obj)
            {
                Sky old = obj.GetComponent <Sky>() as Sky;
                if (old != null)
                {
                    SerializedObject sr = new SerializedObject(old);
                    sr.CopyFromSerializedProperty(scriptType);
                    sr.ApplyModifiedProperties();
                    count++;
                }
            }
        }

        if (count == 0)
        {
            EditorUtility.DisplayDialog("Done Upgrading!", "No deprecated skies found.\n\nPro Tip: Don't forget to use the \"mset\" namespace when scripting with the Sky class.", "Ok");
        }
        else
        {
            EditorUtility.DisplayDialog("Done Upgrading!", count + " deprecated skies found and upgraded.\n\nPro Tip: Don't forget to use the \"mset\" namespace when scripting with the Sky class.", "Ok");
        }

        Component.DestroyImmediate(refObj);
    }
Example #12
0
        public static void generateSH(ref mset.Sky sky)
        {
            skyToGUI(sky.SkyboxCube, sky.HDRSky, null, refSKY, sky.name, false);
            skyToGUI(sky.SpecularCube, sky.HDRSpec, null, refSIM, sky.name, false);

            if (refSIM.computeSH)
            {
                if (refSIM.cube != null)
                {
                    refSIM.update();
                    //refSIM.updateBuffers(); //Slow. Surely this is done after every change?
                    sky.SH.copyFrom(refSIM.SH);
                    mset.SHUtil.convolve(ref sky.SH);
                }

                if (sky.SH != null)
                {
                    sky.SH.copyToBuffer();
                }
            }
        }
Example #13
0
    public static void CreatePrefab()
    {
        //recreate the sky component with an old-school copy constructor, this fixes some kind of serialized bug in old skies
        for (int i = 0; i < Selection.gameObjects.Length; ++i)
        {
            GameObject go = Selection.gameObjects[i];
            if (go == null || !go.activeInHierarchy || go.GetComponent <mset.Sky>() == null)
            {
                continue;
            }

            string path = AssetDatabase.GenerateUniqueAssetPath("Assets/" + go.name + ".prefab");

            //create an unconnected prefab
            GameObject prefab = PrefabUtility.CreatePrefab(path, go);
            if (prefab == null)
            {
                Debug.LogError("Failed to create prefab sky \"" + path + "\"");
                continue;
            }

            //delete its sky
            mset.Sky oldSky = prefab.GetComponent <mset.Sky>();
            GameObject.DestroyImmediate(oldSky, true);

            //add a new sky and copy contents manually
            mset.Sky srcSky = go.GetComponent <mset.Sky>();
            mset.Sky newSky = prefab.AddComponent <mset.Sky>();
            if (newSky != null)
            {
                copySky(newSky, srcSky);
            }
            else
            {
                Debug.LogError("Failed to re-add Sky component to prefab \"" + path + "\"");
            }
        }
    }
Example #14
0
    public static void RefreshSkies()
    {
        mset.Sky[] skies   = UnityEngine.Object.FindObjectsOfType(typeof(mset.Sky)) as mset.Sky[];
        mset.Sky   currSky = mset.Sky.activeSky;

        if (skies.Length > 0)
        {
            Debug.Log("Refreshing " + skies.Length + " skies");
            mset.Util.RegisterUndo(skies as UnityEngine.Object[], "Refresh Skies");
            for (int i = 0; i < skies.Length; ++i)
            {
                if (skies[i] != null)
                {
                    mset.SkyInspector.detectColorSpace(ref skies[i]);
                    mset.SkyInspector.generateSH(ref skies[i]);
                    skies[i].Apply();
                }
            }
            if (currSky)
            {
                currSky.Apply();
            }
        }
    }
Example #15
0
 //for the sake of the apply to selection buttons...
 private void OnSelectionChange()
 {
     mset.BeastConfig.RefreshConfig();
     uiSelectedSky = null;
     if( Selection.activeGameObject ) {
         uiSelectedSky = Selection.activeGameObject.GetComponent<mset.Sky>();
     }
     if( Selection.GetFiltered(typeof(Light),SelectionMode.Deep).Length > 0 ) {
         repaintOften = true;
     } else {
         repaintOften = false;
     }
     this.Repaint();
 }
Example #16
0
        public override void OnInspectorGUI()
        {
            GUI.changed = false;
            bool dirty    = false;              //flag for changed sky parameters
            bool dirtyRef = false;              //flag for changed sky cubemap references (causes SH recompute and preview refresh)

            mset.Sky           sky    = target as mset.Sky;
            mset.SkyApplicator app    = sky.gameObject.GetComponent <mset.SkyApplicator>();
            mset.SkyManager    skymgr = mset.SkyManager.Get();

            //sync GUI from sky
            camExposure     = sky.CamExposure;
            masterIntensity = sky.MasterIntensity;
            skyIntensity    = sky.SkyIntensity;
            diffIntensity   = sky.DiffIntensity;
            specIntensity   = sky.SpecIntensity;
            diffIntensityLM = sky.DiffIntensityLM;
            specIntensityLM = sky.SpecIntensityLM;

            //sync and sync from CubeGUIs
            refSIM.computeSH = (sky.CustomSH == null);

            dirtyRef |= skyToGUI(sky.SkyboxCube, sky.HDRSky, sky.SH, refSKY, sky.name, true);
            bool    prevHDR = sky.HDRSky;
            bool    currHDR = sky.HDRSky;
            Texture refCube = sky.SkyboxCube;

            dirtyRef |= GUIToSky(ref refCube, ref currHDR, null, refSKY);
            if (refCube != sky.SkyboxCube)
            {
                sky.SkyboxCube = refCube;
            }
            if (currHDR != prevHDR)
            {
                sky.HDRSky = currHDR;
            }

            dirtyRef |= skyToGUI(sky.SpecularCube, sky.HDRSpec, sky.SH, refSIM, sky.name, true);
            prevHDR   = sky.HDRSpec;
            currHDR   = sky.HDRSpec;
            refCube   = sky.SpecularCube;
            dirtyRef |= GUIToSky(ref refCube, ref currHDR, sky.SH, refSIM);
            if (refCube != sky.SpecularCube)
            {
                sky.SpecularCube = refCube;
            }
            if (currHDR != prevHDR)
            {
                sky.HDRSpec = currHDR;
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();

            string ashTip = "Accepts custom diffuse irradiance .asset files generated in other software (such as Knald Lys: www.knaldtech.com)\n\nWill override diffuse light generated from the specular cubemap.";

            EditorGUILayout.LabelField(new GUIContent("Custom Diffuse SH (Optional)", ashTip), GUILayout.Width(248));
            if (GUILayout.Button("None", GUILayout.Width(50), GUILayout.Height(14)))
            {
                sky.CustomSH     = null;
                refSIM.computeSH = true;
                refSIM.reloadReference();
            }
            EditorGUILayout.EndHorizontal();

            sky.CustomSH = EditorGUILayout.ObjectField(sky.CustomSH, typeof(mset.SHEncodingFile), false, GUILayout.Width(320)) as mset.SHEncodingFile;
            if (sky.CustomSH != null)
            {
                sky.SH.copyFrom(sky.CustomSH.SH);
                sky.SH.copyToBuffer();
            }
            refSIM.computeSH = (sky.CustomSH == null);

            GUIStyle buttonStyle = new GUIStyle("Button");

            buttonStyle.padding.top  = buttonStyle.padding.bottom = 0;
            buttonStyle.padding.left = buttonStyle.padding.right = 0;

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            //Global button
            if (skymgr != null)
            {
                bool alreadyGlobal = skymgr.GlobalSky == sky;
                EditorGUI.BeginDisabledGroup(alreadyGlobal);
                bool setAsGlobal = GUILayout.Button(new GUIContent("Make Global Sky", "Sets this sky as the global sky in the Sky Manager."), GUILayout.Width(120));
                if (setAsGlobal)
                {
                    skymgr.GlobalSky = sky;
                    SceneView.RepaintAll();
                }
                EditorGUI.EndDisabledGroup();
            }
            //Local Apply button
            EditorGUI.BeginDisabledGroup(app == null || !app.TriggerIsActive);
            string trigTip = "Applies this sky locally only to renderers contained within its Sky Applicator trigger volume.";

            if (app == null || !app.TriggerIsActive)
            {
                trigTip = "Requires Sky Applicator component with active trigger.";
            }

            if (GUILayout.Button(new GUIContent("Preview Apply", trigTip), GUILayout.Width(100)))
            {
                Renderer[] all = GameObject.FindObjectsOfType <Renderer>();
                foreach (Renderer r in all)
                {
                    app.ApplyInside(r);
                }
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();

            //color detection is always on, but still required for LDR skies to function

            /*bool detect = EditorGUILayout.Toggle(new GUIContent("Auto-Detect Color Space","If enabled, attempts to detect the project's gamma correction setting and enables/disables the Linear Space option accordingly"), sky.AutoDetectColorSpace);
             * if( detect != sky.AutoDetectColorSpace ) {
             *      mset.EditorUtil.RegisterUndo(sky, "Color-Space Detection Change");
             *      sky.AutoDetectColorSpace = detect;
             * }
             * bool prevLinear = sky.LinearSpace;
             */

            sky.AutoDetectColorSpace = true;
            if (sky.AutoDetectColorSpace)
            {
                detectColorSpace(ref sky);
            }


            /*
             * EditorGUI.BeginDisabledGroup(sky.AutoDetectColorSpace);
             *      bool userLinearSpace = EditorGUILayout.Toggle(new GUIContent("Linear Space","Enable if gamma correction is enabled for this project (Edit -> Project Settings -> Player -> Color Space: Linear)"), sky.LinearSpace);
             *      if( userLinearSpace != sky.LinearSpace ) {
             *              mset.EditorUtil.RegisterUndo(sky, "Color-Space Change");
             *              sky.LinearSpace = userLinearSpace;
             *      }
             * EditorGUI.EndDisabledGroup();
             * if( prevLinear != sky.LinearSpace ){
             * //	dirty = true;
             * }
             */

            sky.IsProbe = EditorGUILayout.Toggle(new GUIContent("Is Probe", "Enable if this sky has been rendered from within the scene. The \"Probe All Skies\" feature will only process skies marked as probes."), sky.IsProbe);

            bool prevProj = sky.HasDimensions;
            bool boxProj  = EditorGUILayout.Toggle(new GUIContent("Box Projected", "Assign box dimensions to this sky for parallaxed specular reflection."), sky.HasDimensions);

            if (boxProj != prevProj)
            {
                mset.EditorUtil.RegisterUndo(sky, "Box Projection Toggle");
                sky.HasDimensions = boxProj;
            }

            EditorGUILayout.BeginHorizontal();
            if (skymgr != null)
            {
                skymgr.ProbeOnlyStatic = EditorGUILayout.Toggle(new GUIContent("Probe Only Static Objects", ""), skymgr.ProbeOnlyStatic);
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.LabelField("(Global Setting)", GUILayout.Width(320));
                EditorGUI.EndDisabledGroup();
            }
            else
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.Toggle(new GUIContent("Probe Only Static Objects", "Requires a Sky Manager object to be present in the scene."), false);
                EditorGUILayout.LabelField("(Missing Sky Manager in scene)", GUILayout.Width(320));
                EditorGUI.EndDisabledGroup();
            }
            EditorGUILayout.EndHorizontal();

            bool hasTrigger = app && app.TriggerIsActive;

            EditMode prevMode = editMode;

            EditorGUILayout.Space();
            Bounds dim = sky.Dimensions;

            dim.center     = EditorGUILayout.Vector3Field("Projector Center", dim.center);
            dim.size       = EditorGUILayout.Vector3Field("Projector Size", dim.size);
            sky.Dimensions = dim;

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            GUIStyle style = new GUIStyle();

            style.richText = true;
            GUILayout.Label("<b>Viewport Edit Mode</b>", style);

            if (editIconListFull == null)
            {
                editIconListFull = new Texture2D[] {
                    Resources.Load <Texture2D>("editTrans"),
                    Resources.Load <Texture2D>("editProbe"),
                    Resources.Load <Texture2D>("editProjection"),
                    Resources.Load <Texture2D>("editTrigger")
                };

                editIconListAdd = new Texture2D[] {
                    editIconListFull[0],
                    editIconListFull[1],
                    Resources.Load <Texture2D>("addProjection"),
                    Resources.Load <Texture2D>("addTrigger")
                };

                editIconListProj = new Texture2D[] {
                    editIconListFull[0],
                    editIconListFull[1],
                    editIconListFull[2],
                    editIconListAdd[3]                     //no trigger
                };

                editIconListTrigger = new Texture2D[] {
                    editIconListFull[0],
                    editIconListFull[1],
                    editIconListAdd[2],                     //no projection
                    editIconListFull[3]
                };
            }

            int barWidth = 340;

            //reset edit mode if we've lost the tools we need for this sky configuration
            if (editMode == EditMode.PROJECTOR && !boxProj)
            {
                editMode = EditMode.TRANSFORM;
            }
            if (editMode == EditMode.TRIGGER && !hasTrigger)
            {
                editMode = EditMode.TRANSFORM;
            }

            if (hasTrigger && boxProj)
            {
                editMode = (EditMode)GUILayout.Toolbar((int)editMode, editIconListFull, GUILayout.Width(barWidth));
            }
            else if (boxProj)
            {
                editMode = (EditMode)GUILayout.Toolbar((int)editMode, editIconListProj, GUILayout.Width(barWidth));
            }
            else if (hasTrigger)
            {
                editMode = (EditMode)GUILayout.Toolbar((int)editMode, editIconListTrigger, GUILayout.Width(barWidth));
            }
            else
            {
                editMode = (EditMode)GUILayout.Toolbar((int)editMode, editIconListAdd, GUILayout.Width(barWidth));
            }

            if (!boxProj && editMode == EditMode.PROJECTOR)
            {
                boxProj           = true;
                sky.HasDimensions = true;
                editMode          = EditMode.PROJECTOR;
            }

            if (!hasTrigger && editMode == EditMode.TRIGGER)
            {
                hasTrigger = true;
                if (!app)
                {
                    app = sky.gameObject.AddComponent <mset.SkyApplicator>();
                }
                app.TriggerIsActive = true;
            }

            EditorGUILayout.BeginHorizontal(GUILayout.Width(barWidth));
            GUILayout.Label("Transform", GUILayout.Width(82));
            GUILayout.Label("Probe Origin", GUILayout.Width(82));
            if (boxProj)
            {
                GUILayout.Label("Projector", GUILayout.Width(86));
            }
            else
            {
                GUILayout.Label("Add Projector", GUILayout.Width(86));
            }
            if (hasTrigger)
            {
                GUILayout.Label("Trigger", GUILayout.Width(60));
            }
            else
            {
                GUILayout.Label("Add Trigger", GUILayout.Width(80));
            }
            EditorGUILayout.EndHorizontal();

            //edit mode has changed, sync or sync from stored bound centers
            if (prevMode != editMode)
            {
                projCenter = sky.transform.localToWorldMatrix.MultiplyPoint(sky.Dimensions.center);
                if (app)
                {
                    appCenter = sky.transform.localToWorldMatrix.MultiplyPoint(app.TriggerDimensions.center);
                }
                else
                {
                    appCenter = sky.transform.position;
                }
            }
            //turn on applicator resize handle drawing
            mset.SkyApplicatorInspector.triggerEdit = editMode == EditMode.TRIGGER;

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            //sync sky from GUI
            EditorGUILayout.LabelField(new GUIContent("Master Intensity", "Multiplier on the Sky, Diffuse, and Specular cube intensities"));
            masterIntensity = EditorGUILayout.Slider(masterIntensity, 0f, 10f);
            if (sky.MasterIntensity != masterIntensity)
            {
                mset.EditorUtil.RegisterUndo(sky, "Intensity Change");
                sky.MasterIntensity = masterIntensity;
            }

            EditorGUILayout.LabelField(new GUIContent("Skybox Intensity", "Brightness of the skybox"));
            skyIntensity = EditorGUILayout.Slider(skyIntensity, 0f, 10f);
            if (sky.SkyIntensity != skyIntensity)
            {
                mset.EditorUtil.RegisterUndo(sky, "Intensity Change");
                sky.SkyIntensity = skyIntensity;
            }

            EditorGUILayout.LabelField(new GUIContent("Diffuse Intensity", "Multiplier on the diffuse light put out by this sky"));
            diffIntensity = EditorGUILayout.Slider(diffIntensity, 0f, 10f);
            if (sky.DiffIntensity != diffIntensity)
            {
                mset.EditorUtil.RegisterUndo(sky, "Intensity Change");
                sky.DiffIntensity = diffIntensity;
            }

            EditorGUILayout.LabelField(new GUIContent("Specular Intensity", "Multiplier on the specular light put out by this sky"));
            specIntensity = EditorGUILayout.Slider(specIntensity, 0f, 10f);
            if (sky.SpecIntensity != specIntensity)
            {
                mset.EditorUtil.RegisterUndo(sky, "Intensity Change");
                sky.SpecIntensity = specIntensity;
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.LabelField(new GUIContent("Camera Exposure", "Multiplier on all light coming into the camera, including IBL, direct light, and glow maps"));
            camExposure = EditorGUILayout.Slider(camExposure, 0f, 10f);
            if (sky.CamExposure != camExposure)
            {
                mset.EditorUtil.RegisterUndo(sky, "Exposure Change");
                sky.CamExposure = camExposure;
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.LabelField(new GUIContent("Lightmapped Diffuse Multiplier", "Multiplier on the diffuse intensity for lightmapped surfaces"));
            diffIntensityLM = EditorGUILayout.Slider(diffIntensityLM, 0f, 1f);
            if (sky.DiffIntensityLM != diffIntensityLM)
            {
                mset.EditorUtil.RegisterUndo(sky, "Multiplier Change");
                sky.DiffIntensityLM = diffIntensityLM;
            }

            EditorGUILayout.LabelField(new GUIContent("Lightmapped Specular Multiplier", "Multiplier on the specular intensity for lightmapped surfaces"));
            specIntensityLM = EditorGUILayout.Slider(specIntensityLM, 0f, 1f);
            if (sky.SpecIntensityLM != specIntensityLM)
            {
                mset.EditorUtil.RegisterUndo(sky, "Multiplier Change");
                sky.SpecIntensityLM = specIntensityLM;
            }

            dirty |= GUI.changed;

            if (forceDirty)
            {
                refSKY.reloadReference();
                refSIM.reloadReference();

                dirtyRef   = true;
                forceDirty = false;
                dirty      = true;
                Repaint();
            }

            //guess input path
            if (dirtyRef)
            {
                string inPath = refSKY.fullPath;
                if (inPath.Length == 0)
                {
                    inPath = refSIM.fullPath;
                }
                if (inPath.Length > 0)
                {
                    int uscore = inPath.LastIndexOf("_");
                    if (uscore > -1)
                    {
                        inPath = inPath.Substring(0, uscore);
                    }
                    else
                    {
                        inPath = Path.GetDirectoryName(inPath) + "/" + Path.GetFileNameWithoutExtension(inPath);
                    }
                    refSKY.inputPath     =
                        refSIM.inputPath = inPath;
                }
                else
                {
                    refSKY.inputPath     =
                        refSIM.inputPath = "";
                }
                dirty = true;
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
            }

            //reapply and repaint with manager
            mset.SkyManager mgr = mset.SkyManager.Get();

            if (!Application.isPlaying)
            {
                if (dirty || mgr && mgr.GlobalSky)
                {
                    sky.EditorUpdate();
                    if (mgr)
                    {
                        mgr.EditorUpdate(true);
                        SceneView.RepaintAll();
                    }
                }
            }
        }
Example #17
0
        //	Vector3 dotPos;
        public void OnSceneGUI()
        {
            mset.Sky sky = target as mset.Sky;

            if (this.editMode == EditMode.TRIGGER)
            {
                return;
            }

            if (sky.HasDimensions)
            {
                Vector3 campos = Vector3.zero;
                if (Camera.current != null)
                {
                    campos = Camera.current.transform.position;
                }

                Vector3 skyScale = sky.transform.lossyScale;
                if (skyScale.x == 0)
                {
                    skyScale.x = 0.001f;
                }
                if (skyScale.y == 0)
                {
                    skyScale.y = 0.001f;
                }
                if (skyScale.z == 0)
                {
                    skyScale.z = 0.001f;
                }

                xscale = x2scale = sky.Dimensions.size.x * 0.5f * skyScale.x;
                yscale = y2scale = sky.Dimensions.size.y * 0.5f * skyScale.y;
                zscale = z2scale = sky.Dimensions.size.z * 0.5f * skyScale.z;

                if (this.editMode == EditMode.PROJECTOR)
                {
                    Handles.color = new Color(0.2f, 0.8f, 1f, 0.9f);
                    Vector3 dotpos;

                    Vector3 boxcenter = sky.transform.localToWorldMatrix.MultiplyPoint(sky.Dimensions.center);

                    dotpos = boxcenter + xscale * sky.transform.right;
                    dotpos = Handles.Slider(dotpos, sky.transform.right, (dotpos - campos).magnitude / 10.0f, Handles.ArrowHandleCap, 0.05f);
                    xscale = ((dotpos - boxcenter)).magnitude;

                    dotpos  = boxcenter + x2scale * -sky.transform.right;
                    dotpos  = Handles.Slider(dotpos, -sky.transform.right, (dotpos - campos).magnitude / 10.0f, Handles.ArrowHandleCap, 0.05f);
                    x2scale = ((dotpos - boxcenter)).magnitude;

                    dotpos = boxcenter + yscale * sky.transform.up;
                    dotpos = Handles.Slider(dotpos, sky.transform.up, (dotpos - campos).magnitude / 10.0f, Handles.ArrowHandleCap, 0.05f);
                    yscale = ((dotpos - boxcenter)).magnitude;

                    dotpos  = boxcenter + y2scale * -sky.transform.up;
                    dotpos  = Handles.Slider(dotpos, -sky.transform.up, (dotpos - campos).magnitude / 10.0f, Handles.ArrowHandleCap, 0.05f);
                    y2scale = ((dotpos - boxcenter)).magnitude;

                    dotpos = boxcenter + zscale * sky.transform.forward;
                    dotpos = Handles.Slider(dotpos, sky.transform.forward, (dotpos - campos).magnitude / 10.0f, Handles.ArrowHandleCap, 0.05f);
                    zscale = ((dotpos - boxcenter)).magnitude;

                    dotpos  = boxcenter + z2scale * -sky.transform.forward;
                    dotpos  = Handles.Slider(dotpos, -sky.transform.forward, (dotpos - campos).magnitude / 10.0f, Handles.ArrowHandleCap, 0.05f);
                    z2scale = ((dotpos - boxcenter)).magnitude;

                    float xposDiff = sky.Dimensions.size.x - (xscale / skyScale.x) * 2 - (sky.Dimensions.size.x - (x2scale / skyScale.x) * 2);
                    float yposDiff = sky.Dimensions.size.y - (yscale / skyScale.y) * 2 - (sky.Dimensions.size.y - (y2scale / skyScale.y) * 2);
                    float zposDiff = sky.Dimensions.size.z - (zscale / skyScale.z) * 2 - (sky.Dimensions.size.z - (z2scale / skyScale.z) * 2);

                    Bounds dim = sky.Dimensions;
                    dim.center += new Vector3(-xposDiff * 0.25f, -yposDiff * 0.25f, -zposDiff * 0.25f);
                    dim.size    = new Vector3((xscale + x2scale) / skyScale.x, (yscale + y2scale) / skyScale.y, (zscale + z2scale) / skyScale.z);

                    if (!dim.center.Equals(sky.Dimensions.center) || !dim.size.Equals(sky.Dimensions.size))
                    {
                        Undo.RecordObject(sky, "Sky Projection Resize");
                        sky.Dimensions = dim;
                        mset.SkyManager mgr = mset.SkyManager.Get();
                        if (mgr)
                        {
                            mgr.EditorUpdate(true);
                        }
                    }
                }
            }

            mset.SkyApplicator app = sky.gameObject.GetComponent <mset.SkyApplicator>();
            if (this.editMode == EditMode.PROBE)
            {
                //moving probe around, recompute local-space sky dimensions from world-space, cached centers
                Bounds dim = sky.Dimensions;
                dim.center = sky.transform.worldToLocalMatrix.MultiplyPoint(projCenter);

                if (dim.center != sky.Dimensions.center)
                {
                    if (app)
                    {
                        UnityEngine.Object[] undoList = { sky, app };
                        Undo.RecordObjects(undoList, "Probe Center Move");
                    }
                    else
                    {
                        Undo.RecordObject(sky, "Probe Center Move");
                    }
                }

                sky.Dimensions = dim;
                if (app)
                {
                    dim                   = app.TriggerDimensions;
                    dim.center            = sky.transform.worldToLocalMatrix.MultiplyPoint(appCenter);
                    app.TriggerDimensions = dim;
                }
            }
            else
            {
                //moving everything around, cache world-space centers of bounds
                projCenter = sky.transform.localToWorldMatrix.MultiplyPoint(sky.Dimensions.center);
                if (app)
                {
                    appCenter = sky.transform.localToWorldMatrix.MultiplyPoint(app.TriggerDimensions.center);
                }
                else
                {
                    appCenter = sky.transform.position;
                }
            }
        }
Example #18
0
    public static void RefreshSkies()
    {
        mset.Sky[] skies = UnityEngine.Object.FindObjectsOfType(typeof(mset.Sky)) as mset.Sky[];

        mset.SkyManager mgr = mset.SkyManager.Get();
        mset.Sky        currSky;
        if (mgr)
        {
            currSky = mgr.GlobalSky;
        }
        else
        {
            currSky = null;
        }

        if (skies.Length > 0)
        {
            Debug.Log("Refreshing " + skies.Length + " skies");
            mset.EditorUtil.RegisterUndo(skies as UnityEngine.Object[], "Refresh Skies");
            for (int i = 0; i < skies.Length; ++i)
            {
                mset.Sky sky = skies[i];
                if (sky != null)
                {
                    //If this sky is an instance of a prefab, edit the prefab itself.
                    UnityEngine.Object po   = PrefabUtility.GetPrefabParent(sky);
                    mset.Sky           psky = null;
                    if (po && PrefabUtility.GetPrefabType(po) != PrefabType.None)
                    {
                        GameObject pgo = po as GameObject;
                        psky = po as mset.Sky;
                        if (pgo)
                        {
                            Debug.Log("Updating prefab GameObject: " + pgo.name);
                            psky = pgo.GetComponent <mset.Sky>();
                        }
                        else if (psky)
                        {
                            Debug.Log("Updating prefab Sky " + psky.name);
                        }
                        else
                        {
                            Debug.Log("No Sky found in prefab instance " + sky.name);
                        }
                    }

                    if (psky)
                    {
                        if (psky.SpecularCube)
                        {
                            psky.SpecularCube.filterMode = FilterMode.Trilinear;
                        }
                        mset.SkyInspector.detectColorSpace(ref psky);
                        mset.SkyInspector.generateSH(ref psky);
                        PrefabUtility.ResetToPrefabState(sky);
                    }
                    else
                    {
                        mset.SkyInspector.detectColorSpace(ref sky);
                        mset.SkyInspector.generateSH(ref sky);
                    }
                    sky.Apply();
                }
            }
            if (currSky)
            {
                currSky.Apply();
            }
        }
    }
Example #19
0
        public override void OnInspectorGUI()
        {
            GUI.changed = false;

            mset.SkyManager skmgr = target as mset.SkyManager;
            mset.Sky        nusky = EditorGUILayout.ObjectField("Global Sky", skmgr.GlobalSky, typeof(mset.Sky), true) as mset.Sky;
            if (skmgr.GlobalSky != nusky)
            {
                //TODO: is this necessary?
                if (!Application.isPlaying && nusky != null)
                {
                    nusky.Apply();
                }
                if (nusky == null)
                {
                    RenderSettings.skybox = null;
                }
                skmgr.GlobalSky = nusky;
            }

            skmgr.ShowSkybox = GUILayout.Toggle(skmgr.ShowSkybox, new GUIContent("Show Skybox", "Toggles rendering the global sky's background image in both play and edit modes"));

            EditorGUILayout.Space();
            skmgr.ProjectionSupport = GUILayout.Toggle(skmgr.ProjectionSupport, new GUIContent("Box Projection Support", "Optimization for disabling all box projected cubemap distortion at the shader level"));
            skmgr.BlendingSupport   = GUILayout.Toggle(skmgr.BlendingSupport, new GUIContent("Blending Support", "Optimization for disabling blending transitions between skies at the shader level"));
            skmgr.LocalBlendTime    = EditorGUILayout.FloatField("Local Sky Blend Time", skmgr.LocalBlendTime);
            skmgr.GlobalBlendTime   = EditorGUILayout.FloatField("Global Sky Blend Time", skmgr.GlobalBlendTime);
            EditorGUILayout.Space();


            GUILayout.BeginHorizontal();
            skmgr.GameAutoApply = GUILayout.Toggle(skmgr.GameAutoApply, new GUIContent("Auto-Apply in Game", "If enabled for game mode, Sky Manager will keep and constantly update a list of dynamic renderers in the scene, applying local skies to them as they move around.\n\nRequired for dynamic sky binding and Sky Applicator triggers.\n\nNOTE: This feature causes material instances to be spawned at runtime and may hurt render batching."), GUILayout.Width(128));
            EditorGUI.BeginDisabledGroup(true);
            GUILayout.Label("(Creates material instances)");
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();

            skmgr.EditorAutoApply = GUILayout.Toggle(skmgr.EditorAutoApply, new GUIContent("Auto-Apply in Editor", "If enabled for edit mode, Sky Manager will apply local skies to renderers contained in their Sky Applicator trigger volumes.\n\nAffects editor viewport only."));
            skmgr.AutoMaterial    = GUILayout.Toggle(skmgr.AutoMaterial, new GUIContent("Dynamic Materials", "Periodically update the material caches in Sky Anchors. Enable if material lists of renderers are going to change at runtime (e.g. adding, removing, or replacing material references of renderers, property changes won't matter)."));

            //NOTE: The _ vars are stored in sky manager because they're part of the saved state. Pulling the list of layers from the bit mask instead of a full int array would sort the layer list every frame.
            skmgr._IgnoredLayerCount = EditorGUILayout.IntField("Ignored Layer Count", skmgr._IgnoredLayerCount);

            //if never allocated before, allocate ignoredLayers list here, it's only ever used here to display and configure the true hero: IgnoredLayerMask
            if (skmgr._IgnoredLayers == null)
            {
                skmgr._IgnoredLayers = new int[32];
            }

            skmgr.IgnoredLayerMask = 0;
            for (int i = 0; i < skmgr._IgnoredLayerCount; ++i)
            {
                skmgr._IgnoredLayers[i] = EditorGUILayout.LayerField(" ", skmgr._IgnoredLayers[i]);
                skmgr.IgnoredLayerMask |= 1 << skmgr._IgnoredLayers[i];
            }

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("Preview Auto-Apply", "Updates editor viewport to show an accurate representation of which renderers will be bound to which skies in the game.\n\nEditor Auto-Apply performs this every frame."), GUILayout.Width(140)))
            {
                skmgr.EditorUpdate(true);
                SceneView.RepaintAll();
            }
            GUILayout.EndHorizontal();


            EditorGUILayout.Space();

            string tipExponent = "Highest gloss exponent use in the specular mip chain when capturing probes. Other exponents in the chain are generated from this value.";

            skmgr.ProbeExponent = EditorGUILayout.IntField(new GUIContent("Probe Specular Exponent", tipExponent), skmgr.ProbeExponent);
            skmgr.ProbeExponent = Mathf.Max(1, skmgr.ProbeExponent);

            string staticTip = "If enabled, only GameObjects marked as \"Static\" will be rendered when capturing cubemaps.";

            skmgr.ProbeOnlyStatic = GUILayout.Toggle(skmgr.ProbeOnlyStatic, new GUIContent("Probe Only Static Objects", staticTip));

            string dx11Tip = "Uses HDR render-textures to capture sky probes faster and with better quality.\n\nRequires project to be in Direct3D 11 mode while capturing.";

            if (PlayerSettings.useDirect3D11)
            {
                skmgr.ProbeWithCubeRT = GUILayout.Toggle(skmgr.ProbeWithCubeRT, new GUIContent("Probe Using Render-to-Cubemap", dx11Tip));
            }
            else
            {
                EditorGUI.BeginDisabledGroup(true);
                GUILayout.Toggle(false, new GUIContent("Probe Using Render-to-Cubemap (Requires Direct3D11)", dx11Tip));
                EditorGUI.EndDisabledGroup();
            }

            string camTip = "Sky probing is performed using the settings and clipping planes of this camera. If field is empty, Main Camera is used.";

            skmgr.ProbeCamera = EditorGUILayout.ObjectField(new GUIContent("Probe with Camera", camTip), skmgr.ProbeCamera, typeof(Camera), true) as Camera;


            GUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("Probe Skies (Direct)"), GUILayout.Width(140)))
            {
                bool probeNonProbes = false;
                bool probeIBL       = false;
                Probeshop.ProbeSkies(null, GameObject.FindObjectsOfType <mset.Sky>(), probeNonProbes, probeIBL, null);
            }
            if (GUILayout.Button("Probe Skies (Direct+IBL)", GUILayout.Width(170)))
            {
                bool probeNonProbes = false;
                bool probeIBL       = true;
                Probeshop.ProbeSkies(null, GameObject.FindObjectsOfType <mset.Sky>(), probeNonProbes, probeIBL, null);
            }
            GUILayout.EndHorizontal();

            if (GUI.changed)
            {
                skmgr.EditorUpdate(true);
                EditorUtility.SetDirty(target);
                SceneView.RepaintAll();
            }
        }
Example #20
0
    ///
    public void OnGUI()
    {
        GUILayout.BeginArea(new Rect(0, 0, position.width, position.height));
        uiScroll = EditorGUILayout.BeginScrollView(uiScroll, false, false, GUILayout.MinWidth(300), GUILayout.MaxWidth(position.width));

        float rightPad     = 23;
        float minWidth     = 315;
        float sectionWidth = position.width - rightPad;
        float logoSize     = 128;

        Rect logoRect = EditorGUILayout.BeginVertical(); {
            GUILayout.Space(32);
            drawSkyshopLogo(sectionWidth - logoSize, logoRect.y, logoSize);
        } EditorGUILayout.EndVertical();

        uiHideDuringCompute = false;        //EditorGUILayout.Toggle("Hide UI During Compute",uiHideDuringCompute);
        if (!uiHideDuringCompute || !ps.isPlaying())
        {
            // INPUT REF
            EditorGUILayout.BeginVertical(); {
                inSKY.previewWidth = Mathf.Max(328, (int)sectionWidth - 2);
                inSKY.drawGUI();
                outSIM.inputPath = outSKY.inputPath = inSKY.fullPath;
            } EditorGUILayout.EndVertical();

            // OUTPUT REF
            EditorGUILayout.BeginVertical("HelpBox", GUILayout.Width(sectionWidth), GUILayout.MinWidth(minWidth)); {
                uiRefOptions = EditorGUILayout.Foldout(uiRefOptions, "Output Cubemaps");
                if (uiRefOptions)
                {
                    outSKY.drawGUI(); EditorGUILayout.Space();
                    outSIM.drawGUI(); EditorGUILayout.Space();

                    EditorGUILayout.BeginHorizontal(); {
                        string newTip = "Create a new cubemap assets for each output slot and adds them to the project.";
                        if (GUILayout.Button(new GUIContent("New All ", newTip), GUILayout.Width(70), GUILayout.Height(18)))
                        {
                            outSKY.newCube();
                            outSIM.newCube();
                        }
                        string findTip = "Search project for all existing output cubemaps by input panorama name.";
                        if (GUILayout.Button(new GUIContent("Find All", findTip), GUILayout.Width(70), GUILayout.Height(18)))
                        {
                            outSKY.find();
                            outSIM.find();
                        }
                        string clearTip = "Deselect all target cubemaps from output slots.";
                        if (GUILayout.Button(new GUIContent("Clear All", clearTip), GUILayout.Width(80), GUILayout.Height(18)))
                        {
                            outSKY.clear();
                            outSIM.clear();
                        }
                        string reloadTip = "Reload all input and output slot textures and generate preview images for them.";
                        EditorGUI.BeginDisabledGroup(outSKY.fullPath.Length == 0 && outSIM.fullPath.Length == 0 && inSKY.fullPath.Length == 0);
                        {
                            if (GUILayout.Button(new GUIContent("Reload All", reloadTip), GUILayout.Width(85), GUILayout.Height(18)))
                            {
                                outSKY.reloadReference();
                                outSIM.reloadReference();
                                inSKY.reloadReference();
                            }
                        }
                        EditorGUI.EndDisabledGroup();
                    } EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal(); {
                        string   editLabel = "";
                        string   editTip   = "";
                        mset.Sky editSky   = null;

                        if (uiSelectedSky)
                        {
                            editSky   = uiSelectedSky;
                            editLabel = "Edit Selected";
                            editTip   = "Select cubemaps from the selected Sky as output targets.";
                        }
                        else
                        {
                            mset.SkyManager mgr = mset.SkyManager.Get();
                            if (mgr)
                            {
                                editSky = mgr.GlobalSky;
                            }
                            else
                            {
                                editSky = null;
                            }
                            editLabel = "Edit Global";
                            editTip   = "Select cubemaps from the current viewport Sky as output targets.";
                        }
                        EditorGUI.BeginDisabledGroup(editSky == null);
                        if (GUILayout.Button(new GUIContent(editLabel, editTip), GUILayout.Width(95), GUILayout.Height(32)))
                        {
                            if (editSky)
                            {
                                outSKY.HDR = editSky.HDRSky;
                                outSIM.HDR = editSky.HDRSpec;

                                if (editSky.SkyboxCube)
                                {
                                    outSKY.setReference(AssetDatabase.GetAssetPath(editSky.SkyboxCube), false, true);
                                }
                                else
                                {
                                    outSKY.clear();
                                }

                                if (editSky.SpecularCube)
                                {
                                    outSIM.setReference(AssetDatabase.GetAssetPath(editSky.SpecularCube), true, true);
                                }
                                else
                                {
                                    outSIM.clear();
                                }
                            }
                        }
                        EditorGUI.EndDisabledGroup();

                        string applyTip = "Change the selected Sky object to use Skyshop's current output cubemaps.";
                        EditorGUI.BeginDisabledGroup(uiSelectedSky == null);
                        if (GUILayout.Button(new GUIContent("Apply to Selected", applyTip), GUILayout.Width(120), GUILayout.Height(32)))
                        {
                            if (uiSelectedSky)
                            {
                                mset.EditorUtil.RegisterUndo(uiSelectedSky, "Apply to Selected Sky");
                                uiSelectedSky.SpecularCube    = outSIM.cube;
                                uiSelectedSky.SkyboxCube      = outSKY.cube;
                                uiSelectedSky.MasterIntensity = 1f;
                                uiSelectedSky.SkyIntensity    = 1f;
                                uiSelectedSky.DiffIntensity   = 1f;
                                uiSelectedSky.SpecIntensity   = 1f;
                                uiSelectedSky.HDRSky          = outSKY.HDR;
                                uiSelectedSky.HDRSpec         = outSIM.HDR;

                                SceneView.RepaintAll();
                            }
                        }
                        EditorGUI.EndDisabledGroup();

                        string addTip = "Create a new Sky object in the scene and assigns Skyshop's current output cubemaps to it.";
                        if (GUILayout.Button(new GUIContent("Add to Scene", addTip), GUILayout.Width(95), GUILayout.Height(32)))
                        {
                            mset.Sky skyScript = addSky(this.inSKY.skyName);
                            if (skyScript)
                            {
                                skyScript.SpecularCube    = outSIM.cube;
                                skyScript.SkyboxCube      = outSKY.cube;
                                skyScript.MasterIntensity = 1f;
                                skyScript.SkyIntensity    = 1f;
                                skyScript.DiffIntensity   = 1f;
                                skyScript.SpecIntensity   = 1f;
                                skyScript.HDRSky          = outSKY.HDR;
                                skyScript.HDRSpec         = outSIM.HDR;
                                skyScript.Apply();                                 //Add to Scene
                                SceneView.RepaintAll();
                            }
                        }
                    } EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Space();
                }                // end if uiRefOptions
            } EditorGUILayout.EndVertical();

            // BASIC
            string tipExposure = "A multiplier on all the pixels in the Input Panorama during computation. Use for uniform brightness adjustment of results.";
            string tipQuality  = "Changes some advanced options to balance between image quality and computation speed.";

            EditorGUILayout.BeginVertical("HelpBox", GUILayout.Width(sectionWidth), GUILayout.MinWidth(minWidth)); {
                uiBasicOptions = EditorGUILayout.Foldout(uiBasicOptions, "Basic Options");
                if (uiBasicOptions)
                {
                    float newExposure = EditorGUILayout.FloatField(new GUIContent("Baked Exposure", "Baked Exposure -\n" + tipExposure), uiExposure, GUILayout.Width(300));
                    newExposure = Mathf.Max(0.0f, newExposure);
                    if (newExposure != uiExposure)
                    {
                        mset.EditorUtil.RegisterUndo(this, "Change Exposure");
                        uiExposure = newExposure;
                    }

                    mset.Quality newQuality = (mset.Quality)EditorGUILayout.EnumPopup(
                        new GUIContent("Quality", "Quality -\n" + tipQuality),
                        (mset.Quality)uiConvoQuality,
                        GUILayout.Width(300)
                        );

                    if (newQuality != uiConvoQuality)
                    {
                        mset.EditorUtil.RegisterUndo(this, "Change Quality");
                        uiConvoQuality = newQuality;
                        switch (uiConvoQuality)
                        {
                        case mset.Quality.ultra:        uiConvoSize = 64; break;

                        case mset.Quality.high:         uiConvoSize = 32; break;

                        case mset.Quality.medium:       uiConvoSize = 16; break;

                        case mset.Quality.low:          uiConvoSize = 8; break;
                        }
                    }

                    /*
                     * uiCubeSize = (TexSize)EditorGUILayout.EnumPopup(
                     *      new GUIContent("Output Size (cube)","Output Size -\n"+tipCubeSize),
                     *      (CubeSize)uiCubeSize,
                     *      GUILayout.Width(300)
                     * );*/

                    EditorGUILayout.Space();
                }                // end if uiBasicOptions
            } EditorGUILayout.EndVertical();

            // PRO MOVES
            string tipConvoSize    = "Resolution the input panorama is downsampled to for convolution, must be power of 2.\n\nWarning: High resolutions can lead to VERY long computation times!";
            string tipMipChain     = "If enabled, different specular gloss exponents are computed and stored in each mipmap level of the Specular Output cube.\n\nThis must be enabled for Gloss Maps to function in Marmoset Shaders.";
            string tipExponent     = "Gloss exponent used in computing the Specular Output cubemap. Value must be a power of 2, lower values result in a blurrier cubemap. Only available when \"Build Mip Chains\" is disabled.";
            string tipMaxExponent  = "Highest gloss exponent use in the specular mip chain. Other exponents in the chain are generated from this value.";
            string tipExponents    = "Displays a list of the specular gloss exponents used in the various mip levels of the Specular Output cube.";
            string tipResponsiveUI = "Enable if Unity is too unresponsive during computation. Will slow overall computation time.";
            string tipReflection   = "Highest gloss level in the specular mip chain is a polished mirror reflection pulled from the input panorama itself.";

            EditorGUILayout.BeginVertical("HelpBox", GUILayout.Width(sectionWidth), GUILayout.MinWidth(minWidth));
            {
                uiAdvancedOptions = EditorGUILayout.Foldout(uiAdvancedOptions, "Advanced Options");
                if (uiAdvancedOptions)
                {
                    int newConvoSize = EditorGUILayout.IntField(
                        new GUIContent("Convolution Size", "Convolution Size -\n" + tipConvoSize),
                        uiConvoSize,
                        GUILayout.Width(300)
                        );

                    if (newConvoSize < 2)
                    {
                        newConvoSize = 2;
                    }
                    newConvoSize += newConvoSize % 2;

                    if (newConvoSize != uiConvoSize)
                    {
                        mset.EditorUtil.RegisterUndo(this, "Change Convolution Size");
                        uiConvoSize    = newConvoSize;
                        uiConvoQuality = mset.Quality.custom;
                        switch (uiConvoSize)
                        {
                        case 8:  uiConvoQuality = mset.Quality.low; break;

                        case 16: uiConvoQuality = mset.Quality.medium; break;

                        case 32: uiConvoQuality = mset.Quality.high; break;

                        case 64: uiConvoQuality = mset.Quality.ultra; break;
                        }
                        ;
                    }
                    EditorGUILayout.Space();
                    mset.CubemapGUI.drawStaticGUI();

                    bool newMipChain = EditorGUILayout.Toggle(new GUIContent("Build Specular Mip Chain", "Specular Mip Chains -\n" + tipMipChain), uiMipChain);
                    if (newMipChain != uiMipChain)
                    {
                        mset.EditorUtil.RegisterUndo(this, "Toggle Specular Mip Chain");
                        uiMipChain = newMipChain;
                    }
                    if (uiMipChain)
                    {
                        bool newRefInSIM = EditorGUILayout.Toggle(new GUIContent("Highest Mip is Reflection", "Highest Mip is Reflection -\n" + tipReflection), uiReflectionInSIM);
                        if (newRefInSIM != uiReflectionInSIM)
                        {
                            mset.EditorUtil.RegisterUndo(this, "Toggle Mip Chain Reflection");
                            uiReflectionInSIM = newRefInSIM;
                        }
                        int newExponent = EditorGUILayout.IntField(
                            new GUIContent("Max Specular Exponent", "Specular Exponent -\n" + tipMaxExponent),
                            uiExponent,
                            GUILayout.Width(300)
                            );
                        newExponent = Mathf.Max(1, newExponent);
                        if (newExponent != uiExponent)
                        {
                            mset.EditorUtil.RegisterUndo(this, "Change Specular Exponent");
                            uiExponent = newExponent;
                        }

                        EditorGUI.BeginDisabledGroup(true);
                        string mipString;
                        if (uiReflectionInSIM)
                        {
                            mipString = "mirror";
                        }
                        else
                        {
                            mipString = uiExponent.ToString();
                        }
                        for (int i = 1; i < 4; ++i)
                        {
                            if ((1 << i) < uiExponent)
                            {
                                mipString += ", ";
                                mipString += (uiExponent >> i);
                                if (i == 3)
                                {
                                    mipString += "...";
                                }
                            }
                        }
                        EditorGUILayout.TextField(new GUIContent("Specular Exponents", "Specular Exponents -\n" + tipExponents), mipString, GUILayout.Width(300));
                        EditorGUI.EndDisabledGroup();
                    }
                    else
                    {
                        EditorGUI.BeginDisabledGroup(true);
                        EditorGUILayout.Toggle(new GUIContent("Highest Mip is Reflection", "Highest Mip is Reflection -\n" + tipReflection), false);
                        EditorGUI.EndDisabledGroup();
                        int newExponent = EditorGUILayout.IntField(
                            new GUIContent("Specular Exponent", "Specular Exponent -\n" + tipExponent),
                            uiExponent,
                            GUILayout.Width(300)
                            );
                        newExponent = Mathf.Max(1, newExponent);
                        if (newExponent != uiExponent)
                        {
                            mset.EditorUtil.RegisterUndo(this, "Change Specular Exponent");
                            uiExponent = newExponent;
                        }
                    }
                    EditorGUILayout.Space();

                    //TODO: Will anyone ever want this? Marmoset shaders need gamma compression as does sRGB sampling.
                    uiGammaCompress = true;

                    /*
                     * uiGammaCompress = EditorGUILayout.Toggle(new GUIContent(
                     *      "Gamma-Compress RGBM",
                     *      "Gamma-Compress RGBM -\nIf enabled, a gamma of 1/2.2 is applied to HDR data before it is encoded as RGBM. This adds dynamic range but also shader complexity. Leave enabled for Marmoset shaders."),
                     *      uiGammaCompress);
                     */

                    uiResponsiveUI = stepsPerFrame <= 1024 * 16;
                    uiResponsiveUI = EditorGUILayout.Toggle(new GUIContent("Keep UI Responsive", "Keep UI Responsive -\n" + tipResponsiveUI), uiResponsiveUI);
                    ulong newStepsPerFrame = stepsPerFrame;
                    if (uiResponsiveUI)
                    {
                        newStepsPerFrame = 1024 * 16;
                    }
                    else
                    {
                        newStepsPerFrame = 1024 * 256;
                    }

                    if (newStepsPerFrame != stepsPerFrame)
                    {
                        mset.EditorUtil.RegisterUndo(this, "Toggle Responsive UI");
                        stepsPerFrame = newStepsPerFrame;
                    }
                    EditorGUILayout.Space();


                    if (GUILayout.Button("Reset to Default", GUILayout.Width(120)))
                    {
                        uiConvoSize       = Mathf.Min(uiConvoSize, 16);
                        uiMipChain        = true;
                        uiReflectionInSIM = true;
                        uiResponsiveUI    = false;
                        uiGammaCompress   = true;
                        uiExponent        = 512;
                    }
                    EditorGUILayout.Space();
                }
            } EditorGUILayout.EndVertical();

            EditorGUILayout.Space();
            EditorGUILayout.Space();
        }

        //GENERATE
        bool generateGPU = false;
        bool generate    = false;
        bool cancel      = false;

        EditorGUILayout.BeginHorizontal(); {
            bool   hasPro        = UnityEditorInternal.InternalEditorUtility.HasPro();
            string tipGPUCompute = "Generates skybox and specular cubemaps. Specular convolution is performed on the GPU for greater speed and quality.\n\nNote: a different convolution equation is used, results may vary from CPU compute.";
            if (hasPro == false)
            {
                tipGPUCompute = "Requires Unity Pro :-(\n\n" + tipGPUCompute;
            }

            bool playing = ps.isPlaying();
            //if( ps.isPlaying() ) {
            //	cancel = GUILayout.Button("Abort", GUILayout.Width(130), GUILayout.Height(50));
            //} else
            {
                bool valid = true;
                if (inSKY.input == null)
                {
                    valid = false;
                }
                if (outSKY.cube == null && outSIM.cube == null)
                {
                    valid = false;
                }
                EditorGUILayout.BeginVertical();
                EditorGUI.BeginDisabledGroup(!valid);
                generate = GUILayout.Button(playing ? "Cancel" : "Compute", GUILayout.Width(130), GUILayout.Height(50));
                if (playing)
                {
                    cancel = generate; generate = false;
                }
                EditorGUI.EndDisabledGroup();

                EditorGUI.BeginDisabledGroup(!valid || !hasPro || playing);
                generateGPU = GUILayout.Button(new GUIContent("GPU Compute", "GPU Compute -\n" + tipGPUCompute), GUILayout.Width(130), GUILayout.Height(50));
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.EndVertical();

                if (!valid)
                {
                    EditorGUILayout.BeginVertical();
                    if (inSKY.input == null)
                    {
                        EditorGUILayout.HelpBox("Input Panorama is missing.", MessageType.Error);
                    }
                    if (outSKY.cube == null && outSIM.cube == null)
                    {
                        EditorGUILayout.HelpBox("An Output Cubemap is needed.", MessageType.Error);
                    }
                    EditorGUILayout.EndVertical();
                }
            }
        } EditorGUILayout.EndHorizontal();
        if (cancel)
        {
            ps.pause();
            Repaint();

            inSKY.locked          =
                outSKY.locked     =
                    outSIM.locked = false;
            inSKY.updateBuffers();
        }

        progressRect       = GUILayoutUtility.GetRect(sectionWidth - 4, 16);
        progressRect.width = sectionWidth;
        progressRect.x     = 4;
        progressRect.y    += 2;

        //uiShowPreview = true;
        if (uiShowPreview)
        {
            EditorGUILayout.LabelField("Convolution Preview");
            float previewWidth  = position.width - rightPad;
            float previewHeight = previewWidth * 0.5f;
            mset.EditorUtil.GUILayout.drawTexture(4, 0, previewWidth, previewHeight, "", uiConvoPreview, false);
        }

        if (generate)
        {
            startConvo();
            ps.repaintMetric.begin();
        }

        if (generateGPU)
        {
            this.startConvoGPU();
            this.finishSKY();

            if (outSIM.cube)
            {
                Cubemap tempCube = this.outSKY.cube;
                if (tempCube == null)
                {
                    tempCube = new Cubemap(outSIM.cube.width, TextureFormat.ARGB32, false);
                    ps.IN.resampleToCube(ref tempCube, 0, outSIM.colorMode, true, uiExposure);
                    tempCube.Apply(false);
                    mset.AssetUtil.setLinear(new SerializedObject(tempCube), false);
                }

                mset.SkyProbe p = new mset.SkyProbe();
                p.maxExponent        = this.uiExponent;
                p.highestMipIsMirror = this.uiReflectionInSIM;
                p.generateMipChain   = this.uiMipChain;
                bool linear = UnityEditor.PlayerSettings.colorSpace == ColorSpace.Linear;
                p.convolve(this.outSIM.cube, tempCube, this.outSIM.HDR, this.outSKY.HDR, linear);
                outSIM.reloadReference();

                if (ps.buildMipChain)
                {
                    finishSIM();
                }
            }
            this.finishConvoGPU();
        }

        if (ps.isPlaying())
        {
            if (ps.curr == 0)
            {
                finishSKY();
            }
            if (ps.done())
            {
                ps.repaintMetric.end();
                finishConvo();
                Repaint();
                ps.pause();
            }
            else
            {
                ps.repaintMetric.end();
                //execute a subset of convolution steps, take a break to repaint the gui, then continue convolution
                stepConvo();
                EditorGUI.ProgressBar(progressRect, ps.progress(), "Convolution Progress " + Mathf.Floor(100f * ps.progress()) + "%");
                Repaint();
                ps.pendingRepaint = false;
                ps.repaintMetric.begin();
            }
        }

        if (ps.isPlaying() && !ps.done())
        {
            EditorGUI.ProgressBar(progressRect, ps.progress(), "Convolution Progress " + Mathf.Floor(100f * ps.progress()) + "%");
        }

        //DEBUG OPTIONS

        /*
         * EditorGUILayout.BeginVertical("HelpBox", GUILayout.Width(sectionWidth), GUILayout.MinWidth(minWidth)); {
         *      uiPerfReport = EditorGUILayout.Foldout(uiPerfReport,"Debug");
         *      if( uiPerfReport ) {
         *              uiShowPreview = EditorGUILayout.Toggle("Show Preview", uiShowPreview, GUILayout.Height(16));
         *              EditorGUILayout.Space();
         *
         *              string report = "Performance Report\n";
         *              report += ps.totalMetric.getString("Total",0);
         *              report += ps.initMetric.getString("Init",1);
         *              report += ps.blockMetric.getString("Coroutine Step",1);
         *              report += ps.passWriteMetric.getString("Cube Write",2);
         *              report += ps.repaintMetric.getString("Repaint", 1);
         *              report += ps.finishMetric.getString("Finalize", 1);
         *              EditorGUILayout.SelectableLabel(report, "HelpBox", GUILayout.Height(360));
         *              EditorGUILayout.Space();
         *              selectTest();
         *      }
         * }EditorGUILayout.EndVertical();
         */

        EditorGUILayout.BeginVertical("HelpBox", GUILayout.Width(sectionWidth), GUILayout.MinWidth(minWidth));
        {
            uiGIOptions = EditorGUILayout.Foldout(uiGIOptions, "Beast Global Illum Options");
            if (uiGIOptions)
            {
                mset.BeastConfig.DrawGUI();
                EditorGUILayout.Space();
            }
        } EditorGUILayout.EndVertical();


        EditorGUILayout.EndScrollView();
        GUILayout.EndArea();

        //GUIUtility.ExitGUI();
    }
Example #21
0
File: Sky.cs Project: damard/Unity
        // Binds IBL data, exposure, and a skybox texture globally.
        public void Apply()
        {
            #if UNITY_3_5
            if( this.enabled && this.gameObject.active ) {
            #else
            if( this.enabled && this.gameObject.activeInHierarchy ) {
            #endif
                //turn off previously bound sky
                if(Sky.activeSky != null) Sky.activeSky.UnApply();
                Sky.activeSky = this;

                //bind cubemaps
                if(diffuseCube) Shader.SetGlobalTexture("_DiffCubeIBL", diffuseCube);
                else 			Shader.SetGlobalTexture("_DiffCubeIBL", blackCube);

                if(specularCube)Shader.SetGlobalTexture("_SpecCubeIBL", specularCube);
                else 			Shader.SetGlobalTexture("_SpecCubeIBL", blackCube);

                if(skyboxCube)	Shader.SetGlobalTexture("_SkyCubeIBL", skyboxCube);
                else 			Shader.SetGlobalTexture("_SkyCubeIBL", blackCube);

                //build exposure values for shader, HDR skies need the RGBM expansion constant 6.0 in there
                exposures.x = masterIntensity*diffIntensity;
                exposures.y = masterIntensity*specIntensity;
                exposures.z = masterIntensity*skyIntensity*camExposure; //exposure baked right into skybox exposure
                exposures.w = camExposure;

                //prepare exposure values for gamma correction
                float toLinear = 2.2f;
                float toSRGB = 1/toLinear;
                float hdrScale = 6f;
                if(linearSpace) {
                    //HDR scale needs to be applied in linear space
                    hdrScale = Mathf.Pow(6f,toLinear);
                } else {
                    //Exposure values are treated as being in linear space, but the shader is working in sRGB space.
                    //Move exposure into sRGB as well before applying.
                    exposures.x = Mathf.Pow(exposures.x,toSRGB);
                    exposures.y = Mathf.Pow(exposures.y,toSRGB);
                    exposures.z = Mathf.Pow(exposures.z,toSRGB);
                    exposures.w = Mathf.Pow(exposures.w,toSRGB);
                }
                //RGBM cubemaps need a scalar added to their exposure
                if( hdrDiff ) exposures.x *= hdrScale;
                if( hdrSpec ) exposures.y *= hdrScale;
                if( hdrSky )  exposures.z *= hdrScale;

                Shader.SetGlobalVector("ExposureIBL",exposures);

                exposuresLM.x = diffIntensityLM;
                exposuresLM.y = specIntensityLM;
                Shader.SetGlobalVector("ExposureLM", exposuresLM);

                //upload the sky transform to the shader
                ApplySkyTransform();

                //enable any lights parented to this sky
                toggleChildLights(true);

                //NOTE: this causes scene changes on sky selection, may not be desireable in the editor!
                if(showSkybox) {
                    RenderSettings.skybox = skyboxMaterial;
                } else {
                    if(	RenderSettings.skybox &&
                        RenderSettings.skybox.name == "Internal IBL Skybox") {
                        RenderSettings.skybox = null;
                    }
                }

                //toggle between linear-space (gamma-corrected) and gamma-space (uncorrected) shader permutations
                Shader.DisableKeyword("MARMO_GAMMA");
                Shader.DisableKeyword("MARMO_LINEAR");
                if(linearSpace) Shader.EnableKeyword("MARMO_LINEAR");
                else 			Shader.EnableKeyword("MARMO_GAMMA");

                //this is a hint for the Beast Lightmapper, rendering is unaffected
                Shader.SetGlobalFloat("_EmissionLM",1f);
            }
            }

            public void ApplySkyTransform() {
            #if UNITY_3_5
            if( this.enabled && this.gameObject.active ) {
            #else
            if( this.enabled && this.gameObject.activeInHierarchy ) {
            #endif
                skyMatrix.SetTRS(Vector3.zero,transform.rotation,Vector3.one);
                Shader.SetGlobalMatrix("SkyMatrix", skyMatrix);
            }
            }

            public void Reset() {
            diffuseCube = specularCube = skyboxCube = null;
            masterIntensity = skyIntensity = specIntensity = diffIntensity = 1f;
            hdrSky = hdrSpec = hdrDiff = false;
            //Apply(); //Reset
            }

            private void Awake() {
            //Apply(); //Awake
            }
Example #22
0
        public override void OnInspectorGUI()
        {
            bool dirty    = false;              //flag for changed sky parameters
            bool dirtyRef = false;              //flag for changed sky cubemap references (causes SH recompute and preview refresh)

            mset.Sky sky = target as mset.Sky;

            //sync GUI from sky
            camExposure     = sky.camExposure;
            masterIntensity = sky.masterIntensity;
            skyIntensity    = sky.skyIntensity;
            diffIntensity   = sky.diffIntensity;
            specIntensity   = sky.specIntensity;
            diffIntensityLM = sky.diffIntensityLM;
            specIntensityLM = sky.specIntensityLM;

            //sync and sync from CubeGUIs
            dirtyRef |= skyToGUI(ref sky.skyboxCube, ref sky.hdrSky, refSKY, true);
            dirtyRef |= GUIToSky(ref sky.skyboxCube, ref sky.hdrSky, refSKY);

            dirtyRef |= skyToGUI(ref sky.diffuseCube, ref sky.hdrDiff, refDIM, true);
            dirtyRef |= GUIToSky(ref sky.diffuseCube, ref sky.hdrDiff, refDIM);

            dirtyRef |= skyToGUI(ref sky.specularCube, ref sky.hdrSpec, refSIM, true);
            dirtyRef |= GUIToSky(ref sky.specularCube, ref sky.hdrSpec, refSIM);

            GUIStyle buttonStyle = new GUIStyle("Button");

            buttonStyle.padding.top  = buttonStyle.padding.bottom = 0;
            buttonStyle.padding.left = buttonStyle.padding.right = 0;

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            bool prevApply = sky.autoApply;
            bool autoApply = EditorGUILayout.Toggle(new GUIContent("Auto-Apply", "If enabled, this sky will be applied automatically upon level load, or whenever selected in the editor viewport."), sky.autoApply);

            if (autoApply != prevApply)
            {
                mset.Util.RegisterUndo(sky, "Auto-Apply Toggle");
                sky.autoApply = autoApply;
            }
            EditorGUI.BeginDisabledGroup(sky.autoApply); {
                if (GUILayout.Button("Apply to Viewport", GUILayout.Width(164)))
                {
                    sky.Apply();
                }
            } EditorGUI.EndDisabledGroup();

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            bool showSkybox = EditorGUILayout.Toggle(new GUIContent("Show Skybox", "Toggles rendering the background image"), sky.showSkybox);

            if (showSkybox != sky.showSkybox)
            {
                mset.Util.RegisterUndo(sky, "Skybox Toggle");
                sky.showSkybox = showSkybox;
                // if we're toggling skyboxes off, clear the render settings material
                if (!sky.showSkybox)
                {
                    RenderSettings.skybox = null;
                }
                dirty = true;
            }

            bool detect = EditorGUILayout.Toggle(new GUIContent("Auto-Detect Color Space", "If enabled, attempts to detect the project's gamma correction setting and enables/disables the Linear Space option accordingly"), sky.autoDetectColorSpace);

            if (detect != sky.autoDetectColorSpace)
            {
                mset.Util.RegisterUndo(sky, "Color-Space Detection Change");
                sky.autoDetectColorSpace = detect;
            }

            bool prevLinear = sky.linearSpace;

            if (sky.autoDetectColorSpace)
            {
                detectColorSpace(ref sky);
            }
            EditorGUI.BeginDisabledGroup(sky.autoDetectColorSpace);
            bool userLinearSpace = EditorGUILayout.Toggle(new GUIContent("Linear Space", "Enable if gamma correction is enabled for this project (Edit -> Project Settings -> Player -> Color Space: Linear)"), sky.linearSpace);

            if (userLinearSpace != sky.linearSpace)
            {
                mset.Util.RegisterUndo(sky, "Color-Space Change");
                sky.linearSpace = userLinearSpace;
            }
            EditorGUI.EndDisabledGroup();
            if (prevLinear != sky.linearSpace)
            {
                //	dirty = true;
            }

            bool prevDim = sky.hasDimensions;
            bool hasDim  = EditorGUILayout.Toggle(new GUIContent("Has Dimensions (beta)", "Use transform scale as the box projection dimensions of this sky. Only affects box-projected shaders for now."), sky.hasDimensions);

            if (hasDim != prevDim)
            {
                mset.Util.RegisterUndo(sky, "Has Dimensions Toggle");
                sky.hasDimensions = hasDim;
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            //sync sky from GUI
            EditorGUILayout.LabelField(new GUIContent("Master Intensity", "Multiplier on the Sky, Diffuse, and Specular cube intensities"));
            masterIntensity = EditorGUILayout.Slider(masterIntensity, 0f, 10f);
            if (sky.masterIntensity != masterIntensity)
            {
                mset.Util.RegisterUndo(sky, "Intensity Change");
                sky.masterIntensity = masterIntensity;
            }

            EditorGUILayout.LabelField(new GUIContent("Skybox Intensity", "Brightness of the skybox"));
            skyIntensity = EditorGUILayout.Slider(skyIntensity, 0f, 10f);
            if (sky.skyIntensity != skyIntensity)
            {
                mset.Util.RegisterUndo(sky, "Intensity Change");
                sky.skyIntensity = skyIntensity;
            }

            EditorGUILayout.LabelField(new GUIContent("Diffuse Intensity", "Multiplier on the diffuse light put out by this sky"));
            diffIntensity = EditorGUILayout.Slider(diffIntensity, 0f, 10f);
            if (sky.diffIntensity != diffIntensity)
            {
                mset.Util.RegisterUndo(sky, "Intensity Change");
                sky.diffIntensity = diffIntensity;
            }

            EditorGUILayout.LabelField(new GUIContent("Specular Intensity", "Multiplier on the specular light put out by this sky"));
            specIntensity = EditorGUILayout.Slider(specIntensity, 0f, 10f);
            if (sky.specIntensity != specIntensity)
            {
                mset.Util.RegisterUndo(sky, "Intensity Change");
                sky.specIntensity = specIntensity;
                dirty             = true;
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.LabelField(new GUIContent("Camera Exposure", "Multiplier on all light coming into the camera, including IBL, direct light, and glow maps"));
            camExposure = EditorGUILayout.Slider(camExposure, 0f, 10f);
            if (sky.camExposure != camExposure)
            {
                mset.Util.RegisterUndo(sky, "Exposure Change");
                sky.camExposure = camExposure;
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.LabelField(new GUIContent("Lightmapped Diffuse Multiplier", "Multiplier on the diffuse intensity for lightmapped surfaces"));
            diffIntensityLM = EditorGUILayout.Slider(diffIntensityLM, 0f, 1f);
            if (sky.diffIntensityLM != diffIntensityLM)
            {
                mset.Util.RegisterUndo(sky, "Multiplier Change");
                sky.diffIntensityLM = diffIntensityLM;
            }

            EditorGUILayout.LabelField(new GUIContent("Lightmapped Specular Multiplier", "Multiplier on the specular intensity for lightmapped surfaces"));
            specIntensityLM = EditorGUILayout.Slider(specIntensityLM, 0f, 1f);
            if (sky.specIntensityLM != specIntensityLM)
            {
                mset.Util.RegisterUndo(sky, "Multiplier Change");
                sky.specIntensityLM = specIntensityLM;
            }

            dirty    |= GUI.changed;
            dirtyRef |= sky.SH == null;

            if (forceDirty)
            {
                refSKY.reloadReference();
                refDIM.reloadReference();
                refSIM.reloadReference();

                dirtyRef   = true;
                forceDirty = false;
                dirty      = true;
                Repaint();
            }

            //guess input path
            if (dirtyRef)
            {
                string inPath = refSKY.fullPath;
                if (inPath.Length == 0)
                {
                    inPath = refDIM.fullPath;
                }
                if (inPath.Length == 0)
                {
                    inPath = refSIM.fullPath;
                }
                if (inPath.Length > 0)
                {
                    int uscore = inPath.LastIndexOf("_");
                    if (uscore > -1)
                    {
                        inPath = inPath.Substring(0, uscore);
                    }
                    else
                    {
                        inPath = Path.GetDirectoryName(inPath) + "/" + Path.GetFileNameWithoutExtension(inPath);
                    }
                    refSKY.inputPath         =
                        refDIM.inputPath     =
                            refSIM.inputPath = inPath;
                }
                else
                {
                    refSKY.inputPath         =
                        refDIM.inputPath     =
                            refSIM.inputPath = "";
                }

                generateSH(ref sky);
                dirty = true;
            }

            //if the active sky is not whats selected, see whats up with that and try rebinding (catches re-activating disabled skies)
            if (mset.Sky.activeSky != sky)
            {
                dirty = true;
            }

            if (!Application.isPlaying)
            {
                if (sky.autoApply || sky == Sky.activeSky)
                {
                    //if any of the cubemaps have changed, refresh the viewport
                    if (dirty)
                    {
                        sky.Apply();                         //SkyInspector dirty
                        SceneView.RepaintAll();
                    }
                    else
                    {
                        sky.ApplySkyTransform();
                    }
                }
            }
        }