This commit is contained in:
Nick 2023-07-19 00:18:48 -04:00
commit 1eb3e04729
6 changed files with 27 additions and 25 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();
@ -58,7 +59,10 @@ namespace NewHorizons.Builder.Atmosphere
PFC.lodFadeDistance = PFC.fogRadius * 0.5f; PFC.lodFadeDistance = PFC.fogRadius * 0.5f;
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.fogRampPath != null ? ImageUtilities.GetTexture(mod, atmo.fogRampPath) :
atmo.fogTint != null ? ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()) :
_ramp;
PFC.fogColorRampTexture = colorRampTexture; PFC.fogColorRampTexture = colorRampTexture;
PFC.fogColorRampIntensity = 1f; PFC.fogColorRampIntensity = 1f;
if (atmo.fogTint != null) if (atmo.fogTint != null)
@ -78,7 +82,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();
@ -94,7 +98,10 @@ namespace NewHorizons.Builder.Atmosphere
MR.materials = _dbImpostorMaterials; MR.materials = _dbImpostorMaterials;
MR.allowOcclusionWhenDynamic = true; MR.allowOcclusionWhenDynamic = true;
var colorRampTexture = atmo.fogTint == null ? _ramp : ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()); var colorRampTexture =
atmo.fogRampPath != null ? ImageUtilities.GetTexture(mod, atmo.fogRampPath) :
atmo.fogTint != null ? ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()) :
_ramp;
if (atmo.fogTint != null) if (atmo.fogTint != null)
{ {
MR.material.SetColor(Tint, atmo.fogTint.ToColor()); MR.material.SetColor(Tint, atmo.fogTint.ToColor());

View File

@ -120,7 +120,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.
@ -57,6 +57,12 @@ namespace NewHorizons.External.Modules
/// Colour of fog on the planet, if you put fog. /// Colour of fog on the planet, if you put fog.
/// </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 (left at midnight, right at noon), y axis is distance to camera (close at bottom, far at top).
/// </summary>
public string fogRampPath;
/// <summary> /// <summary>
/// Lets you survive on the planet without a suit. /// Lets you survive on the planet without a suit.

View File

@ -29,7 +29,7 @@ namespace NewHorizons.External.Modules
/// <summary> /// <summary>
/// Offsets the player/ship by this local vector when spawning. Used to prevent spawning in the floor. Optional: defaults to (0, 4, 0). /// Offsets the player/ship by this local vector when spawning. Used to prevent spawning in the floor. Optional: defaults to (0, 4, 0).
/// </summary> /// </summary>
public MVector3? offset; public MVector3 offset;
} }
[JsonObject] [JsonObject]

View File

@ -652,7 +652,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>();

View File

@ -345,7 +345,6 @@
"type": "number", "type": "number",
"description": "How dense the fog is, if you put fog.", "description": "How dense the fog is, if you put fog.",
"format": "float", "format": "float",
"maximum": 1.0,
"minimum": 0.0 "minimum": 0.0
}, },
"fogSize": { "fogSize": {
@ -358,6 +357,10 @@
"description": "Colour of fog on the planet, if you put fog.", "description": "Colour of fog on the planet, if you put fog.",
"$ref": "#/definitions/MColor" "$ref": "#/definitions/MColor"
}, },
"fogRampPath": {
"type": "string",
"description": "Relative filepath to the fog color ramp texture, if you put fog.\nx axis is angle to sun (left at midnight, right at noon), y axis is distance to camera (close at bottom, far at top)."
},
"hasOxygen": { "hasOxygen": {
"type": "boolean", "type": "boolean",
"description": "Lets you survive on the planet without a suit." "description": "Lets you survive on the planet without a suit."
@ -3050,14 +3053,7 @@
"properties": { "properties": {
"offset": { "offset": {
"description": "Offsets the player/ship by this local vector when spawning. Used to prevent spawning in the floor. Optional: defaults to (0, 4, 0).", "description": "Offsets the player/ship by this local vector when spawning. Used to prevent spawning in the floor. Optional: defaults to (0, 4, 0).",
"oneOf": [ "$ref": "#/definitions/MVector3"
{
"type": "null"
},
{
"$ref": "#/definitions/MVector3"
}
]
}, },
"rotation": { "rotation": {
"description": "Rotation of the object", "description": "Rotation of the object",
@ -3102,14 +3098,7 @@
"properties": { "properties": {
"offset": { "offset": {
"description": "Offsets the player/ship by this local vector when spawning. Used to prevent spawning in the floor. Optional: defaults to (0, 4, 0).", "description": "Offsets the player/ship by this local vector when spawning. Used to prevent spawning in the floor. Optional: defaults to (0, 4, 0).",
"oneOf": [ "$ref": "#/definitions/MVector3"
{
"type": "null"
},
{
"$ref": "#/definitions/MVector3"
}
]
}, },
"rotation": { "rotation": {
"description": "Rotation of the object", "description": "Rotation of the object",