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.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using NewHorizons.Utility.Files; using NewHorizons.Utility.Files;
using OWML.Common;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Atmosphere 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(); 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(); InitPrefabs();
@ -59,6 +60,7 @@ namespace NewHorizons.Builder.Atmosphere
PFC.fogDensity = atmo.fogDensity; PFC.fogDensity = atmo.fogDensity;
PFC.fogExponent = 1f; PFC.fogExponent = 1f;
var colorRampTexture = atmo.fogTint == null ? _ramp : ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()); 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.fogColorRampTexture = colorRampTexture;
PFC.fogColorRampIntensity = 1f; PFC.fogColorRampIntensity = 1f;
if (atmo.fogTint != null) if (atmo.fogTint != null)
@ -78,7 +80,7 @@ namespace NewHorizons.Builder.Atmosphere
return PFC; return PFC;
} }
public static Renderer MakeProxy(GameObject proxyGO, AtmosphereModule atmo) public static Renderer MakeProxy(GameObject proxyGO, AtmosphereModule atmo, IModBehaviour mod)
{ {
InitPrefabs(); InitPrefabs();
@ -95,6 +97,7 @@ namespace NewHorizons.Builder.Atmosphere
MR.allowOcclusionWhenDynamic = true; MR.allowOcclusionWhenDynamic = true;
var colorRampTexture = atmo.fogTint == null ? _ramp : ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()); 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) if (atmo.fogTint != null)
{ {
MR.material.SetColor(Tint, atmo.fogTint.ToColor()); MR.material.SetColor(Tint, atmo.fogTint.ToColor());

View File

@ -119,7 +119,7 @@ namespace NewHorizons.Builder.Body
if (body.Config.Atmosphere.fogSize != 0) 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; fogCurveMaxVal = body.Config.Atmosphere.fogDensity;
} }

View File

@ -46,7 +46,7 @@ namespace NewHorizons.External.Modules
/// <summary> /// <summary>
/// How dense the fog is, if you put fog. /// How dense the fog is, if you put fog.
/// </summary> /// </summary>
[Range(0f, 1f)] public float fogDensity; [Range(0f, double.MaxValue)] public float fogDensity;
/// <summary> /// <summary>
/// Radius of fog sphere, independent of the atmosphere. This has to be set for there to be fog. /// Radius of fog sphere, independent of the atmosphere. This has to be set for there to be fog.
@ -58,6 +58,12 @@ namespace NewHorizons.External.Modules
/// </summary> /// </summary>
public MColor fogTint; 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> /// <summary>
/// Lets you survive on the planet without a suit. /// Lets you survive on the planet without a suit.
/// </summary> /// </summary>

View File

@ -640,7 +640,7 @@ namespace NewHorizons.Handlers
if (body.Config.Atmosphere.fogSize != 0) 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>(); atmosphere = AtmosphereBuilder.Make(go, sector, body.Config.Atmosphere, surfaceSize).GetComponentInChildren<LODGroup>();