diff --git a/Source/LightsOut/LOAmbient.cs b/Source/LightsOut/LOAmbient.cs index e39d74a..0a721e4 100644 --- a/Source/LightsOut/LOAmbient.cs +++ b/Source/LightsOut/LOAmbient.cs @@ -18,6 +18,7 @@ class LOAmbient { Color originalAmbientLight; LightmapData[] originalLightmapData; Material originalSkybox; + float originalAmbientIntensity; public LOAmbient(EditorFacility facility, EditorLevel level, GameObject[] gameObjects, Camera camera, int layer) { mainCamera = camera; @@ -29,14 +30,15 @@ public LOAmbient(EditorFacility facility, EditorLevel level, GameObject[] gameOb originalAmbientLight = RenderSettings.ambientLight; originalSkybox = RenderSettings.skybox; originalLightmapData = LightmapSettings.lightmaps; + originalAmbientIntensity = RenderSettings.ambientIntensity; // Create fake skybox skyCamera = new GameObject("NightSkyboxCamera", typeof(Camera)); - skyCamera.camera.depth = mainCamera.depth - 1; - skyCamera.camera.clearFlags = CameraClearFlags.Skybox; - skyCamera.camera.cullingMask = 0; - - nightSkyboxMaterial = new Material(originalSkybox); + skyCamera.GetComponent().depth = mainCamera.depth - 1; + skyCamera.GetComponent().clearFlags = CameraClearFlags.Skybox; + skyCamera.GetComponent().cullingMask = 0; + + nightSkyboxMaterial = new Material(originalSkybox); // GalaxyTex_PositiveX should be viewed outside window Debug.Log("LightsOut: Loading Night Sky Textures"); @@ -104,8 +106,8 @@ public LOAmbient(EditorFacility facility, EditorLevel level, GameObject[] gameOb ChangeLayersRecursively(gameObject, newLayer, "Component_611_4"); ChangeLayersRecursively(gameObject, newLayer, "Component_611_5"); ChangeLayersRecursively(gameObject, newLayer, "Component_611_6"); - //ChangeLayersRecursively(gameObject, newLayer, "Component_749_1"); // Glow from Side Lights! - //ChangeLayersRecursively(gameObject, newLayer, "Component_750_1"); // Lights! + ChangeLayersRecursively(gameObject, newLayer, "Component_749_1"); // Glow from Side Lights! + ChangeLayersRecursively(gameObject, newLayer, "Component_750_1"); // Lights! } break; } @@ -114,8 +116,10 @@ public LOAmbient(EditorFacility facility, EditorLevel level, GameObject[] gameOb public void SetAmbientMode(EditorTime time) { if (time == EditorTime.Night) { - RenderSettings.ambientLight = new Color(0.15f, 0.15f, 0.15f); + + RenderSettings.ambientLight = new Color(0.05f, 0.05f, 0.05f); RenderSettings.fog = false; + RenderSettings.ambientIntensity = 0.05f; mainCamera.clearFlags = CameraClearFlags.Nothing; LightmapSettings.lightmaps = new LightmapData[] { }; @@ -125,6 +129,7 @@ public void SetAmbientMode(EditorTime time) { RenderSettings.ambientLight = originalAmbientLight; RenderSettings.fog = true; RenderSettings.skybox = originalSkybox; + RenderSettings.ambientIntensity = originalAmbientIntensity; mainCamera.clearFlags = originalClearFlags; LightmapSettings.lightmaps = originalLightmapData; diff --git a/Source/LightsOut/LOExternalLights.cs b/Source/LightsOut/LOExternalLights.cs index d3a6e25..99eaf67 100644 --- a/Source/LightsOut/LOExternalLights.cs +++ b/Source/LightsOut/LOExternalLights.cs @@ -34,9 +34,11 @@ public LOExternalLights(EditorFacility facility, EditorLevel level) { //[LOG 17:53:55.158] Light 5: Spotlight, RGBA(1.000, 1.000, 1.000, 1.000), Default ON //[LOG 17:53:55.159] Parent: Day Lights lightsToChange = new List() { - new LightToChange(){ name = "SpotlightSun", parentName = "Day Lights" }, - new LightToChange(){ name = "Spotlight", parentName = "Day Lights" } - }; + new LightToChange(){ name = "SpotlightCraft", parentName = "Day Lights" }, + new LightToChange(){ name = "SpotlightSun", parentName = "VAB_interior_modern" }, // + new LightToChange(){ name = "Realtime_SpotlightScenery", parentName = "Lighting_Realtime" }, + new LightToChange(){ name = "Shadow Light", parentName = "Day Lights" } + }; break; case EditorLevel.Level2: @@ -57,10 +59,11 @@ public LOExternalLights(EditorFacility facility, EditorLevel level) { //[LOG 17:56:18.874] Light 7: Spotlight, RGBA(1.000, 1.000, 1.000, 1.000), Default ON //[LOG 17:56:18.875] Parent: Day Lights lightsToChange = new List() { - new LightToChange(){ name = "SpotlightSun", parentName = "Day Lights" }, - new LightToChange(){ name = "Spotlight", parentName = "Day Lights" }, - new LightToChange(){ name = "roofFill", parentName = "Day Lights" } - }; + new LightToChange(){ name = "SpotlightCraft", parentName = "Day Lights" }, + new LightToChange(){ name = "SpotlightSun", parentName = "VAB_interior_modern" }, // + new LightToChange(){ name = "Realtime_SpotlightScenery", parentName = "Lighting_Realtime" }, + new LightToChange(){ name = "Shadow Light", parentName = "Day Lights" } + }; break; case EditorLevel.Level3: @@ -85,9 +88,11 @@ public LOExternalLights(EditorFacility facility, EditorLevel level) { //[LOG 17:58:21.712] Light 9: Spotlight, RGBA(1.000, 1.000, 1.000, 1.000), Default ON //[LOG 17:58:21.713] Parent: Day Lights lightsToChange = new List() { - new LightToChange(){ name = "SpotlightSun", parentName = "Day Lights" }, - new LightToChange(){ name = "Spotlight", parentName = "Day Lights" } - }; + new LightToChange(){ name = "SpotlightCraft", parentName = "Day Lights" }, + new LightToChange(){ name = "SpotlightSun", parentName = "VAB_interior_modern" }, // + new LightToChange(){ name = "Realtime_SpotlightScenery", parentName = "Lighting_Realtime" }, + new LightToChange(){ name = "Shadow Light", parentName = "Day Lights" } + }; break; } } @@ -111,9 +116,11 @@ public LOExternalLights(EditorFacility facility, EditorLevel level) { //[LOG 17:54:50.077] Light 7: SpotlightWindow, RGBA(0.866, 0.863, 0.903, 1.000), Default OFF //[LOG 17:54:50.078] Parent: Editors_DayLights lightsToChange = new List() { - new LightToChange(){ name = "SpotlightCraft", parentName = "Editors_DayLights" }, - new LightToChange(){ name = "SpotlightExteriorSun", parentName = "Editors_DayLights" } - }; + new LightToChange(){ name = "Realtime_SpotlightCraft", parentName = "Lighting_Realtime" }, + new LightToChange(){ name = "Realtime_ExteriorSun", parentName = "Lighting_Realtime" }, + new LightToChange(){ name = "Realtime_SpotlightScenery", parentName = "Lighting_Realtime" }, + new LightToChange(){ name = "Realtime_Shadow Light", parentName = "Lighting_Realtime" } + }; break; case EditorLevel.Level2: @@ -134,9 +141,11 @@ public LOExternalLights(EditorFacility facility, EditorLevel level) { //[LOG 17:57:04.724] Light 7: SpotlightWindow, RGBA(0.866, 0.863, 0.903, 1.000), Default OFF //[LOG 17:57:04.725] Parent: Editors_DayLights lightsToChange = new List() { - new LightToChange(){ name = "SpotlightCraft", parentName = "Editors_DayLights" }, - new LightToChange(){ name = "SpotlightExteriorSun", parentName = "Editors_DayLights" } - }; + new LightToChange(){ name = "Realtime_SpotlightCraft", parentName = "Lighting_Realtime" }, + new LightToChange(){ name = "Realtime_ExteriorSun", parentName = "Lighting_Realtime" }, + new LightToChange(){ name = "Realtime_SpotlightScenery", parentName = "Lighting_Realtime" }, + new LightToChange(){ name = "Realtime_Shadow Light", parentName = "Lighting_Realtime" } + }; break; case EditorLevel.Level3: @@ -157,10 +166,11 @@ public LOExternalLights(EditorFacility facility, EditorLevel level) { //[LOG 17:59:41.833] Light 7: SpotlightWindow, RGBA(0.866, 0.863, 0.903, 1.000), Default ON //[LOG 17:59:41.834] Parent: Editors_DayLights lightsToChange = new List() { - new LightToChange(){ name = "SpotlightCraft", parentName = "Editors_DayLights" }, - new LightToChange(){ name = "SpotlightExteriorSun", parentName = "Editors_DayLights" }, - new LightToChange(){ name = "SpotlightWindow", parentName = "Editors_DayLights" } - }; + new LightToChange(){ name = "Realtime_SpotlightCraft", parentName = "Lighting_Realtime" }, + new LightToChange(){ name = "Realtime_ExteriorSun", parentName = "Lighting_Realtime" }, + new LightToChange(){ name = "Realtime_SpotlightScenery", parentName = "Lighting_Realtime" }, + new LightToChange(){ name = "Realtime_Shadow Light", parentName = "Lighting_Realtime" } + }; break; } } @@ -172,9 +182,10 @@ public void SetExternalLightsMode(EditorTime time, Light[] lights) { foreach (LightToChange lightToChange in lightsToChange) { if (light.name.Equals(lightToChange.name, StringComparison.Ordinal) && light.transform.parent.gameObject.name.Equals(lightToChange.parentName, StringComparison.Ordinal)) { - light.enabled = (time == EditorTime.Day ? true : false); - } - } + light.enabled = (time == EditorTime.Day ? true : false); + //Debug.Log("Light: " + light.name + ", Parent: " + light.transform.parent.gameObject.name + ", " + light.color + ", Default " + (light.enabled ? "ON" : "OFF")); + } + } } } } diff --git a/Source/LightsOut/LOShaders.cs b/Source/LightsOut/LOShaders.cs index 3d93439..0f82b72 100644 --- a/Source/LightsOut/LOShaders.cs +++ b/Source/LightsOut/LOShaders.cs @@ -23,7 +23,7 @@ public LOShaders(EditorFacility facility, EditorLevel level, GameObject[] gameOb List defaultShaders = new List() { "KSP/Emissive/Specular", - "KSP/Emissive/Bumped", + "KSP/Bumped", "KSP/Emissive/Diffuse" }; diff --git a/Source/LightsOut/LightsOut.cs b/Source/LightsOut/LightsOut.cs index 2498d77..6098bbf 100644 --- a/Source/LightsOut/LightsOut.cs +++ b/Source/LightsOut/LightsOut.cs @@ -1,4 +1,5 @@ -using System; +using KSP.UI.Screens; +using System; using System.Collections.Generic; using UnityEngine;