Zone.WellReference owns each body's reference zero (GetHeight uses it). Gravity.cginc mirrors GravityField.Potential; Brushes/Gravity Field draws depth = -h on layer 9 from a StructuredBuffer that GravityLowering.Lower fills from the zone each frame; GravityLowering.CreateField makes the one quad. GravityFieldParityVerify renders it and compares every texel with -Zone.GetHeight (max error 0.0059 u), the gradient with GetForce (0.03 degrees) and the wiring. Deleted: the Gravity Well children of Planet, Gas Giant, Sun and PlanetOutpost prefabs, Wormhole 1's three gravity children, their overrides in Main Menu and TestScene, five wormhole/wave materials and two brush shaders, Planet.GravityWellDepth/Radius, BodyData keys 6-7, PlanetSettings.GravityDepth/GravityRadius (and the Settings.asset keys). Surface Displacement culls layer 9 only. Headless build and tests not yet run at this commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.4 KiB
HLSL
42 lines
1.4 KiB
HLSL
#ifndef AETHERIA_GRAVITY_INCLUDED
|
|
#define AETHERIA_GRAVITY_INCLUDED
|
|
|
|
// The lowering of the zone's potential (aetheria-gravity, cut grid-lowering). The law is ServerShared's GravityField
|
|
// and the height is Zone.GetHeight; this file mirrors them and decides nothing. GravityLowering.Lower fills the
|
|
// buffer and the globals from the zone (positions from Orbit.Position, reference from Zone.WellReference) each frame.
|
|
// GravityFieldParityVerify renders it and compares every texel with -Zone.GetHeight.
|
|
|
|
struct GravityWell
|
|
{
|
|
float2 position;
|
|
float strength;
|
|
float coreRadius;
|
|
float reference;
|
|
};
|
|
|
|
StructuredBuffer<GravityWell> _GravityWells;
|
|
int _GravityWellCount;
|
|
float _HeightExaggeration;
|
|
|
|
// GravityField.Potential, line for line: c is the well's strength, R its core radius, r the distance.
|
|
float gravityPotential(float c, float R, float r)
|
|
{
|
|
return c == 0 ? 0 :
|
|
r < R
|
|
? c * r * r / (2 * R * R)
|
|
: c * (log(r / R) + .5);
|
|
}
|
|
|
|
// Zone.GetHeight at world xz: each well's potential minus its own reference, summed, divided by the exaggeration.
|
|
float gravityHeight(float2 p)
|
|
{
|
|
float result = 0;
|
|
for (int i = 0; i < _GravityWellCount; i++)
|
|
{
|
|
GravityWell well = _GravityWells[i];
|
|
result += gravityPotential(well.strength, well.coreRadius, length(p - well.position)) - well.reference;
|
|
}
|
|
return result / _HeightExaggeration;
|
|
}
|
|
|
|
#endif
|