mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix Shadows (#686)
<!-- A new module or something else important --> ## Major features - <!-- A new parameter added to a module, or API feature --> ## Minor features - <!-- Some improvement that requires no action on the part of add-on creators i.e., improved star graphics --> ## Improvements - <!-- Be sure to reference the existing issue if it exists --> ## Bug fixes - Shadows glitch out way less - Custom planets now can have better, longer shadows (using ProxyShadowCaster and ProxyShadowCasterGroup from existing details and in bundles) - Shadows no longer jitter - Note: short-distance shadows still cast from planets behind suns. However, this also happens in vanilla, so it is not fixed here
This commit is contained in:
commit
fea15287c6
@ -30,6 +30,11 @@ namespace NewHorizons.Builder.Body
|
||||
{
|
||||
groundGO.transform.localScale *= 2; // Multiply by 2 to match top layer
|
||||
}
|
||||
|
||||
var superGroup = planetGO.GetComponent<ProxyShadowCasterSuperGroup>();
|
||||
// idk if we need to set _superGroup manually since it does that in Awake, but it's done everywhere else so wtv
|
||||
if (superGroup != null) groundGO.AddComponent<ProxyShadowCaster>()._superGroup = superGroup;
|
||||
|
||||
groundGO.SetActive(true);
|
||||
|
||||
return groundGO;
|
||||
|
||||
@ -178,14 +178,11 @@ namespace NewHorizons.Builder.Body
|
||||
light.color = lightColour;
|
||||
ambientLight.color = new Color(lightColour.r, lightColour.g, lightColour.b, lightColour.a == 0 ? 0.0001f : lightColour.a);
|
||||
|
||||
// used to use CopyPropertiesFrom, but that doesnt work here. instead, just copy settings from unity explorer
|
||||
var faceActiveCamera = sunLight.AddComponent<FaceActiveCamera>();
|
||||
faceActiveCamera.CopyPropertiesFrom(_sunLight.GetComponent<FaceActiveCamera>());
|
||||
faceActiveCamera._useLookAt = true;
|
||||
var csmTextureCacher = sunLight.AddComponent<CSMTextureCacher>();
|
||||
csmTextureCacher.CopyPropertiesFrom(_sunLight.GetComponent<CSMTextureCacher>());
|
||||
csmTextureCacher._light = light;
|
||||
var proxyShadowLight = sunLight.AddComponent<ProxyShadowLight>();
|
||||
proxyShadowLight.CopyPropertiesFrom(_sunLight.GetComponent<ProxyShadowLight>());
|
||||
proxyShadowLight._light = light;
|
||||
|
||||
sunLight.name = "StarLight";
|
||||
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.Utility;
|
||||
using UnityEngine;
|
||||
namespace NewHorizons.Builder.General
|
||||
{
|
||||
public static class RigidBodyBuilder
|
||||
{
|
||||
public static OWRigidbody Make(GameObject body, PlanetConfig config)
|
||||
public static OWRigidbody Make(GameObject body, float sphereOfInfluence)
|
||||
{
|
||||
body.AddComponent<ProxyShadowCasterSuperGroup>();
|
||||
body.AddComponent<ProxyShadowCasterSuperGroup>()._bounds.radius = sphereOfInfluence;
|
||||
|
||||
Rigidbody rigidBody = body.AddComponent<Rigidbody>();
|
||||
rigidBody.mass = 10000;
|
||||
|
||||
@ -346,10 +346,12 @@ namespace NewHorizons.Handlers
|
||||
body.Config.Base.showMinimap = false;
|
||||
body.Config.Base.hasMapMarker = false;
|
||||
|
||||
var owRigidBody = RigidBodyBuilder.Make(go, body.Config);
|
||||
const float sphereOfInfluence = 2000f;
|
||||
|
||||
var owRigidBody = RigidBodyBuilder.Make(go, sphereOfInfluence);
|
||||
var ao = AstroObjectBuilder.Make(go, null, body.Config, false);
|
||||
|
||||
var sector = SectorBuilder.Make(go, owRigidBody, 2000f);
|
||||
var sector = SectorBuilder.Make(go, owRigidBody, sphereOfInfluence);
|
||||
ao._rootSector = sector;
|
||||
ao._type = AstroObject.Type.None;
|
||||
|
||||
@ -419,10 +421,10 @@ namespace NewHorizons.Handlers
|
||||
};
|
||||
}
|
||||
|
||||
var owRigidBody = RigidBodyBuilder.Make(go, body.Config);
|
||||
var ao = AstroObjectBuilder.Make(go, primaryBody, body.Config, false);
|
||||
|
||||
var sphereOfInfluence = GetSphereOfInfluence(body);
|
||||
|
||||
var owRigidBody = RigidBodyBuilder.Make(go, sphereOfInfluence);
|
||||
var ao = AstroObjectBuilder.Make(go, primaryBody, body.Config, false);
|
||||
|
||||
var sector = SectorBuilder.Make(go, owRigidBody, sphereOfInfluence * 2f);
|
||||
ao._rootSector = sector;
|
||||
|
||||
@ -78,6 +78,12 @@ namespace NewHorizons.Handlers
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
GameObject.FindObjectOfType<SunProxy>().gameObject.SetActive(false);
|
||||
|
||||
// force call update here to make it switch to an active star. idk why we didnt have to do this before
|
||||
SunLightEffectsController.Instance.Update();
|
||||
|
||||
// Since we didn't call RemoveBody on the Stranger have to call this here
|
||||
StrangerRemoved();
|
||||
}, 2); // Have to wait or shit goes wild
|
||||
|
||||
foreach (var streamingAssetBundle in StreamingManager.s_activeBundles)
|
||||
@ -96,14 +102,23 @@ namespace NewHorizons.Handlers
|
||||
}
|
||||
}
|
||||
|
||||
public static void StrangerRemoved()
|
||||
{
|
||||
CloakHandler.FlagStrangerDisabled = true;
|
||||
|
||||
if (Locator._cloakFieldController?.GetComponentInParent<AstroObject>()?.GetAstroObjectName() == AstroObject.Name.RingWorld)
|
||||
{
|
||||
Locator._cloakFieldController = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveBody(AstroObject ao, bool delete = false, List<AstroObject> toDestroy = null)
|
||||
{
|
||||
NHLogger.LogVerbose($"Removing [{ao.name}]");
|
||||
|
||||
if (ao.GetAstroObjectName() == AstroObject.Name.RingWorld)
|
||||
{
|
||||
CloakHandler.FlagStrangerDisabled = true;
|
||||
if (Locator._cloakFieldController?.GetComponentInParent<AstroObject>() == ao) Locator._cloakFieldController = null;
|
||||
StrangerRemoved();
|
||||
}
|
||||
|
||||
if (ao.gameObject == null || !ao.gameObject.activeInHierarchy)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user