Last active
August 7, 2017 15:58
-
-
Save ronyx69/68361dbe11877773b4378597f9ba5437 to your computer and use it in GitHub Desktop.
My locally modded lighting and tonemapping settings, fine tuned for vanilla temperate theme and a custom high contrast LUT. http://i.imgur.com/AJ54HWo.png
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using ICities; | |
using System; | |
using System.Reflection; | |
using UnityEngine; | |
namespace LightingRebalance | |
{ | |
public class LightingRebalanceMod : LoadingExtensionBase, IUserMod | |
{ | |
public string Name | |
{ | |
get | |
{ | |
return "Lighting Rebalance"; | |
} | |
} | |
public string Description | |
{ | |
get | |
{ | |
return "Rebalances lighting, tonemapping and daynight properties."; | |
} | |
} | |
public override void OnLevelLoaded(LoadMode mode) | |
{ | |
// light color gradients | |
// time of day (midnight to midnight) in 0 - 1.0 floats | |
// light from the sides (affects sides of buildings the most) | |
typeof(DayNightProperties.AmbientColor).GetField("m_EquatorColor", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(DayNightProperties.instance.m_AmbientColor, new Gradient | |
{ | |
colorKeys = new GradientColorKey[] | |
{ | |
new GradientColorKey(new Color32(19, 21, 26, 255), 0.24f), | |
new GradientColorKey(new Color32(140, 143, 147, 255), 0.27f), | |
new GradientColorKey(new Color32(160, 163, 167, 255), 0.4f), | |
new GradientColorKey(new Color32(160, 163, 167, 255), 0.6f), | |
new GradientColorKey(new Color32(120, 123, 132, 255), 0.74f), | |
new GradientColorKey(new Color32(19, 21, 26, 255), 0.75f) | |
}, | |
alphaKeys = new GradientAlphaKey[] | |
{ | |
new GradientAlphaKey(1f, 0f), | |
new GradientAlphaKey(1f, 1f) | |
} | |
}); | |
// light from below (affects road undersides) | |
typeof(DayNightProperties.AmbientColor).GetField("m_GroundColor", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(DayNightProperties.instance.m_AmbientColor, new Gradient | |
{ | |
colorKeys = new GradientColorKey[] | |
{ | |
new GradientColorKey(new Color32(20, 23, 27, 255), 0.24f), | |
new GradientColorKey(new Color32(129, 131, 134, 255), 0.27f), | |
new GradientColorKey(new Color32(130, 132, 136, 255), 0.4f), | |
new GradientColorKey(new Color32(130, 132, 136, 255), 0.6f), | |
new GradientColorKey(new Color32(130, 131, 132, 255), 0.74f), | |
new GradientColorKey(new Color32(20, 23, 27, 255), 0.75f) | |
}, | |
alphaKeys = new GradientAlphaKey[] | |
{ | |
new GradientAlphaKey(1f, 0f), | |
new GradientAlphaKey(1f, 1f) | |
} | |
}); | |
// light from the top (affects terrain and building roofs the most) | |
typeof(DayNightProperties.AmbientColor).GetField("m_SkyColor", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(DayNightProperties.instance.m_AmbientColor, new Gradient | |
{ | |
colorKeys = new GradientColorKey[] | |
{ | |
new GradientColorKey(new Color32(32, 36, 42, 255), 0.24f), | |
new GradientColorKey(new Color32(165, 170, 175, 255), 0.27f), | |
new GradientColorKey(new Color32(200, 203, 207, 255), 0.4f), | |
new GradientColorKey(new Color32(200, 203, 207, 255), 0.6f), | |
new GradientColorKey(new Color32(165, 168, 178, 255), 0.74f), | |
new GradientColorKey(new Color32(32, 36, 42, 255), 0.75f) | |
}, | |
alphaKeys = new GradientAlphaKey[] | |
{ | |
new GradientAlphaKey(1f, 0f), | |
new GradientAlphaKey(1f, 1f) | |
} | |
}); | |
// directional light color (sun / moon) | |
UnityEngine.Object.FindObjectOfType<DayNightProperties>().m_LightColor = new Gradient | |
{ | |
colorKeys = new GradientColorKey[] | |
{ | |
new GradientColorKey(new Color32(17, 20, 23, 255), 0.24f), | |
new GradientColorKey(new Color32(159, 125, 99, 255), 0.27f), | |
new GradientColorKey(new Color32(175, 170, 162, 255), 0.4f), | |
new GradientColorKey(new Color32(175, 170, 162, 255), 0.6f), | |
new GradientColorKey(new Color32(190, 150, 109, 255), 0.74f), | |
new GradientColorKey(new Color32(17, 20, 23, 255), 0.75f), | |
}, | |
alphaKeys = new GradientAlphaKey[] | |
{ | |
new GradientAlphaKey(1f, 0f), | |
new GradientAlphaKey(1f, 1f) | |
} | |
}; | |
// light intensities | |
UnityEngine.Object.FindObjectOfType<DayNightProperties>().m_SunIntensity = 1.6f; // sun / moon light | |
UnityEngine.Object.FindObjectOfType<DayNightProperties>().m_Exposure = 1.6f; // ambient light | |
// tonemapping | |
var toneMap = GameObject.Find("Main Camera").GetComponent<ColossalFramework.ToneMapping>(); | |
toneMap.m_Luminance= 0.60f; // brightness but inverted | |
toneMap.m_ToneMappingBoostFactor= 0.90f; // brightness but more linear | |
toneMap.m_ToneMappingGamma= 3.20f; // gamma correction (midtone brightness) | |
toneMap.m_ToneMappingParamsFilmic.A= 0.60f; // brightness, affects midtones/highlights more | |
toneMap.m_ToneMappingParamsFilmic.B= 0.20f; // brightness, affects shadows more, lower values increase contrast, high values wash out | |
toneMap.m_ToneMappingParamsFilmic.C= 0.10f; // similar to B but more intense | |
toneMap.m_ToneMappingParamsFilmic.D= 0.75f; // affects shadows more, low values wash out, high values dark contrasty | |
toneMap.m_ToneMappingParamsFilmic.E= 0.01f; // black clipping, gets intense quickly, values over 0.29 unusable | |
toneMap.m_ToneMappingParamsFilmic.F= 0.35f; // lower values may increase contrast, higher may darken, intense interplay with E | |
toneMap.m_ToneMappingParamsFilmic.W= 11.20f; // wash out at low values, not much change in general | |
// daynight properties | |
var daynight=UnityEngine.Object.FindObjectOfType<DayNightProperties>(); | |
daynight.m_Tonemapping=true; // enables tonemapping for the sky, becomes less dull when true | |
daynight.m_SunAnisotropyFactor=0.7f; // affects light scattering around the sun | |
daynight.m_SunSize=0.02f; // sun size | |
daynight.m_MieScattering=3f; // light scattering around the sun, also affects fog somehow | |
daynight.m_RayleighScattering=1.30f; // affects color contrast between horizon and sky | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment