pub struct WaterBody {
pub extinction: [f32; 3],
pub scatter: [f32; 3],
pub ior: f32,
pub waves: Vec<WaveLayer>,
pub shore_fade: f32,
}Expand description
core.water_body: the optics of the water a material’s surface covers, in the world’s units (metres, seconds,
linear RGB), on a material entity whose crate::MaterialUsage is water. What the surface itself reflects stays
crate::pbr::PbrMaterial’s; this is what lies under it and how the surface moves.
The model it states, which a consumer draws as far as it can: a view ray enters the water at the surface and travels
d metres through it to what is behind (the scene below, read from the frame or a closed volume). What is behind
arrives multiplied by exp(-extinction * d) per channel, and the water body adds scatter * E / pi * (1 - exp(-extinction * d)), E the irradiance (sun and sky, the light a horizontal diffuse surface at the water’s
surface receives). The sum is transmitted through the surface, weighted by 1 - F against the reflection’s F,
Schlick’s F = F0 + (1 - F0) * (1 - cos)^5 with F0 = ((ior - 1) / (ior + 1))^2. The surface’s normal is
WaterBody::waves summed; its opacity at the shore is saturate(depth / shore_fade), depth the water’s depth
below the surface along the view axis.
Fields§
§extinction: [f32; 3]Light lost per metre the view ray travels through the water, per channel: a path of d metres transmits
exp(-extinction * d). Zero is clear water.
scatter: [f32; 3]The diffuse reflectance of the water body where it is infinitely deep, per channel within 0-1: it returns
radiance scatter * E / pi from below the surface for an irradiance E arriving at the surface. A consumer that
has only a body colour takes that colour, linear, as scatter; zero is water that returns nothing of its own,
only what is behind it.
ior: f32The surface’s index of refraction, above 1: its Fresnel reflectance at normal incidence is
((ior - 1) / (ior + 1))^2 (0.02 for 1.33, 0.04 for 1.5), and for a source that states that reflectance F0
instead, ior = (1 + sqrt(F0)) / (1 - sqrt(F0)).
waves: Vec<WaveLayer>The moving normal maps whose tangent-space normals, summed, make the surface’s normal; empty for a still flat surface.
shore_fade: f32The depth of water (metres, below the surface along the view axis) over which the surface fades in from fully transparent at the shore to opaque; zero is a hard edge.
Implementations§
Trait Implementations§
Source§impl Component for WaterBody
impl Component for WaterBody
Source§fn verify(&self, _e: Entity, _w: &World) -> Result<(), String>
fn verify(&self, _e: Entity, _w: &World) -> Result<(), String>
Every range its fields document.
const NAME: &'static str = "core.water_body"
Source§const GEOMETRY: Geometry = Geometry::None
const GEOMETRY: Geometry = Geometry::None
Geometry). Stated by every component,
with no default, so data that describes a mesh can’t be left behind by an edit of it unawares: the World’s edit
paths take it from there.Source§fn to_json(&self) -> Result<Option<Value>, JsonError>
fn to_json(&self) -> Result<Option<Value>, JsonError>
Ok(None) for components
that are not shown (bulk data, handles). The view must never lose a value: components that can be shown
derive serde::Serialize and return crate::json::to_value(self).map(Some), which refuses non-finite
floats instead of writing them as null.Source§fn references(&self, out: &mut Vec<Entity>)
fn references(&self, out: &mut Vec<Entity>)
out: the edges
World::closure follows. A component holding entity references must declare every one of them.Source§const VERSION: u32 = 1
const VERSION: u32 = 1
Source§fn payload_bytes(&self) -> u64
fn payload_bytes(&self) -> u64
Source§fn remap_primitives(&self, _from: &[usize]) -> Option<Result<Self, String>>
fn remap_primitives(&self, _from: &[usize]) -> Option<Result<Self, String>>
Geometry::PerPrimitive, Geometry::PerVertex): new primitive i comes from old primitive
from[i] (a source may repeat, when a primitive is split, or be absent, when one is dropped). Such a component
always answers (a value holding nothing per primitive answers with itself); None, the default, is for
components of Geometry::None, and World::remap_primitives refuses a dependent component that gives it.
An index the component does not have is an error. remap_list does the work for a list with one entry per
primitive.Source§fn remap_vertices(
&self,
_primitive: usize,
_from: &[u32],
) -> Option<Result<Self, String>>
fn remap_vertices( &self, _primitive: usize, _from: &[u32], ) -> Option<Result<Self, String>>
primitive were compacted or reordered, for a
component that holds something per vertex (Geometry::PerVertex): new vertex i of that primitive is old
vertex from[i] (a source may repeat or be absent). Such a component always answers (with itself when it holds
nothing for that primitive); None, the default, is for the others, and World::remap_vertices refuses a
per-vertex component that gives it. An index the component does not have is an error. Every pass that compacts
or reorders a primitive’s vertices calls World::remap_vertices. After a rebuild of the primitive list
(World::rebuild_primitives, Component::remap_primitives) a primitive’s per-vertex data is its source
primitive’s, and the vertex map is relative to that source.Source§fn blend_vertices(
&self,
_primitive: usize,
_from: &[VertexBlend],
) -> Option<Result<Self, String>>
fn blend_vertices( &self, _primitive: usize, _from: &[VertexBlend], ) -> Option<Result<Self, String>>
primitive were rebuilt as blends of old ones
(VertexBlend), for a component that holds something per vertex (Geometry::PerVertex): new vertex i
is the combination from[i] of old vertices, in whatever way the component’s data combines (a morph target’s
delta is interpolated, the way the surface it moves is). It answers as Component::remap_vertices does: with
itself when it holds nothing for that primitive; None, the default, is for a component that does not know how
to combine its data, and World::blend_vertices refuses a per-vertex component that gives it. An index the
component does not have is an error. A vertex that is a copy of one old vertex (VertexBlend::copy) is the
case Component::remap_vertices states, and a component answering one answers the other alike.Source§fn apply_linear(&self, _l: &Linear) -> Linearity<Self>
fn apply_linear(&self, _l: &Linear) -> Linearity<Self>
l (a pass that bakes a placement’s mirror or
shear into a copy of its geometry, so transforms stay rigid). World::apply_linear calls it for every
component of the entity. The default is Linearity::Unsupported: a component that holds local-space
geometry and does not say how it follows is never silently left behind; one without geometry says
Linearity::Invariant.Source§fn restate(&self, _resolved: &Resolved<'_>) -> Restated<Self>
fn restate(&self, _resolved: &Resolved<'_>) -> Restated<Self>
resolve-state (crate::state::ResolveState) gave the axes in resolved their values: a
component that holds crate::state::Clauses of its own (a record of parts each present in some states) reduces
them as core.condition is reduced (crate::state::Resolved::reduce: a clause that fails is dropped, a clause
left with no literal holds whatever the other axes are). Restated::Absent says the entity is not present in
this state (every clause failed): it is despawned as one whose core.condition fails is. The default holds no
clause: Restated::Unchanged.