diff --git a/all-is-cubes/src/block.rs b/all-is-cubes/src/block.rs index c82f4ed84..426a8d88b 100644 --- a/all-is-cubes/src/block.rs +++ b/all-is-cubes/src/block.rs @@ -210,6 +210,10 @@ pub enum Primitive { /// Data of [`Primitive::Atom`]. The definition of a single [block](Block) that has uniform /// material properties rather than spatially varying ones; a single voxel. +/// +/// All properties of an atom are [intensive properties]. +/// +/// [intensive properties]: https://en.wikipedia.org/wiki/Intensive_and_extensive_properties #[derive(Clone, Eq, Hash, PartialEq)] #[allow(clippy::exhaustive_structs)] pub struct Atom { @@ -221,14 +225,32 @@ pub struct Atom { /// The RGB components of this color are the *[reflectance]:* the fraction of incoming light /// that is reflected rather than absorbed. /// - /// The alpha component of this color specifies the opacity of this block, that is, the fraction - /// of light that is reflected or absorbed rather than transmitted. + /// The alpha (α) component of this color specifies the opacity of this block, + /// that is, the fraction of light that is reflected or absorbed rather than transmitted. /// - /// More precisely, when alpha is less than 1 and greater than 0, the reflectance and opacity + /// Whenever α is neither 1 nor 0 (and, trivially, in those cases too), + /// the reflectance and opacity /// should be interpreted as being of **a unit thickness of** this material. Thus, they may be /// modified by the length of material through which a light ray passes, either due to /// viewing angle or due to using this block as a voxel in a [`Primitive::Recur`]. /// + /// This transformation is best understood in terms of _transmittance_ T, + /// defined as 1 − α. + /// The transmittance of a given thickness of material, Td, + /// is defined in terms of the transmittance of a unit thickness, + /// T1, as: + /// + ///
+ /// Td = (T1)d. + ///
+ /// + /// Therefore, + /// + ///+ /// αd = + /// 1 − (1 − α1)d. + ///
+ /// /// [reflectance]: https://en.wikipedia.org/wiki/Reflectance pub color: Rgba, @@ -239,7 +261,7 @@ pub struct Atom { /// In the future this may be redefined in terms of a physical unit, but with the same /// dimensions. /// - /// Note that because we are describing a volume, not a surface, the physical + /// Because we are describing a volume, not a surface, the physical /// interpretation of this value depends on the opacity of the material. /// If `self.color.alpha()` is 1.0, then this light escaping a surface must have been emitted at /// the surface; if the alpha is 0.0, then it must have been emitted throughout the volume; and @@ -247,8 +269,32 @@ pub struct Atom { /// volume to compensate for internal absorption. Still, these are not distinct cases but form /// a continuum. /// - /// TODO: Give the formulas for this interpretation at varying depth and opacity - /// (i.e. how renderers should perform it). + /// The emission Ed of a particular thickness d + /// of this material is + /// + ///+ /// Ed = E1 · + /// ∫0d + /// (T1)x + /// dx + ///
+ /// + /// where E1 = `self.emission` and + /// T1 = `1.0 - self.color.alpha()`. + /// When integrated, this becomes + /// + ///+ /// Ed = E1 · d + ///
+ /// + /// when α = 0 (T = 1) and + /// + ///+ /// Ed = E1 · + /// (Td - 1) / (T1 - 1) + ///
+ /// + /// otherwise. /// /// [luminous emittance]: https://en.wikipedia.org/wiki/Luminous_emittance pub emission: Rgb,