palette

colors using cosine-based palette function for smooth color gradients.

110 total functionsUpdated: Invalid Date

palette

colors using cosine-based palette function for smooth color gradients.

Parameters

NameTypeDescription
tf32Input parameter (typically 0-1) for palette lookup.
avec3<f32>Offset values for RGB channels.
bvec3<f32>Amplitude values for RGB channels.
cvec3<f32>Frequency values for RGB channels.
dvec3<f32>Phase values for RGB channels.

Returns

vec3<f32>RGB color.

WGSL Code

fn palette(t: f32, a: vec3<f32>, b: vec3<f32>, c: vec3<f32>, d: vec3<f32>) -> vec3<f32> {
return a + b * cos(6.28318 * (c * t + d));
}

About wgsl-fns

A JavaScript library providing WGSL utility functions as strings for WebGPU shader development. Includes mathematical utilities, noise generation, signed distance fields, and color manipulation functions.

Install:npm install wgsl-fns
Import:import { palette, getFns } from 'wgsl-fns'
Usage:getFns(['palette'])