mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Merge pull request #179 from xen-42/clouds-prefab-types
added the option to make clouds based on qm clouds, rather than the swirly GD clouds
This commit is contained in:
commit
f84b109a3d
@ -9,7 +9,8 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
public static class CloudsBuilder
|
||||
{
|
||||
private static Shader _sphereShader = null;
|
||||
private static Material[] _gdCloudMaterials;
|
||||
private static Material[] _gdCloudMaterials;
|
||||
private static Material[] _qmCloudMaterials;
|
||||
private static GameObject _lightningPrefab;
|
||||
private static Texture2D _colorRamp;
|
||||
private static readonly int Color1 = Shader.PropertyToID("_Color");
|
||||
@ -21,7 +22,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
|
||||
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, IModBehaviour mod)
|
||||
{
|
||||
if (_lightningPrefab == null) _lightningPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Clouds_GD/LightningGenerator_GD");
|
||||
if (_lightningPrefab == null) _lightningPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Clouds_GD/LightningGenerator_GD");
|
||||
if (_colorRamp == null) _colorRamp = ImageUtilities.GetTexture(Main.Instance, "AssetBundle/textures/Clouds_Bottom_ramp.png");
|
||||
|
||||
GameObject cloudsMainGO = new GameObject("Clouds");
|
||||
@ -36,8 +37,8 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
cloudsBottomGO.transform.localScale = Vector3.one * atmo.clouds.innerCloudRadius;
|
||||
|
||||
TessellatedSphereRenderer bottomTSR = cloudsBottomGO.AddComponent<TessellatedSphereRenderer>();
|
||||
bottomTSR.tessellationMeshGroup = SearchUtilities.Find("CloudsBottomLayer_QM").GetComponent<TessellatedSphereRenderer>().tessellationMeshGroup;
|
||||
var bottomTSRMaterials = SearchUtilities.Find("CloudsBottomLayer_QM").GetComponent<TessellatedSphereRenderer>().sharedMaterials;
|
||||
bottomTSR.tessellationMeshGroup = SearchUtilities.Find("CloudsBottomLayer_QM").GetComponent<TessellatedSphereRenderer>().tessellationMeshGroup;
|
||||
var bottomTSRMaterials = SearchUtilities.Find("CloudsBottomLayer_QM").GetComponent<TessellatedSphereRenderer>().sharedMaterials;
|
||||
|
||||
// If they set a colour apply it to all the materials else keep the default QM one
|
||||
if (atmo.clouds.tint != null)
|
||||
@ -165,15 +166,17 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
cloudsTopGO.transform.localScale = Vector3.one * atmo.clouds.outerCloudRadius;
|
||||
|
||||
MeshFilter topMF = cloudsTopGO.AddComponent<MeshFilter>();
|
||||
topMF.mesh = SearchUtilities.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
|
||||
topMF.mesh = SearchUtilities.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
|
||||
|
||||
MeshRenderer topMR = cloudsTopGO.AddComponent<MeshRenderer>();
|
||||
|
||||
if (_sphereShader == null) _sphereShader = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/SphereTextureWrapper.shader");
|
||||
if (_gdCloudMaterials == null) _gdCloudMaterials = SearchUtilities.Find("CloudsTopLayer_GD").GetComponent<MeshRenderer>().sharedMaterials;
|
||||
if (_gdCloudMaterials == null) _gdCloudMaterials = SearchUtilities.Find("CloudsTopLayer_GD").GetComponent<MeshRenderer>().sharedMaterials;
|
||||
if (_qmCloudMaterials == null) _qmCloudMaterials = SearchUtilities.Find("CloudsTopLayer_QM").GetComponent<MeshRenderer>().sharedMaterials;
|
||||
Material[] prefabMaterials = atmo.clouds.cloudsPrefab == CloudPrefabType.GiantsDeep ? _gdCloudMaterials : _qmCloudMaterials;
|
||||
var tempArray = new Material[2];
|
||||
|
||||
if (atmo.clouds.useBasicCloudShader)
|
||||
if (atmo.clouds.cloudsPrefab == CloudPrefabType.Basic)
|
||||
{
|
||||
var material = new Material(_sphereShader);
|
||||
if (atmo.clouds.unlit) material.renderQueue = 2550;
|
||||
@ -183,14 +186,14 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
}
|
||||
else
|
||||
{
|
||||
var material = new Material(_gdCloudMaterials[0]);
|
||||
var material = new Material(prefabMaterials[0]);
|
||||
if (atmo.clouds.unlit) material.renderQueue = 2550;
|
||||
material.name = atmo.clouds.unlit ? "AdvancedCloud" : "AdvancedShadowCloud";
|
||||
tempArray[0] = material;
|
||||
}
|
||||
|
||||
// This is the stencil material for the fog under the clouds
|
||||
tempArray[1] = new Material(_gdCloudMaterials[1]);
|
||||
tempArray[1] = new Material(prefabMaterials[1]);
|
||||
topMR.sharedMaterials = tempArray;
|
||||
|
||||
foreach (var material in topMR.sharedMaterials)
|
||||
|
||||
6
NewHorizons/External/Configs/PlanetConfig.cs
vendored
6
NewHorizons/External/Configs/PlanetConfig.cs
vendored
@ -234,7 +234,11 @@ namespace NewHorizons.External.Configs
|
||||
|
||||
// Former is obsolete, latter is to validate
|
||||
if (Atmosphere.hasAtmosphere || Atmosphere.atmosphereTint != null)
|
||||
Atmosphere.useAtmosphereShader = true;
|
||||
Atmosphere.useAtmosphereShader = true;
|
||||
|
||||
// useBasicCloudShader is obsolete
|
||||
if (Atmosphere.clouds != null && Atmosphere.clouds.useBasicCloudShader)
|
||||
Atmosphere.clouds.cloudsPrefab = CloudPrefabType.Basic;
|
||||
}
|
||||
|
||||
if (Props?.tornados != null)
|
||||
|
||||
25
NewHorizons/External/Modules/AtmosphereModule.cs
vendored
25
NewHorizons/External/Modules/AtmosphereModule.cs
vendored
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
@ -20,6 +20,16 @@ namespace NewHorizons.External.Modules
|
||||
[EnumMember(Value = @"sand")] Sand = 3,
|
||||
|
||||
[EnumMember(Value = @"plasma")] Plasma = 4
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum CloudPrefabType
|
||||
{
|
||||
[EnumMember(Value = @"giantsDeep")] GiantsDeep = 0,
|
||||
|
||||
[EnumMember(Value = @"quantumMoon")] QuantumMoon = 1,
|
||||
|
||||
[EnumMember(Value = @"basic")] Basic = 2,
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
@ -88,6 +98,11 @@ namespace NewHorizons.External.Modules
|
||||
[JsonObject]
|
||||
public class CloudInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Should these clouds be based on Giant's Deep's banded clouds, or the Quantum Moon's non-banded clouds?
|
||||
/// </summary>
|
||||
public CloudPrefabType cloudsPrefab;
|
||||
|
||||
/// <summary>
|
||||
/// Relative filepath to the cloud cap texture, if the planet has clouds.
|
||||
/// </summary>
|
||||
@ -138,11 +153,19 @@ namespace NewHorizons.External.Modules
|
||||
/// If the top layer shouldn't have shadows. Set to true if you're making a brown dwarf for example.
|
||||
/// </summary>
|
||||
public bool unlit;
|
||||
|
||||
|
||||
|
||||
#region Obsolete
|
||||
|
||||
/// <summary>
|
||||
/// Set to `false` in order to use Giant's Deep's shader. Set to `true` to just apply the cloud texture as is.
|
||||
/// </summary>
|
||||
[Obsolete("useBasicCloudShader is deprecated, please use cloudsPrefab=\"basic\" instead")]
|
||||
public bool useBasicCloudShader;
|
||||
|
||||
#endregion Obsolete
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user