Fog Ramp Path (#569)

<!-- A new module or something else important -->
## Major features
-

<!-- A new parameter added to a module, or API feature -->
## Minor features
- Add support for custom `fogColorRampTexture` (resolves #530)

<!-- Some improvement that requires no action on the part of add-on
creators i.e., improved star graphics -->
## Improvements
-

<!-- Be sure to reference the existing issue if it exists -->
## Bug fixes
-
This commit is contained in:
Nick 2023-07-19 00:10:22 -04:00 committed by GitHub
commit bb49be0002
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 25 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();
@ -58,7 +59,10 @@ namespace NewHorizons.Builder.Atmosphere
PFC.lodFadeDistance = PFC.fogRadius * 0.5f;
PFC.fogDensity = atmo.fogDensity;
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.fogColorRampIntensity = 1f;
if (atmo.fogTint != null)
@ -78,7 +82,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();
@ -94,7 +98,10 @@ namespace NewHorizons.Builder.Atmosphere
MR.materials = _dbImpostorMaterials;
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)
{
MR.material.SetColor(Tint, atmo.fogTint.ToColor());

View File

@ -120,7 +120,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.
@ -58,6 +58,12 @@ namespace NewHorizons.External.Modules
/// </summary>
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>
/// Lets you survive on the planet without a suit.
/// </summary>

View File

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

View File

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

View File

@ -345,7 +345,6 @@
"type": "number",
"description": "How dense the fog is, if you put fog.",
"format": "float",
"maximum": 1.0,
"minimum": 0.0
},
"fogSize": {
@ -358,6 +357,10 @@
"description": "Colour of fog on the planet, if you put fog.",
"$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": {
"type": "boolean",
"description": "Lets you survive on the planet without a suit."
@ -3050,14 +3053,7 @@
"properties": {
"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).",
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/definitions/MVector3"
}
]
"$ref": "#/definitions/MVector3"
},
"rotation": {
"description": "Rotation of the object",
@ -3102,14 +3098,7 @@
"properties": {
"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).",
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/definitions/MVector3"
}
]
"$ref": "#/definitions/MVector3"
},
"rotation": {
"description": "Rotation of the object",