mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add star atmosphere and fog to proxy (#327)
This commit is contained in:
commit
1189e5e595
@ -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._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,24 +46,30 @@ 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);
|
||||
ambientLightGO.transform.localPosition = Vector3.zero;
|
||||
@ -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);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user