Fixed star fog LOD stuff

This commit is contained in:
Nick J. Connors 2022-01-26 00:17:56 -05:00
parent 8e502f2c28
commit 44f87131c9
4 changed files with 12 additions and 4 deletions

View File

@ -126,7 +126,7 @@ namespace NewHorizons.Builder.Body
funnelGO.transform.localPosition = Vector3.zero;
var funnelSizeController = funnelGO.AddComponent<FunnelSizeController>();
var funnelSizeController = funnelGO.AddComponent<FunnelController>();
if(module.Curve != null)
{
@ -137,12 +137,13 @@ namespace NewHorizons.Builder.Body
}
funnelSizeController.scaleCurve = curve;
}
funnelSizeController.anchor = go.transform;
// Finish up next tick
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => PostMake(funnelGO, alignment, funnelSizeController, module));
}
private static void PostMake(GameObject funnelGO, AlignWithTargetBody alignment, FunnelSizeController funnelSizeController, FunnelModule module)
private static void PostMake(GameObject funnelGO, AlignWithTargetBody alignment, FunnelController funnelSizeController, FunnelModule module)
{
var target = AstroObjectLocator.GetAstroObject(module.Target)?.GetAttachedOWRigidbody();
if(target == null)

View File

@ -84,7 +84,8 @@ namespace NewHorizons.Builder.Body
}
fog.transform.localScale = Vector3.one;
fog.fogRadius = starModule.Size * OuterRadiusRatio;
if(starModule.Curve != null)
fog.lodFadeDistance = fog.fogRadius * (StarBuilder.OuterRadiusRatio - 1f);
if (starModule.Curve != null)
{
var controller = sunAtmosphere.AddComponent<StarAtmosphereSizeController>();
controller.scaleCurve = starModule.ToAnimationCurve();

View File

@ -7,14 +7,19 @@ using UnityEngine;
namespace NewHorizons.Components
{
public class FunnelSizeController : MonoBehaviour
public class FunnelController : MonoBehaviour
{
public AnimationCurve scaleCurve;
public Transform target;
public Transform anchor;
private void FixedUpdate()
{
float num = scaleCurve == null ? 1f : scaleCurve.Evaluate(TimeLoop.GetMinutesElapsed());
// Temporary solution that i will never get rid of
transform.position = anchor.position;
var dist = (transform.position - target.position).magnitude;
transform.localScale = new Vector3(num, dist/500f, num);
}

View File

@ -24,6 +24,7 @@ namespace NewHorizons.Components
{
base.FixedUpdate();
fog.fogRadius = initialSize * CurrentScale * StarBuilder.OuterRadiusRatio;
fog.lodFadeDistance = initialSize * CurrentScale * (StarBuilder.OuterRadiusRatio - 1f);
foreach (var lod in atmosphereRenderers)
{
lod.material.SetFloat("_InnerRadius", initialSize * CurrentScale);