MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
LatticeSemantics.hpp
Go to the documentation of this file.
1#pragma once
2
3namespace MayaFlux::Kinesis {
4
5/**
6 * @enum LatticeValueClass
7 * @brief What the values sampled over a lattice mean geometrically.
8 *
9 * A description of the data, not of any consumer. A fog volume's values
10 * are densities: nonnegative, zero outside the medium, meaningful only in
11 * aggregate along a ray. A level set's are signed distances whose zero
12 * crossing is a surface and whose gradient is a normal. A staggered
13 * field's components are sampled on cell faces rather than at the centre,
14 * which is a placement property rather than a meaning one, but it travels
15 * in this enumeration because every interchange format that carries the
16 * distinction carries it here.
17 *
18 * Unknown is the honest default. A field left Unknown is a plain array of
19 * numbers over a lattice, which most fields are, and nothing downstream
20 * should infer otherwise from its name.
21 *
22 * The enumerators correspond one to one with OpenVDB's GridClass and with
23 * the tokens USD's UsdVol schema accepts for fieldClass, so an interchange
24 * writer maps them without a lookup table and without loss.
25 */
26enum class LatticeValueClass : uint8_t {
27 Unknown, ///< Plain numeric values with no further structure claimed.
28 LevelSet, ///< Signed distance to a surface at the zero crossing.
29 FogVolume, ///< Density of a participating medium, zero outside it.
30 Staggered, ///< Vector components sampled on cell faces, not centres.
31};
32
33/**
34 * @enum VectorVariance
35 * @brief How a vector quantity's components behave under a change of frame.
36 *
37 * The distinction is differential-geometric and independent of storage: it
38 * says whether the numbers stored are attached to the lattice's coordinate
39 * basis or to the world, and therefore what must happen to them when the
40 * lattice is scaled, rotated or resampled.
41 *
42 * A velocity is ContravariantRelative: halve the cell size and the stored
43 * components halve with it, because a velocity is a displacement per unit
44 * time expressed in lattice units. A surface normal is CovariantNormalize:
45 * it transforms by the inverse transpose and is renormalized after. A
46 * triple of unrelated scalars carried together for convenience, a colour
47 * for instance, is Invariant: nothing happens to it under any change of
48 * frame.
49 *
50 * Invariant is the default because assuming a vector is a velocity when it
51 * is not silently corrupts it the first time anything rescales the lattice,
52 * whereas the reverse mistake leaves values untouched and visibly wrong.
53 *
54 * Meaningless for scalar quantities. Carried alongside them regardless
55 * rather than split into a separate optional, since the pairing is what
56 * every consumer wants and a scalar's variance is simply ignored.
57 *
58 * The enumerators correspond one to one with OpenVDB's VecType.
59 */
60enum class VectorVariance : uint8_t {
61 Invariant, ///< Unaffected by any change of frame.
62 Covariant, ///< Transforms by the inverse transpose.
63 CovariantNormalize, ///< Inverse transpose, then renormalized.
64 ContravariantRelative, ///< Transforms by the frame itself; velocities.
65 ContravariantAbsolute, ///< Contravariant, treated as a world-space position.
66};
67
68/**
69 * @struct LatticeSemantics
70 * @brief Interpretation attached to one named quantity sampled over a lattice.
71 *
72 * Carries no data and no lattice. It says what a separately stored array of
73 * values means, so that a consumer which never saw the code that produced
74 * them can resample, render or write them correctly.
75 *
76 * Pure description with no behaviour, which is why it lives in Kinesis
77 * rather than in Buffers or IO. A GPU-resident simulation attaches one to
78 * each of its stored quantities at declaration; an interchange writer reads
79 * the same struct and maps it to whatever its format calls these two ideas.
80 * Neither side owns it and neither needs its own copy.
81 *
82 * Both members default to their least presumptuous value, so a caller that
83 * has nothing to say says nothing:
84 *
85 * @code
86 * vol->declare_scalar("density", { .value_class = LatticeValueClass::FogVolume });
87 * vol->declare_vector("velocity", { .variance = VectorVariance::ContravariantRelative });
88 * vol->declare_scratch("divergence");
89 * @endcode
90 */
92 LatticeValueClass value_class = LatticeValueClass::Unknown; ///< Geometric meaning of the values.
93 VectorVariance variance = VectorVariance::Invariant; ///< Vector quantities only.
94};
95
96} // namespace MayaFlux::Kinesis
LatticeValueClass
What the values sampled over a lattice mean geometrically.
@ FogVolume
Density of a participating medium, zero outside it.
@ Unknown
Plain numeric values with no further structure claimed.
@ Staggered
Vector components sampled on cell faces, not centres.
@ LevelSet
Signed distance to a surface at the zero crossing.
VectorVariance
How a vector quantity's components behave under a change of frame.
@ Invariant
Unaffected by any change of frame.
@ ContravariantAbsolute
Contravariant, treated as a world-space position.
@ ContravariantRelative
Transforms by the frame itself; velocities.
@ CovariantNormalize
Inverse transpose, then renormalized.
@ Covariant
Transforms by the inverse transpose.
VectorVariance variance
Vector quantities only.
LatticeValueClass value_class
Geometric meaning of the values.
Interpretation attached to one named quantity sampled over a lattice.