Align stellar lighting and gravity field axes

This commit is contained in:
Meta Vens 2026-07-16 18:50:41 +01:00
commit db35250d09
9 changed files with 136 additions and 58 deletions

View file

@ -62,6 +62,8 @@ namespace Aetheria.Editor
var kernel = program.FindKernel("UpdateParticles");
using var particles = new ComputeBuffer(Span * Span, 7 * sizeof(float), ComputeBufferType.Structured);
var field = ConstantTexture(new Color(0.5f, 0.5f, 0.5f, 1f));
var emptyField = ConstantTexture(Color.clear);
var positiveXField = PositiveXTexture();
var tint = ConstantTexture(Color.white);
var hue = ConstantTexture(Color.white);
try
@ -92,6 +94,15 @@ namespace Aetheria.Editor
program.SetFloat("_DynamicLodLow", 2f);
program.SetInt("span", Span);
program.SetFloat("_FlowAmplitude", 0f);
program.SetTexture(kernel, "_NebulaSurfaceHeight", emptyField);
var flat = DispatchAndRead(program, kernel, particles, 0f, 0f);
program.SetTexture(kernel, "_NebulaSurfaceHeight", positiveXField);
var oriented = DispatchAndRead(program, kernel, particles, 0f, 0f);
AssertPositiveWorldXSamplesPositiveTextureX(flat, oriented);
program.SetTexture(kernel, "_NebulaSurfaceHeight", field);
program.SetFloat("_FlowAmplitude", 15f);
var before = DispatchAndRead(program, kernel, particles, 0f, 0f);
AssertWholeBlockRemapIsInvisible(
before,
@ -114,6 +125,8 @@ namespace Aetheria.Editor
finally
{
UnityEngine.Object.DestroyImmediate(field);
UnityEngine.Object.DestroyImmediate(emptyField);
UnityEngine.Object.DestroyImmediate(positiveXField);
UnityEngine.Object.DestroyImmediate(tint);
UnityEngine.Object.DestroyImmediate(hue);
}
@ -126,7 +139,11 @@ namespace Aetheria.Editor
float gridCenterX,
float gridCenterY)
{
program.SetVector("_GridTransform", new Vector4(gridCenterX, gridCenterY, 1536f, 1536f));
program.SetVector("_GridTransform", new Vector4(
gridCenterX,
gridCenterY,
Span * Spacing,
Span * Spacing));
program.Dispatch(kernel, Mathf.CeilToInt((float)(Span * Span) / GroupSize), 1, 1);
var result = new Particle[Span * Span];
particles.GetData(result);
@ -162,6 +179,20 @@ namespace Aetheria.Editor
}
}
private static void AssertPositiveWorldXSamplesPositiveTextureX(
Particle[] flat,
Particle[] oriented)
{
const int positiveWorldCellX = 3;
const int worldCellY = 0;
var index = (worldCellY + Span / 2) * Span + positiveWorldCellX + Span / 2;
var displacement = oriented[index].Position.y - flat[index].Position.y;
if (displacement > -0.75f)
throw new InvalidOperationException(
$"Stardust positive-world X sampled the wrong side of the typed gravity viewport; " +
$"expected at least one unit of downward displacement, observed {displacement:R}.");
}
private static bool BitwiseEqual(Particle left, Particle right) =>
Bits(left.Position.x) == Bits(right.Position.x) &&
Bits(left.Position.y) == Bits(right.Position.y) &&
@ -187,5 +218,23 @@ namespace Aetheria.Editor
texture.Apply(false, false);
return texture;
}
private static Texture2D PositiveXTexture()
{
const int size = 8;
var texture = new Texture2D(size, size, TextureFormat.RGBA32, false, true)
{
filterMode = FilterMode.Point,
wrapMode = TextureWrapMode.Clamp,
hideFlags = HideFlags.HideAndDontSave
};
var pixels = new Color[size * size];
for (var y = 0; y < size; y++)
for (var x = 0; x < size; x++)
pixels[y * size + x] = x >= size / 2 ? Color.white : Color.clear;
texture.SetPixels(pixels);
texture.Apply(false, false);
return texture;
}
}
}

View file

@ -576,9 +576,6 @@ namespace Aetheria.Editor
var assetNames = bundle.GetAllAssetNames();
foreach (var assetPath in assetNames.Where(path => path.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase)))
VerifyPrefab(bundle.LoadAsset<GameObject>(assetPath), assetPath);
var skybox = LoadAuthoredAsset<Material>(bundle, assetNames, "Assets/Materials/Skybox.mat");
if (skybox == null || skybox.shader == null || !skybox.shader.isSupported)
throw new InvalidOperationException("Aetheria Eve bundle has no supported provider skybox material.");
var reflection = LoadAuthoredAsset<Cubemap>(bundle, assetNames, "Assets/Textures/studio2.hdr");
if (reflection == null)
throw new InvalidOperationException("Aetheria Eve bundle has no provider reflection cubemap.");

View file

@ -80,7 +80,10 @@ float parabola( float x, float k )
float2 getUV(float2 pos)
{
return -(pos-_GridTransform.xy)/_GridTransform.z + float2(.5,.5);
// Eve Fields rasterizes its typed viewport with positive world axes.
// The fossil gravity camera reversed both axes and required a leading
// minus here; that camera is no longer an authority in the daemon path.
return (pos-_GridTransform.xy)/_GridTransform.z + float2(.5,.5);
}
float2 getUVFluid(float2 pos)