Ending: rail camera, stable far planet, green bursts from a US landing

Flights run on rails at even speed along the spline with eased ends and
smooth zoom pushes, no hand-held shake. Grass fur, sector lines and
shadows fade out as the camera climbs, and above 250 m the ground swaps
to an even cube-sphere skin so the relief no longer pops while orbiting.
Per-shot FOV, motion blur, slamming titles and a warp to Earth; the
rocket now lands in Kansas and the green bursts straight out of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bonchellon
2026-12-01 16:30:08 +03:00
parent a3e4f00282
commit d4dff6ea99
6 changed files with 289 additions and 41 deletions

View File

@ -29,6 +29,13 @@ namespace GrassCutter
/// <summary>A plant this close to the camera falls over when its sector is finished; further off it just isn't there any more.</summary>
const float FellSeen = 260f;
Transform _root, _skin;
/// <summary>
/// A film looking at the ball from far off (the ending's rise and orbit): the skin is an even mesh fixed to the ball
/// instead of the rings gathered under the lens, whose coarse far rings swim over the hills as the lens moves round.
/// </summary>
public static bool FarSkin;
MeshFilter _skinMf;
Mesh _nearSkin, _farSkin;
int _rockAt;
static readonly int SkyRotId = Shader.PropertyToID("_GcSkyRot"), SkyOnId = Shader.PropertyToID("_GcSkyOn");
@ -172,7 +179,13 @@ namespace GrassCutter
if (!cam) return;
var p = cam.transform.position;
Planet.SetFrame(p);
_skin.rotation = Quaternion.FromToRotation(Vector3.up, Planet.LocalUp);
if (_skinMf)
{
if (FarSkin && !_farSkin) _farSkin = BuildEvenSkin();
var want = FarSkin ? _farSkin : _nearSkin;
if (_skinMf.sharedMesh != want) _skinMf.sharedMesh = want;
}
_skin.rotation = FarSkin ? Quaternion.identity : Quaternion.FromToRotation(Vector3.up, Planet.LocalUp);
Shader.SetGlobalMatrix(SkyRotId, Matrix4x4.Rotate(Quaternion.Inverse(Planet.Frame)));
Shader.SetGlobalFloat(SkyOnId, 1f);
// climb and the haze lets go of the planet
@ -235,13 +248,57 @@ namespace GrassCutter
var go = new GameObject("Terrain");
go.transform.SetParent(_root, false);
go.transform.position = Planet.Center;
go.AddComponent<MeshFilter>().sharedMesh = m;
_skinMf = go.AddComponent<MeshFilter>();
_skinMf.sharedMesh = m;
_nearSkin = m;
var mr = go.AddComponent<MeshRenderer>();
mr.sharedMaterial = soil;
mr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
_skin = go.transform;
}
/// <summary>The ball's skin with every vertex about the same distance apart (a cube blown up into a sphere), facing out.</summary>
static Mesh BuildEvenSkin()
{
const int N = 160;
var verts = new List<Vector3>(6 * (N + 1) * (N + 1));
var tris = new List<int>(6 * N * N * 6);
Vector3[] fwd = { Vector3.up, Vector3.down, Vector3.left, Vector3.right, Vector3.forward, Vector3.back };
foreach (var f in fwd)
{
var a = Mathf.Abs(f.y) > 0.5f ? Vector3.right : Vector3.up;
var b = Vector3.Cross(f, a);
int o = verts.Count;
for (int y = 0; y <= N; y++)
for (int x = 0; x <= N; x++)
{
// tangent spacing evens the cells out towards the cube's edges
float u = Mathf.Tan((x / (float)N * 2f - 1f) * Mathf.PI * 0.25f);
float v = Mathf.Tan((y / (float)N * 2f - 1f) * Mathf.PI * 0.25f);
verts.Add((f + a * u + b * v).normalized);
}
for (int y = 0; y < N; y++)
for (int x = 0; x < N; x++)
{
int i0 = o + y * (N + 1) + x, i1 = i0 + 1, i2 = i0 + N + 1, i3 = i2 + 1;
AddOut(verts, tris, i0, i2, i1);
AddOut(verts, tris, i1, i2, i3);
}
}
var m = new Mesh { name = "PlanetSkinEven", indexFormat = UnityEngine.Rendering.IndexFormat.UInt32 };
m.SetVertices(verts);
m.SetTriangles(tris, 0);
m.bounds = new Bounds(Vector3.zero, Vector3.one * Planet.Radius * 3f);
return m;
}
static void AddOut(List<Vector3> v, List<int> t, int a, int b, int c)
{
// Unity's front face: the side the clockwise normal points to; it must point out of the ball
if (Vector3.Dot(Vector3.Cross(v[b] - v[a], v[c] - v[a]), v[a]) < 0f) { int s = b; b = c; c = s; }
t.Add(a); t.Add(b); t.Add(c);
}
void Populate()
{
var rng = new System.Random(7177);