Expand description
Mathematical helper types and functions.
Primarily this module adds some traits to help using glam
types on the GPU
without panicking, as well as a few traits to aid in writing generic shader
code that can be run on the CPU.
Lastly, it provides some common geometry and constants used in many shaders.
Structs§
- Const
Texture - A CPU texture with no dimensions that always returns the same value when sampled.
- CpuCubemap
- A CPU-side cubemap texture.
- CpuTexture2d
- CpuTexture2d
Array - GpuRng
- An PCG PRNG that is optimized for GPUs, in that it is fast to evaluate and accepts sequential ids as it’s initial state without sacrificing on RNG quality.
Constants§
- CLIP_
QUAD_ CCW - CLIP_
SPACE_ COORD_ QUAD_ CCW - CLIP_
SPACE_ COORD_ QUAD_ CCW_ BL - CLIP_
SPACE_ COORD_ QUAD_ CCW_ BR - CLIP_
SPACE_ COORD_ QUAD_ CCW_ TL - CLIP_
SPACE_ COORD_ QUAD_ CCW_ TR - CUBE
- Points on the unit cube that create a triangle-list mesh.
- POINTS_
2D_ TEX_ QUAD - UNIT_
INDICES - Triangle faces of the unit cube, winding CCW.
- UNIT_
POINTS - Points around the unit cube.
- UNIT_
QUAD_ CCW - UV_
COORD_ QUAD_ CCW
Traits§
- Fetch
- Float
- Generic trait for floating point numbers
- IsMatrix
- Additional/replacement methods for glam matrix types.
- IsSampler
- IsVector
- Additional/replacement methods for glam vector types.
- Sample2d
- Sample2d
Array - Sample
Cube - Zero
- Defines an additive identity element for
Self
.
Functions§
- clamp
- A value bounded by a minimum and a maximum
- convert_
pixel_ to_ ndc - Convert a pixel coordinate in screen space (origin is top left, Y increases downwards) to normalized device coordinates (origin is center, Y increses upwards).
- convex_
mesh - distance_
to_ line - Quantize an f32
- hex_
to_ vec4 - Convert a color from a hexadecimal number (eg.
0x52b14eff
) into a Vec4. - is_
inside_ clip_ space - luma_
u8_ to_ vec4 - reflect
- scaled_
f32_ to_ u8 - Convert an f32 in range 0.0 - 1.0 into a u8 in range 0-255.
- scaled_
u8_ to_ f32 - Convert a u8 in range 0-255 to an f32 in range 0.0 - 1.0.
- scaled_
u32_ to_ u8 - Convert a u32 in rang 0-u32::MAX to a u8 in rang 0-255.
- signum_
or_ zero - Returns
1.0
ifn
is greater than or equal to0.0
. Returns1.0
ifn
is greater than or equal to-0.0
. Returns-1.0
ifn
is less than0.0
. Returns0.0
ifn
isNaN
. - smoothstep
- step_ge
- Return
1.0
whenvalue
is greater than or equal toedge
and0.0
wherevalue
is less thanedge
. - step_le
- Return
1.0
whenvalue
is less than or equal toedge
and0.0
whenvalue
is greater thanedge
. - triangle_
face_ normal - unit_
cube