diff --git a/NewHorizons/Builder/Atmosphere/FogBuilder.cs b/NewHorizons/Builder/Atmosphere/FogBuilder.cs index c453dfea..14ff2076 100644 --- a/NewHorizons/Builder/Atmosphere/FogBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/FogBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.External.Modules; using NewHorizons.Utility; using NewHorizons.Utility.Files; +using OWML.Common; using UnityEngine; namespace NewHorizons.Builder.Atmosphere { @@ -35,7 +36,7 @@ namespace NewHorizons.Builder.Atmosphere if (_dbImpostorMaterials == null) _dbImpostorMaterials = SearchUtilities.Find("DarkBramble_Body/Atmosphere_DB/FogLOD").GetComponent().sharedMaterials.MakePrefabMaterials(); } - public static PlanetaryFogController Make(GameObject planetGO, Sector sector, AtmosphereModule atmo) + public static PlanetaryFogController Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, IModBehaviour mod) { InitPrefabs(); @@ -59,6 +60,7 @@ namespace NewHorizons.Builder.Atmosphere PFC.fogDensity = atmo.fogDensity; PFC.fogExponent = 1f; var colorRampTexture = atmo.fogTint == null ? _ramp : ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()); + if (atmo.fogRampPath != null) colorRampTexture = ImageUtilities.GetTexture(mod, atmo.fogRampPath, wrap: false); PFC.fogColorRampTexture = colorRampTexture; PFC.fogColorRampIntensity = 1f; if (atmo.fogTint != null) @@ -78,7 +80,7 @@ namespace NewHorizons.Builder.Atmosphere return PFC; } - public static Renderer MakeProxy(GameObject proxyGO, AtmosphereModule atmo) + public static Renderer MakeProxy(GameObject proxyGO, AtmosphereModule atmo, IModBehaviour mod) { InitPrefabs(); @@ -95,6 +97,7 @@ namespace NewHorizons.Builder.Atmosphere MR.allowOcclusionWhenDynamic = true; var colorRampTexture = atmo.fogTint == null ? _ramp : ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()); + if (atmo.fogRampPath != null) colorRampTexture = ImageUtilities.GetTexture(mod, atmo.fogRampPath, wrap: false); if (atmo.fogTint != null) { MR.material.SetColor(Tint, atmo.fogTint.ToColor()); diff --git a/NewHorizons/Builder/Body/ProxyBuilder.cs b/NewHorizons/Builder/Body/ProxyBuilder.cs index 15e6953e..53c5d0d0 100644 --- a/NewHorizons/Builder/Body/ProxyBuilder.cs +++ b/NewHorizons/Builder/Body/ProxyBuilder.cs @@ -119,7 +119,7 @@ namespace NewHorizons.Builder.Body if (body.Config.Atmosphere.fogSize != 0) { - fog = FogBuilder.MakeProxy(proxy, body.Config.Atmosphere); + fog = FogBuilder.MakeProxy(proxy, body.Config.Atmosphere, body.Mod); fogCurveMaxVal = body.Config.Atmosphere.fogDensity; } diff --git a/NewHorizons/External/Modules/AtmosphereModule.cs b/NewHorizons/External/Modules/AtmosphereModule.cs index b93fbb65..9185756b 100644 --- a/NewHorizons/External/Modules/AtmosphereModule.cs +++ b/NewHorizons/External/Modules/AtmosphereModule.cs @@ -46,7 +46,7 @@ namespace NewHorizons.External.Modules /// /// How dense the fog is, if you put fog. /// - [Range(0f, 1f)] public float fogDensity; + [Range(0f, double.MaxValue)] public float fogDensity; /// /// Radius of fog sphere, independent of the atmosphere. This has to be set for there to be fog. @@ -57,6 +57,12 @@ namespace NewHorizons.External.Modules /// Colour of fog on the planet, if you put fog. /// public MColor fogTint; + + /// + /// Relative filepath to the fog color ramp texture, if you put fog. + /// x axis is angle to sun (so time of day), y axis is distance to camera. + /// + public string fogRampPath; /// /// Lets you survive on the planet without a suit. diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index db6f8f22..32720755 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -640,7 +640,7 @@ namespace NewHorizons.Handlers if (body.Config.Atmosphere.fogSize != 0) { - fog = FogBuilder.Make(go, sector, body.Config.Atmosphere); + fog = FogBuilder.Make(go, sector, body.Config.Atmosphere, body.Mod); } atmosphere = AtmosphereBuilder.Make(go, sector, body.Config.Atmosphere, surfaceSize).GetComponentInChildren();