Skip to main content

TextureRecipe

Struct TextureRecipe 

Source
pub struct TextureRecipe {
Show 16 fields pub kind: String, pub scale: f32, pub octaves: u32, pub seed: u32, pub colors: Vec<[f32; 3]>, pub roughness: [f32; 2], pub smoothness: Option<[f32; 2]>, pub metallic: [f32; 2], pub height: f32, pub ao: f32, pub size: u32, pub over: Option<Box<TextureRecipe>>, pub mix: f32, pub mask_scale: f32, pub mask_seed: u32, pub triplanar: f32,
}
Expand description

One procedural material: a pattern drives everything. The pattern’s value (0–1 per texel) indexes the color ramp, lerps roughness/metallic between their two ends, acts as a height field for the normal map, and darkens crevices for ambient occlusion.

Fields§

§kind: String

Pattern: fbm (organic noise) · voronoi (stone cells + cracks) · bricks · wood (warped plank grain) · veins (marble) · checker · flat.

§scale: f32

Pattern repeats across the tile (features per tile edge). Default 4.

§octaves: u32

fbm octaves (detail). Default 4.

§seed: u32

Determinism seed — same recipe, same texels, everywhere. Default 0.

§colors: Vec<[f32; 3]>

Color ramp stops, evenly spaced over the pattern value. 1+ colors.

§roughness: [f32; 2]

Roughness at pattern value 0 → 1. Default [0.9, 0.9].

§smoothness: Option<[f32; 2]>

Unity’s spelling of the same dial, if you think that way: smoothness = 1 − roughness. When present it WINS over roughness (see TextureRecipe::rough_band) — one material vocabulary, two accents.

§metallic: [f32; 2]

Metallic at pattern value 0 → 1. Default [0, 0].

§height: f32

Normal-map strength — the pattern read as a height field. 0 = flat.

§ao: f32

Crevice darkening strength (bakes into the occlusion channel). 0 = none.

§size: u32

Baked texture side in texels. Default 256, clamped to MAX_SIZE.

§over: Option<Box<TextureRecipe>>

A second recipe layered OVER this one, blended by an fbm mask — moss over granite, rust over iron, plaster over brick. One level deep.

§mix: f32

How much of the overlay shows (0 none → 1 full). Default 0.5.

§mask_scale: f32

Feature scale of the blend mask (default 3).

§mask_seed: u32

Seed of the blend mask.

§triplanar: f32

World-space triplanar sampling in the browser (uv repeats per metre; 0 = classic UV sampling). Kills projection seams on carved shapes — set ~0.5 for architecture. Exported GLBs keep UVs (glTF has no triplanar), so exports still look right, just with seams.

Implementations§

Source§

impl TextureRecipe

Source

pub fn rough_band(&self) -> [f32; 2]

The effective roughness band, honouring smoothness when given.

Source

pub fn validate(&self) -> Result<(), String>

Trait Implementations§

Source§

impl Clone for TextureRecipe

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TextureRecipe

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TextureRecipe

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for TextureRecipe

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for TextureRecipe

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TextureRecipe

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.