mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Merge branch 'dev' into scatter-optimization
This commit is contained in:
commit
45ea9f02c4
5
.gitignore
vendored
5
.gitignore
vendored
@ -417,4 +417,9 @@ docs/.m_cache/**
|
||||
# Unity project
|
||||
new-horizons-unity
|
||||
new-horizons-unity/**
|
||||
nh-unity
|
||||
nh-unity/**
|
||||
NewHorizons/Assets/Assets
|
||||
NewHorizons/Assets/Assets.manifest
|
||||
|
||||
docs/.env
|
||||
|
||||
Binary file not shown.
23
NewHorizons/Assets/xen.newhorizons.manifest
Normal file
23
NewHorizons/Assets/xen.newhorizons.manifest
Normal file
@ -0,0 +1,23 @@
|
||||
ManifestFileVersion: 0
|
||||
CRC: 1014555239
|
||||
Hashes:
|
||||
AssetFileHash:
|
||||
serializedVersion: 2
|
||||
Hash: 45fa3430ee7bea1e8384e57927fc0f76
|
||||
TypeTreeHash:
|
||||
serializedVersion: 2
|
||||
Hash: 55d48f4ad9c3b13330b9eb5ee5686477
|
||||
HashAppended: 0
|
||||
ClassTypes:
|
||||
- Class: 48
|
||||
Script: {instanceID: 0}
|
||||
SerializeReferenceClassIdentifiers: []
|
||||
Assets:
|
||||
- Assets/Shaders/SphereTextureWrapper.shader
|
||||
- Assets/Shaders/Ring.shader
|
||||
- Assets/Shaders/SphereTextureWrapperNormal.shader
|
||||
- Assets/Shaders/UnlitRing1Pixel.shader
|
||||
- Assets/Shaders/UnlitTransparent.shader
|
||||
- Assets/Shaders/StandardCullOFF.shader
|
||||
- Assets/Shaders/Ring1Pixel.shader
|
||||
Dependencies: []
|
||||
@ -23,28 +23,31 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
sfv._allowShipAutoroll = true;
|
||||
sfv._disableOnStart = false;
|
||||
|
||||
// Try to parent it to the same as other rulesets to match vanilla but if its null put it on the root object
|
||||
var ruleSetGO = planetGO.GetComponentInChildren<PlanetoidRuleset>()?.gameObject;
|
||||
if (ruleSetGO == null) ruleSetGO = planetGO;
|
||||
|
||||
var shockLayerRuleset = ruleSetGO.AddComponent<ShockLayerRuleset>();
|
||||
shockLayerRuleset._type = ShockLayerRuleset.ShockType.Atmospheric;
|
||||
shockLayerRuleset._radialCenter = airGO.transform;
|
||||
shockLayerRuleset._minShockSpeed = config.Atmosphere.minShockSpeed;
|
||||
shockLayerRuleset._maxShockSpeed = config.Atmosphere.maxShockSpeed;
|
||||
|
||||
if (config.Atmosphere.clouds != null)
|
||||
if (config.Atmosphere.hasShockLayer)
|
||||
{
|
||||
shockLayerRuleset._innerRadius = config.Atmosphere.clouds.innerCloudRadius;
|
||||
shockLayerRuleset._outerRadius = config.Atmosphere.clouds.outerCloudRadius;
|
||||
}
|
||||
else
|
||||
{
|
||||
var bottom = config.Base.surfaceSize;
|
||||
var top = config.Atmosphere.size;
|
||||
// Try to parent it to the same as other rulesets to match vanilla but if its null put it on the root object
|
||||
var ruleSetGO = planetGO.GetComponentInChildren<PlanetoidRuleset>()?.gameObject;
|
||||
if (ruleSetGO == null) ruleSetGO = planetGO;
|
||||
|
||||
shockLayerRuleset._innerRadius = (bottom + top) / 2f;
|
||||
shockLayerRuleset._outerRadius = top;
|
||||
var shockLayerRuleset = ruleSetGO.AddComponent<ShockLayerRuleset>();
|
||||
shockLayerRuleset._type = ShockLayerRuleset.ShockType.Atmospheric;
|
||||
shockLayerRuleset._radialCenter = airGO.transform;
|
||||
shockLayerRuleset._minShockSpeed = config.Atmosphere.minShockSpeed;
|
||||
shockLayerRuleset._maxShockSpeed = config.Atmosphere.maxShockSpeed;
|
||||
|
||||
if (config.Atmosphere.clouds != null)
|
||||
{
|
||||
shockLayerRuleset._innerRadius = config.Atmosphere.clouds.innerCloudRadius;
|
||||
shockLayerRuleset._outerRadius = config.Atmosphere.clouds.outerCloudRadius;
|
||||
}
|
||||
else
|
||||
{
|
||||
var bottom = config.Base.surfaceSize;
|
||||
var top = config.Atmosphere.size;
|
||||
|
||||
shockLayerRuleset._innerRadius = (bottom + top) / 2f;
|
||||
shockLayerRuleset._outerRadius = top;
|
||||
}
|
||||
}
|
||||
|
||||
if (config.Atmosphere.hasOxygen)
|
||||
|
||||
@ -9,7 +9,6 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
public static class CloudsBuilder
|
||||
{
|
||||
private static Shader _sphereShader = null;
|
||||
private static Material[] _gdCloudMaterials;
|
||||
private static Material[] _qmCloudMaterials;
|
||||
private static GameObject _lightningPrefab;
|
||||
@ -91,8 +90,6 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
|
||||
// Fix the rotations once the rest is done
|
||||
cloudsMainGO.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(0, 0, 0));
|
||||
// For the base shader it has to be rotated idk
|
||||
if (atmo.clouds.cloudsPrefab == CloudPrefabType.Basic) cloudsMainGO.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(90, 0, 0));
|
||||
|
||||
// Lightning
|
||||
if (atmo.clouds.hasLightning)
|
||||
@ -170,7 +167,6 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
|
||||
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 (_qmCloudMaterials == null) _qmCloudMaterials = SearchUtilities.Find("CloudsTopLayer_QM").GetComponent<MeshRenderer>().sharedMaterials;
|
||||
Material[] prefabMaterials = atmo.clouds.cloudsPrefab == CloudPrefabType.GiantsDeep ? _gdCloudMaterials : _qmCloudMaterials;
|
||||
@ -178,10 +174,10 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
|
||||
if (atmo.clouds.cloudsPrefab == CloudPrefabType.Basic)
|
||||
{
|
||||
var material = new Material(_sphereShader);
|
||||
var material = new Material(Shader.Find("Standard"));
|
||||
if (atmo.clouds.unlit) material.renderQueue = 3000;
|
||||
material.name = atmo.clouds.unlit ? "BasicCloud" : "BasicShadowCloud";
|
||||
|
||||
material.SetFloat(279, 0f); // smoothness
|
||||
tempArray[0] = material;
|
||||
}
|
||||
else
|
||||
@ -211,8 +207,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
if (atmo.clouds.rotationSpeed != 0f)
|
||||
{
|
||||
var topRT = cloudsTopGO.AddComponent<RotateTransform>();
|
||||
// Idk why but the axis is weird
|
||||
topRT._localAxis = atmo.clouds.cloudsPrefab == CloudPrefabType.Basic ? Vector3.forward : Vector3.up;
|
||||
topRT._localAxis = Vector3.up;
|
||||
topRT._degreesPerSecond = atmo.clouds.rotationSpeed;
|
||||
topRT._randomizeRotationRate = false;
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ namespace NewHorizons.Builder.Body
|
||||
remnantGO.transform.parent = proxy.transform;
|
||||
remnantGO.transform.localPosition = Vector3.zero;
|
||||
|
||||
SharedMake(planetGO, remnantGO, proxyController, remnant);
|
||||
SharedMake(planetGO, remnantGO, null, remnant);
|
||||
|
||||
proxyController.stellarRemnantGO = remnantGO;
|
||||
}
|
||||
@ -125,9 +125,11 @@ namespace NewHorizons.Builder.Body
|
||||
if (realSize < body.Config.Ring.outerRadius) realSize = body.Config.Ring.outerRadius;
|
||||
}
|
||||
|
||||
Renderer starAtmosphere = null;
|
||||
Renderer starFog = null;
|
||||
if (body.Config.Star != null)
|
||||
{
|
||||
StarBuilder.MakeStarProxy(planetGO, proxy, body.Config.Star, body.Mod, body.Config.isStellarRemnant);
|
||||
(_, starAtmosphere, starFog) = StarBuilder.MakeStarProxy(planetGO, proxy, body.Config.Star, body.Mod, body.Config.isStellarRemnant);
|
||||
|
||||
if (realSize < body.Config.Star.size) realSize = body.Config.Star.size;
|
||||
}
|
||||
@ -217,9 +219,17 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
if (proxyController != null)
|
||||
{
|
||||
proxyController._atmosphere = atmosphere;
|
||||
proxyController._fog = fog;
|
||||
proxyController._fogCurveMaxVal = fogCurveMaxVal;
|
||||
proxyController._atmosphere = atmosphere ?? starAtmosphere;
|
||||
if (fog != null)
|
||||
{
|
||||
proxyController._fog = fog;
|
||||
proxyController._fogCurveMaxVal = fogCurveMaxVal;
|
||||
}
|
||||
else if (starFog != null)
|
||||
{
|
||||
proxyController._fog = starFog;
|
||||
proxyController._fogCurveMaxVal = 0.05f;
|
||||
}
|
||||
proxyController.topClouds = topClouds;
|
||||
proxyController.lightningGenerator = lightningGenerator;
|
||||
proxyController.supernovaPlanetEffectController = supernovaPlanetEffect;
|
||||
|
||||
@ -46,23 +46,29 @@ namespace NewHorizons.Builder.Body
|
||||
sunAtmosphere.transform.position = planetGO.transform.position;
|
||||
sunAtmosphere.transform.localScale = Vector3.one * OuterRadiusRatio;
|
||||
sunAtmosphere.name = "Atmosphere_Star";
|
||||
|
||||
var atmospheres = sunAtmosphere.transform.Find("AtmoSphere");
|
||||
atmospheres.transform.localScale = Vector3.one;
|
||||
var lods = atmospheres.GetComponentsInChildren<MeshRenderer>();
|
||||
foreach (var lod in lods)
|
||||
{
|
||||
lod.material.SetFloat(InnerRadius, starModule.size);
|
||||
lod.material.SetFloat(OuterRadius, starModule.size * OuterRadiusRatio);
|
||||
}
|
||||
|
||||
var fog = sunAtmosphere.transform.Find("FogSphere").GetComponent<PlanetaryFogController>();
|
||||
fog.transform.localScale = Vector3.one;
|
||||
fog.fogRadius = starModule.size * OuterRadiusRatio;
|
||||
fog.lodFadeDistance = fog.fogRadius * (StarBuilder.OuterRadiusRatio - 1f);
|
||||
|
||||
fog.fogImpostor.material.SetFloat(Radius, starModule.size * OuterRadiusRatio);
|
||||
if (starModule.tint != null)
|
||||
{
|
||||
fog.fogTint = starModule.tint.ToColor();
|
||||
fog.fogImpostor.material.SetColor(Tint, starModule.tint.ToColor());
|
||||
sunAtmosphere.transform.Find("AtmoSphere").transform.localScale = Vector3.one;
|
||||
foreach (var lod in sunAtmosphere.transform.Find("AtmoSphere").GetComponentsInChildren<MeshRenderer>())
|
||||
{
|
||||
foreach (var lod in lods)
|
||||
lod.material.SetColor(SkyColor, starModule.tint.ToColor());
|
||||
lod.material.SetFloat(InnerRadius, starModule.size);
|
||||
lod.material.SetFloat(OuterRadius, starModule.size * OuterRadiusRatio);
|
||||
}
|
||||
}
|
||||
fog.transform.localScale = Vector3.one;
|
||||
fog.fogRadius = starModule.size * OuterRadiusRatio;
|
||||
fog.lodFadeDistance = fog.fogRadius * (StarBuilder.OuterRadiusRatio - 1f);
|
||||
fog.fogImpostor.material.SetFloat(Radius, starModule.size * OuterRadiusRatio);
|
||||
}
|
||||
|
||||
var ambientLightGO = Object.Instantiate(SearchUtilities.Find("Sun_Body/AmbientLight_SUN"), starGO.transform);
|
||||
@ -179,10 +185,37 @@ namespace NewHorizons.Builder.Body
|
||||
return (starGO, starController, starEvolutionController);
|
||||
}
|
||||
|
||||
public static GameObject MakeStarProxy(GameObject planet, GameObject proxyGO, StarModule starModule, IModBehaviour mod, bool isStellarRemnant)
|
||||
public static (GameObject, Renderer, Renderer) MakeStarProxy(GameObject planet, GameObject proxyGO, StarModule starModule, IModBehaviour mod, bool isStellarRemnant)
|
||||
{
|
||||
var (starGO, controller, supernova) = SharedStarGeneration(proxyGO, null, mod, starModule, isStellarRemnant);
|
||||
|
||||
Renderer atmosphere = null;
|
||||
Renderer fog = null;
|
||||
if (starModule.hasAtmosphere)
|
||||
{
|
||||
GameObject sunAtmosphere = Object.Instantiate(SearchUtilities.Find("SunProxy/Sun_Proxy_Body/Atmosphere_SUN", false) ?? SearchUtilities.Find("SunProxy(Clone)/Sun_Proxy_Body/Atmosphere_SUN"), starGO.transform);
|
||||
sunAtmosphere.transform.position = proxyGO.transform.position;
|
||||
sunAtmosphere.transform.localScale = Vector3.one * OuterRadiusRatio;
|
||||
sunAtmosphere.name = "Atmosphere_Star";
|
||||
|
||||
atmosphere = sunAtmosphere.transform.Find("Atmosphere_LOD2").GetComponent<MeshRenderer>();
|
||||
atmosphere.transform.localScale = Vector3.one;
|
||||
atmosphere.material.SetFloat(InnerRadius, starModule.size);
|
||||
atmosphere.material.SetFloat(OuterRadius, starModule.size * OuterRadiusRatio);
|
||||
|
||||
fog = sunAtmosphere.transform.Find("FogSphere").GetComponent<MeshRenderer>();
|
||||
fog.transform.localScale = Vector3.one;
|
||||
fog.material.SetFloat(Radius, starModule.size * OuterRadiusRatio);
|
||||
|
||||
if (starModule.tint != null)
|
||||
{
|
||||
fog.material.SetColor(Tint, starModule.tint.ToColor());
|
||||
atmosphere.material.SetColor(SkyColor, starModule.tint.ToColor());
|
||||
}
|
||||
|
||||
controller.atmosphere = sunAtmosphere;
|
||||
}
|
||||
|
||||
controller.isProxy = true;
|
||||
|
||||
// Planet can have multiple stars on them, so find the one that is also a remnant / not a remnant
|
||||
@ -198,7 +231,7 @@ namespace NewHorizons.Builder.Body
|
||||
supernova.mainStellerDeathController = mainController.supernova;
|
||||
}
|
||||
|
||||
return starGO;
|
||||
return (starGO, atmosphere, fog);
|
||||
}
|
||||
|
||||
private static (GameObject, StarEvolutionController, StellarDeathController) SharedStarGeneration(GameObject planetGO, Sector sector, IModBehaviour mod, StarModule starModule, bool isStellarRemnant)
|
||||
|
||||
@ -88,7 +88,7 @@ namespace NewHorizons.Builder.Body
|
||||
lightRadius = 10000,
|
||||
solarLuminosity = 0.5f
|
||||
};
|
||||
if (proxy != null) return StarBuilder.MakeStarProxy(planetGO, proxy, whiteDwarfModule, mod, true);
|
||||
if (proxy != null) return StarBuilder.MakeStarProxy(planetGO, proxy, whiteDwarfModule, mod, true).Item1;
|
||||
else return StarBuilder.Make(planetGO, sector, whiteDwarfModule, mod, true).Item1;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
// Instead of showing the typical star surface we use a tinted singularity
|
||||
GameObject neutronStar;
|
||||
if (proxy != null) neutronStar = StarBuilder.MakeStarProxy(planetGO, proxy, neutronStarModule, mod, true);
|
||||
if (proxy != null) neutronStar = StarBuilder.MakeStarProxy(planetGO, proxy, neutronStarModule, mod, true).Item1;
|
||||
else (neutronStar, _, _) = StarBuilder.Make(planetGO, sector, neutronStarModule, mod, true);
|
||||
neutronStar.FindChild("Surface").SetActive(false);
|
||||
|
||||
|
||||
@ -100,6 +100,11 @@ namespace NewHorizons.External.Modules
|
||||
/// </summary>
|
||||
public bool useAtmosphereShader;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this atmosphere will have flames appear when your ship goes a certain speed.
|
||||
/// </summary>
|
||||
[DefaultValue(true)] public bool hasShockLayer = true;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum speed that your ship can go in the atmosphere where flames will appear.
|
||||
/// </summary>
|
||||
|
||||
@ -313,6 +313,11 @@
|
||||
"type": "boolean",
|
||||
"description": "Whether we use an atmospheric shader on the planet. Doesn't affect clouds, fog, rain, snow, oxygen, etc. Purely\nvisual."
|
||||
},
|
||||
"hasShockLayer": {
|
||||
"type": "boolean",
|
||||
"description": "Whether this atmosphere will have flames appear when your ship goes a certain speed.",
|
||||
"default": true
|
||||
},
|
||||
"minShockSpeed": {
|
||||
"type": "number",
|
||||
"description": "Minimum speed that your ship can go in the atmosphere where flames will appear.",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user