Centralize temporal evidence lowering
This commit is contained in:
parent
857b51dbcb
commit
d3dfb065be
7 changed files with 172 additions and 66 deletions
|
|
@ -38,20 +38,7 @@ public sealed class TemporalGaussianAccumulator
|
|||
|
||||
public void Observe(IEnumerable<TemporalGaussianObservation> observations)
|
||||
{
|
||||
reservoir.Observe(observations.Select(observation => new TemporalSpatialEvidenceObservation(
|
||||
observation.StableKey,
|
||||
observation.Center,
|
||||
observation.Radii,
|
||||
observation.Orientation,
|
||||
observation.ColorOpacity,
|
||||
new Vector4(
|
||||
MathF.Max(0.0001f, observation.Falloff),
|
||||
MathF.Max(0.0001f, observation.ShapePower),
|
||||
0.0f,
|
||||
0.0f),
|
||||
observation.Confidence,
|
||||
observation.ObservedTimeSeconds,
|
||||
observation.FieldId)));
|
||||
reservoir.Observe(observations.Select(TemporalSpatialEvidenceLowering.FromGaussianObservation));
|
||||
}
|
||||
|
||||
public AquariumTemporalGaussianField BuildField(float renderTimeSeconds)
|
||||
|
|
@ -61,21 +48,7 @@ public sealed class TemporalGaussianAccumulator
|
|||
|
||||
for (var index = 0; index < snapshot.Samples.Count; index++)
|
||||
{
|
||||
var sample = snapshot.Samples[index];
|
||||
gaussians[index] = new AquariumTemporalSdfGaussian(
|
||||
sample.StableKey,
|
||||
sample.Center,
|
||||
sample.PreviousCenter,
|
||||
sample.Velocity,
|
||||
sample.Radii,
|
||||
sample.Orientation,
|
||||
sample.Payload0,
|
||||
sample.Confidence,
|
||||
sample.HistoryWeight,
|
||||
sample.LastObservedTimeSeconds,
|
||||
sample.Payload1.X,
|
||||
sample.Payload1.Y,
|
||||
sample.FieldId);
|
||||
gaussians[index] = TemporalSpatialEvidenceLowering.ToTemporalGaussian(snapshot.Samples[index]);
|
||||
}
|
||||
|
||||
return new AquariumTemporalGaussianField
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
using System.Numerics;
|
||||
using Aquarium.Engine.Render;
|
||||
|
||||
namespace Aquarium.Engine.Fractal.Temporal;
|
||||
|
||||
public static class TemporalSpatialEvidenceLowering
|
||||
{
|
||||
public static TemporalSpatialEvidenceObservation FromGaussianObservation(TemporalGaussianObservation observation)
|
||||
{
|
||||
return new TemporalSpatialEvidenceObservation(
|
||||
observation.StableKey,
|
||||
observation.Center,
|
||||
observation.Radii,
|
||||
observation.Orientation,
|
||||
observation.ColorOpacity,
|
||||
new Vector4(
|
||||
MathF.Max(0.0001f, observation.Falloff),
|
||||
MathF.Max(0.0001f, observation.ShapePower),
|
||||
0.0f,
|
||||
0.0f),
|
||||
observation.Confidence,
|
||||
observation.ObservedTimeSeconds,
|
||||
observation.FieldId);
|
||||
}
|
||||
|
||||
public static AquariumTemporalSdfGaussian ToTemporalGaussian(TemporalSpatialEvidenceSample sample)
|
||||
{
|
||||
return new AquariumTemporalSdfGaussian(
|
||||
sample.StableKey,
|
||||
sample.Center,
|
||||
sample.PreviousCenter,
|
||||
sample.Velocity,
|
||||
sample.Radii,
|
||||
sample.Orientation,
|
||||
sample.Payload0,
|
||||
sample.Confidence,
|
||||
sample.HistoryWeight,
|
||||
sample.LastObservedTimeSeconds,
|
||||
MathF.Max(0.0001f, sample.Payload1.X),
|
||||
MathF.Max(0.0001f, sample.Payload1.Y),
|
||||
sample.FieldId);
|
||||
}
|
||||
|
||||
public static TemporalSpatialEvidenceObservation FromGpuFusionSeed(AquariumGpuFusionSeed seed, float observedTimeSeconds)
|
||||
{
|
||||
return new TemporalSpatialEvidenceObservation(
|
||||
seed.StableKey,
|
||||
seed.Center,
|
||||
seed.Radii,
|
||||
Quaternion.Identity,
|
||||
seed.ColorOpacity,
|
||||
new Vector4(
|
||||
MathF.Max(0.0001f, seed.Falloff),
|
||||
MathF.Max(0.0001f, seed.ShapePower),
|
||||
seed.HistoryWeight,
|
||||
0.0f),
|
||||
seed.Confidence,
|
||||
observedTimeSeconds,
|
||||
seed.FieldId);
|
||||
}
|
||||
|
||||
public static AquariumGpuFusionSeed ToGpuFusionSeed(TemporalSpatialEvidenceSample sample)
|
||||
{
|
||||
return new AquariumGpuFusionSeed(
|
||||
sample.StableKey,
|
||||
sample.Center,
|
||||
sample.PreviousCenter,
|
||||
sample.Velocity,
|
||||
sample.Radii,
|
||||
sample.Payload0,
|
||||
sample.Confidence,
|
||||
sample.HistoryWeight,
|
||||
MathF.Max(0.0001f, sample.Payload1.X),
|
||||
MathF.Max(0.0001f, sample.Payload1.Y),
|
||||
sample.FieldId);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
using System.Numerics;
|
||||
using Aquarium.Engine.Fractal.Temporal;
|
||||
using Aquarium.Engine.Render;
|
||||
|
||||
|
|
@ -28,7 +27,7 @@ public sealed class LocalCastGpuFusionAccumulator
|
|||
{
|
||||
var field = mapper.Map(frame);
|
||||
var frameTimeSeconds = mapper.ToTimelineSeconds(frame.SourceTimeMaxNs);
|
||||
reservoir.Observe(field.Seeds.Select(seed => ToObservation(seed, frameTimeSeconds)));
|
||||
reservoir.Observe(field.Seeds.Select(seed => TemporalSpatialEvidenceLowering.FromGpuFusionSeed(seed, frameTimeSeconds)));
|
||||
}
|
||||
|
||||
public AquariumGpuFusionField BuildField(float renderTimeSeconds)
|
||||
|
|
@ -37,43 +36,9 @@ public sealed class LocalCastGpuFusionAccumulator
|
|||
|
||||
return new AquariumGpuFusionField
|
||||
{
|
||||
Seeds = snapshot.Samples.Select(ToSeed).ToArray(),
|
||||
Seeds = snapshot.Samples.Select(TemporalSpatialEvidenceLowering.ToGpuFusionSeed).ToArray(),
|
||||
AccumulationWindowSeconds = historySeconds,
|
||||
PresentationDelaySeconds = PresentationDelaySeconds,
|
||||
};
|
||||
}
|
||||
|
||||
private static TemporalSpatialEvidenceObservation ToObservation(AquariumGpuFusionSeed seed, float frameTimeSeconds)
|
||||
{
|
||||
return new TemporalSpatialEvidenceObservation(
|
||||
seed.StableKey,
|
||||
seed.Center,
|
||||
seed.Radii,
|
||||
Quaternion.Identity,
|
||||
seed.ColorOpacity,
|
||||
new Vector4(
|
||||
MathF.Max(0.0001f, seed.Falloff),
|
||||
MathF.Max(0.0001f, seed.ShapePower),
|
||||
seed.HistoryWeight,
|
||||
0.0f),
|
||||
seed.Confidence,
|
||||
frameTimeSeconds,
|
||||
seed.FieldId);
|
||||
}
|
||||
|
||||
private static AquariumGpuFusionSeed ToSeed(TemporalSpatialEvidenceSample sample)
|
||||
{
|
||||
return new AquariumGpuFusionSeed(
|
||||
sample.StableKey,
|
||||
sample.Center,
|
||||
sample.PreviousCenter,
|
||||
sample.Velocity,
|
||||
sample.Radii,
|
||||
sample.Payload0,
|
||||
sample.Confidence,
|
||||
sample.HistoryWeight,
|
||||
MathF.Max(0.0001f, sample.Payload1.X),
|
||||
MathF.Max(0.0001f, sample.Payload1.Y),
|
||||
sample.FieldId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue