Skip to main content

WGSLSnippets

Struct WGSLSnippets 

Source
pub struct WGSLSnippets;
Expand description

Collection of reusable WGSL code snippets for common algorithms.

Implementations§

Source§

impl WGSLSnippets

Source

pub fn linear_map( val: &str, in_lo: f32, in_hi: f32, out_lo: f32, out_hi: f32, ) -> String

Emit a linear map from [in_lo, in_hi] to [out_lo, out_hi].

Source

pub fn rotate2d(v: &str, angle: &str) -> String

Emit a 2D rotation matrix applied to a vec2f.

Source

pub fn linear_to_srgb(c: &str) -> String

Emit an sRGB gamma correction (linear -> sRGB).

Source

pub fn srgb_to_linear(c: &str) -> String

Emit an sRGB -> linear conversion.

Source

pub fn blinn_phong(normal: &str, halfway: &str, shininess: &str) -> String

Emit a Blinn-Phong specular term.

Source

pub fn wang_hash(seed: &str) -> String

Emit a simple hash function for a u32 (Wang hash).

Source

pub fn pcg_next(state: &str) -> String

Emit a PCG random number step.

Source

pub fn rgb_to_hsv_fn() -> String

Emit an RGB-to-HSV conversion expression for a vec3f.

Source

pub fn hsv_to_rgb_fn() -> String

Emit an HSV-to-RGB conversion function.

Source

pub fn gaussian_weight(i: i32, sigma: f32) -> f32

Emit a Gaussian blur weight at offset i with standard deviation sigma.

Source

pub fn gaussian_blur_fn(radius: i32, sigma: f32, horizontal: bool) -> String

Emit a separable Gaussian blur kernel helper function.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.