Skip to main content

MeshSpecification

Type Alias MeshSpecification 

pub type MeshSpecification = RCHandle<SkMeshSpecification>;
Expand description

A specification for custom meshes. Specifies the vertex buffer attributes and stride, the vertex program that produces a user-defined set of varyings, and a fragment program that ingests the interpolated varyings and produces local coordinates for shading and optionally a color.

The varyings must include a float2 named position. If the passed varyings does not contain such a varying then one is implicitly added to the final specification and the SkSL Varyings struct described below. It is an error to have a varying named position that has a type other than float2.

The provided attributes and varyings are used to create Attributes and Varyings structs in SkSL that are used by the shaders. Each attribute from the Attribute slice becomes a member of the SkSL Attributes struct and likewise for the varyings.

The signature of the vertex program must be: Varyings main(const Attributes).

The signature of the fragment program must be either: float2 main(const Varyings) or float2 main(const Varyings, out (half4|float4) color)

where the return value is the local coordinates that will be used to access crate::Shader. If the color variant is used, the returned color will be blended with crate::Paint’s crate::Shader (or crate::Paint color in absence of a crate::Shader) using the crate::Blender passed to crate::Canvas::draw_mesh(). To use interpolated local space positions as the shader coordinates, equivalent to how crate::Paths are shaded, return the position field from the Varying struct as the coordinates.

The vertex and fragment programs may both contain uniforms. Uniforms with the same name are assumed to be shared between stages. It is an error to specify uniforms in the vertex and fragment program with the same name but different types, dimensionality, or layouts.

Aliased Type§

pub struct MeshSpecification(/* private fields */);