pub struct DeformerDesc {
pub name: &'static str,
pub stage: DeformStage,
pub priority: i32,
pub wgsl_body: String,
pub per_vertex_stride: u32,
}Expand description
Description of a deformer to register against the mesh shader family.
wgsl_body defines:
fn <name>_deform(v: DeformVertex, ctx: DeformContext) -> DeformVertex { ... }The composer prefixes every top-level identifier it finds inside
wgsl_body with <name>__ to keep multiple deformers independent. The
body may read deform_data / deform_instance_data via the
deform_read_* helpers in deform.wgsl, and read its slot’s parameter
region via deform_header.slot_params[ctx.slot * 4 + k].
§Hook contract
The shipped deform.wgsl declares:
struct DeformVertex {
position: vec3<f32>,
normal: vec3<f32>,
vertex_index: u32,
};
struct DeformContext {
model: mat4x4<f32>,
object_origin: vec3<f32>,
time_seconds: f32,
flags: u32,
slot: u32,
};These signatures are stable: additive changes only. Existing fields will not be renamed, retyped, or removed. New fields may be appended; bodies compiled against an older view continue to work because the WGSL struct init they don’t touch is filled by the caller.
position is object-space on entry to an ObjectSpace body and
world-space on entry to a WorldSpace body. vertex_index is the
@builtin(vertex_index) from the vertex stage. ctx.slot is the slot
the registry assigned to this deformer; use it to address deform_data
and deform_instance_data rather than baking in a literal.
§Composition order
Deformers run in two stages: every DeformStage::ObjectSpace body
first, then every DeformStage::WorldSpace body. Within a stage,
bodies execute in ascending priority (lower runs first); ties break by
name. The in-crate skinning deformer registers at
DEFORM_PRIORITY_SKINNING = -1000 so morph-class deformers registered
at the default priority of 0 run after it. This ordering is part of
the contract: a body that wants to run before skinning must register
with a priority strictly less than -1000.
§Pass scope
Every registered deformer runs in every mesh-family pass: the main solid and transparent passes, the OIT accumulate pass, the instanced and instanced-OIT pipelines, the shadow pass, and the outline-mask pass. A deformer cannot opt out of a single pass; the composed pipeline is shared across them.
In particular: shadows always deform. A skinned or wind-swept mesh casts a shadow that matches its deformed silhouette. The outline mask follows the deformed silhouette for the same reason. GPU picking, which uses the same mesh family, picks the deformed mesh.
Bodies that have nothing to do for a draw (no slot data attached, flag bit clear) are gated off by the per-slot flag branch the composer wraps the call in, so the cost on undeformed draws is the branch predicate, not the body.
Fields§
§name: &'static strDeformer name. Must be a valid WGSL identifier and unique across the
registry. The composer uses it as the prefix for every top-level
declaration spliced from wgsl_body.
stage: DeformStageWhich side of the model transform the body runs on.
priority: i32Execution order within the stage; lower runs first. Ties break by name.
wgsl_body: StringWGSL body defining fn <name>_deform(v: DeformVertex, ctx: DeformContext) -> DeformVertex
plus any helper declarations. All top-level identifiers in this body
are prefixed with <name>__ at composition time.
per_vertex_stride: u32Bytes per vertex in the slot storage buffer (validated on attach).
Trait Implementations§
Source§impl Clone for DeformerDesc
impl Clone for DeformerDesc
Source§fn clone(&self) -> DeformerDesc
fn clone(&self) -> DeformerDesc
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DeformerDesc
impl RefUnwindSafe for DeformerDesc
impl Send for DeformerDesc
impl Sync for DeformerDesc
impl Unpin for DeformerDesc
impl UnsafeUnpin for DeformerDesc
impl UnwindSafe for DeformerDesc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.