hueToRgb

function for HSL to RGB conversion - converts hue component to RGB.

110 total functionsUpdated: Invalid Date

hueToRgb

function for HSL to RGB conversion - converts hue component to RGB.

Parameters

NameTypeDescription
pf32First HSL conversion parameter.
qf32Second HSL conversion parameter.
tf32Hue value (adjusted).

Returns

f32component value.

WGSL Code

fn hueToRgb(p: f32, q: f32, t: f32) -> f32 {
var t_adj = t;
if (t_adj < 0.0) { t_adj += 1.0; }
if (t_adj > 1.0) { t_adj -= 1.0; }
if (t_adj < 1.0 / 6.0) { return p + (q - p) * 6.0 * t_adj; }
if (t_adj < 1.0 / 2.0) { return q; }
if (t_adj < 2.0 / 3.0) { return p + (q - p) * (2.0 / 3.0 - t_adj) * 6.0; }
return p;
}

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 { hueToRgb, getFns } from 'wgsl-fns'
Usage:getFns(['hueToRgb'])