mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Simplify atmosphere proxy building
This commit is contained in:
parent
d32f77f6df
commit
3a1f77a1a1
@ -26,50 +26,39 @@ namespace NewHorizons.Builder.Atmosphere
|
|||||||
|
|
||||||
if (atmosphereModule.useAtmosphereShader)
|
if (atmosphereModule.useAtmosphereShader)
|
||||||
{
|
{
|
||||||
if (proxy)
|
GameObject prefab;
|
||||||
|
if (proxy) prefab = (SearchUtilities.Find("TimberHearth_DistantProxy", false) ?? SearchUtilities.Find("TimberHearth_DistantProxy(Clone)", false))?
|
||||||
|
.FindChild("Atmosphere_TH/Atmosphere_LOD3");
|
||||||
|
else prefab = SearchUtilities.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere");
|
||||||
|
|
||||||
|
if (prefab != null)
|
||||||
{
|
{
|
||||||
var distantProxy = (SearchUtilities.Find("TimberHearth_DistantProxy", false) ?? SearchUtilities.Find("TimberHearth_DistantProxy(Clone)", false))?.FindChild("Atmosphere_TH/Atmosphere_LOD3");
|
GameObject atmo = GameObject.Instantiate(prefab, atmoGO.transform, true);
|
||||||
if (distantProxy != null)
|
atmo.name = "Atmosphere";
|
||||||
|
atmo.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
|
||||||
|
|
||||||
|
Material material;
|
||||||
|
|
||||||
|
if (proxy)
|
||||||
{
|
{
|
||||||
GameObject atmo = GameObject.Instantiate(distantProxy, atmoGO.transform, true);
|
|
||||||
atmo.name = "Atmosphere_LOD3";
|
|
||||||
atmo.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
|
|
||||||
atmo.transform.localScale = Vector3.one * atmosphereModule.size * 1.2f * 2f;
|
atmo.transform.localScale = Vector3.one * atmosphereModule.size * 1.2f * 2f;
|
||||||
|
|
||||||
var renderer = atmo.GetComponent<MeshRenderer>();
|
var renderer = atmo.GetComponent<MeshRenderer>();
|
||||||
var material = renderer.material; // makes a new material
|
material = renderer.material; // makes a new material
|
||||||
renderer.sharedMaterial = material;
|
renderer.sharedMaterial = material;
|
||||||
material.SetFloat(InnerRadius, atmosphereModule.clouds != null ? atmosphereModule.size : surfaceSize);
|
|
||||||
material.SetFloat(OuterRadius, atmosphereModule.size * 1.2f);
|
|
||||||
if (atmosphereModule.atmosphereTint != null) material.SetColor(SkyColor, atmosphereModule.atmosphereTint.ToColor());
|
|
||||||
|
|
||||||
atmo.SetActive(true);
|
|
||||||
|
|
||||||
if (atmosphereModule.atmosphereSunIntensity == 0)
|
|
||||||
{
|
|
||||||
// do it based on distance
|
|
||||||
Skys.Add((planetGO, material));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// use the override instead
|
|
||||||
material.SetFloat(SunIntensity, atmosphereModule.atmosphereSunIntensity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
|
||||||
{
|
|
||||||
GameObject atmo = GameObject.Instantiate(SearchUtilities.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere"), atmoGO.transform, true);
|
|
||||||
atmo.name = "AtmoSphere";
|
|
||||||
atmo.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
|
|
||||||
atmo.transform.localScale = Vector3.one * atmosphereModule.size * 1.2f;
|
|
||||||
|
|
||||||
var renderers = atmo.GetComponentsInChildren<MeshRenderer>();
|
|
||||||
var material = renderers[0].material; // makes a new material
|
|
||||||
foreach (var renderer in renderers)
|
|
||||||
{
|
{
|
||||||
renderer.sharedMaterial = material;
|
atmo.transform.localScale = Vector3.one * atmosphereModule.size * 1.2f;
|
||||||
|
|
||||||
|
var renderers = atmo.GetComponentsInChildren<MeshRenderer>();
|
||||||
|
material = renderers[0].material; // makes a new material
|
||||||
|
foreach (var renderer in renderers)
|
||||||
|
{
|
||||||
|
renderer.sharedMaterial = material;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
material.SetFloat(InnerRadius, atmosphereModule.clouds != null ? atmosphereModule.size : surfaceSize);
|
material.SetFloat(InnerRadius, atmosphereModule.clouds != null ? atmosphereModule.size : surfaceSize);
|
||||||
material.SetFloat(OuterRadius, atmosphereModule.size * 1.2f);
|
material.SetFloat(OuterRadius, atmosphereModule.size * 1.2f);
|
||||||
if (atmosphereModule.atmosphereTint != null) material.SetColor(SkyColor, atmosphereModule.atmosphereTint.ToColor());
|
if (atmosphereModule.atmosphereTint != null) material.SetColor(SkyColor, atmosphereModule.atmosphereTint.ToColor());
|
||||||
@ -78,12 +67,12 @@ namespace NewHorizons.Builder.Atmosphere
|
|||||||
|
|
||||||
if (atmosphereModule.atmosphereSunIntensity == 0)
|
if (atmosphereModule.atmosphereSunIntensity == 0)
|
||||||
{
|
{
|
||||||
// do it based on distance
|
// Do it based on distance
|
||||||
Skys.Add((planetGO, material));
|
Skys.Add((planetGO, material));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// use the override instead
|
// Use the override instead
|
||||||
material.SetFloat(SunIntensity, atmosphereModule.atmosphereSunIntensity);
|
material.SetFloat(SunIntensity, atmosphereModule.atmosphereSunIntensity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user