├── GIF └── adam4.gif ├── LightProbeAdjustment ├── Assets │ ├── Materials.meta │ ├── Materials │ │ ├── Red.mat │ │ └── Red.mat.meta │ ├── Scenes.meta │ ├── Scenes │ │ ├── TestScene.unity │ │ └── TestScene.unity.meta │ ├── Scripts.meta │ ├── Scripts │ │ ├── ProbeIntensity.cs │ │ └── ProbeIntensity.cs.meta │ ├── smcs.rsp │ └── smcs.rsp.meta └── ProjectSettings │ ├── AudioManager.asset │ ├── ClusterInputManager.asset │ ├── DynamicsManager.asset │ ├── EditorBuildSettings.asset │ ├── EditorSettings.asset │ ├── GraphicsSettings.asset │ ├── InputManager.asset │ ├── NavMeshAreas.asset │ ├── NetworkManager.asset │ ├── Physics2DSettings.asset │ ├── ProjectSettings.asset │ ├── ProjectVersion.txt │ ├── QualitySettings.asset │ ├── TagManager.asset │ ├── TimeManager.asset │ └── UnityConnectSettings.asset └── README.md /GIF/adam4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/GIF/adam4.gif -------------------------------------------------------------------------------- /LightProbeAdjustment/Assets/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1ae013c220471a4d80c0989981451ee 3 | folderAsset: yes 4 | timeCreated: 1488217575 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LightProbeAdjustment/Assets/Materials/Red.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/Assets/Materials/Red.mat -------------------------------------------------------------------------------- /LightProbeAdjustment/Assets/Materials/Red.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d142e7ca48f1085429051181745ac7ce 3 | timeCreated: 1488217504 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LightProbeAdjustment/Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5be92b219ef34994399f225fb4602aac 3 | folderAsset: yes 4 | timeCreated: 1488217585 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LightProbeAdjustment/Assets/Scenes/TestScene.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/Assets/Scenes/TestScene.unity -------------------------------------------------------------------------------- /LightProbeAdjustment/Assets/Scenes/TestScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e8c3b5de9453ca4ab74caa99f845523 3 | timeCreated: 1488217500 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LightProbeAdjustment/Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ff7e7a0eb706044ba144e00daf2c9b9 3 | folderAsset: yes 4 | timeCreated: 1488217563 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LightProbeAdjustment/Assets/Scripts/ProbeIntensity.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System; 4 | using System.Collections.Generic; 5 | using UnityEngine.Rendering; 6 | 7 | [CanEditMultipleObjects] 8 | public class ProbeIntensity : EditorWindow 9 | 10 | { 11 | private float maxSliderValue = 5.0f; 12 | static private float sliderValue = 2.0f; 13 | private float minSliderValue = 1.0f; 14 | private GUIStyle currentStyle = null; 15 | private Color textColor = new Color(0.71f, 0.71f, 0.71f); 16 | public float inputNumber = 2.0f; 17 | static public bool noBaked = false; 18 | 19 | public static List inputValues = new List(); 20 | public static List oldValuesList = new List(); 21 | 22 | public static Lightmapping.OnCompletedFunction completed; 23 | 24 | void Update() 25 | { 26 | CheckBaking(); 27 | } 28 | 29 | bool CheckBaking() 30 | { 31 | if (Lightmapping.isRunning) 32 | { 33 | oldValuesList.Clear(); 34 | return true; 35 | } 36 | else 37 | { 38 | StoreProbeData(); 39 | return false; 40 | } 41 | } 42 | 43 | unsafe private static void ScaleLightProbeData(float scale) 44 | { 45 | DisplayWarning(); 46 | inputValues.Add(scale); 47 | 48 | var probes = LightmapSettings.lightProbes.bakedProbes; 49 | if (probes == null) 50 | { 51 | Debug.LogError("No probes in the scene!"); 52 | return; 53 | } 54 | 55 | var probeType = typeof(UnityEngine.Rendering.SphericalHarmonicsL2); 56 | var allFields = probeType.GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); 57 | 58 | for (int j = 0; j < probes.Length; j++) 59 | { 60 | var probe = probes[j]; 61 | 62 | float* probePointer = (float*)&probe; 63 | 64 | //Currently all of these are floats. If this changes, the code should be re-evaluated. 65 | for (int i = 0; i < allFields.Length; i++) 66 | { 67 | float* valueAddress = probePointer + i; 68 | float oldValue = *valueAddress; 69 | *valueAddress = oldValue * scale; 70 | } 71 | 72 | probes[j] = probe; 73 | } 74 | 75 | SetProbeData(probes); 76 | } 77 | 78 | unsafe private static void StoreProbeData() 79 | { 80 | var probes = LightmapSettings.lightProbes.bakedProbes; 81 | var probeType = typeof(UnityEngine.Rendering.SphericalHarmonicsL2); 82 | var allFields = probeType.GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); 83 | 84 | for (int j = 0; j < probes.Length; j++) 85 | { 86 | var probe = probes[j]; 87 | 88 | float* probePointer = (float*)&probe; 89 | 90 | //Currently all of these are floats. If this changes, the code should be re-evaluated. 91 | for (int i = 0; i < allFields.Length; i++) 92 | { 93 | 94 | float* valueAddress = probePointer + i; 95 | float oldValue = *valueAddress; 96 | oldValuesList.Add(oldValue); 97 | } 98 | 99 | probes[j] = probe; 100 | } 101 | 102 | SetProbeData(probes); 103 | inputValues.Clear(); 104 | 105 | } 106 | 107 | unsafe private static void ResetProbeData() 108 | { 109 | DisplayWarning(); 110 | var probes = LightmapSettings.lightProbes.bakedProbes; 111 | var probeType = typeof(UnityEngine.Rendering.SphericalHarmonicsL2); 112 | var allFields = probeType.GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); 113 | 114 | try 115 | { 116 | StoreProbeData(); 117 | 118 | } 119 | finally 120 | { 121 | } 122 | 123 | for (int j = 0; j < probes.Length; j++) 124 | { 125 | var probe = probes[j]; 126 | 127 | float* probePointer = (float*)&probe; 128 | 129 | //Currently all of these are floats. If this changes, the code should be re-evaluated. 130 | for (int i = 0; i < allFields.Length; i++) 131 | { 132 | float* valueAddress = probePointer + i; 133 | 134 | *valueAddress = oldValuesList[i]; 135 | } 136 | 137 | probes[j] = probe; 138 | } 139 | 140 | SetProbeData(probes); 141 | inputValues.Clear(); 142 | 143 | } 144 | 145 | [MenuItem("Tools/Light Probe Intensity")] 146 | public static void ShowWindow() 147 | { 148 | EditorWindow window = GetWindow(typeof(ProbeIntensity)); 149 | window.Show(); 150 | } 151 | 152 | public void OnGUI() 153 | { 154 | if (inputNumber > 5.0f) 155 | { 156 | sliderValue = 5.0f; 157 | } 158 | else if (inputNumber < 1) 159 | { 160 | sliderValue = 1; 161 | } 162 | 163 | InitStyles(); 164 | GUILayout.Label(" Adjust the brightness of light probes"); 165 | 166 | string inputText = " "; 167 | 168 | // Wrap everything in the designated GUI Area 169 | GUILayout.BeginArea(new Rect(10, 20, 260, 60)); 170 | 171 | // Begin the singular Horizontal Group 172 | GUILayout.BeginHorizontal(); 173 | 174 | GUILayout.Box("Scale Value ", currentStyle); 175 | 176 | if (inputNumber != sliderValue) 177 | { 178 | if (Single.TryParse(inputText, out inputNumber)) 179 | { 180 | sliderValue = Mathf.Clamp(inputNumber, minSliderValue, maxSliderValue); 181 | } 182 | else if (inputText == " ") 183 | { 184 | inputNumber = sliderValue; 185 | } 186 | } 187 | 188 | sliderValue = EditorGUILayout.Slider(sliderValue, minSliderValue, maxSliderValue); 189 | 190 | // End the Groups and Area 191 | GUILayout.EndHorizontal(); 192 | GUILayout.EndArea(); 193 | GUILayout.Space(70); 194 | GUILayout.BeginArea(new Rect(10, 60, 260, 60)); 195 | 196 | GUILayout.BeginHorizontal(); 197 | 198 | if (GUILayout.Button("Increase Intensity")) 199 | { 200 | 201 | ScaleLightProbeData(sliderValue); 202 | DisplayWarning(); 203 | } 204 | 205 | if (GUILayout.Button("Decrease Intensity")) 206 | { 207 | ScaleLightProbeData(1 / Mathf.Abs(sliderValue)); 208 | } 209 | 210 | GUILayout.EndHorizontal(); 211 | GUILayout.EndArea(); 212 | GUILayout.BeginArea(new Rect(10, 80, 260, 60)); 213 | GUILayout.BeginHorizontal(); 214 | 215 | if (GUILayout.Button("Reset Intensity")) 216 | { 217 | ResetProbeData(); 218 | DisplayWarning(); 219 | } 220 | 221 | GUILayout.EndHorizontal(); 222 | GUILayout.EndArea(); 223 | 224 | } 225 | 226 | private void InitStyles() 227 | { 228 | if (currentStyle == null) 229 | { 230 | currentStyle = new GUIStyle(GUI.skin.box); 231 | currentStyle.alignment = TextAnchor.MiddleLeft; 232 | currentStyle.normal.textColor = textColor; 233 | } 234 | } 235 | 236 | private Texture2D MakeTex(int width, int height, Color col) 237 | { 238 | Color[] pix = new Color[width * height]; 239 | for (int i = 0; i < pix.Length; ++i) 240 | { 241 | pix[i] = col; 242 | } 243 | Texture2D result = new Texture2D(width, height); 244 | result.SetPixels(pix); 245 | result.Apply(); 246 | return result; 247 | } 248 | 249 | public static float MultItems() 250 | { 251 | float result = 1.0f; 252 | for (int i = 0; i < inputValues.Count; i++) 253 | { 254 | result *= inputValues[i]; 255 | } 256 | return result; 257 | } 258 | 259 | public static void DisplayWarning() 260 | { 261 | Light[] lights = FindObjectsOfType(typeof(Light)) as Light[]; 262 | 263 | try 264 | { 265 | foreach (Light l in lights) 266 | { 267 | if (l.isBaked == true) 268 | { 269 | noBaked = false; 270 | Debug.LogWarning("Realtime light information is not stored in light probes!"); 271 | } 272 | else 273 | { 274 | noBaked = true; 275 | } 276 | } 277 | } 278 | finally 279 | { 280 | foreach (Light l in lights) 281 | { 282 | if (l.isBaked == false) 283 | { 284 | Debug.LogWarning("No lights in the scene"); 285 | } 286 | } 287 | } 288 | } 289 | 290 | public static void SetProbeData(UnityEngine.Rendering.SphericalHarmonicsL2[] probeData) 291 | { 292 | var lightProbes = LightmapSettings.lightProbes; 293 | 294 | lightProbes.bakedProbes = probeData; 295 | LightmapSettings.lightProbes = lightProbes; 296 | EditorUtility.SetDirty(lightProbes); 297 | SceneView.RepaintAll(); 298 | } 299 | 300 | } -------------------------------------------------------------------------------- /LightProbeAdjustment/Assets/Scripts/ProbeIntensity.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a548589f82bf7640bd666a3a51f0473 3 | timeCreated: 1488217569 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LightProbeAdjustment/Assets/smcs.rsp: -------------------------------------------------------------------------------- 1 | -unsafe -------------------------------------------------------------------------------- /LightProbeAdjustment/Assets/smcs.rsp.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 79ccc19a2d726824387fe0728ce00a54 3 | timeCreated: 1488217633 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.6.0b7 2 | -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /LightProbeAdjustment/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kemalakay/lightprobes/dc76f969b1f71a66ab4f026ef3e685be8724bb9b/LightProbeAdjustment/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Light Probe Intensity Adjustment Tool for Unity3D 2 | A tool that allows you to change the brightness of your light probes in Unity3D. 3 | 4 | ### Why? 5 | 6 | This can be used for adjusting the brightness of your dynamic objects in the scene that sample the lighting through light probes. In addition, there is no need to bake to change intensity, it simply post-processes the present data. By default, it is not possible to change the brightness of light probes in Unity3D. The reason behind this is because SH coefficients [1] of light probes are generated through PBR [2] principles therefore tweaking it can render incorrect results. However, this can become a problem when you are working with unrealistic, cartoony style graphics and in fact, many users requested this feature on Unity forums. This custom script addresses that issue and attempts to resolve this bottleneck. The script can be further developed if there is enough demand from users. 7 | 8 | Note that script is only tested in simple scenarios and may not work in certain cases. Use it at your own risk. 9 | 10 | ![](https://github.com/kemalakay/lightprobes/blob/master/GIF/adam4.gif) 11 | 12 | ### How To 13 | 14 | 1. Drag LightProbeIntensity.cs and .smcrsp files to your project 15 | 2. Open Tools > Light Probe Intensity Tool 16 | 3. Bake your light probes 17 | 4. Adjust the intensity of light probes 18 | 19 | 20 | Known Issues: 21 | * Resetting the intensity applies same SH values to all light probes 22 | 23 | TO-DO (Feature Requests): 24 | * Using a slider for UI 25 | * Changing the intensity of selected probes (currently the intensity of all probes are overwritten) 26 | * Refactoring of some code and fixing bug(s) 27 | 28 | #### Updates: 29 | * 14/02/2017 - First version of the light probe adjuster 30 | * 06/02/2017 - Initial commit 31 | 32 | [1] - In Unity, spherical harmonics are used to store the lighting information in light probes. Find more information about the concept's theoretical background in this [Wikipedia page](https://en.wikipedia.org/wiki/Spherical_harmonics) 33 | 34 | [2] - For more details about PBR in Unity, please check [this link](https://blogs.unity3d.com/2015/02/18/working-with-physically-based-shading-a-practical-approach/) --------------------------------------------------------------------------------