From 84d59a1d762bcead3d73a95016b423878c2eefb6 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 4 Apr 2023 00:15:47 -0700 Subject: [PATCH 1/8] fog ramp path --- NewHorizons/Builder/Atmosphere/FogBuilder.cs | 7 +++++-- NewHorizons/Builder/Body/ProxyBuilder.cs | 2 +- NewHorizons/External/Modules/AtmosphereModule.cs | 8 +++++++- NewHorizons/Handlers/PlanetCreationHandler.cs | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) 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(); From 5676aace43b7ead3bda2804f81af34525422caf3 Mon Sep 17 00:00:00 2001 From: Ben C Date: Tue, 4 Apr 2023 07:18:25 +0000 Subject: [PATCH 2/8] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 3ed03cf8..5686105c 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -341,7 +341,6 @@ "type": "number", "description": "How dense the fog is, if you put fog.", "format": "float", - "maximum": 1.0, "minimum": 0.0 }, "fogSize": { @@ -354,6 +353,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 (so time of day), y axis is distance to camera." + }, "hasOxygen": { "type": "boolean", "description": "Lets you survive on the planet without a suit." From 660789ef52551d632ec8b3a748528276feed9c3c Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 4 Apr 2023 00:19:48 -0700 Subject: [PATCH 3/8] comment --- NewHorizons/Builder/Atmosphere/FogBuilder.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NewHorizons/Builder/Atmosphere/FogBuilder.cs b/NewHorizons/Builder/Atmosphere/FogBuilder.cs index 14ff2076..46915f8c 100644 --- a/NewHorizons/Builder/Atmosphere/FogBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/FogBuilder.cs @@ -60,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()); + // maybe dont tint image since this overrides? oh well if (atmo.fogRampPath != null) colorRampTexture = ImageUtilities.GetTexture(mod, atmo.fogRampPath, wrap: false); PFC.fogColorRampTexture = colorRampTexture; PFC.fogColorRampIntensity = 1f; @@ -97,6 +98,7 @@ namespace NewHorizons.Builder.Atmosphere MR.allowOcclusionWhenDynamic = true; var colorRampTexture = atmo.fogTint == null ? _ramp : ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()); + // maybe dont tint image since this overrides? oh well if (atmo.fogRampPath != null) colorRampTexture = ImageUtilities.GetTexture(mod, atmo.fogRampPath, wrap: false); if (atmo.fogTint != null) { From 76cca07f2d054ce1db1b5c5e63980fd9e487a281 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 18 Jul 2023 20:52:35 -0700 Subject: [PATCH 4/8] better description --- NewHorizons/External/Modules/AtmosphereModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/External/Modules/AtmosphereModule.cs b/NewHorizons/External/Modules/AtmosphereModule.cs index b2c637ad..675ed837 100644 --- a/NewHorizons/External/Modules/AtmosphereModule.cs +++ b/NewHorizons/External/Modules/AtmosphereModule.cs @@ -60,7 +60,7 @@ namespace NewHorizons.External.Modules /// /// 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. + /// x axis is angle to sun (left at midnight, right at noon), y axis is distance to camera (close at bottom, far at top). /// public string fogRampPath; From 8a17c693e455571fb0be81da43173b36612a7b2d Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 18 Jul 2023 20:59:21 -0700 Subject: [PATCH 5/8] better --- NewHorizons/Builder/Atmosphere/FogBuilder.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/NewHorizons/Builder/Atmosphere/FogBuilder.cs b/NewHorizons/Builder/Atmosphere/FogBuilder.cs index 46915f8c..8c1025bc 100644 --- a/NewHorizons/Builder/Atmosphere/FogBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/FogBuilder.cs @@ -59,9 +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()); - // maybe dont tint image since this overrides? oh well - if (atmo.fogRampPath != null) colorRampTexture = ImageUtilities.GetTexture(mod, atmo.fogRampPath, wrap: false); + 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) @@ -97,9 +98,10 @@ namespace NewHorizons.Builder.Atmosphere MR.materials = _dbImpostorMaterials; MR.allowOcclusionWhenDynamic = true; - var colorRampTexture = atmo.fogTint == null ? _ramp : ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()); - // maybe dont tint image since this overrides? oh well - if (atmo.fogRampPath != null) colorRampTexture = ImageUtilities.GetTexture(mod, atmo.fogRampPath, wrap: false); + 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()); From 0bdf9c087a31b8a15fae0014513d78b5585adad2 Mon Sep 17 00:00:00 2001 From: Ben C Date: Wed, 19 Jul 2023 04:02:11 +0000 Subject: [PATCH 6/8] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 0c0d14a6..33e355ad 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -359,7 +359,7 @@ }, "fogRampPath": { "type": "string", - "description": "Relative filepath to the fog color ramp texture, if you put fog.\nx axis is angle to sun (so time of day), y axis is distance to camera." + "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", From ea3ee71b97815f25ba3b8f98c44729081830d77d Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 18 Jul 2023 21:02:44 -0700 Subject: [PATCH 7/8] remove "?" since MVector3 is already nullable --- NewHorizons/External/Modules/SpawnModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/External/Modules/SpawnModule.cs b/NewHorizons/External/Modules/SpawnModule.cs index 5899b658..f8af3fa1 100644 --- a/NewHorizons/External/Modules/SpawnModule.cs +++ b/NewHorizons/External/Modules/SpawnModule.cs @@ -29,7 +29,7 @@ namespace NewHorizons.External.Modules /// /// Offsets the player/ship by this local vector when spawning. Used to prevent spawning in the floor. Optional: defaults to (0, 4, 0). /// - public MVector3? offset; + public MVector3 offset; } [JsonObject] From 25f36ecf34c2d4518eb349bd9fd20830a8d0ee49 Mon Sep 17 00:00:00 2001 From: Ben C Date: Wed, 19 Jul 2023 04:07:01 +0000 Subject: [PATCH 8/8] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 33e355ad..8974ffde 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -3053,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", @@ -3105,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",