internal static unsafe bool IsLightmapsModeSupported(LightmapsMode mode) { bool isSupported; IsLightmapsModeSupportedByRef(mode, new IntPtr(&isSupported)); return(isSupported); }
internal unsafe static bool IsLightmapsModeSupported(LightmapsMode mode) { bool result; SupportedRenderingFeatures.IsLightmapsModeSupportedByRef(mode, new IntPtr((void *)(&result))); return(result); }
public void SaveSettings() { mode = LightmapSettings.lightmapsMode; lightmapFar = null; lightmapNear = null; if (LightmapSettings.lightmaps != null && LightmapSettings.lightmaps.Length > 0) { int l = LightmapSettings.lightmaps.Length; lightmapFar = new Texture2D[l]; lightmapNear = new Texture2D[l]; // str_lightmapColor = new string[l]; str_lightmapDir = new string[l]; // for (int i = 0; i < l; i++) { lightmapFar[i] = LightmapSettings.lightmaps[i].lightmapColor; lightmapNear[i] = LightmapSettings.lightmaps[i].lightmapDir; // str_lightmapColor[i] = LightmapSettings.lightmaps[i].lightmapColor.name; str_lightmapDir[i] = LightmapSettings.lightmaps[i].lightmapDir.name; // } } //Debug.Log("test"); RendererLightMapSetting[] savers = Transform.FindObjectsOfType <RendererLightMapSetting>(); foreach (RendererLightMapSetting s in savers) { s.SaveSettings(); } }
static int IntToEnum(IntPtr L) { int arg0 = (int)LuaDLL.lua_tonumber(L, 1); LightmapsMode o = (LightmapsMode)arg0; LuaScriptMgr.PushEnum(L, o); return(1); }
public void StoreLightmapInfos(int index) { var newLightingScenarioData = new LightingScenarioData(); var newRendererInfos = new List <RendererInfo>(); var newLightmapsTextures = new List <Texture2D>(); var newLightmapsTexturesDir = new List <Texture2D>(); var newLightmapsMode = new LightmapsMode(); var newLightmapsShadowMasks = new List <Texture2D>(); newLightmapsMode = LightmapSettings.lightmapsMode; GenerateLightmapInfo(gameObject, newRendererInfos, newLightmapsTextures, newLightmapsTexturesDir, newLightmapsShadowMasks, newLightmapsMode); newLightingScenarioData.lightmapsMode = newLightmapsMode; newLightingScenarioData.lightmaps = newLightmapsTextures.ToArray(); if (newLightmapsMode != LightmapsMode.NonDirectional) { newLightingScenarioData.lightmapsDir = newLightmapsTexturesDir.ToArray(); } //Mixed or realtime support newLightingScenarioData.hasRealtimeLights = latestBuildHasReltimeLights; newLightingScenarioData.shadowMasks = newLightmapsShadowMasks.ToArray(); newLightingScenarioData.rendererInfos = newRendererInfos.ToArray(); newLightingScenarioData.lightProbes = LightmapSettings.lightProbes.bakedProbes; if (lightingScenariosData.Count < index + 1) { lightingScenariosData.Insert(index, newLightingScenarioData); } else { lightingScenariosData[index] = newLightingScenarioData; } lightingScenariosCount = lightingScenariosData.Count; if (lightingScenesNames == null || lightingScenesNames.Length < lightingScenariosCount) { lightingScenesNames = new string[lightingScenariosCount]; } else { lightingScenariosData[index].sceneName = lightingScenesNames[index]; lightingScenariosData[index].name = lightingScenesNames[index]; } }
private IEnumerator BuildLightingAsync(string ScenarioName) { var newLightmapMode = new LightmapsMode(); newLightmapMode = LightmapSettings.lightmapsMode; Lightmapping.BakeAsync(); while (Lightmapping.isRunning) { yield return(null); } Lightmapping.lightingDataAsset = null; EditorSceneManager.SaveScene(EditorSceneManager.GetSceneByPath("Assets/Scenes/" + ScenarioName + ".unity")); EditorSceneManager.CloseScene(EditorSceneManager.GetSceneByPath("Assets/Scenes/" + ScenarioName + ".unity"), true); LightmapSettings.lightmapsMode = newLightmapMode; }
private IEnumerator BuildLightingAsync(Scene lightingScene) { var newLightmapMode = new LightmapsMode(); newLightmapMode = LightmapSettings.lightmapsMode; Lightmapping.BakeAsync(); while (Lightmapping.isRunning) { yield return(null); } //Lightmapping.lightingDataAsset = null; EditorSceneManager.SaveScene(lightingScene); EditorSceneManager.CloseScene(lightingScene, true); LightmapSettings.lightmapsMode = newLightmapMode; }
private IEnumerator BuildLightingAsync(string ScenarioName) { var newLightmapMode = new LightmapsMode(); newLightmapMode = LightmapSettings.lightmapsMode; Lightmapping.BakeAsync(); while (Lightmapping.isRunning) { yield return(null); } Lightmapping.lightingDataAsset = null; EditorSceneManager.SaveScene(EditorSceneManager.GetSceneByPath("Assets/Scenes/MapData_1212/UPBR_daytime001.unity")); // EditorSceneManager.SaveScene(EditorSceneManager.GetSceneByPath("Assets/Scenes/MapData_1122/UPBR001.unity")); LightmapSettings.lightmapsMode = newLightmapMode; }
private void SaveLightmap() { fogInfo = new FogInfo(); fogInfo.fog = RenderSettings.fog; fogInfo.fogMode = RenderSettings.fogMode; fogInfo.fogColor = RenderSettings.fogColor; fogInfo.fogStartDistance = RenderSettings.fogStartDistance; fogInfo.fogEndDistance = RenderSettings.fogEndDistance; lightmapNear = new List <Texture2D>(); lightmapFar = new List <Texture2D>(); for (int i = 0; i < LightmapSettings.lightmaps.Length; i++) { LightmapData data = LightmapSettings.lightmaps[i]; if (data.lightmapDir != null) { lightmapNear.Add(data.lightmapDir); } if (data.lightmapColor != null) { lightmapFar.Add(data.lightmapColor); } } m_RendererInfo = new List <RendererInfo>(); var renderers = GetComponentsInChildren <MeshRenderer>(); foreach (MeshRenderer r in renderers) { if (r.lightmapIndex != -1) { RendererInfo info = new RendererInfo(); info.renderer = r; info.lightmapOffsetScale = r.lightmapScaleOffset; info.lightmapIndex = r.lightmapIndex; m_RendererInfo.Add(info); } } terrain = GetComponentInChildren <Terrain>(); if (terrain != null) { terrainRendererInfo = new RendererInfo(); terrainRendererInfo.lightmapOffsetScale = terrain.lightmapScaleOffset; terrainRendererInfo.lightmapIndex = terrain.lightmapIndex; } lightmapsMode = LightmapSettings.lightmapsMode; }
static void GenerateLightmapInfo(GameObject root, List <RendererInfo> newRendererInfos, List <Texture2D> newLightmapsLight, List <Texture2D> newLightmapsDir, List <Texture2D> newShadowmasks, LightmapsMode newLightmapsMode) { var renderers = FindObjectsOfType(typeof(MeshRenderer)); Debug.Log("stored info for " + renderers.Length + " meshrenderers"); foreach (MeshRenderer renderer in renderers) { // TEMP CODE!!!!!!!!!!!! 测试场景中有很多物体用的shader无法烘焙出lightmap,index=65536.... by mage //if (renderer.lightmapIndex != -1) if (renderer.lightmapIndex == 0) { RendererInfo info = new RendererInfo(); info.renderer = renderer; info.lightmapOffsetScale = renderer.lightmapScaleOffset; Texture2D lightmaplight = LightmapSettings.lightmaps[renderer.lightmapIndex].lightmapColor; info.lightmapIndex = newLightmapsLight.IndexOf(lightmaplight); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsLight.Count; newLightmapsLight.Add(lightmaplight); } Texture2D shadowmask = LightmapSettings.lightmaps[renderer.lightmapIndex].shadowMask; info.lightmapIndex = newShadowmasks.IndexOf(shadowmask); if (info.lightmapIndex == -1) { info.lightmapIndex = newShadowmasks.Count; newShadowmasks.Add(shadowmask); } if (newLightmapsMode != LightmapsMode.NonDirectional) { Texture2D lightmapdir = LightmapSettings.lightmaps[renderer.lightmapIndex].lightmapDir; info.lightmapIndex = newLightmapsDir.IndexOf(lightmapdir); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsDir.Count; newLightmapsDir.Add(lightmapdir); } } newRendererInfos.Add(info); } } }
public void SaveLightmap() { m_RendererInfo.Clear(); lightmapsMode = LightmapSettings.lightmapsMode; lightProbes = LightmapSettings.lightProbes; var renderers = GetComponentsInChildren <MeshRenderer> (); Texture2D lightmapTexture; LightmapData lightMapData; m_Lightmaps = new Texture2D[LightmapSettings.lightmaps.Length]; foreach (MeshRenderer r in renderers) { if (r.lightmapIndex != -1) { RendererInfo info = new RendererInfo(); info.renderer = r; info.lightmapOffsetScale = r.lightmapScaleOffset; info.lightmapIndex = r.lightmapIndex; //===================================== // Debug.Log (r.lightmapIndex); lightMapData = LightmapSettings.lightmaps [r.lightmapIndex]; #if UNITY_5_6_OR_NEWER lightmapTexture = lightMapData.lightmapColor; #else lightmapTexture = lightMapData.lightmapLight; #endif // info.lightmapIndex = m_Lightmaps.IndexOf (lightmapTexture); if (m_Lightmaps [r.lightmapIndex] == null) { info.lightmapIndex = r.lightmapIndex; // m_Lightmaps.Add (lightmapTexture); m_Lightmaps [r.lightmapIndex] = lightmapTexture; } //===================================== m_RendererInfo.Add(info); } } }
public void SaveSettings() { mode = LightmapSettings.lightmapsMode; lightmapFar = null; lightmapNear = null; if (LightmapSettings.lightmaps != null && LightmapSettings.lightmaps.Length > 0) { int l = LightmapSettings.lightmaps.Length; lightmapFar = new Texture2D[l]; lightmapNear = new Texture2D[l]; for (int i = 0; i < l; i++) { lightmapFar[i] = LightmapSettings.lightmaps[i].lightmapColor; lightmapNear[i] = LightmapSettings.lightmaps[i].lightmapDir; } } RendererLightMapSetting[] savers = Transform.FindObjectsOfType <RendererLightMapSetting>(); foreach (RendererLightMapSetting s in savers) { s.SaveSettings(); } }
public void LoadLightmaps() { mode = LightmapSettings.lightmapsMode; lightmapFar = null; lightmapNear = null; if (LightmapSettings.lightmaps != null && LightmapSettings.lightmaps.Length > 0) { int l = LightmapSettings.lightmaps.Length; lightmapFar = new Texture2D[l]; lightmapNear = new Texture2D[l]; for (int i = 0; i < l; i++) { lightmapFar[i] = LightmapSettings.lightmaps[i].lightmapFar; lightmapNear[i] = LightmapSettings.lightmaps[i].lightmapNear; } } MeshLightmapSetting[] savers = FindObjectsOfType <MeshLightmapSetting>(); foreach (MeshLightmapSetting s in savers) { s.SaveSettings(); } }
public void SaveLightmap() { fogInfo = new FogInfo(); fogInfo.fog = RenderSettings.fog; fogInfo.fogMode = RenderSettings.fogMode; fogInfo.fogColor = RenderSettings.fogColor; fogInfo.fogStartDistance = RenderSettings.fogStartDistance; fogInfo.fogEndDistance = RenderSettings.fogEndDistance; m_RendererInfo = new List <RendererInfo>(); var renderers = GetComponentsInChildren <MeshRenderer>(); foreach (MeshRenderer r in renderers) { if (r.lightmapIndex != -1) { RendererInfo info = new RendererInfo(); info.renderer = r; info.lightmapOffsetScale = r.lightmapScaleOffset; info.lightmapIndex = r.lightmapIndex; m_RendererInfo.Add(info); } } terrains = GetComponentsInChildren <Terrain>(); if (terrains != null) { int cnt = terrains.Length; terrainsRendererInfo = new TerrainInfo[cnt]; for (int i = 0; i < cnt; i++) { var terrainRenderer = new TerrainInfo(); terrainRenderer.lightmapOffsetScale = terrains[i].lightmapScaleOffset; terrainRenderer.lightmapIndex = terrains[i].lightmapIndex; terrainsRendererInfo[i] = terrainRenderer; } } lightmapsMode = LightmapSettings.lightmapsMode; }
/// <summary>This function needs to be called after importing an assetbundle with exported lightmap data (see <see cref="StoreAll"/>), in order to restore it to the object. The collection it lightmaps will be set from the set of all lightmaps of all <see cref="LightmapParams"/> instances.</summary> public static void RestoreAll(LightmapsMode mode, bool removeComponentsAfterwards = false, bool setStatic = false) { List <LightmapData> newLightmaps = new List <LightmapData>(); foreach (LightmapParams p in FindObjectsOfType <LightmapParams>()) { Renderer r = p.gameObject.GetComponent <Renderer>(); if (!r) { continue; } r.lightmapIndex = p.lightmapIndex; r.lightmapScaleOffset = p.lightmapScaleOffset; // collect lightmaps from references: while (newLightmaps.Count <= p.lightmapIndex) { newLightmaps.Add(new LightmapData()); } newLightmaps[p.lightmapIndex].lightmapDir = p.lightmapNear; newLightmaps[p.lightmapIndex].lightmapColor = p.lightmapFar; if (setStatic) { r.gameObject.isStatic = true; } if (removeComponentsAfterwards) { Destroy(p); } } // activate: LightmapSettings.lightmaps = newLightmaps.ToArray(); LightmapSettings.lightmapsMode = mode; }
public void StoreLightmapInfos(int index) { if (GLog.IsLogInfoEnabled) { GLog.LogInfo("Storing data for lighting scenario " + index); } if (UnityEditor.Lightmapping.giWorkflowMode != UnityEditor.Lightmapping.GIWorkflowMode.OnDemand) { if (GLog.IsLogErrorEnabled) { GLog.LogError("ExtractLightmapData requires that you have baked you lightmaps and Auto mode is disabled."); } return; } var newLightingScenarioData = new LightingScenarioData(); var newRendererInfos = new List <RendererInfo>(); var newLightmapsTextures = new List <Texture2D>(); var newLightmapsTexturesDir = new List <Texture2D>(); var newLightmapsMode = new LightmapsMode(); var newSphericalHarmonicsList = new List <SphericalHarmonics>(); newLightmapsMode = LightmapSettings.lightmapsMode; GenerateLightmapInfo(gameObject, newRendererInfos, newLightmapsTextures, newLightmapsTexturesDir, newLightmapsMode); newLightingScenarioData.lightmapsMode = newLightmapsMode; newLightingScenarioData.lightmaps = newLightmapsTextures.ToArray(); if (newLightmapsMode != LightmapsMode.NonDirectional) { newLightingScenarioData.lightmapsDir = newLightmapsTexturesDir.ToArray(); } newLightingScenarioData.rendererInfos = newRendererInfos.ToArray(); var scene_LightProbes = new SphericalHarmonicsL2[LightmapSettings.lightProbes.bakedProbes.Length]; scene_LightProbes = LightmapSettings.lightProbes.bakedProbes; for (int i = 0; i < scene_LightProbes.Length; i++) { var SHCoeff = new SphericalHarmonics(); // j is coefficient for (int j = 0; j < 3; j++) { //k is channel ( r g b ) for (int k = 0; k < 9; k++) { SHCoeff.coefficients[j * 9 + k] = scene_LightProbes[i][j, k]; } } newSphericalHarmonicsList.Add(SHCoeff); } newLightingScenarioData.lightProbes = newSphericalHarmonicsList.ToArray(); lightingScenariosData = newLightingScenarioData; if (lightingScenesNames == null || lightingScenesNames.Count < lightingScenariosCount) { lightingScenesNames = new List <string>(); while (lightingScenesNames.Count < lightingScenariosCount) { lightingScenesNames.Add(null); } } }
internal unsafe static void IsLightmapsModeSupportedByRef(LightmapsMode mode, IntPtr isSupportedPtr) { bool *ptr = (bool *)((void *)isSupportedPtr); *ptr = ((SupportedRenderingFeatures.active.lightmapsModes & mode) == mode); }
internal static unsafe void IsLightmapsModeSupportedByRef(LightmapsMode mode, IntPtr isSupportedPtr) { var isSupported = (bool *)isSupportedPtr; *isSupported = ((active.lightmapsModes & mode) == mode); }
public void SetMode(LightmapsMode mode) { LightmapSettings.lightmapsMode = mode; }
//Nav mesh settings can't be accessed via script :( //Lightmapping is VERY version-specific. You may have to modify the settings that are compared public void CaptureSettings() { #if UNITY_5 #else aoAmount = LightmapEditorSettings.aoAmount; aoContrast = LightmapEditorSettings.aoContrast; bounceBoost = LightmapEditorSettings.bounceBoost; bounceIntensity = LightmapEditorSettings.bounceIntensity; bounces = LightmapEditorSettings.bounces; quality = LightmapEditorSettings.quality; skyLightColor = LightmapEditorSettings.skyLightColor; skyLightIntensity = LightmapEditorSettings.skyLightIntensity; finalGatherContrastThreshold = LightmapEditorSettings.finalGatherContrastThreshold; finalGatherGradientThreshold = LightmapEditorSettings.finalGatherGradientThreshold; finalGatherInterpolationPoints = LightmapEditorSettings.finalGatherInterpolationPoints; finalGatherRays = LightmapEditorSettings.finalGatherRays; lastUsedResolution = LightmapEditorSettings.lastUsedResolution; lockAtlas = LightmapEditorSettings.lockAtlas; #if !(UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5) bakedColorSpace = LightmapSettings.bakedColorSpace; #endif #endif ambientLight = RenderSettings.ambientLight; #if UNITY_4_3 || UNITY_4_5 || UNITY_5 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 flareFadeSpeed = RenderSettings.flareFadeSpeed; #endif #if UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 #else lightProbes = LightmapSettings.lightProbes; padding = LightmapEditorSettings.padding; #endif flareStrength = RenderSettings.flareStrength; fog = RenderSettings.fog; fogColor = RenderSettings.fogColor; fogDensity = RenderSettings.fogDensity; fogEndDistance = RenderSettings.fogEndDistance; fogMode = RenderSettings.fogMode; fogStartDistance = RenderSettings.fogStartDistance; haloStrength = RenderSettings.haloStrength; skybox = RenderSettings.skybox; lightmaps = LightmapSettings.lightmaps; lightmapsMode = LightmapSettings.lightmapsMode; aoMaxDistance = LightmapEditorSettings.aoMaxDistance; maxAtlasHeight = LightmapEditorSettings.maxAtlasHeight; maxAtlasWidth = LightmapEditorSettings.maxAtlasWidth; resolution = LightmapEditorSettings.resolution; textureCompression = LightmapEditorSettings.textureCompression; }
static void GenerateLightmapInfo(GameObject root, List <RendererInfo> newRendererInfos, List <Texture2D> newLightmapsLight, List <Texture2D> newLightmapsDir, LightmapsMode newLightmapsMode) { //BuglyAgent.PrintLog(LogSeverity.LogDebug, "GenerateLightmapInfo"); var renderers = FindObjectsOfType(typeof(MeshRenderer)); if (GLog.IsLogInfoEnabled) { GLog.LogInfo("stored info for " + renderers.Length + " meshrenderers"); } foreach (MeshRenderer renderer in renderers) { if (renderer.lightmapIndex != -1) { RendererInfo info = new RendererInfo(); info.renderer = renderer; info.lightmapOffsetScale = renderer.lightmapScaleOffset; if (renderer.lightmapIndex >= LightmapSettings.lightmaps.Length) { if (GLog.IsLogErrorEnabled) { GLog.LogError("Render Errror"); } continue; } Texture2D lightmaplight = LightmapSettings.lightmaps[renderer.lightmapIndex].lightmapColor; info.lightmapIndex = newLightmapsLight.IndexOf(lightmaplight); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsLight.Count; newLightmapsLight.Add(lightmaplight); } if (newLightmapsMode != LightmapsMode.NonDirectional) { Texture2D lightmapdir = LightmapSettings.lightmaps[renderer.lightmapIndex].lightmapDir; info.lightmapIndex = newLightmapsDir.IndexOf(lightmapdir); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsDir.Count; newLightmapsDir.Add(lightmapdir); } } newRendererInfos.Add(info); } } }
static void GenerateLightmapInfo(GameObject root, List <RendererInfo> newRendererInfos, List <Texture2D> newLightmapsLight, List <Texture2D> newLightmapsDir, List <Texture2D> newLightmapsShadow, LightmapsMode newLightmapsMode) { var renderers = FindObjectsOfType(typeof(MeshRenderer)); Debug.Log("stored info for " + renderers.Length + " meshrenderers"); foreach (MeshRenderer renderer in renderers) { if (renderer.lightmapIndex != -1) { RendererInfo info = new RendererInfo(); info.renderer = renderer; info.lightmapOffsetScale = renderer.lightmapScaleOffset; if (renderer.lightmapIndex == 65534) { return; } Texture2D lightmaplight = LightmapSettings.lightmaps[renderer.lightmapIndex].lightmapColor; info.lightmapIndex = newLightmapsLight.IndexOf(lightmaplight); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsLight.Count; newLightmapsLight.Add(lightmaplight); } if (newLightmapsMode != LightmapsMode.NonDirectional) { Texture2D lightmapdir = LightmapSettings.lightmaps[renderer.lightmapIndex].lightmapDir; info.lightmapIndex = newLightmapsDir.IndexOf(lightmapdir); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsDir.Count; newLightmapsDir.Add(lightmapdir); } } if (LightmapSettings.lightmaps[renderer.lightmapIndex].shadowMask != null) { Texture2D lightmapShadow = LightmapSettings.lightmaps[renderer.lightmapIndex].shadowMask; info.lightmapIndex = newLightmapsShadow.IndexOf(lightmapShadow); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsShadow.Count; newLightmapsShadow.Add(lightmapShadow); } } newRendererInfos.Add(info); } } }
internal static bool IsLightmapsModeSupported(LightmapsMode mode) { return((SupportedRenderingFeatures.active.supportedLightmapsModes & mode) == mode); }
static void GenerateLightmapInfo(GameObject root, List <RendererInfo> newRendererInfos, List <Texture2D> newLightmapsLight, List <Texture2D> newLightmapsDir, List <Texture2D> newLightmapsShadow, LightmapsMode newLightmapsMode) { Terrain terrain = FindObjectOfType <Terrain>(); if (terrain != null && terrain.lightmapIndex != -1 && terrain.lightmapIndex != 65534) { RendererInfo terrainRendererInfo = new RendererInfo(); terrainRendererInfo.lightmapOffsetScale = terrain.lightmapScaleOffset; Texture2D lightmaplight = LightmapSettings.lightmaps[terrain.lightmapIndex].lightmapColor; terrainRendererInfo.lightmapIndex = newLightmapsLight.IndexOf(lightmaplight); if (terrainRendererInfo.lightmapIndex == -1) { terrainRendererInfo.lightmapIndex = newLightmapsLight.Count; newLightmapsLight.Add(lightmaplight); } if (newLightmapsMode != LightmapsMode.NonDirectional) { Texture2D lightmapdir = LightmapSettings.lightmaps[terrain.lightmapIndex].lightmapDir; terrainRendererInfo.lightmapIndex = newLightmapsDir.IndexOf(lightmapdir); if (terrainRendererInfo.lightmapIndex == -1) { terrainRendererInfo.lightmapIndex = newLightmapsDir.Count; newLightmapsDir.Add(lightmapdir); } } if (LightmapSettings.lightmaps[terrain.lightmapIndex].shadowMask != null) { Texture2D lightmapShadow = LightmapSettings.lightmaps[terrain.lightmapIndex].shadowMask; terrainRendererInfo.lightmapIndex = newLightmapsShadow.IndexOf(lightmapShadow); if (terrainRendererInfo.lightmapIndex == -1) { terrainRendererInfo.lightmapIndex = newLightmapsShadow.Count; newLightmapsShadow.Add(lightmapShadow); } } newRendererInfos.Add(terrainRendererInfo); if (Application.isEditor) { Debug.Log("Terrain lightmap stored in" + terrainRendererInfo.lightmapIndex.ToString()); } } var renderers = FindObjectsOfType(typeof(Renderer)); if (Application.isEditor) { Debug.Log("stored info for " + renderers.Length + " meshrenderers"); } foreach (Renderer renderer in renderers) { if (renderer.lightmapIndex != -1 && renderer.lightmapIndex != 65534) { RendererInfo info = new RendererInfo(); info.renderer = renderer; info.lightmapOffsetScale = renderer.lightmapScaleOffset; Texture2D lightmaplight = LightmapSettings.lightmaps[renderer.lightmapIndex].lightmapColor; info.lightmapIndex = newLightmapsLight.IndexOf(lightmaplight); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsLight.Count; newLightmapsLight.Add(lightmaplight); } if (newLightmapsMode != LightmapsMode.NonDirectional) { Texture2D lightmapdir = LightmapSettings.lightmaps[renderer.lightmapIndex].lightmapDir; info.lightmapIndex = newLightmapsDir.IndexOf(lightmapdir); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsDir.Count; newLightmapsDir.Add(lightmapdir); } } if (LightmapSettings.lightmaps[renderer.lightmapIndex].shadowMask != null) { Texture2D lightmapShadow = LightmapSettings.lightmaps[renderer.lightmapIndex].shadowMask; info.lightmapIndex = newLightmapsShadow.IndexOf(lightmapShadow); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsShadow.Count; newLightmapsShadow.Add(lightmapShadow); } } newRendererInfos.Add(info); } } }
public void StoreLightmapInfos(int index) { var newLightingScenarioData = new LightingScenarioData(); var newRendererInfos = new List <RendererInfo>(); var newLightmapsTextures = new List <Texture2D>(); var newLightmapsTexturesDir = new List <Texture2D>(); var newLightmapsMode = new LightmapsMode(); var newSphericalHarmonicsList = new List <SphericalHarmonics>(); var newLightmapsShadowMasks = new List <Texture2D>(); newLightmapsMode = LightmapSettings.lightmapsMode; GenerateLightmapInfo(gameObject, newRendererInfos, newLightmapsTextures, newLightmapsTexturesDir, newLightmapsShadowMasks, newLightmapsMode); newLightingScenarioData.lightmapsMode = newLightmapsMode; newLightingScenarioData.lightmaps = newLightmapsTextures.ToArray(); if (newLightmapsMode != LightmapsMode.NonDirectional) { newLightingScenarioData.lightmapsDir = newLightmapsTexturesDir.ToArray(); } //Mixed or realtime support newLightingScenarioData.hasRealtimeLights = latestBuildHasReltimeLights; newLightingScenarioData.shadowMasks = newLightmapsShadowMasks.ToArray(); newLightingScenarioData.rendererInfos = newRendererInfos.ToArray(); var scene_LightProbes = new SphericalHarmonicsL2[LightmapSettings.lightProbes.bakedProbes.Length]; scene_LightProbes = LightmapSettings.lightProbes.bakedProbes; for (int i = 0; i < scene_LightProbes.Length; i++) { var SHCoeff = new SphericalHarmonics(); // j is coefficient for (int j = 0; j < 3; j++) { //k is channel ( r g b ) for (int k = 0; k < 9; k++) { SHCoeff.coefficients[j * 9 + k] = scene_LightProbes[i][j, k]; } } newSphericalHarmonicsList.Add(SHCoeff); } newLightingScenarioData.lightProbes = newSphericalHarmonicsList.ToArray(); if (lightingScenariosData.Count < index + 1) { lightingScenariosData.Insert(index, newLightingScenarioData); } else { lightingScenariosData[index] = newLightingScenarioData; } lightingScenariosCount = lightingScenariosData.Count; if (lightingScenesNames == null || lightingScenesNames.Length < lightingScenariosCount) { lightingScenesNames = new string[lightingScenariosCount]; } }
public static void SetDirectionalMode(LightmapsMode mode) { SetInt("m_LightmapEditorSettings.m_LightmapsBakeMode", (int)mode); }
public void SaveLightMaps() { LightingScenarioData newLightingScenario = new LightingScenarioData(); var newRendererInfos = new List <RendererInfo>(); var newLightmapsTextures = new List <Texture2D>(); var newLightmapsTexturesDir = new List <Texture2D>(); var newLightmapsTexturesShadow = new List <Texture2D>(); var newLightmapsMode = new LightmapsMode(); var newSphericalHarmonicsList = new List <SphericalHarmonics>(); newLightmapsMode = LightmapSettings.lightmapsMode; var renderers = FindObjectsOfType(typeof(MeshRenderer)); Debug.Log("stored info for " + renderers.Length + " meshrenderers"); foreach (MeshRenderer renderer in renderers) { if (renderer.lightmapIndex != -1) { RendererInfo info = new RendererInfo(); info.renderer = renderer; info.lightmapOffsetScale = renderer.lightmapScaleOffset; Texture2D lightmaplight = LightmapSettings.lightmaps[renderer.lightmapIndex].lightmapColor; info.lightmapIndex = newLightmapsTextures.IndexOf(lightmaplight); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsTextures.Count; newLightmapsTextures.Add(lightmaplight); } if (newLightmapsMode != LightmapsMode.NonDirectional) { //first directional lighting Texture2D lightmapdir = LightmapSettings.lightmaps[renderer.lightmapIndex].lightmapDir; info.lightmapIndex = newLightmapsTexturesDir.IndexOf(lightmapdir); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsTexturesDir.Count; newLightmapsTexturesDir.Add(lightmapdir); } LightmapData lmd = LightmapSettings.lightmaps[0]; //now the shadowmask Texture2D lightmapshadow = LightmapSettings.lightmaps[renderer.lightmapIndex].shadowMask; if (lightmapshadow != null) { info.lightmapIndex = newLightmapsTexturesShadow.IndexOf(lightmapshadow); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsTexturesShadow.Count; newLightmapsTexturesShadow.Add(lightmapshadow); } } } newRendererInfos.Add(info); } } newLightingScenario.lightmapsMode = newLightmapsMode; newLightingScenario.lightmaps = newLightmapsTextures.ToArray(); if (newLightmapsMode != LightmapsMode.NonDirectional) { newLightingScenario.lightmapsDir = newLightmapsTexturesDir.ToArray(); newLightingScenario.lightmapsShadow = newLightmapsTexturesShadow.ToArray(); } newLightingScenario.rendererInfos = newRendererInfos.ToArray(); var scene_LightProbes = new SphericalHarmonicsL2[LightmapSettings.lightProbes.bakedProbes.Length]; scene_LightProbes = LightmapSettings.lightProbes.bakedProbes; for (int i = 0; i < scene_LightProbes.Length; i++) { var SHCoeff = new SphericalHarmonics(); // j is coefficient for (int j = 0; j < 3; j++) { //k is channel ( r g b ) for (int k = 0; k < 9; k++) { SHCoeff.coefficients[j * 9 + k] = scene_LightProbes[i][j, k]; } } newSphericalHarmonicsList.Add(SHCoeff); } newLightingScenario.lightProbes = newSphericalHarmonicsList.ToArray(); // write the files and map config data. CreateResourcesDirectory(m_currentLightScenario); string resourcesDir = GetResourcesDirectory(m_currentLightScenario); CopyTextureToResources(resourcesDir, newLightingScenario.lightmaps); CopyTextureToResources(resourcesDir, newLightingScenario.lightmapsDir); CopyTextureToResources(resourcesDir, newLightingScenario.lightmapsShadow); newLightingScenario.name = m_currentLightScenario; SaveLightScenarioData(newLightingScenario); UnityEditor.EditorUtility.SetDirty(this.gameObject); }
public void StoreLightmapInfos(int index) { Debug.Log("Storing data for lighting scenario " + index); if (UnityEditor.Lightmapping.giWorkflowMode != UnityEditor.Lightmapping.GIWorkflowMode.OnDemand) { Debug.LogError("ExtractLightmapData requires that you have baked you lightmaps and Auto mode is disabled."); return; } var newLightingScenarioData = new LightingScenarioData(); var newRendererInfos = new List <RendererInfo>(); var newLightmapsTextures = new List <Texture2D>(); var newShadowmasksTextures = new List <Texture2D>(); var newLightmapsTexturesDir = new List <Texture2D>(); var newLightmapsMode = new LightmapsMode(); var newSphericalHarmonicsList = new List <SphericalHarmonics>(); newLightmapsMode = LightmapSettings.lightmapsMode; GenerateLightmapInfo(gameObject, newRendererInfos, newLightmapsTextures, newLightmapsTexturesDir, newShadowmasksTextures, newLightmapsMode); newLightingScenarioData.lightmapsMode = newLightmapsMode; newLightingScenarioData.lightmaps = newLightmapsTextures.ToArray(); newLightingScenarioData.shadowMasks = newShadowmasksTextures.ToArray(); if (newLightmapsMode != LightmapsMode.NonDirectional) { newLightingScenarioData.lightmapsDir = newLightmapsTexturesDir.ToArray(); } newLightingScenarioData.rendererInfos = newRendererInfos.ToArray(); //var scene_LightProbes = new SphericalHarmonicsL2[LightmapSettings.lightProbes.bakedProbes.Length]; //scene_LightProbes = LightmapSettings.lightProbes.bakedProbes; // for (int i = 0; i < scene_LightProbes.Length; i++) // { // var SHCoeff = new SphericalHarmonics(); // // j is coefficient // for (int j = 0; j < 3; j++) // { // //k is channel ( r g b ) // for (int k = 0; k < 9; k++) // { // SHCoeff.coefficients[j*9+k] = scene_LightProbes[i][j, k]; // } // } // newSphericalHarmonicsList.Add(SHCoeff); // } //newLightingScenarioData.lightProbes = newSphericalHarmonicsList.ToArray (); if (lightingScenariosData.Count < index + 1) { lightingScenariosData.Insert(index, newLightingScenarioData); } else { lightingScenariosData[index] = newLightingScenarioData; } lightingScenariosCount = lightingScenariosData.Count; }
public void Save() { if (_ambientEquatorColor != RenderSettings.ambientEquatorColor) { _ambientEquatorColor = RenderSettings.ambientEquatorColor; } if (_ambientGroundColor != RenderSettings.ambientGroundColor) { _ambientGroundColor = RenderSettings.ambientGroundColor; } if (_ambientIntensity != RenderSettings.ambientIntensity) { _ambientIntensity = RenderSettings.ambientIntensity; } if (_subtractiveShadowColor != RenderSettings.subtractiveShadowColor) { _subtractiveShadowColor = RenderSettings.subtractiveShadowColor; } if (_ambientProbe != RenderSettings.ambientProbe) { _ambientProbe = RenderSettings.ambientProbe; } if (_ambientMode != RenderSettings.ambientMode) { _ambientMode = RenderSettings.ambientMode; } if (_ambientSkyColor != RenderSettings.ambientSkyColor) { _ambientSkyColor = RenderSettings.ambientSkyColor; } if (_defaultReflectionMode != RenderSettings.defaultReflectionMode) { _defaultReflectionMode = RenderSettings.defaultReflectionMode; } if (_defaultReflectionResolution != RenderSettings.defaultReflectionResolution) { _defaultReflectionResolution = RenderSettings.defaultReflectionResolution; } if (_reflectionBounces != RenderSettings.reflectionBounces) { _reflectionBounces = RenderSettings.reflectionBounces; } if (_reflectionIntensity != RenderSettings.reflectionIntensity) { _reflectionIntensity = RenderSettings.reflectionIntensity; } if (_aoExponentDirect != LightmapEditorSettings.aoExponentDirect) { _aoExponentDirect = LightmapEditorSettings.aoExponentDirect; } if (_aoExponentIndirect != LightmapEditorSettings.aoExponentIndirect) { _aoExponentIndirect = LightmapEditorSettings.aoExponentIndirect; } if (_aoMaxDistance != LightmapEditorSettings.aoMaxDistance) { _aoMaxDistance = LightmapEditorSettings.aoMaxDistance; } if (_bakeResolution != LightmapEditorSettings.bakeResolution) { _bakeResolution = LightmapEditorSettings.bakeResolution; } if (_enableAmbientOcclusion != LightmapEditorSettings.enableAmbientOcclusion) { _enableAmbientOcclusion = LightmapEditorSettings.enableAmbientOcclusion; } if (_maxAtlasSize != LightmapEditorSettings.maxAtlasSize) { _maxAtlasSize = LightmapEditorSettings.maxAtlasSize; } if (_padding != LightmapEditorSettings.padding) { _padding = LightmapEditorSettings.padding; } if (_realtimeResolution != LightmapEditorSettings.realtimeResolution) { _realtimeResolution = LightmapEditorSettings.realtimeResolution; } if (_reflectionCubemapCompression != LightmapEditorSettings.reflectionCubemapCompression) { _reflectionCubemapCompression = LightmapEditorSettings.reflectionCubemapCompression; } if (_textureCompression != LightmapEditorSettings.textureCompression) { _textureCompression = LightmapEditorSettings.textureCompression; } if (_bakedGI != Lightmapping.bakedGI) { _bakedGI = Lightmapping.bakedGI; } if (_bounceBoost != Lightmapping.bounceBoost) { _bounceBoost = Lightmapping.bounceBoost; } if (_giWorkflowMode != Lightmapping.giWorkflowMode) { _giWorkflowMode = Lightmapping.giWorkflowMode; } if (_indirectOutputScale != Lightmapping.indirectOutputScale) { _indirectOutputScale = Lightmapping.indirectOutputScale; } if (_realtimeGI != Lightmapping.realtimeGI) { _realtimeGI = Lightmapping.realtimeGI; } if (_lightmapsMode != LightmapSettings.lightmapsMode) { _lightmapsMode = LightmapSettings.lightmapsMode; } }
internal static unsafe void IsLightmapsModeSupportedByRef(LightmapsMode mode, IntPtr isSupportedPtr) { var isSupported = (bool *)isSupportedPtr; *isSupported = ((SupportedRenderingFeatures.active.supportedLightmapsModes & mode) == mode); }
public void StoreLightmapInfos(int index) { Debug.Log("Storing data for lighting scenario " + index); if (UnityEditor.Lightmapping.giWorkflowMode != UnityEditor.Lightmapping.GIWorkflowMode.OnDemand) { Debug.LogError("ExtractLightmapData requires that you have baked you lightmaps and Auto mode is disabled."); return; } var newLightingScenarioData = new LightingScenarioData(); var newRendererInfos = new List <RendererInfo>(); var newLightmapsTextures = new List <Texture2D>(); var newLightmapsTexturesDir = new List <Texture2D>(); var newLightmapsMode = new LightmapsMode(); var newSphericalHarmonicsList = new List <SphericalHarmonics>(); var newLightmapsShadowMasks = new List <Texture2D>(); newLightmapsMode = LightmapSettings.lightmapsMode; GenerateLightmapInfo(gameObject, newRendererInfos, newLightmapsTextures, newLightmapsTexturesDir, newLightmapsShadowMasks, newLightmapsMode); newLightingScenarioData.lightmapsMode = newLightmapsMode; newLightingScenarioData.lightmaps = newLightmapsTextures.ToArray(); if (newLightmapsMode != LightmapsMode.NonDirectional) { newLightingScenarioData.lightmapsDir = newLightmapsTexturesDir.ToArray(); } //Mixed or realtime support newLightingScenarioData.hasRealtimeLights = latestBuildHasReltimeLights; newLightingScenarioData.shadowMasks = newLightmapsShadowMasks.ToArray(); newLightingScenarioData.rendererInfos = newRendererInfos.ToArray(); var scene_LightProbes = new SphericalHarmonicsL2[LightmapSettings.lightProbes.bakedProbes.Length]; scene_LightProbes = LightmapSettings.lightProbes.bakedProbes; for (int i = 0; i < scene_LightProbes.Length; i++) { var SHCoeff = new SphericalHarmonics(); // j is coefficient for (int j = 0; j < 3; j++) { //k is channel ( r g b ) for (int k = 0; k < 9; k++) { SHCoeff.coefficients[j * 9 + k] = scene_LightProbes[i][j, k]; } } newSphericalHarmonicsList.Add(SHCoeff); } newLightingScenarioData.lightProbes = newSphericalHarmonicsList.ToArray(); if (lightingScenariosData.Count < index + 1) { lightingScenariosData.Insert(index, newLightingScenarioData); } else { lightingScenariosData[index] = newLightingScenarioData; } lightingScenariosCount = lightingScenariosData.Count; if (lightingScenesNames == null || lightingScenesNames.Length < lightingScenariosCount) { lightingScenesNames = new string[lightingScenariosCount]; } if (latestBuildHasReltimeLights && lightingScenesNames[index] != null) { lightingScenesNames[index] = lightingScenariosScenes[index].name; } }