The nebula patch reads gravity from the R32 surface height, not a half-float copy

Patch Displacement no longer culls layer 9; cloudDensity adds the surface displacement to the patch-only displacement.
GravityFieldParityVerify wiring checks the camera. Neither commit has been built when this is written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-15 17:45:57 +02:00
commit 3b039d069b
4 changed files with 16 additions and 3 deletions

View file

@ -8037,7 +8037,7 @@ Camera:
m_Depth: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 5632
m_Bits: 5120
m_RenderingPath: 1
m_TargetTexture: {fileID: 8400000, guid: 06ec5ef8a5830fc44b1ac1a6e123add5, type: 2}
m_TargetDisplay: 0

View file

@ -295,6 +295,17 @@ namespace Aetheria.EditorTools
}
if (seen < gravityTargets.Length) Fail("wiring", $"only {seen} gravity cameras found in ARPG.unity");
// The patch texture is half-float: it holds the patch layers only, the nebula reads gravity from the R32 surface.
var patchCameras = 0;
foreach (var camera in UnityEngine.Object.FindObjectsByType<Camera>(FindObjectsInactive.Include, FindObjectsSortMode.None))
{
if (camera.targetTexture == null || camera.targetTexture.name != "Fog Patch Displacement") continue;
patchCameras++;
if ((camera.cullingMask & 1 << GravityLowering.FieldLayer) != 0)
Fail("wiring", $"camera {camera.name} (target Fog Patch Displacement) culls layer {GravityLowering.FieldLayer}, the gravity layer");
}
if (patchCameras != 1) Fail("wiring", $"{patchCameras} Fog Patch Displacement cameras in ARPG.unity, expected 1");
// The map screen's gravity camera has no target until MapRenderer gives it one at run time.
var map = UnityEngine.Object.FindFirstObjectByType<MapRenderer>(FindObjectsInactive.Include);
if (map == null || map.GravityCamera == null) Fail("wiring", "no MapRenderer.GravityCamera in ARPG.unity");

View file

@ -1,5 +1,5 @@
// Draws the zone's gravity: depth = -Zone.GetHeight at the world xz of every texel, into whichever gravity camera culls
// layer 9 (Surface Displacement, Patch Displacement, Slime Gravity, both Map Gravity). One quad covers the zone; the
// layer 9 (Surface Displacement, Slime Gravity, both Map Gravity). One quad covers the zone; the
// law lives in Gravity.cginc, which mirrors ServerShared's GravityField.
Shader "Brushes/Gravity Field" {
Category {

View file

@ -97,7 +97,9 @@ float cloudDensity(float3 pos, float surfaceDisp)
float2 uv = getUV(pos.xz);
const float dist = pos.y + surfaceDisp - _NebulaFloorOffset;
const float patch = tex2Dlod(_NebulaPatch, half4(uv, 0, 0)).r;
const float patchDisp = tex2Dlod(_NebulaPatchHeight, half4(uv, 0, 0)).r;
// Gravity comes from the R32 surface height the caller sampled at this uv; the patch texture carries only the patch
// layers (sector waves, patch brushes), small enough for half floats.
const float patchDisp = surfaceDisp + tex2Dlod(_NebulaPatchHeight, half4(uv, 0, 0)).r;
const float patchDensity = saturate((-abs(pos.y+patchDisp - _NebulaFloorOffset)+patch)/_NebulaPatchBlend)*_NebulaPatchDensity;
const float floorDist = -dist;