fog ramp path

This commit is contained in:
JohnCorby 2023-04-04 00:15:47 -07:00
parent 444bcbf8b7
commit 84d59a1d76
4 changed files with 14 additions and 5 deletions

View File

@ -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<MeshRenderer>().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());

View File

@ -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;
}

View File

@ -46,7 +46,7 @@ namespace NewHorizons.External.Modules
/// <summary>
/// How dense the fog is, if you put fog.
/// </summary>
[Range(0f, 1f)] public float fogDensity;
[Range(0f, double.MaxValue)] public float fogDensity;
/// <summary>
/// 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.
/// </summary>
public MColor fogTint;
/// <summary>
/// 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.
/// </summary>
public string fogRampPath;
/// <summary>
/// Lets you survive on the planet without a suit.

View File

@ -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<LODGroup>();