Merge remote-tracking branch 'origin/eureka/aetheria-gravity-nebula-tint' into eureka/aetheria-gravity-merge-ag3
This commit is contained in:
commit
6865af813f
12 changed files with 537 additions and 10 deletions
|
|
@ -27,6 +27,8 @@ public class ZoneRenderer : MonoBehaviour
|
|||
public GameSettings Settings;
|
||||
public Transform ZoneRoot;
|
||||
public Transform SectorBrushes;
|
||||
// The ambient tint quad, sized from the zone's populated radius, never under SectorBrushes: FitAmbientLight.
|
||||
public Transform AmbientLight;
|
||||
public CinemachineVirtualCamera SceneCamera;
|
||||
public Camera[] FogCameras;
|
||||
public Camera[] MinimapCameras;
|
||||
|
|
@ -187,11 +189,35 @@ public class ZoneRenderer : MonoBehaviour
|
|||
_transposer = SceneCamera.GetCinemachineComponent<CinemachineTransposer>();
|
||||
}
|
||||
|
||||
// The ambient is a gaussian: its brightness at the populated edge is the material's _EdgeBrightness (a shape, authored), and
|
||||
// the quad reaches out to where its brightest channel falls to AmbientFloor. Fog Tint is B10G11R11_UFloatPack32 and cannot
|
||||
// follow a gaussian into its tail: measured, the drawn value stops following it near 4 floors and holds a plateau of
|
||||
// about 3.2e-5 before dropping to zero (AmbientEdgeVerify asserts the format and measures it). A quad sized to 1e-5 of the
|
||||
// centre therefore ended in a plateau and a step to zero; sized to the floor it ends at the last value the format holds,
|
||||
// so the one step to dark is that value. The one writer of the quad's size and _Reach, and the one place the verify
|
||||
// reads the sizing from.
|
||||
public const float AmbientFloor = 1f / (1 << 15);
|
||||
|
||||
public static void FitAmbientLight(Transform light, Zone zone)
|
||||
{
|
||||
var renderer = light.GetComponent<MeshRenderer>();
|
||||
var material = renderer.sharedMaterial;
|
||||
var tint = material.GetColor("_Color").linear;
|
||||
var centre = material.GetFloat("_Depth") * Mathf.Max(tint.r, Mathf.Max(tint.g, tint.b));
|
||||
var reach = Mathf.Sqrt(Mathf.Log(centre / AmbientFloor) / Mathf.Log(1f / material.GetFloat("_EdgeBrightness")));
|
||||
light.localScale = 2f * reach * zone.PopulatedRadius * Vector3.one;
|
||||
var block = new MaterialPropertyBlock();
|
||||
renderer.GetPropertyBlock(block);
|
||||
block.SetFloat("_Reach", reach);
|
||||
renderer.SetPropertyBlock(block);
|
||||
}
|
||||
|
||||
public void LoadZone(Zone zone)
|
||||
{
|
||||
ClearZone();
|
||||
Zone = zone;
|
||||
SectorBrushes.localScale = zone.Pack.Radius * 2 * Vector3.one;
|
||||
FitAmbientLight(AmbientLight, zone);
|
||||
SlimeGravityCamera.orthographicSize = zone.Pack.Radius;
|
||||
SlimeRenderer.ZoneRadius = zone.Pack.Radius;
|
||||
if (_gravityField == null) _gravityField = GravityLowering.CreateField(GravityField);
|
||||
|
|
|
|||
Loading…
Reference in a new issue